|
@@ -3,20 +3,20 @@ import util from '../../utils/util'; |
|
@@ -3,20 +3,20 @@ import util from '../../utils/util'; |
|
3
|
import comm from '../../utils/bookCommon';
|
3
|
import comm from '../../utils/bookCommon';
|
|
4
|
import App from '../../utils/api';
|
4
|
import App from '../../utils/api';
|
|
5
|
const {regeneratorRuntime} = global
|
5
|
const {regeneratorRuntime} = global
|
|
6
|
-const formTpl={
|
|
|
|
7
|
- rid:'',
|
|
|
|
8
|
- date:0,
|
|
|
|
9
|
- time:0,
|
|
|
|
10
|
- //pnum_str:'1-4',
|
|
|
|
11
|
- pnum:6,
|
|
|
|
12
|
- tabid:0,
|
6
|
+const formTpl = {
|
|
|
|
7
|
+ rid: '',
|
|
|
|
8
|
+ date: 0,
|
|
|
|
9
|
+ time: 0,
|
|
|
|
10
|
+ //pnum_str:'1-4',
|
|
|
|
11
|
+ pnum: 6,
|
|
|
|
12
|
+ tabid: 0,
|
|
13
|
|
13
|
|
|
14
|
- rname:'',
|
|
|
|
15
|
- phone:'',
|
|
|
|
16
|
- sex:1,
|
|
|
|
17
|
- cusdem:'',
|
14
|
+ rname: '',
|
|
|
|
15
|
+ phone: '',
|
|
|
|
16
|
+ sex: 1,
|
|
|
|
17
|
+ cusdem: '',
|
|
18
|
|
18
|
|
|
19
|
- tid:[],
|
19
|
+ tid: [],
|
|
20
|
|
20
|
|
|
21
|
}
|
21
|
}
|
|
22
|
Page({
|
22
|
Page({
|
|
@@ -25,124 +25,125 @@ Page({ |
|
@@ -25,124 +25,125 @@ Page({ |
|
25
|
* 页面的初始数据
|
25
|
* 页面的初始数据
|
|
26
|
*/
|
26
|
*/
|
|
27
|
data: {
|
27
|
data: {
|
|
28
|
- dateStr:[],
|
|
|
|
29
|
- form:JSON.parse(JSON.stringify(formTpl)),
|
|
|
|
30
|
- tables:[],
|
|
|
|
31
|
- grand:[
|
|
|
|
32
|
- {
|
|
|
|
33
|
- sex:1,
|
|
|
|
34
|
- grand_title:'先生',
|
|
|
|
35
|
- isselect:true
|
|
|
|
36
|
- },
|
|
|
|
37
|
- {
|
|
|
|
38
|
- sex:2,
|
|
|
|
39
|
- grand_title:'女士',
|
|
|
|
40
|
- isselect:false
|
|
|
|
41
|
- },
|
|
|
|
42
|
- {
|
|
|
|
43
|
- sex:3,
|
|
|
|
44
|
- grand_title:'公司',
|
|
|
|
45
|
- isselect:false
|
|
|
|
46
|
- }
|
|
|
|
47
|
- ],
|
|
|
|
48
|
- buttonhide:true,
|
28
|
+ dateStr: [],
|
|
|
|
29
|
+ form: JSON.parse(JSON.stringify(formTpl)),
|
|
|
|
30
|
+ tables: [],
|
|
|
|
31
|
+ grand: [
|
|
|
|
32
|
+ {
|
|
|
|
33
|
+ sex: 1,
|
|
|
|
34
|
+ grand_title: '先生',
|
|
|
|
35
|
+ isselect: true
|
|
|
|
36
|
+ },
|
|
|
|
37
|
+ {
|
|
|
|
38
|
+ sex: 2,
|
|
|
|
39
|
+ grand_title: '女士',
|
|
|
|
40
|
+ isselect: false
|
|
|
|
41
|
+ },
|
|
|
|
42
|
+ {
|
|
|
|
43
|
+ sex: 3,
|
|
|
|
44
|
+ grand_title: '公司',
|
|
|
|
45
|
+ isselect: false
|
|
|
|
46
|
+ }
|
|
|
|
47
|
+ ],
|
|
|
|
48
|
+ buttonhide: true,
|
|
49
|
|
49
|
|
|
50
|
- calendarMaskLoad:false,
|
|
|
|
51
|
- calendarMask:false,
|
|
|
|
52
|
- dayStyle:[
|
|
|
|
53
|
- { month: 'current', day: new Date().getDate(), color: 'white', background: '#AAD4F5' },
|
|
|
|
54
|
- { month: 'current', day: new Date().getDate(), color: 'white', background: '#AAD4F5' }
|
|
|
|
55
|
- ],
|
|
|
|
56
|
- timePickerArray:[
|
|
|
|
57
|
- [],
|
|
|
|
58
|
- [],
|
|
|
|
59
|
- [],
|
|
|
|
60
|
- ],
|
|
|
|
61
|
- timePickerIndex:[0,0,0],
|
|
|
|
62
|
- tablesLength:0,
|
50
|
+ calendarMaskLoad: false,
|
|
|
|
51
|
+ calendarMask: false,
|
|
|
|
52
|
+ dayStyle: [
|
|
|
|
53
|
+ {month: 'current', day: new Date().getDate(), color: 'white', background: '#AAD4F5'},
|
|
|
|
54
|
+ {month: 'current', day: new Date().getDate(), color: 'white', background: '#AAD4F5'}
|
|
|
|
55
|
+ ],
|
|
|
|
56
|
+ timePickerArray: [
|
|
|
|
57
|
+ [],
|
|
|
|
58
|
+ [],
|
|
|
|
59
|
+ [],
|
|
|
|
60
|
+ ],
|
|
|
|
61
|
+ timePickerIndex: [0, 0, 0],
|
|
|
|
62
|
+ tablesLength: 0,
|
|
63
|
|
63
|
|
|
64
|
- timePickerMask:false,
|
|
|
|
65
|
- pnumInputFocus:false,
|
|
|
|
66
|
- pageMarginBottom:0,
|
|
|
|
67
|
- speciallist:[],
|
|
|
|
68
|
- calendar:{
|
|
|
|
69
|
- nextNum:0,
|
64
|
+ timePickerMask: false,
|
|
|
|
65
|
+ pnumInputFocus: false,
|
|
|
|
66
|
+ pageMarginBottom: 0,
|
|
|
|
67
|
+ speciallist: [],
|
|
|
|
68
|
+ calendar: {
|
|
|
|
69
|
+ nextNum: 0,
|
|
70
|
},
|
70
|
},
|
|
71
|
- defDtime:['','12:00','18:30'],
|
|
|
|
72
|
- hasUseDefDtime:true,
|
71
|
+ defDtime: ['', '12:00', '18:30'],
|
|
|
|
72
|
+ hasUseDefDtime: true,
|
|
73
|
},
|
73
|
},
|
|
74
|
/**
|
74
|
/**
|
|
75
|
* 生命周期函数--监听页面加载
|
75
|
* 生命周期函数--监听页面加载
|
|
76
|
*/
|
76
|
*/
|
|
77
|
- reserve_id:'',
|
77
|
+ reserve_id: '',
|
|
|
|
78
|
+ checkedTables:{},//已选中的桌子集合
|
|
78
|
onLoad: async function (options) {
|
79
|
onLoad: async function (options) {
|
|
79
|
- this.initLoad(options)
|
80
|
+ this.initLoad(options)
|
|
80
|
},
|
81
|
},
|
|
81
|
- async initLoad(options={}){
|
|
|
|
82
|
- let nt=new Date()/1000;
|
|
|
|
83
|
- let speciallist=[
|
|
|
|
84
|
- { date: util.unixtoTime(nt,'YYYY-MM-DD'), background: '', text:'今 天' },
|
|
|
|
85
|
- { date: util.unixtoTime(nt+86400,'YYYY-MM-DD'), background: '', text: '明 天' },
|
|
|
|
86
|
- { date: util.unixtoTime(nt+86400*2,'YYYY-MM-DD'), background: '', text: '后 天' },
|
|
|
|
87
|
- ];
|
|
|
|
88
|
- this.reserve_id=options.id||'';
|
82
|
+ async initLoad(options = {}){
|
|
|
|
83
|
+ let nt = new Date() / 1000;
|
|
|
|
84
|
+ let speciallist = [
|
|
|
|
85
|
+ {date: util.unixtoTime(nt, 'YYYY-MM-DD'), background: '', text: '今 天'},
|
|
|
|
86
|
+ {date: util.unixtoTime(nt + 86400, 'YYYY-MM-DD'), background: '', text: '明 天'},
|
|
|
|
87
|
+ {date: util.unixtoTime(nt + 86400 * 2, 'YYYY-MM-DD'), background: '', text: '后 天'},
|
|
|
|
88
|
+ ];
|
|
|
|
89
|
+ this.reserve_id = options.id || '';
|
|
89
|
await this.setDateStr();
|
90
|
await this.setDateStr();
|
|
90
|
- this.sellerid=util.cache('sellerid');
|
|
|
|
91
|
- let timePickerArray= await comm.getDayTimeSpace();
|
91
|
+ this.sellerid = util.cache('sellerid');
|
|
|
|
92
|
+ let timePickerArray = await comm.getDayTimeSpace();
|
|
92
|
//判断hasUseDefDtime
|
93
|
//判断hasUseDefDtime
|
|
93
|
- let hasUseDefDtime=true;
|
|
|
|
94
|
- let mmii=util.unixtoTime(new Date()/1000,'HH:II');
|
|
|
|
95
|
- if(mmii>this.data.defDtime[this.data.form.time]){
|
|
|
|
96
|
- hasUseDefDtime=false;
|
94
|
+ let hasUseDefDtime = true;
|
|
|
|
95
|
+ let mmii = util.unixtoTime(new Date() / 1000, 'HH:II');
|
|
|
|
96
|
+ if (mmii > this.data.defDtime[this.data.form.time]) {
|
|
|
|
97
|
+ hasUseDefDtime = false;
|
|
97
|
}
|
98
|
}
|
|
98
|
|
99
|
|
|
99
|
this.setData({
|
100
|
this.setData({
|
|
100
|
timePickerArray: timePickerArray,
|
101
|
timePickerArray: timePickerArray,
|
|
101
|
- speciallist:speciallist,
|
|
|
|
102
|
- hasUseDefDtime:hasUseDefDtime,
|
102
|
+ speciallist: speciallist,
|
|
|
|
103
|
+ hasUseDefDtime: hasUseDefDtime,
|
|
103
|
})
|
104
|
})
|
|
104
|
- if(this.reserve_id>0){
|
105
|
+ if (this.reserve_id > 0) {
|
|
105
|
this.initModify(this.reserve_id);
|
106
|
this.initModify(this.reserve_id);
|
|
106
|
- }else{
|
107
|
+ } else {
|
|
107
|
this.getTables();
|
108
|
this.getTables();
|
|
108
|
}
|
109
|
}
|
|
109
|
},
|
110
|
},
|
|
110
|
- /**
|
|
|
|
111
|
- *
|
|
|
|
112
|
- * @param d
|
|
|
|
113
|
- *
|
|
|
|
114
|
- */
|
|
|
|
115
|
- async setDateStr(d=new Date()/1000){
|
|
|
|
116
|
- let ns=new Date()/1000;
|
|
|
|
117
|
- let dateStr=[
|
|
|
|
118
|
- util.unixtoTime(ns,'MM-DD `DAY/周WW`'),
|
|
|
|
119
|
- util.unixtoTime(parseInt(ns)+86400,'MM-DD `DAY/周WW`'),
|
|
|
|
120
|
- ];
|
|
|
|
121
|
- //let dateStr=this.data.dateStr;
|
|
|
|
122
|
- let nowStr=util.unixtoTime(d,'MM-DD `DAY/周WW`')
|
|
|
|
123
|
- let form=this.data.form;
|
111
|
+ /**
|
|
|
|
112
|
+ *
|
|
|
|
113
|
+ * @param d
|
|
|
|
114
|
+ *
|
|
|
|
115
|
+ */
|
|
|
|
116
|
+ async setDateStr(d = new Date() / 1000){
|
|
|
|
117
|
+ let ns = new Date() / 1000;
|
|
|
|
118
|
+ let dateStr = [
|
|
|
|
119
|
+ util.unixtoTime(ns, 'MM-DD `DAY/周WW`'),
|
|
|
|
120
|
+ util.unixtoTime(parseInt(ns) + 86400, 'MM-DD `DAY/周WW`'),
|
|
|
|
121
|
+ ];
|
|
|
|
122
|
+ //let dateStr=this.data.dateStr;
|
|
|
|
123
|
+ let nowStr = util.unixtoTime(d, 'MM-DD `DAY/周WW`')
|
|
|
|
124
|
+ let form = this.data.form;
|
|
124
|
|
125
|
|
|
125
|
- let timeObj = await comm.getTimeSpaceIndexData(d);
|
|
|
|
126
|
- //form.time=await comm.getTimeSpaceIndex(d);
|
|
|
|
127
|
- form.time=timeObj.timeIndex;
|
126
|
+ let timeObj = await comm.getTimeSpaceIndexData(d);
|
|
|
|
127
|
+ //form.time=await comm.getTimeSpaceIndex(d);
|
|
|
|
128
|
+ form.time = timeObj.timeIndex;
|
|
128
|
|
129
|
|
|
129
|
- let ind=dateStr._indexOf(nowStr);
|
|
|
|
130
|
- if(ind>-1){
|
|
|
|
131
|
- form.date=ind
|
|
|
|
132
|
- }else{
|
|
|
|
133
|
- dateStr.push(nowStr.substr(0,5));
|
|
|
|
134
|
- form.date=2;
|
|
|
|
135
|
- }
|
|
|
|
136
|
- let timePickerIndex=this.data.timePickerIndex;
|
|
|
|
137
|
- timePickerIndex[timeObj.timeIndex]=timeObj.timeMatchIndex;
|
|
|
|
138
|
- let obj={
|
|
|
|
139
|
- dateStr:dateStr,
|
|
|
|
140
|
- form:form,
|
|
|
|
141
|
- timePickerIndex:timePickerIndex,
|
|
|
|
142
|
- timeOpt:timeObj.timeOpt,
|
|
|
|
143
|
- };
|
|
|
|
144
|
- this.setData(obj)
|
|
|
|
145
|
- return obj;
|
130
|
+ let ind = dateStr._indexOf(nowStr);
|
|
|
|
131
|
+ if (ind > -1) {
|
|
|
|
132
|
+ form.date = ind
|
|
|
|
133
|
+ } else {
|
|
|
|
134
|
+ dateStr.push(nowStr.substr(0, 5));
|
|
|
|
135
|
+ form.date = 2;
|
|
|
|
136
|
+ }
|
|
|
|
137
|
+ let timePickerIndex = this.data.timePickerIndex;
|
|
|
|
138
|
+ timePickerIndex[timeObj.timeIndex] = timeObj.timeMatchIndex;
|
|
|
|
139
|
+ let obj = {
|
|
|
|
140
|
+ dateStr: dateStr,
|
|
|
|
141
|
+ form: form,
|
|
|
|
142
|
+ timePickerIndex: timePickerIndex,
|
|
|
|
143
|
+ timeOpt: timeObj.timeOpt,
|
|
|
|
144
|
+ };
|
|
|
|
145
|
+ this.setData(obj)
|
|
|
|
146
|
+ return obj;
|
|
146
|
|
147
|
|
|
147
|
},
|
148
|
},
|
|
148
|
|
149
|
|
|
@@ -157,16 +158,16 @@ Page({ |
|
@@ -157,16 +158,16 @@ Page({ |
|
157
|
* 生命周期函数--监听页面显示
|
158
|
* 生命周期函数--监听页面显示
|
|
158
|
*/
|
159
|
*/
|
|
159
|
onShow: function () {
|
160
|
onShow: function () {
|
|
160
|
- //if(!this.reserve_id || util.cache('tableid').length>0){
|
|
|
|
161
|
- if(util.cache('tableid').length>0){
|
|
|
|
162
|
- this.getTables();
|
|
|
|
163
|
- }
|
|
|
|
164
|
- setTimeout(()=>{
|
|
|
|
165
|
- this.setData({
|
|
|
|
166
|
- calendarMaskLoad:true,
|
|
|
|
167
|
- })
|
|
|
|
168
|
- },1000);
|
|
|
|
169
|
- this.conditionInfo()
|
161
|
+ //if(!this.reserve_id || util.cache('tableid').length>0){
|
|
|
|
162
|
+ if (util.cache('tableid').length > 0) {
|
|
|
|
163
|
+ this.getTables();
|
|
|
|
164
|
+ }
|
|
|
|
165
|
+ setTimeout(() => {
|
|
|
|
166
|
+ this.setData({
|
|
|
|
167
|
+ calendarMaskLoad: true,
|
|
|
|
168
|
+ })
|
|
|
|
169
|
+ }, 1000);
|
|
|
|
170
|
+ this.conditionInfo()
|
|
170
|
},
|
171
|
},
|
|
171
|
|
172
|
|
|
172
|
/**
|
173
|
/**
|
|
@@ -203,401 +204,429 @@ Page({ |
|
@@ -203,401 +204,429 @@ Page({ |
|
203
|
onShareAppMessage: function () {
|
204
|
onShareAppMessage: function () {
|
|
204
|
|
205
|
|
|
205
|
},
|
206
|
},
|
|
206
|
- selectedValue(e){
|
|
|
|
207
|
- console.log(e);
|
|
|
|
208
|
- let key=util.attr(e,'key');
|
|
|
|
209
|
- let val;
|
|
|
|
210
|
- let sobj={};
|
|
|
|
211
|
- if(e.type=='input' || e.type=='confirm'){
|
|
|
|
212
|
- val=util.val(e);
|
|
|
|
213
|
- if(key=='phone'){
|
|
|
|
214
|
- var that=this;
|
|
|
|
215
|
- if(e.detail.value!='' && e.detail.value.length>=3) {
|
|
|
|
216
|
- App.Reserve.GetReserveUser(
|
|
|
|
217
|
- {
|
|
|
|
218
|
- keywords:e.detail.value,
|
|
|
|
219
|
- sid:this.sellerid
|
|
|
|
220
|
- }
|
|
|
|
221
|
- ).then(function(json){
|
|
|
|
222
|
- if(json.ret==200 && json.data.length>0){
|
|
|
|
223
|
- that.setData({
|
|
|
|
224
|
- searchlist:json.data
|
|
|
|
225
|
- })
|
|
|
|
226
|
- }else{
|
|
|
|
227
|
- that.setData({
|
|
|
|
228
|
- searchlist:null
|
|
|
|
229
|
- })
|
|
|
|
230
|
- }
|
|
|
|
231
|
- })
|
|
|
|
232
|
- }else{
|
|
|
|
233
|
- this.setData({
|
|
|
|
234
|
- searchlist:null
|
|
|
|
235
|
- })
|
|
|
|
236
|
- }
|
|
|
|
237
|
- }
|
|
|
|
238
|
- if(key=='pnum'){
|
|
|
|
239
|
- sobj.pnumInputFocus=true;
|
|
|
|
240
|
- }
|
|
|
|
241
|
- }else{
|
|
|
|
242
|
- val=util.attr(e,'value');
|
207
|
+ selectedValue(e){
|
|
|
|
208
|
+ console.log(e);
|
|
|
|
209
|
+ let key = util.attr(e, 'key');
|
|
|
|
210
|
+ let val;
|
|
|
|
211
|
+ let sobj = {};
|
|
|
|
212
|
+ if (e.type == 'input' || e.type == 'confirm') {
|
|
|
|
213
|
+ val = util.val(e);
|
|
|
|
214
|
+ if (key == 'phone') {
|
|
|
|
215
|
+ var that = this;
|
|
|
|
216
|
+ if (e.detail.value != '' && e.detail.value.length >= 3) {
|
|
|
|
217
|
+ App.Reserve.GetReserveUser(
|
|
|
|
218
|
+ {
|
|
|
|
219
|
+ keywords: e.detail.value,
|
|
|
|
220
|
+ sid: this.sellerid
|
|
|
|
221
|
+ }
|
|
|
|
222
|
+ ).then(function (json) {
|
|
|
|
223
|
+ if (json.ret == 200 && json.data.length > 0) {
|
|
|
|
224
|
+ that.setData({
|
|
|
|
225
|
+ searchlist: json.data
|
|
|
|
226
|
+ })
|
|
|
|
227
|
+ } else {
|
|
|
|
228
|
+ that.setData({
|
|
|
|
229
|
+ searchlist: null
|
|
|
|
230
|
+ })
|
|
|
|
231
|
+ }
|
|
|
|
232
|
+ })
|
|
|
|
233
|
+ } else {
|
|
|
|
234
|
+ this.setData({
|
|
|
|
235
|
+ searchlist: null
|
|
|
|
236
|
+ })
|
|
|
|
237
|
+ }
|
|
243
|
}
|
238
|
}
|
|
244
|
- if(key=='time'){
|
|
|
|
245
|
- if(this.data.timeOpt[val]) return;
|
239
|
+ if (key == 'pnum') {
|
|
|
|
240
|
+ sobj.pnumInputFocus = true;
|
|
246
|
}
|
241
|
}
|
|
247
|
- if((key=='time' && this.data.form.time==val) || (key=='date' && this.data.form.date==val) ){
|
|
|
|
248
|
- if(util.attr(e,'display')!='block') {
|
|
|
|
249
|
- return;
|
|
|
|
250
|
- }
|
242
|
+ } else {
|
|
|
|
243
|
+ val = util.attr(e, 'value');
|
|
|
|
244
|
+ }
|
|
|
|
245
|
+ if (key == 'time') {
|
|
|
|
246
|
+ if (this.data.timeOpt[val]) return;
|
|
|
|
247
|
+ }
|
|
|
|
248
|
+ if ((key == 'time' && this.data.form.time == val) || (key == 'date' && this.data.form.date == val)) {
|
|
|
|
249
|
+ if (util.attr(e, 'display') != 'block') {
|
|
|
|
250
|
+ return;
|
|
251
|
}
|
251
|
}
|
|
252
|
- let form=this.data.form;
|
252
|
+ }
|
|
|
|
253
|
+ let form = this.data.form;
|
|
253
|
|
254
|
|
|
254
|
- if(key=='tid'){
|
|
|
|
255
|
- let ts=this.data.tables;
|
|
|
|
256
|
- if(ts[val].isselect){
|
|
|
|
257
|
- ts[val].isselect=false;
|
|
|
|
258
|
- form.tid.remove(ts[val].id);
|
|
|
|
259
|
- }else{
|
|
|
|
260
|
- ts[val].isselect=true;
|
|
|
|
261
|
- form.tid.push(ts[val].id);
|
|
|
|
262
|
- }
|
|
|
|
263
|
- sobj.tables=ts;
|
|
|
|
264
|
- }else{
|
|
|
|
265
|
- form[key]=val;
|
255
|
+ if (key == 'tid') {
|
|
|
|
256
|
+ let ts = this.data.tables;
|
|
|
|
257
|
+ if (ts[val].isselect) {
|
|
|
|
258
|
+ ts[val].isselect = false;
|
|
|
|
259
|
+ form.tid.remove(ts[val].id);
|
|
|
|
260
|
+ delete this.checkedTables[ts[val].id]
|
|
|
|
261
|
+ } else {
|
|
|
|
262
|
+ ts[val].isselect = true;
|
|
|
|
263
|
+ form.tid.push(ts[val].id);
|
|
|
|
264
|
+ this.checkedTables[ts[val].id]=ts[val].name
|
|
266
|
}
|
265
|
}
|
|
267
|
- console.log('ts',sobj.tables);
|
|
|
|
268
|
- //console.log(e.type,key,val,form);
|
|
|
|
269
|
- sobj.form=form;
|
|
|
|
270
|
- sobj.buttonhide=true;
|
|
|
|
271
|
- if(form.tid.length>0 && form.rname.length>0){
|
|
|
|
272
|
- sobj.buttonhide=false;
|
|
|
|
273
|
- }
|
|
|
|
274
|
- let displayTimes=false;
|
|
|
|
275
|
- if(key=='time'){
|
|
|
|
276
|
- if(util.attr(e,'display')=='block'){
|
|
|
|
277
|
- displayTimes=true;
|
|
|
|
278
|
- sobj.timePickerMask=true;
|
|
|
|
279
|
- }
|
266
|
+ sobj.tables = ts;
|
|
|
|
267
|
+ } else {
|
|
|
|
268
|
+ form[key] = val;
|
|
|
|
269
|
+ }
|
|
|
|
270
|
+ console.log('ts', sobj.tables,this.checkedTables);
|
|
|
|
271
|
+ //console.log(e.type,key,val,form);
|
|
|
|
272
|
+ sobj.form = form;
|
|
|
|
273
|
+ sobj.buttonhide = true;
|
|
|
|
274
|
+ if (form.tid.length > 0 && form.rname.length > 0) {
|
|
|
|
275
|
+ sobj.buttonhide = false;
|
|
|
|
276
|
+ }
|
|
|
|
277
|
+ let displayTimes = false;
|
|
|
|
278
|
+ if (key == 'time') {
|
|
|
|
279
|
+ if (util.attr(e, 'display') == 'block') {
|
|
|
|
280
|
+ displayTimes = true;
|
|
|
|
281
|
+ sobj.timePickerMask = true;
|
|
280
|
}
|
282
|
}
|
|
281
|
- if('date,time,pnum,pnum_str,tabid'.indexOf(key)>-1){
|
|
|
|
282
|
- if(!displayTimes){
|
|
|
|
283
|
- sobj.form.tid=[];
|
|
|
|
284
|
- sobj.buttonhide=true;
|
|
|
|
285
|
- this.getTables();
|
|
|
|
286
|
- }
|
|
|
|
287
|
- if(key=='date'){
|
|
|
|
288
|
- let xtime=util.unixtoTime(new Date()/1000,'YYYY-'+(this.data.dateStr[val].substr(0,5))+' HH:II:SS');
|
|
|
|
289
|
- this.setDateStr(util.timetouUnix(xtime));
|
|
|
|
290
|
- }
|
283
|
+ }
|
|
|
|
284
|
+ if ('date,time,pnum,pnum_str,tabid'.indexOf(key) > -1) {
|
|
|
|
285
|
+ if (!displayTimes) {
|
|
|
|
286
|
+ //sobj.form.tid = []; //切换日期时间清空桌位
|
|
|
|
287
|
+ sobj.buttonhide = true;
|
|
|
|
288
|
+ this.getTables();
|
|
291
|
}
|
289
|
}
|
|
292
|
- //判断hasUseDefDtime
|
|
|
|
293
|
- if((key=='time' || key=='date') && !sobj.timePickerMask){
|
|
|
|
294
|
- sobj.hasUseDefDtime=true
|
290
|
+ if (key == 'date') {
|
|
|
|
291
|
+ let xtime = util.unixtoTime(new Date() / 1000, 'YYYY-' + (this.data.dateStr[val].substr(0, 5)) + ' HH:II:SS');
|
|
|
|
292
|
+ this.setDateStr(util.timetouUnix(xtime));
|
|
295
|
}
|
293
|
}
|
|
296
|
- if(this.data.form.date==0){//
|
|
|
|
297
|
- let mmii=util.unixtoTime(new Date()/1000,'HH:II');
|
|
|
|
298
|
- if(mmii>this.data.defDtime[key=='time'?val:this.data.form.time]){
|
|
|
|
299
|
- sobj.hasUseDefDtime=false;
|
|
|
|
300
|
- }
|
294
|
+ }
|
|
|
|
295
|
+ //判断hasUseDefDtime
|
|
|
|
296
|
+ if ((key == 'time' || key == 'date') && !sobj.timePickerMask) {
|
|
|
|
297
|
+ sobj.hasUseDefDtime = true
|
|
|
|
298
|
+ }
|
|
|
|
299
|
+ if (this.data.form.date == 0) {//
|
|
|
|
300
|
+ let mmii = util.unixtoTime(new Date() / 1000, 'HH:II');
|
|
|
|
301
|
+ if (mmii > this.data.defDtime[key == 'time' ? val : this.data.form.time]) {
|
|
|
|
302
|
+ sobj.hasUseDefDtime = false;
|
|
301
|
}
|
303
|
}
|
|
302
|
- this.setData(sobj)
|
|
|
|
303
|
- },
|
|
|
|
304
|
- async getTables(){
|
|
|
|
305
|
- let form=this.data.form;
|
|
|
|
306
|
- let tableid=util.cache('tableid');
|
|
|
|
307
|
- console.log('getTables-tableid',tableid.length,this.reserve_id);
|
|
|
|
308
|
- if(tableid.length<1 && this.reserve_id){
|
|
|
|
309
|
- tableid=this.data.form.tid;
|
|
|
|
310
|
- }
|
|
|
|
311
|
- console.log('getTables-tableid',tableid,tableid.length);
|
|
|
|
312
|
- try{
|
|
|
|
313
|
- let rdate=await comm.getTimeSpace(this.data.dateStr[this.data.form.date],this.data.form.time);
|
|
|
|
314
|
- console.log('rdate',this.data.dateStr[this.data.form.date],rdate);
|
|
|
|
315
|
- App.Reserve.GetTableList({
|
|
|
|
316
|
- sid:this.sellerid,
|
|
|
|
317
|
- //pnum_str:form.pnum_str,
|
|
|
|
318
|
- pnum:form.pnum,
|
|
|
|
319
|
- rdate:rdate,
|
|
|
|
320
|
- tid:form.tabid,
|
|
|
|
321
|
- rid:this.reserve_id,
|
|
|
|
322
|
- }).then(res=>{
|
|
|
|
323
|
- let tables=[],tables_tmp=[];
|
|
|
|
324
|
- let tablesLength=0;
|
|
|
|
325
|
- if(tableid.length>0){
|
|
|
|
326
|
- res.data.forEach(p=>{
|
|
|
|
327
|
- //if(tables.length>=3) return true;
|
|
|
|
328
|
- p.list.forEach(t=>{
|
|
|
|
329
|
- tablesLength++;
|
|
|
|
330
|
- if(tables.length>=3) return true;
|
|
|
|
331
|
- if(tableid._indexOf(t.id)>-1){
|
|
|
|
332
|
- t.isselect=true;
|
|
|
|
333
|
- tables.push(t);
|
|
|
|
334
|
- }
|
|
|
|
335
|
- })
|
|
|
|
336
|
- })
|
|
|
|
337
|
- wx.removeStorage({key:'tableid'})
|
|
|
|
338
|
- }else{
|
|
|
|
339
|
- res.data.forEach(p=>{
|
|
|
|
340
|
- p.list.forEach(t=>{
|
|
|
|
341
|
- tablesLength++;
|
|
|
|
342
|
- //if(tables.length>=3) return true;
|
|
|
|
343
|
- if(t.tid==2) {
|
|
|
|
344
|
- tables.push(t);
|
|
|
|
345
|
- }else{
|
|
|
|
346
|
- tables_tmp.push(t);
|
|
|
|
347
|
- }
|
|
|
|
348
|
- })
|
|
|
|
349
|
- })
|
|
|
|
350
|
- if(tables.length<3){
|
|
|
|
351
|
- tables=tables.concat(tables_tmp);
|
|
|
|
352
|
- }
|
|
|
|
353
|
- if(tables.length>=3){
|
|
|
|
354
|
- tables=tables.slice(0,3);
|
|
|
|
355
|
- }
|
|
|
|
356
|
- }
|
|
|
|
357
|
- this.tablesLength=tablesLength;
|
|
|
|
358
|
- this.setData({
|
|
|
|
359
|
- tables:tables,
|
|
|
|
360
|
- tablesLength:tablesLength
|
|
|
|
361
|
- })
|
304
|
+ }
|
|
|
|
305
|
+ this.setData(sobj)
|
|
|
|
306
|
+ },
|
|
|
|
307
|
+ async getTables(){
|
|
|
|
308
|
+ let form = this.data.form;
|
|
|
|
309
|
+ let tableid = util.cache('tableid');
|
|
|
|
310
|
+ console.log('getTables-tableid', tableid.length, this.reserve_id);
|
|
|
|
311
|
+ //if (tableid.length < 1 && this.reserve_id) {
|
|
|
|
312
|
+ if (tableid.length < 1) {
|
|
|
|
313
|
+ tableid = this.data.form.tid;
|
|
|
|
314
|
+ }
|
|
|
|
315
|
+ console.log('getTables-tableid', tableid, tableid.length);
|
|
|
|
316
|
+ try {
|
|
|
|
317
|
+ let rdate = await comm.getTimeSpace(this.data.dateStr[this.data.form.date], this.data.form.time);
|
|
|
|
318
|
+ console.log('rdate', this.data.dateStr[this.data.form.date], rdate);
|
|
|
|
319
|
+ App.Reserve.GetTableList({
|
|
|
|
320
|
+ sid: this.sellerid,
|
|
|
|
321
|
+ //pnum_str:form.pnum_str,
|
|
|
|
322
|
+ pnum: form.pnum,
|
|
|
|
323
|
+ rdate: rdate,
|
|
|
|
324
|
+ tid: form.tabid,
|
|
|
|
325
|
+ rid: this.reserve_id,
|
|
|
|
326
|
+ }).then(res => {
|
|
|
|
327
|
+ let tables = [], tables_tmp = [];
|
|
|
|
328
|
+ let tablesLength = 0;
|
|
|
|
329
|
+ if (tableid.length > 0) {
|
|
|
|
330
|
+ let toastTables={...this.checkedTables}
|
|
|
|
331
|
+ res.data.forEach(p => {
|
|
|
|
332
|
+ //if(tables.length>=3) return true;
|
|
|
|
333
|
+ p.list.forEach(t => {
|
|
|
|
334
|
+ delete toastTables[t.id]
|
|
|
|
335
|
+ tablesLength++;
|
|
|
|
336
|
+ if (tables.length >= 3) return true;
|
|
|
|
337
|
+ if (tableid._indexOf(t.id) > -1) {
|
|
|
|
338
|
+ t.isselect = true;
|
|
|
|
339
|
+ tables.push(t);
|
|
|
|
340
|
+ }
|
|
362
|
})
|
341
|
})
|
|
363
|
- }catch (e){
|
342
|
+ })
|
|
|
|
343
|
+ console.log('toastTables',toastTables);
|
|
|
|
344
|
+ //清理已选中的桌位
|
|
|
|
345
|
+ let toastTablesInfo=[];
|
|
|
|
346
|
+ let tid=this.data.form.tid
|
|
|
|
347
|
+ Object.keys(this.checkedTables).forEach(ckid=>{
|
|
|
|
348
|
+ if(toastTables[ckid]){
|
|
|
|
349
|
+ delete this.checkedTables[ckid]
|
|
|
|
350
|
+ tid.remove(ckid);
|
|
|
|
351
|
+ toastTablesInfo.push(toastTables[ckid]);
|
|
|
|
352
|
+ }
|
|
|
|
353
|
+ })
|
|
|
|
354
|
+ if(toastTablesInfo.length>0){
|
|
364
|
this.setData({
|
355
|
this.setData({
|
|
365
|
- tables:[]
|
356
|
+ [`form.tid`]:tid,
|
|
366
|
})
|
357
|
})
|
|
|
|
358
|
+ util.toast(toastTablesInfo.toString()+'已被占用啦','none');
|
|
|
|
359
|
+ }
|
|
|
|
360
|
+ wx.removeStorage({key: 'tableid'})
|
|
367
|
}
|
361
|
}
|
|
368
|
- },
|
|
|
|
369
|
- async formsubmit(){
|
|
|
|
370
|
- if(this.data.buttonhide) return;
|
|
|
|
371
|
- try {
|
|
|
|
372
|
- let d_stimestr=this.data.timePickerArray[this.data.form.time][this.data.timePickerIndex[this.data.form.time]];
|
|
|
|
373
|
- let d_rdate = await comm.getTimeSpace(this.data.dateStr[this.data.form.date],
|
|
|
|
374
|
- this.data.form.time,d_stimestr);
|
|
|
|
375
|
- let stimestr=this.data.timePickerArray[this.data.form.time][this.data.timePickerIndex[0]];
|
|
|
|
376
|
- let rdate = await comm.getTimeSpace(this.data.dateStr[this.data.form.date],
|
|
|
|
377
|
- this.data.form.time,stimestr);
|
|
|
|
378
|
- console.log('stimestr', stimestr,this.data.form.time,this.data.timePickerIndex);
|
|
|
|
379
|
- console.log('rdate', rdate);
|
|
|
|
380
|
- this.setData({
|
|
|
|
381
|
- buttonhide: true,
|
|
|
|
382
|
- })
|
|
|
|
383
|
- let form = JSON.parse(JSON.stringify(this.data.form));
|
|
|
|
384
|
- console.log('typeof form.tid',typeof form.tid);
|
|
|
|
385
|
- if(typeof form.tid=='object'){
|
|
|
|
386
|
- let tid= new Set(form.tid);//tid 去重
|
|
|
|
387
|
- form.tid = [...tid].toString();
|
|
|
|
388
|
- }
|
|
|
|
389
|
- if(!form.tid){
|
|
|
|
390
|
- return util.toast('请选择桌子','none');
|
|
|
|
391
|
- }
|
|
|
|
392
|
- form.sid = this.sellerid;
|
|
|
|
393
|
- form.rdate =rdate
|
|
|
|
394
|
- if(!form.rid){
|
|
|
|
395
|
- try{
|
|
|
|
396
|
- let enter_params=util.cache('enter_params');
|
|
|
|
397
|
- let sc=(await App.Reserve.SellerInfo(enter_params)).data
|
|
|
|
398
|
- let note_openid=enter_params.seller_openid;
|
|
|
|
399
|
- let note_name=sc.seller_user.nickname;
|
|
|
|
400
|
- form.note_openid=note_openid||'';
|
|
|
|
401
|
- form.note_name=note_name||'';
|
|
|
|
402
|
- }catch (e){}
|
|
|
|
403
|
- }
|
|
|
|
404
|
- form.ddate=d_rdate.substr(0,10);
|
|
|
|
405
|
- if(this.data.hasUseDefDtime && this.data.form.time>0){//转为默认时间
|
|
|
|
406
|
- let ddateStr=util.unixtoTime(form.ddate,"YYYY-MM-DD "+this.data.defDtime[this.data.form.time]+":00");
|
|
|
|
407
|
- form.ddate=util.timetouUnix(ddateStr);
|
|
|
|
408
|
- }
|
|
|
|
409
|
- App.Reserve.SetReserveInfo(form).then(res => {
|
|
|
|
410
|
- if(res.ret==200){
|
|
|
|
411
|
- let _id=(res.data.id || res.data)
|
|
|
|
412
|
- this.setData({
|
|
|
|
413
|
- form:JSON.parse(JSON.stringify(formTpl)),
|
|
|
|
414
|
- tables:[],
|
|
|
|
415
|
- timePickerIndex:[0,0,0],
|
|
|
|
416
|
- })
|
|
|
|
417
|
- this.initLoad();
|
|
|
|
418
|
- App.Reserve.Detail({rid:_id,openid:''},'clear')
|
|
|
|
419
|
- wx.navigateTo({
|
|
|
|
420
|
- url:'b_detail?id='+_id,
|
|
|
|
421
|
- });
|
|
|
|
422
|
- }else{
|
|
|
|
423
|
- util.toast(res.msg,'none')
|
|
|
|
424
|
- }
|
362
|
+ if(tables.length<1){
|
|
|
|
363
|
+ tablesLength=0;
|
|
|
|
364
|
+ tables_tmp = [];
|
|
|
|
365
|
+ res.data.forEach(p => {
|
|
|
|
366
|
+ p.list.forEach(t => {
|
|
|
|
367
|
+ tablesLength++;
|
|
|
|
368
|
+ //if(tables.length>=3) return true;
|
|
|
|
369
|
+ if (t.tid == 2) {
|
|
|
|
370
|
+ tables.push(t);
|
|
|
|
371
|
+ } else {
|
|
|
|
372
|
+ tables_tmp.push(t);
|
|
|
|
373
|
+ }
|
|
425
|
})
|
374
|
})
|
|
426
|
- }catch (e){}
|
|
|
|
427
|
- },
|
|
|
|
428
|
- selectphone:function(e){
|
|
|
|
429
|
- this.data.form.phone=e.detail.phone;
|
|
|
|
430
|
- this.data.form.rname=e.detail.rname;
|
|
|
|
431
|
- this.data.form.cusdem=e.detail.cusdem;
|
|
|
|
432
|
- var form=this.data.form
|
|
|
|
433
|
- this.data.form.sex=e.detail.sex;
|
|
|
|
434
|
- this.setData({
|
|
|
|
435
|
- form:this.data.form,
|
|
|
|
436
|
- searchlist:null
|
|
|
|
437
|
- })
|
|
|
|
438
|
- this.conditionInfo();
|
|
|
|
439
|
- },
|
|
|
|
440
|
- calendarShow(){
|
|
|
|
441
|
- this.setData({
|
|
|
|
442
|
- calendarMask:true
|
|
|
|
443
|
- })
|
|
|
|
444
|
- },
|
|
|
|
445
|
- dateChange(event){
|
|
|
|
446
|
- console.log(event);
|
|
|
|
447
|
- //let cktime=util.timetouUnix(event.detail.year+'/'+event.detail.month+'/'+event.detail.day)
|
|
|
|
448
|
- let cktime=util.timetouUnix(event.detail.date)
|
|
|
|
449
|
- let day0=parseInt(new Date(new Date().setHours(0, 0, 0, 0)) / 1000);
|
|
|
|
450
|
- if(cktime<day0){
|
|
|
|
451
|
- util.toast('请选择有效日期','none');
|
|
|
|
452
|
- return;
|
375
|
+ })
|
|
|
|
376
|
+ if (tables.length < 3) {
|
|
|
|
377
|
+ tables = tables.concat(tables_tmp);
|
|
|
|
378
|
+ }
|
|
|
|
379
|
+ if (tables.length >= 3) {
|
|
|
|
380
|
+ tables = tables.slice(0, 3);
|
|
|
|
381
|
+ }
|
|
453
|
}
|
382
|
}
|
|
454
|
- let clickDay = event.detail.date.substr(8,2);
|
|
|
|
455
|
- let changeDay = `dayStyle[1].day`;
|
|
|
|
456
|
- let changeBg = `dayStyle[1].background`;
|
|
|
|
457
|
- this.setData({
|
|
|
|
458
|
- [changeDay]: clickDay,
|
|
|
|
459
|
- [changeBg]: "#84e7d0",
|
|
|
|
460
|
- [`form.tid`]:[],
|
|
|
|
461
|
- buttonhide:true,
|
|
|
|
462
|
- })
|
|
|
|
463
|
- this.setDateStr(cktime==day0?new Date()/1000:cktime)
|
|
|
|
464
|
- this.getTables();
|
|
|
|
465
|
- this.calendarClose();
|
|
|
|
466
|
- },
|
|
|
|
467
|
- calendarClose(){
|
383
|
+ this.tablesLength = tablesLength;
|
|
468
|
this.setData({
|
384
|
this.setData({
|
|
469
|
- calendarMask:false,
|
|
|
|
470
|
- timePickerMask:false,
|
385
|
+ tables: tables,
|
|
|
|
386
|
+ tablesLength: tablesLength
|
|
471
|
})
|
387
|
})
|
|
472
|
- },
|
|
|
|
473
|
- async selectdesk(){
|
|
|
|
474
|
- let rdate=await comm.getTimeSpace(this.data.dateStr[this.data.form.date],this.data.form.time);
|
|
|
|
475
|
- console.log(this.data.form)
|
|
|
|
476
|
- wx.navigateTo({
|
|
|
|
477
|
- url:'b_desk?rdate='+rdate+'&tid='+this.data.form.tabid
|
|
|
|
478
|
- //+'&pnum_str='+this.data.form.pnum_str
|
|
|
|
479
|
- +'&pnum='+this.data.form.pnum
|
|
|
|
480
|
- +'&checked_tids='+this.data.form.tid
|
|
|
|
481
|
- +'&rid='+this.reserve_id
|
|
|
|
482
|
- })
|
|
|
|
483
|
- },
|
|
|
|
484
|
- conditionInfo:function(){
|
|
|
|
485
|
- var form=this.data.form
|
|
|
|
486
|
- if(form.tid.length>0 && form.rname.length>0){
|
|
|
|
487
|
- this.data.buttonhide=false;
|
388
|
+ })
|
|
|
|
389
|
+ } catch (e) {
|
|
|
|
390
|
+ this.setData({
|
|
|
|
391
|
+ tables: []
|
|
|
|
392
|
+ })
|
|
|
|
393
|
+ }
|
|
|
|
394
|
+ },
|
|
|
|
395
|
+ async formsubmit(){
|
|
|
|
396
|
+ if (this.data.buttonhide) return;
|
|
|
|
397
|
+ try {
|
|
|
|
398
|
+ let d_stimestr = this.data.timePickerArray[this.data.form.time][this.data.timePickerIndex[this.data.form.time]];
|
|
|
|
399
|
+ let d_rdate = await comm.getTimeSpace(this.data.dateStr[this.data.form.date],
|
|
|
|
400
|
+ this.data.form.time, d_stimestr);
|
|
|
|
401
|
+ let stimestr = this.data.timePickerArray[this.data.form.time][this.data.timePickerIndex[0]];
|
|
|
|
402
|
+ let rdate = await comm.getTimeSpace(this.data.dateStr[this.data.form.date],
|
|
|
|
403
|
+ this.data.form.time, stimestr);
|
|
|
|
404
|
+ console.log('stimestr', stimestr, this.data.form.time, this.data.timePickerIndex);
|
|
|
|
405
|
+ console.log('rdate', rdate);
|
|
|
|
406
|
+ this.setData({
|
|
|
|
407
|
+ buttonhide: true,
|
|
|
|
408
|
+ })
|
|
|
|
409
|
+ let form = JSON.parse(JSON.stringify(this.data.form));
|
|
|
|
410
|
+ console.log('typeof form.tid', typeof form.tid);
|
|
|
|
411
|
+ if (typeof form.tid == 'object') {
|
|
|
|
412
|
+ let tid = new Set(form.tid);//tid 去重
|
|
|
|
413
|
+ form.tid = [...tid].toString();
|
|
|
|
414
|
+ }
|
|
|
|
415
|
+ if (!form.tid) {
|
|
|
|
416
|
+ return util.toast('请选择桌子', 'none');
|
|
|
|
417
|
+ }
|
|
|
|
418
|
+ form.sid = this.sellerid;
|
|
|
|
419
|
+ form.rdate = rdate
|
|
|
|
420
|
+ if (!form.rid) {
|
|
|
|
421
|
+ try {
|
|
|
|
422
|
+ let enter_params = util.cache('enter_params');
|
|
|
|
423
|
+ let sc = (await App.Reserve.SellerInfo(enter_params)).data
|
|
|
|
424
|
+ let note_openid = enter_params.seller_openid;
|
|
|
|
425
|
+ let note_name = sc.seller_user.nickname;
|
|
|
|
426
|
+ form.note_openid = note_openid || '';
|
|
|
|
427
|
+ form.note_name = note_name || '';
|
|
|
|
428
|
+ } catch (e) {
|
|
488
|
}
|
429
|
}
|
|
489
|
- this.setData({
|
|
|
|
490
|
- buttonhide:this.data.buttonhide
|
|
|
|
491
|
- })
|
|
|
|
492
|
- },
|
|
|
|
493
|
- /**
|
|
|
|
494
|
- * 选中时间区域
|
|
|
|
495
|
- */
|
|
|
|
496
|
- bindTimePickerChange(e){
|
|
|
|
497
|
- let timeIndex=util.attr(e,'timeIndex');
|
|
|
|
498
|
- if(timeIndex<0) return;
|
|
|
|
499
|
- let timePickerIndex=this.data.timePickerIndex;
|
|
|
|
500
|
- //timePickerIndex[timeIndex]=util.val(e);
|
|
|
|
501
|
- timePickerIndex[timeIndex]=util.attr(e,'val');
|
|
|
|
502
|
-
|
|
|
|
503
|
- console.log(e,timeIndex,util.attr(e,'val'));
|
|
|
|
504
|
- this.setData({
|
|
|
|
505
|
- timePickerIndex:timePickerIndex,
|
|
|
|
506
|
- hasUseDefDtime:false,
|
|
|
|
507
|
- })
|
|
|
|
508
|
- },
|
|
|
|
509
|
- /**
|
|
|
|
510
|
- * 修改初始化
|
|
|
|
511
|
- */
|
|
|
|
512
|
- async initModify(id){
|
|
|
|
513
|
- try{
|
|
|
|
514
|
- let res= await App.Reserve.Detail({rid:id,openid:''});
|
|
|
|
515
|
-
|
|
|
|
516
|
- console.log('initModify',res);
|
|
|
|
517
|
- //设置日期
|
|
|
|
518
|
- let obj = await this.setDateStr(res.data.ddate);
|
|
|
|
519
|
- //设置时间
|
|
|
|
520
|
- let nd=util.unixtoTime(res.data.ddate,'HH:II');
|
|
|
|
521
|
- let timePickerIndex=this.data.timePickerIndex
|
|
|
|
522
|
- console.log('initModify-',this.data.timePickerArray,obj.form.time,nd)
|
|
|
|
523
|
- this.data.timePickerArray[obj.form.time].forEach((dd,ii)=>{
|
|
|
|
524
|
- console.log('initModify-',nd,dd)
|
|
|
|
525
|
- if(nd==dd){
|
|
|
|
526
|
- timePickerIndex[obj.form.time]=ii;
|
|
|
|
527
|
- return true;
|
|
|
|
528
|
- }
|
|
|
|
529
|
- })
|
430
|
+ }
|
|
|
|
431
|
+ form.ddate = d_rdate.substr(0, 10);
|
|
|
|
432
|
+ if (this.data.hasUseDefDtime && this.data.form.time > 0) {//转为默认时间
|
|
|
|
433
|
+ let ddateStr = util.unixtoTime(form.ddate, "YYYY-MM-DD " + this.data.defDtime[this.data.form.time] + ":00");
|
|
|
|
434
|
+ form.ddate = util.timetouUnix(ddateStr);
|
|
|
|
435
|
+ }
|
|
|
|
436
|
+ App.Reserve.SetReserveInfo(form).then(res => {
|
|
|
|
437
|
+ if (res.ret == 200) {
|
|
|
|
438
|
+ let _id = (res.data.id || res.data)
|
|
|
|
439
|
+ this.setData({
|
|
|
|
440
|
+ form: JSON.parse(JSON.stringify(formTpl)),
|
|
|
|
441
|
+ tables: [],
|
|
|
|
442
|
+ timePickerIndex: [0, 0, 0],
|
|
|
|
443
|
+ })
|
|
|
|
444
|
+ this.initLoad();
|
|
|
|
445
|
+ this.checkedTables={};
|
|
|
|
446
|
+ App.Reserve.Detail({rid: _id, openid: ''}, 'clear')
|
|
|
|
447
|
+ wx.navigateTo({
|
|
|
|
448
|
+ url: 'b_detail?id=' + _id,
|
|
|
|
449
|
+ });
|
|
|
|
450
|
+ } else {
|
|
|
|
451
|
+ util.toast(res.msg, 'none')
|
|
|
|
452
|
+ }
|
|
|
|
453
|
+ })
|
|
|
|
454
|
+ } catch (e) {
|
|
|
|
455
|
+ }
|
|
|
|
456
|
+ },
|
|
|
|
457
|
+ selectphone: function (e) {
|
|
|
|
458
|
+ this.data.form.phone = e.detail.phone;
|
|
|
|
459
|
+ this.data.form.rname = e.detail.rname;
|
|
|
|
460
|
+ this.data.form.cusdem = e.detail.cusdem;
|
|
|
|
461
|
+ var form = this.data.form
|
|
|
|
462
|
+ this.data.form.sex = e.detail.sex;
|
|
|
|
463
|
+ this.setData({
|
|
|
|
464
|
+ form: this.data.form,
|
|
|
|
465
|
+ searchlist: null
|
|
|
|
466
|
+ })
|
|
|
|
467
|
+ this.conditionInfo();
|
|
|
|
468
|
+ },
|
|
|
|
469
|
+ calendarShow(){
|
|
|
|
470
|
+ this.setData({
|
|
|
|
471
|
+ calendarMask: true
|
|
|
|
472
|
+ })
|
|
|
|
473
|
+ },
|
|
|
|
474
|
+ dateChange(event){
|
|
|
|
475
|
+ console.log(event);
|
|
|
|
476
|
+ //let cktime=util.timetouUnix(event.detail.year+'/'+event.detail.month+'/'+event.detail.day)
|
|
|
|
477
|
+ let cktime = util.timetouUnix(event.detail.date)
|
|
|
|
478
|
+ let day0 = parseInt(new Date(new Date().setHours(0, 0, 0, 0)) / 1000);
|
|
|
|
479
|
+ if (cktime < day0) {
|
|
|
|
480
|
+ util.toast('请选择有效日期', 'none');
|
|
|
|
481
|
+ return;
|
|
|
|
482
|
+ }
|
|
|
|
483
|
+ let clickDay = event.detail.date.substr(8, 2);
|
|
|
|
484
|
+ let changeDay = `dayStyle[1].day`;
|
|
|
|
485
|
+ let changeBg = `dayStyle[1].background`;
|
|
|
|
486
|
+ this.setData({
|
|
|
|
487
|
+ [changeDay]: clickDay,
|
|
|
|
488
|
+ [changeBg]: "#84e7d0",
|
|
|
|
489
|
+ //[`form.tid`]: [], //切换日期时间清空桌位
|
|
|
|
490
|
+ buttonhide: true,
|
|
|
|
491
|
+ })
|
|
|
|
492
|
+ this.setDateStr(cktime == day0 ? new Date() / 1000 : cktime)
|
|
|
|
493
|
+ this.getTables();
|
|
|
|
494
|
+ this.calendarClose();
|
|
|
|
495
|
+ },
|
|
|
|
496
|
+ calendarClose(){
|
|
|
|
497
|
+ this.setData({
|
|
|
|
498
|
+ calendarMask: false,
|
|
|
|
499
|
+ timePickerMask: false,
|
|
|
|
500
|
+ })
|
|
|
|
501
|
+ },
|
|
|
|
502
|
+ async selectdesk(){
|
|
|
|
503
|
+ let rdate = await comm.getTimeSpace(this.data.dateStr[this.data.form.date], this.data.form.time);
|
|
|
|
504
|
+ console.log(this.data.form)
|
|
|
|
505
|
+ wx.navigateTo({
|
|
|
|
506
|
+ url: 'b_desk?rdate=' + rdate + '&tid=' + this.data.form.tabid
|
|
|
|
507
|
+ //+'&pnum_str='+this.data.form.pnum_str
|
|
|
|
508
|
+ + '&pnum=' + this.data.form.pnum
|
|
|
|
509
|
+ + '&checked_tids=' + this.data.form.tid
|
|
|
|
510
|
+ + '&rid=' + this.reserve_id
|
|
|
|
511
|
+ })
|
|
|
|
512
|
+ },
|
|
|
|
513
|
+ conditionInfo: function () {
|
|
|
|
514
|
+ var form = this.data.form
|
|
|
|
515
|
+ if (form.tid.length > 0 && form.rname.length > 0) {
|
|
|
|
516
|
+ this.data.buttonhide = false;
|
|
|
|
517
|
+ }
|
|
|
|
518
|
+ this.setData({
|
|
|
|
519
|
+ buttonhide: this.data.buttonhide
|
|
|
|
520
|
+ })
|
|
|
|
521
|
+ },
|
|
|
|
522
|
+ /**
|
|
|
|
523
|
+ * 选中时间区域
|
|
|
|
524
|
+ */
|
|
|
|
525
|
+ bindTimePickerChange(e){
|
|
|
|
526
|
+ let timeIndex = util.attr(e, 'timeIndex');
|
|
|
|
527
|
+ if (timeIndex < 0) return;
|
|
|
|
528
|
+ let timePickerIndex = this.data.timePickerIndex;
|
|
|
|
529
|
+ //timePickerIndex[timeIndex]=util.val(e);
|
|
|
|
530
|
+ timePickerIndex[timeIndex] = util.attr(e, 'val');
|
|
530
|
|
531
|
|
|
531
|
- console.log('initModify-timePickerIndex',timePickerIndex);
|
|
|
|
532
|
- //obj.form.pnum_str=res.data.pnum_str;
|
|
|
|
533
|
- obj.form.pnum=res.data.pnum||6;
|
|
|
|
534
|
- obj.form.rname=res.data.rname;
|
|
|
|
535
|
- obj.form.phone=res.data.phone||"";
|
|
|
|
536
|
- obj.form.sex=res.data.sex;
|
|
|
|
537
|
- obj.form.cusdem=res.data.cusdem;
|
|
|
|
538
|
- obj.form.rid=id;
|
|
|
|
539
|
- obj.form.tid=[];
|
|
|
|
540
|
- let tablesed=[];
|
|
|
|
541
|
- res.data.tables.forEach((t,ti)=>{
|
|
|
|
542
|
- obj.form.tid.push(t.id)
|
|
|
|
543
|
- if(ti>=3) return;
|
|
|
|
544
|
- t.isselect=true
|
|
|
|
545
|
- t["isselected"]=1
|
|
|
|
546
|
- tablesed.push(t);
|
|
|
|
547
|
- })
|
|
|
|
548
|
- this.setData({
|
|
|
|
549
|
- timePickerIndex:timePickerIndex,
|
|
|
|
550
|
- form:obj.form,
|
|
|
|
551
|
- //tablesed:tablesed,
|
|
|
|
552
|
- hasUseDefDtime:false,
|
|
|
|
553
|
- })
|
|
|
|
554
|
- setTimeout(()=>{
|
|
|
|
555
|
- this.getTables();
|
|
|
|
556
|
- },300)
|
532
|
+ console.log(e, timeIndex, util.attr(e, 'val'));
|
|
|
|
533
|
+ this.setData({
|
|
|
|
534
|
+ timePickerIndex: timePickerIndex,
|
|
|
|
535
|
+ hasUseDefDtime: false,
|
|
|
|
536
|
+ })
|
|
|
|
537
|
+ },
|
|
|
|
538
|
+ /**
|
|
|
|
539
|
+ * 修改初始化
|
|
|
|
540
|
+ */
|
|
|
|
541
|
+ async initModify(id){
|
|
|
|
542
|
+ try {
|
|
|
|
543
|
+ let res = await App.Reserve.Detail({rid: id, openid: ''});
|
|
557
|
|
544
|
|
|
558
|
- }catch (e){
|
|
|
|
559
|
- console.log('initModify',e)
|
545
|
+ console.log('initModify', res);
|
|
|
|
546
|
+ //设置日期
|
|
|
|
547
|
+ let obj = await this.setDateStr(res.data.ddate);
|
|
|
|
548
|
+ //设置时间
|
|
|
|
549
|
+ let nd = util.unixtoTime(res.data.ddate, 'HH:II');
|
|
|
|
550
|
+ let timePickerIndex = this.data.timePickerIndex
|
|
|
|
551
|
+ console.log('initModify-', this.data.timePickerArray, obj.form.time, nd)
|
|
|
|
552
|
+ this.data.timePickerArray[obj.form.time].forEach((dd, ii) => {
|
|
|
|
553
|
+ console.log('initModify-', nd, dd)
|
|
|
|
554
|
+ if (nd == dd) {
|
|
|
|
555
|
+ timePickerIndex[obj.form.time] = ii;
|
|
|
|
556
|
+ return true;
|
|
560
|
}
|
557
|
}
|
|
561
|
- },
|
|
|
|
562
|
- pnumInputFocusEvent(e){
|
|
|
|
563
|
- console.log(e);
|
558
|
+ })
|
|
|
|
559
|
+
|
|
|
|
560
|
+ console.log('initModify-timePickerIndex', timePickerIndex);
|
|
|
|
561
|
+ //obj.form.pnum_str=res.data.pnum_str;
|
|
|
|
562
|
+ obj.form.pnum = res.data.pnum || 6;
|
|
|
|
563
|
+ obj.form.rname = res.data.rname;
|
|
|
|
564
|
+ obj.form.phone = res.data.phone || "";
|
|
|
|
565
|
+ obj.form.sex = res.data.sex;
|
|
|
|
566
|
+ obj.form.cusdem = res.data.cusdem;
|
|
|
|
567
|
+ obj.form.rid = id;
|
|
|
|
568
|
+ obj.form.tid = [];
|
|
|
|
569
|
+ let tablesed = [];
|
|
|
|
570
|
+ res.data.tables.forEach((t, ti) => {
|
|
|
|
571
|
+ obj.form.tid.push(t.id)
|
|
|
|
572
|
+ if (ti >= 3) return;
|
|
|
|
573
|
+ t.isselect = true
|
|
|
|
574
|
+ t["isselected"] = 1
|
|
|
|
575
|
+ tablesed.push(t);
|
|
|
|
576
|
+ })
|
|
564
|
this.setData({
|
577
|
this.setData({
|
|
565
|
- pnumInputFocus:'focus'==e.type
|
578
|
+ timePickerIndex: timePickerIndex,
|
|
|
|
579
|
+ form: obj.form,
|
|
|
|
580
|
+ //tablesed:tablesed,
|
|
|
|
581
|
+ hasUseDefDtime: false,
|
|
566
|
})
|
582
|
})
|
|
|
|
583
|
+ setTimeout(() => {
|
|
|
|
584
|
+ this.getTables();
|
|
|
|
585
|
+ }, 300)
|
|
|
|
586
|
+
|
|
|
|
587
|
+ } catch (e) {
|
|
|
|
588
|
+ console.log('initModify', e)
|
|
|
|
589
|
+ }
|
|
|
|
590
|
+ },
|
|
|
|
591
|
+ pnumInputFocusEvent(e){
|
|
|
|
592
|
+ console.log(e);
|
|
|
|
593
|
+ this.setData({
|
|
|
|
594
|
+ pnumInputFocus: 'focus' == e.type
|
|
|
|
595
|
+ })
|
|
567
|
},
|
596
|
},
|
|
568
|
- inputFocusTime:0,
|
|
|
|
569
|
- blurTime:0,
|
597
|
+ inputFocusTime: 0,
|
|
|
|
598
|
+ blurTime: 0,
|
|
570
|
inputFocus(e){
|
599
|
inputFocus(e){
|
|
571
|
- console.log(e,this.inputFocusTime);
|
600
|
+ console.log(e, this.inputFocusTime);
|
|
572
|
return;
|
601
|
return;
|
|
573
|
- if(e.timeStamp>this.inputFocusTime){
|
|
|
|
574
|
- this.inputFocusTime=e.timeStamp;
|
|
|
|
575
|
- if(e.type=='focus' && this.data.pageMarginBottom==0){
|
602
|
+ if (e.timeStamp > this.inputFocusTime) {
|
|
|
|
603
|
+ this.inputFocusTime = e.timeStamp;
|
|
|
|
604
|
+ if (e.type == 'focus' && this.data.pageMarginBottom == 0) {
|
|
576
|
this.setData({
|
605
|
this.setData({
|
|
577
|
- pageMarginBottom:300
|
606
|
+ pageMarginBottom: 300
|
|
578
|
})
|
607
|
})
|
|
579
|
- setTimeout(res=>{
|
608
|
+ setTimeout(res => {
|
|
580
|
this.pageScrollToBottom();
|
609
|
this.pageScrollToBottom();
|
|
581
|
- },100)
|
|
|
|
582
|
- }else{
|
|
|
|
583
|
- if(this.blurTime>5){
|
|
|
|
584
|
- this.blurTime=0;
|
610
|
+ }, 100)
|
|
|
|
611
|
+ } else {
|
|
|
|
612
|
+ if (this.blurTime > 5) {
|
|
|
|
613
|
+ this.blurTime = 0;
|
|
585
|
this.setData({
|
614
|
this.setData({
|
|
586
|
- pageMarginBottom:0
|
615
|
+ pageMarginBottom: 0
|
|
587
|
})
|
616
|
})
|
|
588
|
- }else{
|
|
|
|
589
|
- setTimeout(res=>{
|
|
|
|
590
|
- this.blurTime+=1;
|
617
|
+ } else {
|
|
|
|
618
|
+ setTimeout(res => {
|
|
|
|
619
|
+ this.blurTime += 1;
|
|
591
|
this.inputFocus(e);
|
620
|
this.inputFocus(e);
|
|
592
|
- },300)
|
621
|
+ }, 300)
|
|
593
|
}
|
622
|
}
|
|
594
|
|
623
|
|
|
595
|
}
|
624
|
}
|
|
596
|
|
625
|
|
|
597
|
}
|
626
|
}
|
|
598
|
},
|
627
|
},
|
|
599
|
- pageScrollToBottom: function() {
|
|
|
|
600
|
- wx.createSelectorQuery().select('#j_page').boundingClientRect(function(rect){
|
628
|
+ pageScrollToBottom: function () {
|
|
|
|
629
|
+ wx.createSelectorQuery().select('#j_page').boundingClientRect(function (rect) {
|
|
601
|
// 使页面滚动到底部
|
630
|
// 使页面滚动到底部
|
|
602
|
wx.pageScrollTo({
|
631
|
wx.pageScrollTo({
|
|
603
|
scrollTop: rect.bottom
|
632
|
scrollTop: rect.bottom
|
|
@@ -606,17 +635,17 @@ Page({ |
|
@@ -606,17 +635,17 @@ Page({ |
|
606
|
},
|
635
|
},
|
|
607
|
gotoday(e){
|
636
|
gotoday(e){
|
|
608
|
this.setData({
|
637
|
this.setData({
|
|
609
|
- [`calendar.nextNum`]:0
|
638
|
+ [`calendar.nextNum`]: 0
|
|
610
|
})
|
639
|
})
|
|
611
|
},
|
640
|
},
|
|
612
|
nextMonth(e){
|
641
|
nextMonth(e){
|
|
613
|
this.setData({
|
642
|
this.setData({
|
|
614
|
- [`calendar.nextNum`]:this.data.calendar.nextNum+1
|
643
|
+ [`calendar.nextNum`]: this.data.calendar.nextNum + 1
|
|
615
|
})
|
644
|
})
|
|
616
|
},
|
645
|
},
|
|
617
|
prevMonth(e){
|
646
|
prevMonth(e){
|
|
618
|
this.setData({
|
647
|
this.setData({
|
|
619
|
- [`calendar.nextNum`]:this.data.calendar.nextNum-1
|
648
|
+ [`calendar.nextNum`]: this.data.calendar.nextNum - 1
|
|
620
|
})
|
649
|
})
|
|
621
|
},
|
650
|
},
|
|
622
|
}) |
651
|
}) |