Commit 568103a6acd10587f2c5fdd0bd0266c31d5079a7

Authored by yiren
1 parent d4181854

提前点餐

@@ -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 });
1 <!--pack-cookbook/pages/index_new.wxml--> 1 <!--pack-cookbook/pages/index_new.wxml-->
2 <nav backgroundColor="#4d4e50" color="#fff">{{options.sellerName||'提前点菜'}}</nav> 2 <nav backgroundColor="#4d4e50" color="#fff">{{options.sellerName||'提前点菜'}}</nav>
3 <loading wx:if="{{isloading}}">数据加载中</loading> 3 <loading wx:if="{{isloading}}">数据加载中</loading>
4 -<view wx:if="{{type=='A'}}" class="wrapIine"></view> 4 +<view class="wrapIine"></view>
5 <scroll-view style="height:100vh;" class="content" scroll-into-view="{{toView}}" scroll-y="true" scroll-with-animation="true"> 5 <scroll-view style="height:100vh;" class="content" scroll-into-view="{{toView}}" scroll-y="true" scroll-with-animation="true">
6 <block wx:for="{{cookbooklist}}" wx:key="cookbooklist-key" wx:for-index="indexs"> 6 <block wx:for="{{cookbooklist}}" wx:key="cookbooklist-key" wx:for-index="indexs">
7 <view class="dishWrap" id="{{ 'inToView'+item.id}}"> 7 <view class="dishWrap" id="{{ 'inToView'+item.id}}">
8 - <block wx:if="{{type=='A'}}"> 8 + <block wx:if="{{item.class_type=='1'}}">
9 <view class="heand flex-vc flex-cc"> 9 <view class="heand flex-vc flex-cc">
10 <view class="style_round flex-vc flex-cc"> 10 <view class="style_round flex-vc flex-cc">
11 <view class="round"></view> 11 <view class="round"></view>
@@ -19,7 +19,8 @@ @@ -19,7 +19,8 @@
19 </view> 19 </view>
20 </block> 20 </block>
21 <block wx:for="{{item.cookbooklist[0]}}" wx:key="{{item.id}}" wx:for-index="index"> 21 <block wx:for="{{item.cookbooklist[0]}}" wx:key="{{item.id}}" wx:for-index="index">
22 - <view wx:if="{{item.type=='1'}}" class="dishWrap"> 22 + <!-- name_type 1左侧,2右侧,3顶部分开 image_type 1大图,2小图 -->
  23 + <view wx:if="{{item.image_type=='1'}}" class="dishWrap">
