|
...
|
...
|
@@ -30,7 +30,7 @@ Page({ |
|
|
|
order: {},
|
|
|
|
orderItemCount: 0,
|
|
|
|
checkObj: '',
|
|
|
|
quantum: '',
|
|
|
|
normsIndex: '',
|
|
|
|
normsList: [{
|
|
|
|
text: '做饭',
|
|
|
|
},
|
|
...
|
...
|
@@ -79,30 +79,15 @@ Page({ |
|
|
|
},
|
|
|
|
// 已选菜单页面跳转
|
|
|
|
gotoShoppingCart() {
|
|
|
|
// let arr = [];
|
|
|
|
// this.data.cookbooklist.forEach(item => {
|
|
|
|
// let obj = {
|
|
|
|
// class_name: item.class_name,
|
|
|
|
// id: item.id,
|
|
|
|
// status: item.status,
|
|
|
|
// class_type: item.class_type,
|
|
|
|
// arr: [],
|
|
|
|
// }
|
|
|
|
// item.cookbooklist[0].forEach(i => {
|
|
|
|
// if (i.quantum != '0') {
|
|
|
|
// obj.arr.push(i)
|
|
|
|
// }
|
|
|
|
// })
|
|
|
|
// arr.push(obj)
|
|
|
|
// })
|
|
|
|
// console.log(arr);
|
|
|
|
let cookbooklist = this.data.cookbooklist;
|
|
|
|
let obj = {
|
|
|
|
sellerName: this.data.options.sellerName,
|
|
|
|
sellerid: this.data.options.sid,
|
|
|
|
}
|
|
|
|
wx.setStorageSync('cookbooklist', JSON.stringify(cookbooklist))
|
|
|
|
wx.setStorageSync('cookbookObj', JSON.stringify(obj))
|
|
|
|
wx.navigateTo({
|
|
|
|
url: `/pack-cookbook/pages/cart_new?cookbooklist=${JSON.stringify(cookbooklist)}&obj=${JSON.stringify(obj)}`,
|
|
|
|
url: '/pack-cookbook/pages/cart_new',
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 选择规格
|
|
...
|
...
|
@@ -114,7 +99,6 @@ Page({ |
|
|
|
},
|
|
|
|
// 展示做法规格弹窗
|
|
|
|
showModal() {
|
|
|
|
console.log(this.data.checkItem);
|
|
|
|
this.checkModal.showModal()
|
|
|
|
},
|
|
|
|
// 关闭做法规格弹窗
|
|
...
|
...
|
@@ -137,66 +121,110 @@ Page({ |
|
|
|
this.setData({
|
|
|
|
toView: 'inToView' + _id
|
|
|
|
})
|
|
|
|
console.log(_id);
|
|
|
|
},
|
|
|
|
// 选择做法和规格后点击确定
|
|
|
|
determineFun() {
|
|
|
|
let index = this.data.checkObj.index;
|
|
|
|
let indexs = this.data.checkObj.indexs;
|
|
|
|
let quantum = this.data.quantum;
|
|
|
|
let check1 = this.data.check1;
|
|
|
|
let check2 = this.data.check2;
|
|
|
|
let checkObj = `cookbooklist[${indexs}].cookbooklist[0][${index}].quantum`;
|
|
|
|
let practice = `cookbooklist[${indexs}].cookbooklist[0][${index}].practice`;
|
|
|
|
let unit = `cookbooklist[${indexs}].cookbooklist[0][${index}].unit`;
|
|
|
|
this.setData({
|
|
|
|
[checkObj]: quantum,
|
|
|
|
[practice]: check1,
|
|
|
|
[unit]: check2,
|
|
|
|
let price = this.data.checkObj.price;
|
|
|
|
let data = this.data.cookbooklist[indexs].cookbooklist[0][index]
|
|
|
|
let isAlike = false;
|
|
|
|
data.norms.forEach(item => {
|
|
|
|
if (this.data.check1 == item.practice && this.data.check2 == item.unit) {
|
|
|
|
isAlike = true
|
|
|
|
item.quantum = item.quantum * 1 + 1
|
|
|
|
}
|
|
|
|
})
|
|
|
|
console.log('cookbooklist', this.data.cookbooklist);
|
|
|
|
if (isAlike) {
|
|
|
|
this.setData({
|
|
|
|
cookbooklist: this.data.cookbooklist,
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
let obj = {
|
|
|
|
practice: this.data.check1,
|
|
|
|
unit: this.data.check2,
|
|
|
|
quantum: 1,
|
|
|
|
price
|
|
|
|
}
|
|
|
|
this.data.cookbooklist[indexs].cookbooklist[0][index].norms.push(obj)
|
|
|
|
this.setData({
|
|
|
|
cookbooklist: this.data.cookbooklist,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
this.closeModal()
|
|
|
|
|
|
|
|
},
|
|
|
|
// 点击加号
|
|
|
|
addition(e) {
|
|
|
|
const item = e.currentTarget.dataset['item'];
|
|
|
|
const index = e.currentTarget.dataset['key']; //菜下标
|
|
|
|
const indexs = e.currentTarget.dataset['indexs']; //分类下标
|
|
|
|
let quantum = item.quantum * 1 + 1;
|
|
|
|
const type = e.currentTarget.dataset['type']; //1 弹框 0不选规格型号
|
|
|
|
const normsIndex = e.currentTarget.dataset['norms']; //菜品点菜的数组下标
|
|
|
|
this.setData({
|
|
|
|
checkObj: {
|
|
|
|
indexs,
|
|
|
|
index,
|
|
|
|
price:item.price
|
|
|
|
},
|
|
|
|
quantum,
|
|
|
|
normsIndex,
|
|
|
|
checkItem: item
|
|
|
|
})
|
|
|
|
console.log('index', index);
|
|
|
|
console.log('indexs', indexs);
|
|
|
|
console.log('checkItem', this.data.checkItem);
|
|
|
|
this.showModal()
|
|
|
|
let norms = this.data.cookbooklist[indexs].cookbooklist[0][index].norms
|
|
|
|
let normsNum;
|
|
|
|
if (norms.length != '0' && type == '0') {
|
|
|
|
normsNum = this.data.cookbooklist[indexs].cookbooklist[0][index].norms[normsIndex].quantum * 1 + 1;
|
|
|
|
} else {
|
|
|
|
normsNum = 1
|
|
|
|
}
|
|
|
|
if (type == '1') {
|
|
|
|
return this.showModal()
|
|
|
|
}
|
|
|
|
if (type == '0') {
|
|
|
|
this.data.cookbooklist[indexs].cookbooklist[0][index].norms[normsIndex].quantum = normsNum;
|
|
|
|
this.setData({
|
|
|
|
cookbooklist: this.data.cookbooklist,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if(this.data.cookbooklist[indexs].cookbooklist[0][index].norms.length>0){
|
|
|
|
this.data.cookbooklist[indexs].cookbooklist[0][index].isTrue=true
|
|
|
|
}else{
|
|
|
|
this.data.cookbooklist[indexs].cookbooklist[0][index].isTrue=false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 点击减号
|
|
|
|
subtraction(e) {
|
|
|
|
const item = e.currentTarget.dataset['item'];
|
|
|
|
const index = e.currentTarget.dataset['key']; //菜下标
|
|
|
|
const indexs = e.currentTarget.dataset['indexs']; //分类下标
|
|
|
|
let quantum = item.quantum * 1 - 1;
|
|
|
|
console.log('index', index);
|
|
|
|
console.log('indexs', indexs);
|
|
|
|
let quantumObj = `cookbooklist[${indexs}].cookbooklist[0][${index}].quantum`;
|
|
|
|
let practice = `cookbooklist[${indexs}].cookbooklist[0][${index}].practice`;
|
|
|
|
let unit = `cookbooklist[${indexs}].cookbooklist[0][${index}].unit`;
|
|
|
|
const normsIndex = e.currentTarget.dataset['norms']; //菜品点菜的数组下标
|
|
|
|
let normsNum;
|
|
|
|
normsNum = this.data.cookbooklist[indexs].cookbooklist[0][index].norms[normsIndex].quantum * 1 - 1;
|
|
|
|
if (normsNum == 0) {
|
|
|
|
this.data.cookbooklist[indexs].cookbooklist[0][index].norms.splice(normsIndex, 1)
|
|
|
|
} else {
|
|
|
|
this.data.cookbooklist[indexs].cookbooklist[0][index].norms[normsIndex].quantum = normsNum;
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
checkObj: {
|
|
|
|
indexs,
|
|
|
|
index
|
|
|
|
},
|
|
|
|
quantum,
|
|
|
|
[quantumObj]: quantum,
|
|
|
|
[practice]: this.data.check1,
|
|
|
|
[unit]: this.data.check2,
|
|
|
|
cookbooklist: this.data.cookbooklist,
|
|
|
|
})
|
|
|
|
|
|
|
|
if(this.data.cookbooklist[indexs].cookbooklist[0][index].norms.length>0){
|
|
|
|
this.data.cookbooklist[indexs].cookbooklist[0][index].isTrue=true
|
|
|
|
}else{
|
|
|
|
this.data.cookbooklist[indexs].cookbooklist[0][index].isTrue=false
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// let practice = `cookbooklist[${indexs}].cookbooklist[0][${index}].practice`;
|
|
|
|
// let unit = `cookbooklist[${indexs}].cookbooklist[0][${index}].unit`;
|
|
|
|
// this.setData({
|
|
|
|
// checkObj: {
|
|
|
|
// indexs,
|
|
|
|
// index
|
|
|
|
// },
|
|
|
|
// [practice]: this.data.check1,
|
|
|
|
// [unit]: this.data.check2,
|
|
|
|
// })
|
|
|
|
},
|
|
|
|
// 扫桌码点餐
|
|
|
|
initOrder() {
|
|
...
|
...
|
@@ -284,10 +312,8 @@ Page({ |
|
|
|
}
|
|
|
|
}
|
|
|
|
cook.item_clear_num = item_clear_num;
|
|
|
|
cook.quantum = 0; //选择的数量
|
|
|
|
cook.index = n; //分类下菜品的下标
|
|
|
|
cook.practice = ''; //做法
|
|
|
|
cook.unit = ''; //规格
|
|
|
|
cook.norms = []; //做法规格
|
|
|
|
// let type;//模拟种类 1为一行显示1个 2为一行显示2个
|
|
|
|
// if(n=='0' || n=='3'){
|
|
|
|
// type='1'
|
|
...
|
...
|
@@ -299,6 +325,7 @@ Page({ |
|
|
|
cook.arr2 = ['小份', '中份', '份', '例', '两只'];
|
|
|
|
check1 = cook.arr1[0];
|
|
|
|
check2 = cook.arr2[0];
|
|
|
|
cook.isTrue=false;//是否选了菜
|
|
|
|
if (item_clear_num == 0) {
|
|
|
|
flag = false;
|
|
|
|
}
|
...
|
...
|
|