Commit 379284cbcf97de40f3fa94af5d2be16b5ed30a18

Authored by zhangyan
1 parent 5ec18909

no message

@@ -23,6 +23,11 @@ Component({ @@ -23,6 +23,11 @@ Component({
23 v.isselect=!v.isselect 23 v.isselect=!v.isselect
24 } 24 }
25 }) 25 })
  26 + var pages = getCurrentPages();
  27 + pages[pages.length-2].data.form.tid=tables;
  28 + pages[pages.length-2].setData({
  29 + form:pages[pages.length-2].data.form
  30 + })
26 util.cache('tableid',tables); 31 util.cache('tableid',tables);
27 this.triggerEvent("changedesk"); 32 this.triggerEvent("changedesk");
28 this.setData({ 33 this.setData({
@@ -5,12 +5,7 @@ @@ -5,12 +5,7 @@
5 <view class="font38r font-bold desk-name flex-cc font-more">{{item.name}}</view> 5 <view class="font38r font-bold desk-name flex-cc font-more">{{item.name}}</view>
6 <view class="font34r desk-pnum flex-cc">{{item.table_pnum}}人桌</view> 6 <view class="font34r desk-pnum flex-cc">{{item.table_pnum}}人桌</view>
7 <view class="desk-mask {{item.isselect==true ? 'desk-mask-active white-font flex-vc font24r' : ''}}"> 7 <view class="desk-mask {{item.isselect==true ? 'desk-mask-active white-font flex-vc font24r' : ''}}">
8 - <block wx:if="{{item.isselect==false}}">  
9 - <icon type="success_no_circle" class="icon-success" color="#fff" size="13"></icon>  
10 - </block>  
11 - <block wx:else>  
12 - {{index+1}}  
13 - </block> 8 + <icon type="success_no_circle" class="icon-success" color="#fff" size="13"></icon>
14 </view> 9 </view>
15 </view> 10 </view>
16 </block> 11 </block>
@@ -224,5 +224,12 @@ Page({ @@ -224,5 +224,12 @@ Page({
224 form:this.data.form, 224 form:this.data.form,
225 searchlist:null 225 searchlist:null
226 }) 226 })
  227 + },
  228 + async selectdesk(){
  229 + let rdate=await comm.getTimeSpace(this.data.dateStr[this.data.form.date],this.data.form.time);
  230 + console.log(this.data.form)
  231 + wx.navigateTo({
  232 + url:'b_desk?rdate='+rdate+'&tid='+this.data.form.tabid+'&pnum_str='+this.data.form.pnum_str
  233 + })
227 } 234 }
228 }) 235 })
1 -var util = require('../../utils/util.js')  
2 -var uri=require('../../utils/uri.js')  
3 -var bookOrder=require('../../utils/bookCommon.js') 1 +import util from '../../utils/util';
  2 +import comm from '../../utils/bookCommon';
  3 +import App from '../../utils/api';
  4 +const {regeneratorRuntime} = global
