|
@@ -7,6 +7,11 @@ Page({
|
|
|
* 页面的初始数据
|
|
* 页面的初始数据
|
|
|
*/
|
|
*/
|
|
|
data: {
|
|
data: {
|
|
|
|
|
+ tabs: [],
|
|
|
|
|
+ tabsWidth:'100%',
|
|
|
|
|
+ currentTab:0,
|
|
|
|
|
+ isTabs:false,
|
|
|
|
|
+ selectGridProductList:[],//当前选中得柜子
|
|
|
userInfo: {},
|
|
userInfo: {},
|
|
|
storeList: [],
|
|
storeList: [],
|
|
|
schemeList:[],
|
|
schemeList:[],
|
|
@@ -25,8 +30,8 @@ Page({
|
|
|
agentId: '',
|
|
agentId: '',
|
|
|
payType:'wx,zfb,xj',//默认选择所有支付方式
|
|
payType:'wx,zfb,xj',//默认选择所有支付方式
|
|
|
gridProductList:[]
|
|
gridProductList:[]
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ gridProductList:[]//商品数据
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -103,7 +108,6 @@ Page({
|
|
|
|
|
|
|
|
|
|
|
|
|
formSubmit: function (e) {
|
|
formSubmit: function (e) {
|
|
|
- console.log(this.data.values)
|
|
|
|
|
var that = this
|
|
var that = this
|
|
|
//表单规则
|
|
//表单规则
|
|
|
let rules = [{
|
|
let rules = [{
|
|
@@ -155,6 +159,26 @@ Page({
|
|
|
let formData = e.detail.value;
|
|
let formData = e.detail.value;
|
|
|
let checkRes = form.validation(formData, rules);
|
|
let checkRes = form.validation(formData, rules);
|
|
|
if (!checkRes) {
|
|
if (!checkRes) {
|
|
|
|
|
+ let currentTab = this.data.currentTab;
|
|
|
|
|
+ //提交时设置当前选中柜子商品
|
|
|
|
|
+ var gridProductList = `gridProductList[${currentTab}]`
|
|
|
|
|
+ var selectGridProductList = this.data.selectGridProductList;
|
|
|
|
|
+ that.setData({
|
|
|
|
|
+ [gridProductList]:selectGridProductList
|
|
|
|
|
+ })
|
|
|
|
|
+ var gridProductListSub = this.data.gridProductList;
|
|
|
|
|
+ var gridList = [];
|
|
|
|
|
+ gridProductListSub.forEach((d,index) => {
|
|
|
|
|
+ gridList = gridList.concat(d)
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ var valuesGridList = `values.gridProductList`
|
|
|
|
|
+ that.setData({
|
|
|
|
|
+ [valuesGridList]:gridList
|
|
|
|
|
+ })
|
|
|
|
|
+ console.log( that.data.values)
|
|
|
|
|
+
|
|
|
util.request(util.api.addDevice, that.data.values, "POST", false, true,app.globalData.token).then((res) => {
|
|
util.request(util.api.addDevice, that.data.values, "POST", false, true,app.globalData.token).then((res) => {
|
|
|
if (res.code == 200) {
|
|
if (res.code == 200) {
|
|
|
wx.redirectTo({
|
|
wx.redirectTo({
|
|
@@ -176,19 +200,31 @@ Page({
|
|
|
},
|
|
},
|
|
|
//选设备类型
|
|
//选设备类型
|
|
|
bindDeviceTypePickerChange: function (e) {
|
|
bindDeviceTypePickerChange: function (e) {
|
|
|
- var item = this.data.deviceTypeList[e.detail.value]
|
|
|
|
|
|
|
+ var that = this;
|
|
|
|
|
+ var item = that.data.deviceTypeList[e.detail.value]
|
|
|
var gridSize = item.gridSize?item.gridSize:0
|
|
var gridSize = item.gridSize?item.gridSize:0
|
|
|
- var gridProductList =[];
|
|
|
|
|
- for (let index = 0; index < gridSize; index++) {
|
|
|
|
|
- gridProductList.push({productGrid:index+1});
|
|
|
|
|
|
|
+ var gridLists =[];//机子数量
|
|
|
|
|
+ var tabs = [];
|
|
|
|
|
+ for (let deviceNum = 0; deviceNum < item.deviceNums; deviceNum++) {//柜子数量
|
|
|
|
|
+ var gridProductList =[];
|
|
|
|
|
+ var tab = {};
|
|
|
|
|
+ tab.name = '柜子'+deviceNum
|
|
|
|
|
+ tabs.push(tab)
|
|
|
|
|
+ for (let index = 0; index < gridSize; index++) {
|
|
|
|
|
+ gridProductList.push({productGrid:index+1,deviceNum:deviceNum});
|
|
|
|
|
+ }
|
|
|
|
|
+ gridLists.push(gridProductList)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- console.log(gridProductList)
|
|
|
|
|
|
|
|
|
|
- this.setData({
|
|
|
|
|
|
|
+ that.setData({
|
|
|
['values.deviceTypeId']: item.id,
|
|
['values.deviceTypeId']: item.id,
|
|
|
['values.deviceTypeName']: item.deviceName,
|
|
['values.deviceTypeName']: item.deviceName,
|
|
|
- ['values.gridProductList']:gridProductList
|
|
|
|
|
|
|
+ ['gridProductList']:gridLists,
|
|
|
|
|
+ isTabs:true,
|
|
|
|
|
+ tabsWidth:100/tabs.length+'%',
|
|
|
|
|
+ tabs:tabs,
|
|
|
|
|
+ selectGridProductList:gridLists[that.data.currentTab]
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
//选门店
|
|
//选门店
|
|
@@ -231,9 +267,7 @@ Page({
|
|
|
},
|
|
},
|
|
|
//选择支付类别 数组拼装成逗号分割
|
|
//选择支付类别 数组拼装成逗号分割
|
|
|
checkboxChange(e){
|
|
checkboxChange(e){
|
|
|
- console.log(e)
|
|
|
|
|
var selectPayTypeList = e.detail.value;
|
|
var selectPayTypeList = e.detail.value;
|
|
|
-
|
|
|
|
|
var payTypes = "";
|
|
var payTypes = "";
|
|
|
selectPayTypeList.forEach(payType => {
|
|
selectPayTypeList.forEach(payType => {
|
|
|
payTypes+=payType+","
|
|
payTypes+=payType+","
|
|
@@ -246,9 +280,8 @@ Page({
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
number: function (e) {
|
|
number: function (e) {
|
|
|
- console.log(e)
|
|
|
|
|
let value = this.validateNumber(e.detail.value)
|
|
let value = this.validateNumber(e.detail.value)
|
|
|
- let inx = `values.gridProductList[${e.target.dataset.index}].${e.target.dataset.name}`
|
|
|
|
|
|
|
+ let inx = `selectGridProductList[${e.target.dataset.index}].${e.target.dataset.name}`
|
|
|
this.setData({
|
|
this.setData({
|
|
|
//parseInt将数字字符串转换成数字
|
|
//parseInt将数字字符串转换成数字
|
|
|
[inx]: parseInt(value)
|
|
[inx]: parseInt(value)
|
|
@@ -268,4 +301,12 @@ Page({
|
|
|
[name]: _this.data[name]
|
|
[name]: _this.data[name]
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
|
|
+ //选择柜子
|
|
|
|
|
+ selectDevice: function(e){
|
|
|
|
|
+ var gridProductList = this.data.gridProductList[e.detail.index]
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ currentTab:e.detail.index,
|
|
|
|
|
+ selectGridProductList:gridProductList
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|