collect.js
5.13 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
// pages/reserveNew/collect.js
import App from '../../utils/api';
Page({
/**
* 页面的初始数据
*/
data: {
barHeight: '', //状态栏+导航栏高度
checkType: '', //城市筛选1 美食筛选2
cateList: [], //美食列表
seachList: [{
id: '1',
title: '全部城市',
check: false,
},
{
id: '2',
title: '美食筛选',
check: false,
}
],
cityList: [{
id: '1',
name: '全部城市',
check: true,
},
{
id: '2',
name: '北京市',
check: false,
},
{
id: '3',
name: '天津市',
check: false,
},
{
id: '4',
name: '唐山市',
check: false,
}
],
sellerInfo: [{
"id": "8",
"sellername": "石府大酒店",
"is_parking": "1",
"average": "85",
"cate": [
"中餐",
"京菜鲁菜",
"淮扬菜"
],
"juli": '300m',
'shoucang': '0',
"seller_image": "http://libpc.colorcun.com/20250313162436_f5f597ea863038dbfbe3ee31287a915a",
}]
},
modal: '',
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.modal = this.selectComponent("#seachModal");
this.getCates()
},
// 选择筛选
checkDish(e) {
let activeId = e.currentTarget.dataset['id'];
const {
data
} = this;
const list = data.checkType == '1' ? data.cityList : data.cateList;
const idx = list.findIndex(item => item.id === activeId);
if (idx !== -1) {
if (data.checkType == '1') {
list.forEach((item, i) => {
if (i != idx) {
item.check = false;
} else {
item.check = true;
}
})
let seachList = data.seachList
seachList[0].title = data.cityList[idx].name;
this.setData({
seachList
})
this.modal.closeModal()
} else {
list[idx].check = !list[idx].check;
}
}
this.setData({
[data.checkType === '1' ? 'cityList' : 'cateList']: list,
});
},
// 重置
resetFun() {
let cateList = this.data.cateList;
cateList.forEach(i => {
i.check = false;
})
this.setData({
cateList,
});
},
// 筛选点确定
submitFun() {
const result1 = this.data.cateList.filter(item => item.check).map(item => item.id).join(',');
console.log('选择的菜品id', result1);
this.modal.closeModal()
},
// 切换筛选
checkSeachFun(e) {
let type = e.currentTarget.dataset['type'];
let seachList = this.data.seachList;
let i = type == '1' ? 0 : 1;
let idx = type == '1' ? 1 : 0
let check = seachList[i].check
if (check) {
seachList[i].check = false
seachList[idx].check = false
this.modal.closeModal()
} else {
seachList[i].check = true
seachList[idx].check = false
this.modal.showModal()
}
this.setData({
checkType: type,
seachList
})
},
// 获取美食列表
getCates() {
App.Reserve.GetCustomerConfig().then(res => {
let cateList = res.data.cate;
cateList.forEach(i => {
i.check = false;
})
this.setData({
cateList,
})
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
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() {
}
})