index.js
7.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
// pages/reserveNew/index.js
import App from '../../utils/api';
Page({
/**
* 页面的初始数据
*/
data: {
displayModal: false, //更多的弹框
customItem: '全部',
region: ['北京市', '北京市', '东城区'],
activeId: '1', //选择的tab
barHeight: '', //状态栏+导航栏高度
checkType: '1',
cateList: [],
seachList: [{
id: '1',
title: '美食筛选',
check: true,
},
{
id: '2',
title: '包间筛选',
check: false,
}
],
roomList: [{
id: '1',
name: '2人间',
check: false,
},
{
id: '2',
name: '4人间',
check: false,
},
{
id: '3',
name: '6人间',
check: false,
},
{
id: '4',
name: '8人间',
check: false,
},
{
id: '5',
name: '10人间',
check: false,
},
{
id: '6',
name: '12人间',
check: false,
},
{
id: '7',
name: '15人间',
check: false,
},
{
id: '8',
name: '20人间',
check: false,
},
{
id: '9',
name: '特大包间',
check: false,
}
],
tabList: [{
title: '订过',
id: '1'
},
{
title: '去过',
id: '2'
},
{
title: '好友订过',
id: '3'
},
{
title: '我有券',
id: '4'
},
{
title: '更多',
id: '5'
}
],
sellerInfo: [{
"id": "8",
"sellername": "石府大酒店",
"is_parking": "1",
"average": "85",
"cate": [
"中餐",
"京菜鲁菜",
"淮扬菜"
],
"juli": '300m',
'shoucang': '0',
"seller_image": "http://libpc.colorcun.com/20250313162436_f5f597ea863038dbfbe3ee31287a915a",
},
{
"id": "8",
"sellername": "石府大酒店",
"is_parking": "1",
"average": "85",
"cate": [
"中餐",
"京菜鲁菜",
"淮扬菜"
],
"juli": '300m',
'shoucang': '1',
"seller_image": "http://libpc.colorcun.com/20250313162436_f5f597ea863038dbfbe3ee31287a915a",
},
{
"id": "8",
"sellername": "石府大酒店",
"is_parking": "1",
"average": "85",
"cate": [
"中餐",
"京菜鲁菜",
"淮扬菜"
],
"juli": '300m',
'shoucang': '1',
"seller_image": "http://libpc.colorcun.com/20250313162436_f5f597ea863038dbfbe3ee31287a915a",
},
{
"id": "8",
"sellername": "石府大酒店",
"is_parking": "1",
"average": "85",
"cate": [
"中餐",
"京菜鲁菜",
"淮扬菜"
],
"juli": '300m',
'shoucang': '1',
"seller_image": "http://libpc.colorcun.com/20250313162436_f5f597ea863038dbfbe3ee31287a915a",
}
]
},
modal: '',
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.modal = this.selectComponent("#seachModal"); //通过给组件所起的id调用组件
},
// 选择筛选
checkDish(e) {
let activeId = e.currentTarget.dataset['id'];
const {
data
} = this;
const list = data.checkType == '1' ? data.cateList : data.roomList;
const idx = list.findIndex(item => item.id === activeId);
if (idx !== -1) {
list[idx].check = !list[idx].check;
}
this.setData({
[data.checkType === '1' ? 'cateList' : 'roomList']: list,
checkList: list,
});
},
// 重置
resetFun() {
let data = this.data;
let list = data.checkType == '1' ? data.cateList : data.roomList;
list.forEach(i => {
i.check = false;
})
this.setData({
[data.checkType === '1' ? 'cateList' : 'roomList']: list,
checkList: list,
});
},
// 筛选点确定
submitFun() {
const result1 = this.data.cateList.filter(item => item.check).map(item => item.id).join(',');
const result2 = this.data.roomList.filter(item => item.check).map(item => item.id).join(',');
console.log('result1result1result1-------', result1);
console.log('result2result2-----------', result2);
this.modal.closeModal()
},
// 切换tab
checkTabFun(e) {
let activeId = e.currentTarget.dataset['id'];
let displayModal = this.data.displayModal
if (activeId == '5') {
if (displayModal) {
this.modal.closeModal()
} else {
this.modal.showModal()
}
}
this.setData({
activeId,
displayModal: !displayModal
})
},
checkSeachFun(e) {
let type = e.currentTarget.dataset['type'];
let checkList = type == '1' ? this.data.cateList : this.data.roomList
this.setData({
checkType: type,
checkList
})
},
// 获取美食列表
getCates() {
App.Reserve.GetCustomerConfig().then(res => {
let cateList = res.data.cate;
cateList.forEach(i => {
i.check = false;
})
this.setData({
cateList,
checkList: cateList
})
})
},
bindRegionChange(e) {
console.log('picker发送选择改变,携带值为', e.detail.value)
this.setData({
region: e.detail.value
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
//导航栏自适应
let systemInfo = wx.getSystemInfoSync();
let reg = /ios/i;
let pt = 20; //导航状态栏上内边距
let h = 44; //导航状态栏高度
if (reg.test(systemInfo.system)) {
pt = systemInfo.statusBarHeight;
h = 44;
} else {
pt = systemInfo.statusBarHeight;
h = 48;
}
this.setData({
barHeight: pt + h,
})
this.modal.closeModal()
this.getCates()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})