23 <view class="dishItem flex-lr"> 24 <view class="dishItem flex-lr">
24 <view class="dishLeft dishTexts">{{item.name}}</view> 25 <view class="dishLeft dishTexts">{{item.name}}</view>
25 <view class="dishTexts dishRight">{{item.first_name}}</view> 26 <view class="dishTexts dishRight">{{item.first_name}}</view>
@@ -39,7 +40,7 @@ @@ -39,7 +40,7 @@
39 </view> 40 </view>
40 <view class="norms">{{item.first_name}}</view> 41 <view class="norms">{{item.first_name}}</view>
41 </block> 42 </block>
42 - <image wx:if="{{item.image}}" src="{{item.image}}" class="dishImg" mode="aspectFill" /> 43 + <image wx:if="{{item.image}}" src="{{item.image}}" class="dishImg" mode="aspectFill" />
43 <view class="greens"> 44 <view class="greens">
44 <view class="news">{{item.first_name}}</view> 45 <view class="news">{{item.first_name}}</view>
45 </view> 46 </view>
@@ -47,13 +48,13 @@ @@ -47,13 +48,13 @@
47 <image src="https://qn.colorcun.com/WechatIMG697.png" mode="aspectFill" class="reduceImg" bindtap="subtraction" data-item="{{item}}" data-norms="{{normsIndex}}" data-key="{{index}}" data-indexs="{{indexs}}" /> 48 <image src="https://qn.colorcun.com/WechatIMG697.png" mode="aspectFill" class="reduceImg" bindtap="subtraction" data-item="{{item}}" data-norms="{{normsIndex}}" data-key="{{index}}" data-indexs="{{indexs}}" />
48 <view class="box flex-cc"> 49 <view class="box flex-cc">
49 <view class="num flex-cc"> 50 <view class="num flex-cc">
50 - {{item.quantum}}<view>{{item.unit}}</view> 51 + {{item.quantum}}<view>{{item.unitName}}</view>
51 </view> 52 </view>
52 - <view class="practice">{{item.practice}}</view> 53 + <view class="practice">{{item.practiceName}}</view>
53 </view> 54 </view>
54 <image id="add" src="https://qn.colorcun.com/WechatIMG696.png" mode="aspectFill" class="imgs" data-type="0" bindtap="addition" data-norms="{{normsIndex}}" data-item="{{item}}" data-key="{{index}}" data-indexs="{{indexs}}" /> 55 <image id="add" src="https://qn.colorcun.com/WechatIMG696.png" mode="aspectFill" class="imgs" data-type="0" bindtap="addition" data-norms="{{normsIndex}}" data-item="{{item}}" data-key="{{index}}" data-indexs="{{indexs}}" />
55 </view> 56 </view>
56 - <view class="algorithmImg flex-rr"> 57 + <view wx:if="{{(item.spec.length>1 || item.practice.length>1) || item.norms.length=='0'}}" class="algorithmImg flex-rr">
57 <image src="https://qn.colorcun.com/WechatIMG696.png" class="imgs" mode="aspectFill" bindtap="addition" data-norms="{{normsIndex}}" data-type="1" data-item="{{item}}" data-key="{{index}}" data-indexs="{{indexs}}" /> 58 <image src="https://qn.colorcun.com/WechatIMG696.png" class="imgs" mode="aspectFill" bindtap="addition" data-norms="{{normsIndex}}" data-type="1" data-item="{{item}}" data-key="{{index}}" data-indexs="{{indexs}}" />
58 </view> 59 </view>
59 <view class="wrapIine"></view> 60 <view class="wrapIine"></view>
@@ -101,16 +102,16 @@ @@ -101,16 +102,16 @@
101 <scroll-view scroll-y style="height: 78%;overflow: auto;"> 102 <scroll-view scroll-y style="height: 78%;overflow: auto;">
102 <view class="textSty">做法</view> 103 <view class="textSty">做法</view>
103 <view class="itemBox"> 104 <view class="itemBox">
104 - <block wx:for="{{checkItem.arr1}}">  
105 - <view class="single {{check1==item?'active':''}}" data-item="{{item}}" bindtap="checkSingle1">  
106 - {{item}}</view> 105 + <block wx:for="{{checkItem.practice}}">
  106 + <view class="single {{checkItem.check1==item.id?'active':''}}" data-item="{{item}}" data-item="{{item}}" bindtap="checkSingle1">
  107 + {{item.name}}</view>
107 </block> 108 </block>
108 </view> 109 </view>
109 <view class="checkLine"></view> 110 <view class="checkLine"></view>
110 <view class="textSty">规格</view> 111 <view class="textSty">规格</view>
111 <view class="itemBox"> 112 <view class="itemBox">
112 - <view class="single {{check2==item?'active':''}}" bindtap="checkSingle2" wx:for="{{checkItem.arr2}}" data-item="{{item}}">  
113 - {{item}}</view> 113 + <view class="single {{checkItem.check2==item.id?'active':''}}" bindtap="checkSingle2" wx:for="{{checkItem.spec}}" data-item="{{item}}">
  114 + {{item.specs}}</view>
114 </view> 115 </view>
115 </scroll-view> 116 </scroll-view>
116 <view class="btns"> 117 <view class="btns">