|
@@ -3,77 +3,81 @@ import comm from '../../../utils/bookCommon'; |
|
@@ -3,77 +3,81 @@ import comm from '../../../utils/bookCommon'; |
|
3
|
import App from '../../../utils/api';
|
3
|
import App from '../../../utils/api';
|
|
4
|
const {regeneratorRuntime} = global
|
4
|
const {regeneratorRuntime} = global
|
|
5
|
Page({
|
5
|
Page({
|
|
6
|
- data:{
|
|
|
|
7
|
- menu_active_id:''
|
|
|
|
8
|
- },
|
|
|
|
9
|
- checked_tids:[],
|
|
|
|
10
|
- desks:[],
|
|
|
|
11
|
- onLoad:function(opt){
|
|
|
|
12
|
- console.log('onLoad',opt)
|
|
|
|
13
|
- util.setBarTitle('选择桌位');
|
|
|
|
14
|
- var radio=750/util.getsystem().windowWidth;
|
|
|
|
15
|
- var contentHeight=util.getsystem().windowHeight-Math.ceil(350/radio);
|
|
|
|
16
|
- if(opt.tid==0){
|
|
|
|
17
|
- delete opt.tid
|
|
|
|
18
|
- }
|
|
|
|
19
|
- if(opt.checked_tids){
|
|
|
|
20
|
- this.checked_tids=opt.checked_tids.split(',')
|
|
|
|
21
|
- util.cache('tableid',this.checked_tids)
|
|
|
|
22
|
- }
|
|
|
|
23
|
- this.setData({
|
|
|
|
24
|
- sellerid:util.cache('sellerid'),
|
|
|
|
25
|
- opt:opt,
|
|
|
|
26
|
- hasCheckedTable:this.checked_tids.length>0
|
|
|
|
27
|
- })
|
|
|
|
28
|
- this.getdesklist();
|
|
|
|
29
|
- },
|
|
|
|
30
|
- onShow:function(){
|
|
|
|
31
|
- this.setData({
|
|
|
|
32
|
- height:getApp().system.windowHeight-55
|
|
|
|
33
|
- })
|
|
|
|
34
|
- },
|
|
|
|
35
|
- changedesk:function(e){
|
|
|
|
36
|
- let tableid=util.cache('tableid');
|
|
|
|
37
|
- this.checked_tids= tableid && tableid.length>0?tableid:[];
|
|
|
|
38
|
- this.setData({
|
|
|
|
39
|
- hasCheckedTable:this.checked_tids.length>0
|
|
|
|
40
|
- })
|
|
|
|
41
|
- },
|
|
|
|
42
|
- back:function(){
|
|
|
|
43
|
- this.setData({
|
|
|
|
44
|
- buttonClick:true
|
|
|
|
45
|
- })
|
|
|
|
46
|
- //wx.removeStorage({key:'tableid'})
|
|
|
|
47
|
- wx.navigateBack();
|
|
|
|
48
|
- },
|
|
|
|
49
|
- getdesklist:function(){
|
|
|
|
50
|
- var formdata=this.data.opt;
|
|
|
|
51
|
- formdata.sid=this.data.sellerid;
|
|
|
|
52
|
- var that=this;
|
|
|
|
53
|
- App.Reserve.GetTableList(formdata).then(function (json) {
|
|
|
|
54
|
- if(json.ret==200){
|
|
|
|
55
|
- console.log('this.checked_tids',that.checked_tids);
|
|
|
|
56
|
- that.desks=json.data
|
|
|
|
57
|
- that.formatDesklist(true)
|
|
|
|
58
|
- }
|
|
|
|
59
|
- })
|
|
|
|
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;
|
6
|
+ data: {
|
|
|
|
7
|
+ menu_active_id: ''
|
|
|
|
8
|
+ },
|
|
|
|
9
|
+ checked_tids: [],
|
|
|
|
10
|
+ desks: [],
|
|
|
|
11
|
+ sellerid:'',
|
|
|
|
12
|
+ options:null,
|
|
|
|
13
|
+ onLoad: function (opt) {
|
|
|
|
14
|
+ console.log('onLoad', opt)
|
|
|
|
15
|
+ this.options=opt;
|
|
|
|
16
|
+ var radio = 750 / util.getsystem().windowWidth;
|
|
|
|
17
|
+ var contentHeight = util.getsystem().windowHeight - Math.ceil(350 / radio);
|
|
|
|
18
|
+ if (opt.tid == 0) {
|
|
|
|
19
|
+ delete opt.tid
|
|
|
|
20
|
+ }
|
|
|
|
21
|
+ if (opt.checked_tids) {
|
|
|
|
22
|
+ this.checked_tids = opt.checked_tids.split(',')
|
|
|
|
23
|
+ util.cache('tableid', this.checked_tids)
|
|
|
|
24
|
+ }
|
|
|
|
25
|
+ this.sellerid=util.cache('sellerid');
|
|
|
|
26
|
+ this.setData({
|
|
|
|
27
|
+ sellerid: this.sellerid,
|
|
|
|
28
|
+ opt: opt,
|
|
|
|
29
|
+ hasCheckedTable: this.checked_tids.length > 0
|
|
|
|
30
|
+ })
|
|
|
|
31
|
+ //this.getdesklist();
|
|
|
|
32
|
+ this.getDeskList();
|
|
|
|
33
|
+ },
|
|
|
|
34
|
+ onShow: function () {
|
|
|
|
35
|
+ this.setData({
|
|
|
|
36
|
+ height: getApp().system.windowHeight - 55
|
|
|
|
37
|
+ })
|
|
|
|
38
|
+ },
|
|
|
|
39
|
+ changedesk: function (e) {
|
|
|
|
40
|
+ let tableid = util.cache('tableid');
|
|
|
|
41
|
+ this.checked_tids = tableid && tableid.length > 0 ? tableid : [];
|
|
|
|
42
|
+ this.setData({
|
|
|
|
43
|
+ hasCheckedTable: this.checked_tids.length > 0
|
|
|
|
44
|
+ })
|
|
|
|
45
|
+ },
|
|
|
|
46
|
+ back: function () {
|
|
|
|
47
|
+ this.setData({
|
|
|
|
48
|
+ buttonClick: true
|
|
|
|
49
|
+ })
|
|
|
|
50
|
+ //wx.removeStorage({key:'tableid'})
|
|
|
|
51
|
+ wx.navigateBack();
|
|
|
|
52
|
+ },
|
|
|
|
53
|
+ getdesklist: function () {
|
|
|
|
54
|
+ var formdata = this.data.opt;
|
|
|
|
55
|
+ formdata.sid = this.data.sellerid;
|
|
|
|
56
|
+ var that = this;
|
|
|
|
57
|
+ App.Reserve.GetTableList(formdata).then(function (json) {
|
|
|
|
58
|
+ if (json.ret == 200) {
|
|
|
|
59
|
+ console.log('this.checked_tids', that.checked_tids);
|
|
|
|
60
|
+ that.desks = json.data
|
|
|
|
61
|
+ that.formatDesklist(true)
|
|
|
|
62
|
+ }
|
|
|
|
63
|
+ })
|
|
|
|
64
|
+ },
|
|
|
|
65
|
+ formatDesklist(hasFirst = true){
|
|
|
|
66
|
+ let desks = this.desks;
|
|
|
|
67
|
+ if (desks.length > 0) {
|
|
|
|
68
|
+ desks.forEach((v, i) => {
|
|
|
|
69
|
+ v.list.forEach((r, n) => {
|
|
|
|
70
|
+ r.isselect = false
|
|
|
|
71
|
+ if (this.checked_tids._indexOf(r.id) > -1) {
|
|
|
|
72
|
+ r.isselect = true;
|
|
69
|
}
|
73
|
}
|
|
70
|
})
|
74
|
})
|
|
71
|
})
|
75
|
})
|
|
72
|
- let param={
|
|
|
|
73
|
- desklist:desks,
|
76
|
+ let param = {
|
|
|
|
77
|
+ desklist: desks,
|
|
74
|
}
|
78
|
}
|
|
75
|
- if(hasFirst){
|
|
|
|
76
|
- param.menu_active_id=desks[0].name
|
79
|
+ if (hasFirst) {
|
|
|
|
80
|
+ param.menu_active_id = desks[0].name
|
|
77
|
}
|
81
|
}
|
|
78
|
this.setData(param)
|
82
|
this.setData(param)
|
|
79
|
}
|
83
|
}
|
|
@@ -83,7 +87,85 @@ Page({ |
|
@@ -83,7 +87,85 @@ Page({ |
|
83
|
|
87
|
|
|
84
|
this.formatDesklist(false)
|
88
|
this.formatDesklist(false)
|
|
85
|
this.setData({
|
89
|
this.setData({
|
|
86
|
- menu_active_id:util.attr(e,'id')
|
90
|
+ menu_active_id: util.attr(e, 'id')
|
|
|
|
91
|
+ })
|
|
|
|
92
|
+ },
|
|
|
|
93
|
+ getDeskList(){
|
|
|
|
94
|
+ App.Tables.GetTableListsBySellerId({
|
|
|
|
95
|
+ sellerid:this.sellerid
|
|
|
|
96
|
+ }).then((res)=>{
|
|
|
|
97
|
+ this.desks=res.data[0];
|
|
|
|
98
|
+ this.getbooklist();
|
|
|
|
99
|
+ })
|
|
|
|
100
|
+ },
|
|
|
|
101
|
+ async getbooklist(){
|
|
|
|
102
|
+ let obj={};
|
|
|
|
103
|
+
|
|
|
|
104
|
+ let formdata={};
|
|
|
|
105
|
+ formdata.sid=this.sellerid;
|
|
|
|
106
|
+ formdata.x=1;
|
|
|
|
107
|
+ formdata.y=200;
|
|
|
|
108
|
+ formdata.rdate=this.options.rdate;
|
|
|
|
109
|
+ formdata.status='1,2';
|
|
|
|
110
|
+ let tids={};
|
|
|
|
111
|
+ let reserves=await App.Reserve.GetReserveList(formdata);
|
|
|
|
112
|
+ if(reserves.data.length>0){
|
|
|
|
113
|
+ reserves.data.forEach(r=>{
|
|
|
|
114
|
+ let ts=r.tid.split(',');
|
|
|
|
115
|
+ ts.forEach(tid=>{
|
|
|
|
116
|
+ let rname='';
|
|
|
|
117
|
+ if(r.sex==3){
|
|
|
|
118
|
+ rname=r.rname.substr(0,10)
|
|
|
|
119
|
+ }else{
|
|
|
|
120
|
+ rname=r.rname.substr(0,1)+(r.sex==1?'先生':'女士')
|
|
|
|
121
|
+ }
|
|
|
|
122
|
+ tids[tid]={
|
|
|
|
123
|
+ rdate:r.rdate,
|
|
|
|
124
|
+ id:r.id,
|
|
|
|
125
|
+ status:r.status,
|
|
|
|
126
|
+ rname:rname,
|
|
|
|
127
|
+ }
|
|
|
|
128
|
+ })
|
|
|
|
129
|
+ })
|
|
|
|
130
|
+ }
|
|
|
|
131
|
+ console.log('tids',tids);
|
|
|
|
132
|
+ let regions=[];
|
|
|
|
133
|
+ this.desks.forEach(region=>{
|
|
|
|
134
|
+ if(region.list.length>0){
|
|
|
|
135
|
+ let list_num=0;
|
|
|
|
136
|
+ region.list.forEach(tb=>{
|
|
|
|
137
|
+ tb.status_str='';
|
|
|
|
138
|
+ tb.status_classname='enabled'
|
|
|
|
139
|
+ tb.reserve_name=''
|
|
|
|
140
|
+ tb.reserve_id=''
|
|
|
|
141
|
+ if(tb.status!=0 && tb.status!=""){
|
|
|
|
142
|
+ tb.status_str='用餐中';
|
|
|
|
143
|
+ tb.status_classname='highlight';
|
|
|
|
144
|
+ tb.reserve_name=tb.spell==1?'拼桌':'堂食';
|
|
|
|
145
|
+ }else if(tids[tb.id]){
|
|
|
|
146
|
+ console.log('tids',region.name,tb.name);
|
|
|
|
147
|
+ tb.status_str=tids[tb.id].status==2?'用餐中':'已预订';
|
|
|
|
148
|
+ tb.status_classname='highlight';
|
|
|
|
149
|
+ tb.reserve_id=tids[tb.id].id;
|
|
|
|
150
|
+ tb.reserve_name=tids[tb.id].rname;
|
|
|
|
151
|
+ }
|
|
|
|
152
|
+ if(tb.enable!=1){
|
|
|
|
153
|
+ if(tb.status_str){
|
|
|
|
154
|
+ tb.status_classname='disabled-highlight';
|
|
|
|
155
|
+ }else{
|
|
|
|
156
|
+ tb.status_str='已停用';
|
|
|
|
157
|
+ tb.status_classname='disabled';
|
|
|
|
158
|
+ }
|
|
|
|
159
|
+ }
|
|
|
|
160
|
+ if(!tb.status_str){
|
|
|
|
161
|
+ list_num++;
|
|
|
|
162
|
+ }
|
|
|
|
163
|
+ region.list_num=list_num;
|
|
|
|
164
|
+ })
|
|
|
|
165
|
+ regions.push(region);
|
|
|
|
166
|
+ }
|
|
87
|
})
|
167
|
})
|
|
|
|
168
|
+ this.desks=regions
|
|
|
|
169
|
+ this.formatDesklist(true);
|
|
88
|
},
|
170
|
},
|
|
89
|
}) |
171
|
}) |