Commit 20287fd694df936e8fa192ca9c7bfc59acc73246

Authored by wangfan
1 parent c39728de

选择桌位 & 卡座

@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 </view> 9 </view>
10 </view> 10 </view>
11 <view class="tid" wx:if="{{board.tid==2}}">包间</view> 11 <view class="tid" wx:if="{{board.tid==2}}">包间</view>
  12 + <view class="tid" wx:if="{{board.tid==3}}">卡座</view>
12 <view class="status" wx:if="{{board.status_str}}" style="width: {{width}}rpx;">{{board.status_str}}</view> 13 <view class="status" wx:if="{{board.status_str}}" style="width: {{width}}rpx;">{{board.status_str}}</view>
13 <icon type="success" size="20" color="#199095" class="desk-active" wx:if="{{board.isselect==true}}"/> 14 <icon type="success" size="20" color="#199095" class="desk-active" wx:if="{{board.isselect==true}}"/>
14 </view> 15 </view>
@@ -7,6 +7,7 @@ Page({ @@ -7,6 +7,7 @@ Page({
7 menu_active_id:'' 7 menu_active_id:''
8 }, 8 },
9 checked_tids:[], 9 checked_tids:[],
  10 + desks:[],
10 onLoad:function(opt){ 11 onLoad:function(opt){
11 console.log('onLoad',opt) 12 console.log('onLoad',opt)
12 util.setBarTitle('选择桌位'); 13 util.setBarTitle('选择桌位');
@@ -52,24 +53,35 @@ Page({ @@ -52,24 +53,35 @@ Page({
52 App.Reserve.GetTableList(formdata).then(function (json) { 53 App.Reserve.GetTableList(formdata).then(function (json) {
53 if(json.ret==200){ 54 if(json.ret==200){
54 console.log('this.checked_tids',that.checked_tids); 55 console.log('this.checked_tids',that.checked_tids);
55 - if(json.data.length>0){  
56 - json.data.forEach(function(v,i){  
57 - v.list.forEach(function(r,n){  
58 - r.isselect=false  
59 - if(that.checked_tids._indexOf(r.id)>-1){  
60 - r.isselect=true;  
61 - }  
62 - })  
63 - })  
64 - }  
65 - that.setData({  
66 - desklist:json.data,  
67 - menu_active_id:json.data[0].name  
68 - }) 56 + that.desks=json.data
  57 + that.formatDesklist(true)
69 } 58 }
70 }) 59 })
71 }, 60 },
  61 + formatDesklist(hasFirst=true){
  62 + let desks=this.desks;
  63 + if(desks.length>0){
  64 + desks.forEach((v,i)=>{
  65 + v.list.forEach((r,n)=>{
  66 + r.isselect=false
  67 + if(this.checked_tids._indexOf(r.id)>-1){
  68 + r.isselect=true;
  69 + }
  70 + })
  71 + })
  72 + let param={
  73 + desklist:desks,
  74 + }
  75 + if(hasFirst){
  76 + param.menu_active_id=desks[0].name
  77 + }
  78 + this.setData(param)
  79 + }
  80 + return desks;
  81 + },
72 switchMenu(e){ 82 switchMenu(e){
  83 +
  84 + this.formatDesklist(false)
73 this.setData({ 85 this.setData({
74 menu_active_id:util.attr(e,'id') 86 menu_active_id:util.attr(e,'id')
75 }) 87 })