4 Page({ 5 Page({
5 data:{ 6 data:{
6 - desk_type:[  
7 - {  
8 - type:2,  
9 - type_name:'包厢',  
10 - isselect:true  
11 - },  
12 - {  
13 - type:1,  
14 - type_name:'散座',  
15 - isselect:false,  
16 - },  
17 - {  
18 - type:'',  
19 - type_name:'全部',  
20 - isselect:false  
21 - }  
22 - ],  
23 - tabletype:2  
24 7
25 }, 8 },
26 onLoad:function(opt){ 9 onLoad:function(opt){
@@ -28,142 +11,16 @@ Page({ @@ -28,142 +11,16 @@ Page({
28 util.setBarTitle('选择桌位'); 11 util.setBarTitle('选择桌位');
29 var radio=750/util.getsystem().windowWidth; 12 var radio=750/util.getsystem().windowWidth;
30 var contentHeight=util.getsystem().windowHeight-Math.ceil(350/radio); 13 var contentHeight=util.getsystem().windowHeight-Math.ceil(350/radio);
31 - var temdate=bookOrder.get_date(opt.date);  
32 - var stringTime =opt.year+'-'+temdate+' ' +opt.time_dur+':00';  
33 - console.log(stringTime)  
34 - var time=bookOrder.gettimestamp(stringTime);  
35 - this.setData({  
36 - sellerid:util.cache('sellerid'),  
37 - selectdate:opt.date,  
38 - time_dur:opt.time_dur,  
39 - pnum:opt.pnum,  
40 - contentHeight:contentHeight,  
41 - time:time,  
42 - thisyear:opt.year  
43 - })  
44 - console.log(time)  
45 - var thistype=util.cache('tabletype');  
46 - var fixedtype=this.data.desk_type;  
47 - var dd=[];  
48 - for(var key in thistype){  
49 - var type=key.split('_')[1];  
50 - fixedtype.forEach(function(v,i){  
51 - if(v.type==type){  
52 - v.isselect=false;  
53 - if(type==2){  
54 - dd.unshift(v)  
55 - }else{  
56 - dd.push(v)  
57 - }  
58 -  
59 - }  
60 - }) 14 + if(opt.tid==0){
  15 + delete opt.tid
61 } 16 }
62 - dd.push({  
63 - type:'',  
64 - type_name:'全部',  
65 - isselect:false  
66 - })  
67 - dd[0].isselect=true;  
68 this.setData({ 17 this.setData({
69 - desk_type:dd,  
70 - tabletype:dd[0].type 18 + sellerid:util.cache('sellerid'),
  19 + opt:opt
71 }) 20 })
72 this.getdesklist(); 21 this.getdesklist();
73 }, 22 },
74 onShow:function(){ 23 onShow:function(){
75 - var that=this;  
76 - util.postSuccessFun=function(json,uri_code){  
77 - switch (uri_code) {  
78 - case uri.CGI_USER_GETTABLELIST__CODE:  
79 - console.log(json)  
80 - var desklist=json.data;  
81 - var thisdesk=[];  
82 - for(var key in desklist){  
83 - if(bookOrder.isInteger(key)==true){  
84 - desklist[key].list.forEach(function(r,n){  
85 - r.isselect=false;  
86 - if(util.cache('tableid')){  
87 - var tables=util.cache('tableid');  
88 - tables.forEach(function(v,i){  
89 - if(v==r.id){  
90 - r.isselect=true;  
91 - }  
92 - })  
93 - }  
94 - })  
95 - thisdesk.push(desklist[key])  
96 - }  
97 -  
98 - }  
99 - if(that.data.tabletype!=''){  
100 - that.selectdesk(thisdesk);  
101 - }else{  
102 - that.setData({  
103 - desklist:thisdesk  
104 - })  
105 - }  
106 -  
107 - console.log(that.data.desklist)  
108 - break;  
109 - }  
110 - }  
111 - },  
112 - selectType:function(e){  
113 - var type=e.currentTarget.dataset.type;  
114 - var desktype=this.data.desk_type;  
115 - desktype.forEach(function(v,i){  
116 - v.isselect=false  
117 - if(v.type==type){  
118 - v.isselect=true  
119 - }  
120 - })  
121 - this.setData({  
122 - desk_type:desktype,  
123 - tabletype:type  
124 - })  
125 - this.getdesklist();  
126 - },  
127 - selectdesk:function(desklist){  
128 - var type=this.data.tabletype;  
129 - console.log('tttt',desklist)  
130 - var thislist=[];  
131 - var temp={}  
132 - desklist.forEach(function(v,i){  
133 - v.list.forEach(function(r,n){  
134 - if(r.tid==type){  
135 - if(!temp.hasOwnProperty(v.name)){  
136 - temp[v.name]=true;  
137 - thislist.push({  
138 - name:v.name,  
139 - list:[]  
140 - })  
141 - }  
142 - }  
143 - })  
144 - })  
145 - console.log(thislist)  
146 - desklist.forEach(function(v,i){  
147 - thislist.forEach(function(r,n){  
148 - if(v.name==r.name){  
149 - v.list.forEach(function(r1,n1){  
150 - if(r1.tid==type){  
151 - r.list.push(r1)  
152 - }  
153 - })  
154 - }  
155 -  
156 - })  
157 - })  
158 - this.setData({  
159 - desklist:thislist  
160 - })  
161 - },  
162 - changepnum:function(e){  
163 - this.setData({  
164 - pnum:e.detail  
165 - })  
166 - this.getdesklist();  
167 }, 24 },
168 changedesk:function(e){ 25 changedesk:function(e){
169 var tableid=e.detail; 26 var tableid=e.detail;
@@ -178,276 +35,22 @@ Page({ @@ -178,276 +35,22 @@ Page({
178 wx.navigateBack() 35 wx.navigateBack()
179 }, 36 },
180 getdesklist:function(){ 37 getdesklist:function(){
181 - util.post(uri.CGI_USER_GETTABLELIST,{sid:this.data.sellerid,pnum:parseInt(this.data.pnum),rdate:this.data.time},uri.CGI_USER_GETTABLELIST__CODE)  
182 - },  
183 - backtime:function () {  
184 - var pages=getCurrentPages();  
185 - var len=pages.length;  
186 - var timelist=pages[len-3].data.timeList;  
187 - var datelist=pages[len-3].data.dateList;  
188 - var currendate=bookOrder.get_date(this.data.selectdate)  
189 - var time_dur=this.data.time_dur;  
190 - var dateindex;  
191 - datelist.forEach(function(v,i){  
192 - if(v.date==currendate){  
193 - dateindex=i;  
194 - }  
195 - }) 38 + var formdata=this.data.opt;
  39 + formdata.sid=this.data.sellerid;
196 var that=this; 40 var that=this;
197 - var timeIndex;  
198 - var durIndex;  
199 - timelist.forEach(function(v,i){  
200 - v.list.forEach(function(r,n){  
201 - r.isselect=false;  
202 - if(r.time_dur==time_dur){  
203 - console.log('xxxx',n,i,time_dur)  
204 - timeIndex=n;  
205 - durIndex=i;  
206 - if(n==0 && i==0){  
207 - if(dateindex==0){  
208 - console.log('不能再退了')  
209 - }else{  
210 - console.log(11111)  
211 - dateindex=dateindex-1;  
212 - datelist.forEach(function(r1,n1){  
213 - r1.isActive=false;  
214 - if(dateindex==n1){  
215 - r1.isActive=true;  
216 - that.setData({  
217 - thisyear:r1.year  
218 - })  
219 - }  
220 - })  
221 - pages[len-3].setData({  
222 - selectdate:datelist[dateindex].date,  
223 - dateList:datelist  
224 - })  
225 - pages[len-3].getimelist();  
226 - timelist=pages[len-3].data.timeList;  
227 - that.setData({  
228 - selectdate:bookOrder.getdate_num(pages[len-3].data.selectdate),  
229 - time_dur:'22:00'  
230 - })  
231 - pages[len-2].setData({  
232 - selectdate:bookOrder.getdate_num(pages[len-3].data.selectdate),  
233 - time_dur:'22:00'  
234 - })  
235 - console.log(that.data.time_dur)  
236 - timelist.forEach(function(r1,n1){  
237 - r1.list.forEach(function(r2,n2){  
238 - r2.isselect=false;  
239 - console.log(r2)  
240 - if(r2.time_dur==that.data.time_dur){  
241 - console.log('xxxxx',r2)  
242 - r2.isselect=true;  
243 - }  
244 - })  
245 - })  
246 - console.log(timelist)  
247 - pages[len-3].setData({  
248 - timeList:timelist,  
249 - time_dur:'22:00'  
250 - })  
251 -  
252 - }  
253 -  
254 - }  
255 - if(n>0 && i==0){  
256 - that.setData({  
257 - time_dur:v.list[n-1].time_dur  
258 - })  
259 - v.list[n-1].isselect=true;  
260 - pages[len-3].setData({  
261 - timeList:timelist,  
262 - time_dur:v.list[n-1].time_dur  
263 - })  
264 - pages[len-2].setData({  
265 - time_dur:v.list[n-1].time_dur  
266 - })  
267 - }  
268 - if(n==0 && i>0){  
269 - console.log('xxxx',2)  
270 - that.setData({  
271 - time_dur:timelist[i-1].list[timelist[i-1].list.length-1].time_dur,  
272 - })  
273 - timelist[i-1].list[timelist[i-1].list.length-1].isselect=true;  
274 - pages[len-3].setData({  
275 - timeList:timelist,  
276 - time_dur:timelist[i-1].list[timelist[i-1].list.length-1].time_dur, 41 + App.Reserve.GetTableList(formdata).then(function (json) {
  42 + if(json.ret==200){
  43 + if(json.data.length>0){
  44 + json.data.forEach(function(v,i){
  45 + v.list.forEach(function(r,n){
  46 + r.isselect=false
277 }) 47 })
278 - pages[len-2].setData({  
279 - time_dur:timelist[i-1].list[timelist[i-1].list.length-1].time_dur  
280 - })  
281 - }  
282 - if(n>0 && i>0){  
283 - that.setData({  
284 - time_dur:v.list[n-1].time_dur  
285 - })  
286 - v.list[n-1].isselect=true;  
287 - pages[len-3].setData({  
288 - timeList:timelist,  
289 - time_dur:timelist[i-1].list[timelist[i-1].list.length-1].time_dur,  
290 - })  
291 - pages[len-2].setData({  
292 - time_dur:v.list[n-1].time_dur  
293 - })  
294 - } 48 + })
295 } 49 }
296 - })  
297 - })  
298 - var temdate=bookOrder.get_date(this.data.selectdate);  
299 - var stringTime =this.data.thisyear+'-'+temdate+' ' +this.data.time_dur;  
300 - var time=bookOrder.gettimestamp(stringTime);  
301 - this.setData({  
302 - time:time  
303 - })  
304 - pages[len-3].setData({  
305 - time:time  
306 - })  
307 - pages[len-2].setData({  
308 - time:time  
309 - })  
310 - this.getdesklist();  
311 -  
312 -  
313 - },  
314 - aftertime:function(){  
315 - var pages=getCurrentPages();  
316 - var len=pages.length;  
317 - console.log(len)  
318 - var timelist=pages[len-3].data.timeList;  
319 - var datelist=pages[len-3].data.dateList;  
320 - var currendate=bookOrder.get_date(this.data.selectdate);  
321 - var time_dur=this.data.time_dur;  
322 - var dateindex;  
323 - datelist.forEach(function(v,i){  
324 - if(v.date==currendate){  
325 - dateindex=i; 50 + that.setData({
  51 + desklist:json.data
  52 + })
326 } 53 }
327 }) 54 })
328 - var that=this;  
329 - timelist.forEach(function(v,i){  
330 - v.list.forEach(function(r,n){  
331 - r.isselect=false  
332 - if(r.time_dur==time_dur){  
333 - if(i==timelist.length-1 && n==v.list.length-1){  
334 - if(dateindex==2){  
335 - console.log('不能再加了')  
336 - }else{  
337 - console.log('tttttt')  
338 - dateindex=dateindex+1;  
339 - datelist.forEach(function(r1,n1){  
340 - r1.isActive=false;  
341 - if(dateindex==n1){  
342 - r1.isActive=true;  
343 - that.setData({  
344 - thisyear:r1.year  
345 - })  
346 - }  
347 - })  
348 - pages[len-3].setData({  
349 - selectdate:datelist[dateindex].date,  
350 - dateList:datelist  
351 - })  
352 - pages[len-3].getimelist();  
353 - timelist=pages[len-3].data.timeList;  
354 - that.setData({  
355 - selectdate:bookOrder.getdate_num(pages[len-3].data.selectdate),  
356 - time_dur:'6:00'  
357 - })  
358 - console.log(time_dur)  
359 - console.log('hhhh',that.data.time_dur)  
360 - pages[len-2].setData({  
361 - selectdate:bookOrder.getdate_num(pages[len-3].data.selectdate),  
362 - time_dur:'6:00'  
363 - })  
364 - console.log(timelist)  
365 - timelist.forEach(function(r1,n1){  
366 - r1.list.forEach(function(r2,n2){  
367 - r2.isselect=false;  
368 - if(r2.time_dur==that.data.time_dur){  
369 - r2.isselect=true;  
370 - }  
371 - })  
372 - })  
373 - timelist[2].list[0].isselect=false  
374 - console.log('ffff',timelist)  
375 - pages[len-3].setData({  
376 - timeList:timelist,  
377 - time_dur:'6:00'  
378 - })  
379 - var temdate=bookOrder.get_date(that.data.selectdate);  
380 - var stringTime =that.data.thisyear+'-'+temdate+' ' +that.data.time_dur;  
381 - var time=bookOrder.gettimestamp(stringTime);  
382 - that.setData({  
383 - time:time  
384 - })  
385 - pages[len-3].setData({  
386 - time:time  
387 - })  
388 - pages[len-2].setData({  
389 - time:time  
390 - })  
391 - that.getdesklist();  
392 - return;  
393 -  
394 - }  
395 - }  
396 - if(i==timelist.length-1 && n<v.list.length-1){  
397 - that.setData({  
398 - time_dur:v.list[n+1].time_dur  
399 - })  
400 - v.list[n+1].isselect=true  
401 - pages[len-3].setData({  
402 - time_dur:v.list[n+1].time_dur,  
403 - timeList:timelist  
404 - })  
405 - pages[len-2].setData({  
406 - time_dur:v.list[n+1].time_dur  
407 - })  
408 - }  
409 - if(i<timelist.length-1 && n==v.list.length-1){  
410 - that.setData({  
411 - time_dur:timelist[i+1].list[0].time_dur,  
412 - })  
413 - timelist[i+1].list[0].isselect=true;  
414 - pages[len-3].setData({  
415 - time_dur:timelist[i+1].list[0].time_dur,  
416 - timeList:timelist  
417 - })  
418 - pages[len-2].setData({  
419 - time_dur:timelist[i+1].list[0].time_dur,  
420 - })  
421 - }  
422 - if(i<timelist.length-1 && n<v.list.length-1){  
423 - that.setData({  
424 - time_dur:v.list[n+1].time_dur  
425 - })  
426 - v.list[n+1].isselect=true  
427 - pages[len-3].setData({  
428 - time_dur:v.list[n+1].time_dur,  
429 - timeList:timelist  
430 - })  
431 - pages[len-2].setData({  
432 - time_dur:v.list[n+1].time_dur  
433 - })  
434 - }  
435 - }  
436 - })  
437 - })  
438 - var temdate=bookOrder.get_date(this.data.selectdate);  
439 - var stringTime =this.data.thisyear+'-'+temdate+' ' +this.data.time_dur;  
440 - var time=bookOrder.gettimestamp(stringTime);  
441 - this.setData({  
442 - time:time  
443 - })  
444 - pages[len-3].setData({  
445 - time:time  
446 - })  
447 - pages[len-2].setData({  
448 - time:time  
449 - })  
450 - this.getdesklist();  
451 -  
452 }, 55 },
453 }) 56 })
1 -<nav>点餐商户端</nav>  
2 -<view class="other-info flex-lr">  
3 - <view class="selected-time flex-lr">  
4 - <view style="padding:30rpx 40rpx;" bindtap="backtime">  
5 - <image src="../image/green-click-reduce.png" class="icon12-22"></image>  
6 - </view>  
7 - <view class="flex-vc">  
8 - <view class="font34r green-font">{{selectdate}}</view>  
9 - <view class="actual-time green-font font34r">{{time_dur}}</view>  
10 - </view>  
11 - <view style="padding:30rpx 40rpx;" bindtap="aftertime">  
12 - <image src="../image/green-click-add.png" class="icon12-22"></image>  
13 - </view>  
14 - </view>  
15 - <selectPeople bind:changepnum="changepnum" pnum="{{pnum}}"></selectPeople>  
16 -</view>  
17 -<view class="cut"></view>  
18 -  
19 -  
20 -  
21 - 1 +<nav>选择桌位</nav>
22 <!--桌位状态--> 2 <!--桌位状态-->
23 -<view class="desk-type flex-lr">  
24 - <block wx:for="{{desk_type}}">  
25 - <view class="desk-type-single flex-cc {{item.isselect==true ? 'desk-type-single-active white-font' : 'black-font'}} font34r" bindtap="selectType" data-type="{{item.type}}">{{item.type_name}}</view>  
26 - </block>  
27 -</view>  
28 <view class="desk-list" style="padding-bottom:180rpx;"> 3 <view class="desk-list" style="padding-bottom:180rpx;">
29 <block wx:for="{{desklist}}"> 4 <block wx:for="{{desklist}}">
30 <view class="desk-region black-font font34r font-bold">{{item.name}}</view> 5 <view class="desk-region black-font font34r font-bold">{{item.name}}</view>