更新api封装结构
This commit is contained in:
parent
f3baf4708a
commit
464c8aaf11
|
@ -2,7 +2,28 @@
|
||||||
export const baseurl = 'http://market.api.system.com'
|
export const baseurl = 'http://market.api.system.com'
|
||||||
|
|
||||||
|
|
||||||
|
// const getImg=(url)=>{
|
||||||
|
// const xhr = new XMLHttpRequest()
|
||||||
|
// xhr.open('GET', url)
|
||||||
|
// xhr.responseType = "arraybuffer";
|
||||||
|
// xhr.onreadystatechange = function (response) {
|
||||||
|
// response.header = {
|
||||||
|
// 'Accept': 'application/json',
|
||||||
|
// 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
|
||||||
|
// }
|
||||||
|
|
||||||
|
// var byteArray = new Uint8Array(response.target.response);
|
||||||
|
// var binary = '';
|
||||||
|
// for (var i = 0; i < byteArray.byteLength; i++) {
|
||||||
|
// binary += String.fromCharCode(byteArray[i]);
|
||||||
|
// }
|
||||||
|
// let str = 'data:image/png;base64,' + window.btoa(binary)
|
||||||
|
// console.log(func)
|
||||||
|
// func(str,xhr);
|
||||||
|
|
||||||
|
// }
|
||||||
|
// xhr.send()
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,6 +34,10 @@ const req = (method, url, params, responseType) => {
|
||||||
var obj = {
|
var obj = {
|
||||||
method: method,
|
method: method,
|
||||||
params: params,
|
params: params,
|
||||||
|
headers: new Headers({
|
||||||
|
'Content-Type': 'image/png; charset=utf-8'
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(method == "post")
|
if(method == "post")
|
||||||
|
@ -25,14 +50,24 @@ const req = (method, url, params, responseType) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fetch(url).then(res => res.json()).catch(error => console.error('Error:', error)).then(response => console.log('Success:', response));
|
let http = fetch(url).then(res => res.json());
|
||||||
|
return http.then(response =>response.data ).catch(error => console.error('Error:', error));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//营销计划列表
|
//营销计划列表
|
||||||
export const getPlanList = (params) => {
|
export const getPlanList = (params) => {
|
||||||
return req('get', baseurl + "/plan", params)
|
return req('get', baseurl + "/plan", params)
|
||||||
}
|
}
|
||||||
|
//获取分销商下拉菜单
|
||||||
|
export const getReSellerOption = (params) => {
|
||||||
|
return req('get', baseurl + "/reseller/choice", params)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//新建营销计划
|
//新建营销计划
|
||||||
export const getPlanStep = (id,params) => {
|
export const getPlanStep = (id,params) => {
|
||||||
return req('get', baseurl + "/plan/step/:"+id, params)
|
return req('get', baseurl + "/plan/step/:"+id, params)
|
||||||
|
@ -82,6 +117,8 @@ export const putKeyEmail = (id,params) => {
|
||||||
return req('put', baseurl + "/keys/receive/:"+id, params)
|
return req('put', baseurl + "/keys/receive/:"+id, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//销售单中的出库
|
//销售单中的出库
|
||||||
export {
|
export {
|
||||||
req
|
req
|
||||||
|
|
|
@ -6,6 +6,7 @@ import Ipt from "../../../components/input/main"
|
||||||
import Form from "../../../components/form/main"
|
import Form from "../../../components/form/main"
|
||||||
import FormItem from "../../../components/form-item/main"
|
import FormItem from "../../../components/form-item/main"
|
||||||
import Bus from "../../../assets/eventBus.js"
|
import Bus from "../../../assets/eventBus.js"
|
||||||
|
import {getVerify,getReSellerOption} from "../../../assets/api.js"
|
||||||
const TabPanel = Tabs.TabPanel;
|
const TabPanel = Tabs.TabPanel;
|
||||||
|
|
||||||
export default class acclist extends React.Component{
|
export default class acclist extends React.Component{
|
||||||
|
@ -18,14 +19,24 @@ export default class acclist extends React.Component{
|
||||||
reseller:null,
|
reseller:null,
|
||||||
return_id:"1",
|
return_id:"1",
|
||||||
date_time:""
|
date_time:""
|
||||||
}
|
},
|
||||||
|
reseller_option:[]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount(e){
|
componentDidMount(e){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getReSellerOption()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
submit(){
|
submit(){
|
||||||
if(this.refs.form1.validator())
|
if(this.refs.form1.validator())
|
||||||
{
|
{
|
||||||
|
@ -38,7 +49,6 @@ export default class acclist extends React.Component{
|
||||||
}
|
}
|
||||||
|
|
||||||
onTypeChange(e){
|
onTypeChange(e){
|
||||||
console.log(e.target.value)
|
|
||||||
let model = this.state.model;
|
let model = this.state.model;
|
||||||
model.type = e.target.value;
|
model.type = e.target.value;
|
||||||
this.setState({model:model})
|
this.setState({model:model})
|
||||||
|
@ -114,13 +124,6 @@ export default class acclist extends React.Component{
|
||||||
|
|
||||||
} } />
|
} } />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem labelname=" 计划充值返回" prop="return_id" id="return_id">
|
|
||||||
<RadioGroup onChange={this.onChange} value={this.state.model.return_id}>
|
|
||||||
<RadioButton value="1">直接返回</RadioButton>
|
|
||||||
<RadioButton value="2">卡单</RadioButton>
|
|
||||||
</RadioGroup>
|
|
||||||
</FormItem>
|
|
||||||
|
|
||||||
<FormItem labelname="开始~结束时间" prop="date_time" id="date_time">
|
<FormItem labelname="开始~结束时间" prop="date_time" id="date_time">
|
||||||
<CombinedDateRangePicker canClear={false}
|
<CombinedDateRangePicker canClear={false}
|
||||||
className="zent-datepicker-plan"
|
className="zent-datepicker-plan"
|
||||||
|
|
|
@ -46,6 +46,14 @@ export default class acclist extends React.Component{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onStyleChange(e){
|
||||||
|
let model2 = this.state.model;
|
||||||
|
model2.type = e.target.value;
|
||||||
|
this.setState({model:model2})
|
||||||
|
// let model2 = this.state.model
|
||||||
|
// model2.style = e;
|
||||||
|
// this.setState({model:model2})
|
||||||
|
}
|
||||||
render(){
|
render(){
|
||||||
const Column = [
|
const Column = [
|
||||||
{
|
{
|
||||||
|
@ -116,34 +124,25 @@ export default class acclist extends React.Component{
|
||||||
return(
|
return(
|
||||||
<div id="step2">
|
<div id="step2">
|
||||||
<Form model={this.state.model} rules={rules} ref="form1">
|
<Form model={this.state.model} rules={rules} ref="form1">
|
||||||
<FormItem labelname=" key样式" prop="style">
|
<FormItem labelname=" key样式" prop="style" id="style">
|
||||||
|
<RadioGroup onChange={(e)=>{ this.onStyleChange(e)} } value={this.state.model.style}>
|
||||||
<RadioGroup onChange={this.onChange} value={this.state.return_id}>
|
|
||||||
<RadioButton value="1">串码</RadioButton>
|
<RadioButton value="1">串码</RadioButton>
|
||||||
<RadioButton value="2">链接</RadioButton>
|
<RadioButton value="2">链接</RadioButton>
|
||||||
<RadioButton value="3">二维码</RadioButton>
|
<RadioButton value="3">二维码</RadioButton>
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem labelname="分销商" prop="reseller">
|
|
||||||
<Select options={options} placeholder="选择一项" width={515} value={this.state.model.reseller} />
|
<FormItem labelname="key数量" prop="quantity" id="quantity" >
|
||||||
</FormItem>
|
|
||||||
<FormItem labelname=" key方式" prop="return_id">
|
|
||||||
<RadioGroup onChange={this.onChange} value={this.state.return_id}>
|
|
||||||
<RadioButton value="1">指定数量</RadioButton>
|
|
||||||
<RadioButton value="2">不限</RadioButton>
|
|
||||||
</RadioGroup>
|
|
||||||
</FormItem>
|
|
||||||
<FormItem labelname="key数量" prop="date_time" >
|
|
||||||
<Ipt onChange={(e)=>{
|
<Ipt onChange={(e)=>{
|
||||||
let model2 = this.state.model;
|
let model2 = this.state.model;
|
||||||
model2.name = e;
|
model2.quantity = e;
|
||||||
this.setState({model:model2})
|
this.setState({model:model2})
|
||||||
}} value={this.state.model.name} placeholder={"请输入"} labelWidth={'0px'} maxLength={12} height={'36px'} width={'400px'} alignment={'left'}/>
|
}} value={this.state.model.quantity} placeholder={"请输入"} labelWidth={'0px'} maxLength={12} height={'36px'} width={'400px'} alignment={'left'}/>
|
||||||
<Button className="import-btn" >导入白名单</Button>
|
<Button className="import-btn" >导入白名单</Button>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
||||||
|
|
||||||
<FormItem labelname="绑定类型" prop="checkedList" >
|
<FormItem labelname="绑定类型" prop="bind_object" id="bind_object" >
|
||||||
<Checkbox.Group value={this.state.checkedList} onChange={this.onCheckChange}>
|
<Checkbox.Group value={this.state.checkedList} onChange={this.onCheckChange}>
|
||||||
<Checkbox value="1">兑换码</Checkbox>
|
<Checkbox value="1">兑换码</Checkbox>
|
||||||
<Checkbox value="2">优惠券</Checkbox>
|
<Checkbox value="2">优惠券</Checkbox>
|
||||||
|
@ -155,7 +154,7 @@ export default class acclist extends React.Component{
|
||||||
<Button>新建优惠券</Button>
|
<Button>新建优惠券</Button>
|
||||||
<Button>新建立减金</Button>
|
<Button>新建立减金</Button>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem labelname="绑定对象">
|
<FormItem labelname="绑定对象" >
|
||||||
<Grid
|
<Grid
|
||||||
headBackgroud="#f9fafc"
|
headBackgroud="#f9fafc"
|
||||||
isShowPageBar={false}
|
isShowPageBar={false}
|
||||||
|
@ -169,26 +168,21 @@ export default class acclist extends React.Component{
|
||||||
this.pageChange(e)
|
this.pageChange(e)
|
||||||
}}
|
}}
|
||||||
checkChange ={(selection)=>{
|
checkChange ={(selection)=>{
|
||||||
console.log(selection)
|
|
||||||
}}
|
}}
|
||||||
ComponentHandler={(com,rowData)=>{
|
ComponentHandler={(com,rowData)=>{
|
||||||
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem labelname="重复选择商品">
|
<FormItem labelname="重复选择商品" id="allow_repetition" prop="allow_repetition">
|
||||||
<RadioGroup onChange={this.onChange} value={this.state.value}>
|
<RadioGroup onChange={this.onChange} value={this.state.value}>
|
||||||
<RadioButton value="1">是</RadioButton>
|
<RadioButton value="1">是</RadioButton>
|
||||||
<RadioButton value="2">否</RadioButton>
|
<RadioButton value="2">否</RadioButton>
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem labelname="是否合并库存">
|
|
||||||
<RadioGroup onChange={this.onChange} value={this.state.value}>
|
<FormItem labelname="是否允许亏损" id="allow_loss" prop="allow_loss">
|
||||||
<RadioButton value="1">是</RadioButton>
|
|
||||||
<RadioButton value="2">否</RadioButton>
|
|
||||||
</RadioGroup>
|
|
||||||
</FormItem>
|
|
||||||
<FormItem labelname="是否允许亏损">
|
|
||||||
<RadioGroup onChange={this.onChange} value={this.state.value}>
|
<RadioGroup onChange={this.onChange} value={this.state.value}>
|
||||||
<RadioButton value="1" >是</RadioButton>
|
<RadioButton value="1" >是</RadioButton>
|
||||||
<RadioButton value="2" >否</RadioButton>
|
<RadioButton value="2" >否</RadioButton>
|
||||||
|
|
|
@ -36,12 +36,13 @@ export default class acclist extends React.Component{
|
||||||
}
|
}
|
||||||
//分页
|
//分页
|
||||||
onPageChange(e){
|
onPageChange(e){
|
||||||
this.setState({distdata:[]})
|
|
||||||
}
|
}
|
||||||
componentDidMount(e){
|
componentDidMount(e){
|
||||||
getPlanList((res)=>{
|
getPlanList().then((res)=>{
|
||||||
console.log(res)
|
console.log(res)
|
||||||
})
|
}).catch(()=>{})
|
||||||
|
|
||||||
}
|
}
|
||||||
//切换siwtch
|
//切换siwtch
|
||||||
onSwitchChange(status,row){
|
onSwitchChange(status,row){
|
||||||
|
|
Loading…
Reference in New Issue