|
@@ -14,6 +14,8 @@ Page({ |
|
@@ -14,6 +14,8 @@ Page({ |
|
14
|
options: {},
|
14
|
options: {},
|
|
15
|
check1: '', //做法
|
15
|
check1: '', //做法
|
|
16
|
check2: '', //规格
|
16
|
check2: '', //规格
|
|
|
|
17
|
+ check1Name:'',
|
|
|
|
18
|
+ check2Name:'',
|
|
17
|
isloading: true,
|
19
|
isloading: true,
|
|
18
|
toView: "inToView27",
|
20
|
toView: "inToView27",
|
|
19
|
hasEnter: false,
|
21
|
hasEnter: false,
|
|
@@ -62,13 +64,6 @@ Page({ |
|
@@ -62,13 +64,6 @@ Page({ |
|
62
|
onReady() {
|
64
|
onReady() {
|
|
63
|
|
65
|
|
|
64
|
},
|
66
|
},
|
|
65
|
- // 选择做法
|
|
|
|
66
|
- checkSingle1(e) {
|
|
|
|
67
|
- const check1 = e.currentTarget.dataset['item'];
|
|
|
|
68
|
- this.setData({
|
|
|
|
69
|
- check1
|
|
|
|
70
|
- })
|
|
|
|
71
|
- },
|
|
|
|
72
|
// 已选菜单页面跳转
|
67
|
// 已选菜单页面跳转
|
|
73
|
gotoShoppingCart() {
|
68
|
gotoShoppingCart() {
|
|
74
|
let cookbooklist = this.data.cookbooklist;
|
69
|
let cookbooklist = this.data.cookbooklist;
|
|
@@ -89,11 +84,26 @@ Page({ |
|
@@ -89,11 +84,26 @@ Page({ |
|
89
|
url: '/pack-cookbook/pages/cart_new',
|
84
|
url: '/pack-cookbook/pages/cart_new',
|
|
90
|
})
|
85
|
})
|
|
91
|
},
|
86
|
},
|
|
|
|
87
|
+ // 选择做法
|
|
|
|
88
|
+ checkSingle1(e) {
|
|
|
|
89
|
+ const item = e.currentTarget.dataset['item'];
|
|
|
|
90
|
+ let checkItem=this.data.checkItem
|
|
|
|
91
|
+ checkItem.check1=item.id
|
|
|
|
92
|
+ this.setData({
|
|
|
|
93
|
+ check1:item.id,
|
|
|
|
94
|
+ check1Name:item.name,
|
|
|
|
95
|
+ checkItem
|
|
|
|
96
|
+ })
|
|
|
|
97
|
+ },
|
|
92
|
// 选择规格
|
98
|
// 选择规格
|
|
93
|
checkSingle2(e) {
|
99
|
checkSingle2(e) {
|
|
94
|
- const check2 = e.currentTarget.dataset['item'];
|
100
|
+ const item = e.currentTarget.dataset['item'];
|
|
|
|
101
|
+ let checkItem=this.data.checkItem
|
|
|
|
102
|
+ checkItem.check2=item.id
|
|
95
|
this.setData({
|
103
|
this.setData({
|
|
96
|
- check2
|
104
|
+ check2:item.id,
|
|
|
|
105
|
+ check2Name:item.specs,
|
|
|
|
106
|
+ checkItem
|
|
97
|
})
|
107
|
})
|
|
98
|
},
|
108
|
},
|
|
99
|
getNormsLen() {
|
109
|
getNormsLen() {
|
|
@@ -154,9 +164,11 @@ Page({ |
|
@@ -154,9 +164,11 @@ Page({ |
|
154
|
})
|
164
|
})
|
|
155
|
} else {
|
165
|
} else {
|
|
156
|
let obj = {
|
166
|
let obj = {
|
|
157
|
- practice: this.data.check1,
|
|
|
|
158
|
- unit: this.data.check2,
|
|
|
|
159
|
quantum: 1,
|
167
|
quantum: 1,
|
|
|
|
168
|
+ practice: this.data.check1?this.data.check1:data.check1,
|
|
|
|
169
|
+ unit: this.data.check2?this.data.check2:data.check2,
|
|
|
|
170
|
+ practiceName:this.data.check1Name?this.data.check1Name:data.check1Name,
|
|
|
|
171
|
+ unitName:this.data.check2Name?this.data.check2Name:data.check2Name,
|
|
160
|
price
|
172
|
price
|
|
161
|
}
|
173
|
}
|
|
162
|
this.data.cookbooklist[indexs].cookbooklist[0][index].norms.push(obj)
|
174
|
this.data.cookbooklist[indexs].cookbooklist[0][index].norms.push(obj)
|
|
@@ -185,20 +197,31 @@ Page({ |
|
@@ -185,20 +197,31 @@ Page({ |
|
185
|
})
|
197
|
})
|
|
186
|
let norms = this.data.cookbooklist[indexs].cookbooklist[0][index].norms
|
198
|
let norms = this.data.cookbooklist[indexs].cookbooklist[0][index].norms
|
|
187
|
let normsNum;
|
199
|
let normsNum;
|
|
188
|
- if (norms.length != '0' && type == '0') {
|
|
|
|
189
|
- normsNum = this.data.cookbooklist[indexs].cookbooklist[0][index].norms[normsIndex].quantum * 1 + 1;
|
|
|
|
190
|
- } else {
|
|
|
|
191
|
- normsNum = 1
|
|
|
|
192
|
- }
|
|
|
|
193
|
- if (type == '1') {
|
200
|
+ // 点击下面的加号并且有规格或者做法的,弹框选规格 下面的直接加
|
|
|
|
201
|
+ if (type == '1' && (item.practice.length>1 || item.spec.length>1)) {
|
|
194
|
return this.showModal()
|
202
|
return this.showModal()
|
|
|
|
203
|
+ }else {
|
|
|
|
204
|
+ normsNum = 1;
|
|
|
|
205
|
+ let obj={
|
|
|
|
206
|
+ quantum:normsNum,
|
|
|
|
207
|
+ practice: item.check1Name,
|
|
|
|
208
|
+ unit:item.unit,
|
|
|
|
209
|
+ practiceName:item.check1Name,
|
|
|
|
210
|
+ unitName:item.check2Name,
|
|
|
|
211
|
+ }
|
|
|
|
212
|
+ if(!normsIndex && norms.length == '0'){
|
|
|
|
213
|
+ this.data.cookbooklist[indexs].cookbooklist[0][index].norms.push(obj)
|
|
|
|
214
|
+ }
|
|
195
|
}
|
215
|
}
|
|
196
|
- if (type == '0') {
|
216
|
+ if (type == '0' && norms.length != '0') {
|
|
|
|
217
|
+ normsNum = this.data.cookbooklist[indexs].cookbooklist[0][index].norms[normsIndex].quantum * 1 + 1;
|
|
197
|
this.data.cookbooklist[indexs].cookbooklist[0][index].norms[normsIndex].quantum = normsNum;
|
218
|
this.data.cookbooklist[indexs].cookbooklist[0][index].norms[normsIndex].quantum = normsNum;
|
|
198
|
- this.setData({
|
|
|
|
199
|
- cookbooklist: this.data.cookbooklist,
|
|
|
|
200
|
- })
|
219
|
+ }else{
|
|
|
|
220
|
+ normsNum = 1
|
|
201
|
}
|
221
|
}
|
|
|
|
222
|
+ this.setData({
|
|
|
|
223
|
+ cookbooklist: this.data.cookbooklist,
|
|
|
|
224
|
+ })
|
|
202
|
this.getNormsLen()
|
225
|
this.getNormsLen()
|
|
203
|
},
|
226
|
},
|
|
204
|
// 点击减号
|
227
|
// 点击减号
|
|
@@ -308,22 +331,19 @@ Page({ |
|
@@ -308,22 +331,19 @@ Page({ |
|
308
|
if (!cook.norms || cook.norms.length == 0) {
|
331
|
if (!cook.norms || cook.norms.length == 0) {
|
|
309
|
cook.norms = []; //做法规格
|
332
|
cook.norms = []; //做法规格
|
|
310
|
}
|
333
|
}
|
|
311
|
- // let type;//模拟种类 1为一行显示1个 2为一行显示2个
|
|
|
|
312
|
- // if(n=='0' || n=='3'){
|
|
|
|
313
|
- // type='1'
|
|
|
|
314
|
- // }else{
|
|
|
|
315
|
- // type='2'
|
|
|
|
316
|
- // }
|
|
|
|
317
|
cook.type = '1';
|
334
|
cook.type = '1';
|
|
318
|
- cook.arr1 = ['香辣', '清蒸', '爆炒', '清汤'];
|
|
|
|
319
|
- cook.arr2 = ['小份', '中份', '份', '例', '两只'];
|
|
|
|
320
|
- check1 = cook.arr1[0];
|
|
|
|
321
|
- check2 = cook.arr2[0];
|
335
|
+ let cook_style=cook.cook_style?JSON.parse(cook.cook_style):'';
|
|
|
|
336
|
+ cook.cook_style = cook_style;
|
|
|
|
337
|
+ cook.image_type = cook_style.image_type?cook_style.image_type:'1';//1大图,2小图 默认大图
|
|
|
|
338
|
+ cook.name_type = cook_style.name_type?cook_style.name_type:'3';//1左侧,2右侧,3顶部分开 默认分开
|
|
|
|
339
|
+ cook.check1 = cook.practice.length>0?cook.practice[0].id:'';
|
|
|
|
340
|
+ cook.check2 = cook.spec.length>0?cook.spec[0].id:'';
|
|
|
|
341
|
+ cook.check1Name = cook.practice.length>0?cook.practice[0].name:'';
|
|
|
|
342
|
+ cook.check2Name = cook.spec.length>0?cook.spec[0].specs:'';
|
|
322
|
if (item_clear_num == 0) {
|
343
|
if (item_clear_num == 0) {
|
|
323
|
flag = false;
|
344
|
flag = false;
|
|
324
|
}
|
345
|
}
|
|
325
|
}
|
346
|
}
|
|
326
|
-
|
|
|
|
327
|
if (flag) {
|
347
|
if (flag) {
|
|
328
|
cooks.push(cook);
|
348
|
cooks.push(cook);
|
|
329
|
//cooks_order.push(cook.order_o);
|
349
|
//cooks_order.push(cook.order_o);
|
|
@@ -333,13 +353,26 @@ Page({ |
|
@@ -333,13 +353,26 @@ Page({ |
|
333
|
})
|
353
|
})
|
|
334
|
if (cooks.length > 0) {
|
354
|
if (cooks.length > 0) {
|
|
335
|
//cooks 排序...
|
355
|
//cooks 排序...
|
|
336
|
-
|
|
|
|
337
|
cate.cookbooklist[0] = cooks;
|
356
|
cate.cookbooklist[0] = cooks;
|
|
338
|
flist.push(cate)
|
357
|
flist.push(cate)
|
|
339
|
}
|
358
|
}
|
|
340
|
}
|
359
|
}
|
|
341
|
})
|
360
|
})
|
|
342
|
}
|
361
|
}
|
|
|
|
362
|
+ let sortArr=[]
|
|
|
|
363
|
+ flist.forEach(item=>{
|
|
|
|
364
|
+ item.cookbooklist[0].sort((a,b)=>{
|
|
|
|
365
|
+ return a.order_o-b.order_o
|
|
|
|
366
|
+ })
|
|
|
|
367
|
+ sortArr.push(item)
|
|
|
|
368
|
+ })
|
|
|
|
369
|
+ // let image_typeArr=[];
|
|
|
|
370
|
+ // sortArr.forEach(item=>{
|
|
|
|
371
|
+ // item.cookbooklist[0].sort((a,b)=>{
|
|
|
|
372
|
+ // return a.image_type-b.image_type
|
|
|
|
373
|
+ // })
|
|
|
|
374
|
+ // image_typeArr.push(item)
|
|
|
|
375
|
+ // })
|
|
343
|
setTimeout(() => {
|
376
|
setTimeout(() => {
|
|
344
|
this.setData({
|
377
|
this.setData({
|
|
345
|
check1,
|
378
|
check1,
|
|
@@ -347,8 +380,7 @@ Page({ |
|
@@ -347,8 +380,7 @@ Page({ |
|
347
|
assortArr
|
380
|
assortArr
|
|
348
|
})
|
381
|
})
|
|
349
|
}, 1);
|
382
|
}, 1);
|
|
350
|
- console.log('flist', flist);
|
|
|
|
351
|
- return flist;
|
383
|
+ return sortArr;
|
|
352
|
},
|
384
|
},
|
|
353
|
// 获取所有分类下所有菜品列表
|
385
|
// 获取所有分类下所有菜品列表
|
|
354
|
getCookList(orderid) {
|
386
|
getCookList(orderid) {
|
|
@@ -369,15 +401,15 @@ Page({ |
|
@@ -369,15 +401,15 @@ Page({ |
|
369
|
status: '0,1',
|
401
|
status: '0,1',
|
|
370
|
};
|
402
|
};
|
|
371
|
App.Advance.GetCookbookByClass(param).then(json => {
|
403
|
App.Advance.GetCookbookByClass(param).then(json => {
|
|
372
|
- //菜单分类添加修饰
|
|
|
|
373
|
- let cookbooklist = this.formatCookList(json.data[0].list);
|
404
|
+ let cookbooklist=this.formatCookList(json.data[0].list)
|
|
|
|
405
|
+ console.log('cookbooklist',cookbooklist);
|
|
374
|
setTimeout(() => {
|
406
|
setTimeout(() => {
|
|
375
|
this.setData({
|
407
|
this.setData({
|
|
376
|
cookbooklist,
|
408
|
cookbooklist,
|
|
377
|
isloading: false,
|
409
|
isloading: false,
|
|
378
|
showSkeleton: false,
|
410
|
showSkeleton: false,
|
|
379
|
})
|
411
|
})
|
|
380
|
- }, 0)
|
412
|
+ }, 1)
|
|
381
|
}).catch(res => {
|
413
|
}).catch(res => {
|
|
382
|
console.log(res);
|
414
|
console.log(res);
|
|
383
|
});
|
415
|
});
|