appment_main.js
7.45 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
var e = getApp(),
a = e.globalData.setting,
os = a,
t = e.request,
d = e.globalData;
Page({
/**
* 页面的初始数据
*/
data: {
iurl: a.imghost, //服务器网址
store: 0, //是否显示服务门店列表
beautician: 0, //是否显示美容师列表
beautician_name: "", //选中的美容师名称
placeholder: "填写备注", //备注为空的placeholder
store_list: [], //门店列表
beautician_list: [], //美容师列表
store_name: "", //选择的服务门店
fir_pick_index: 0, //选择的门店下标
curpage: 1, //当前分页数
pageSize: 8, //页大小
total: 0,
ismore: 0, //是否加载完毕
itemId: "", //项目id
isScroll: true, //scroll-y是否可以滑动
key_word: "", //是否按门店文字查询
is_service_read: 0, //是否调用过门店接口
is_search: 0, //是否通过key_word调用接口
is_success: 0, //是否提交成功
remarks: "", //备注
storageId: "", //线下门店id
},
onclickstore: function() {
var th = this;
var store = th.data.store;
if (store) {
th.setData({
store: 0,
placeholder: "填写备注"
})
wx.hideLoading();
} else {
th.setData({
store: 1,
placeholder: ""
})
if (th.data.store_list.length < 1) {
th.query_store();
}
}
},
//输入的备注
input_remarks: function(e) {
var remarks = e.detail.value;
this.setData({
remarks: remarks
})
},
//提交预约
sub_success: function() {
var th = this;
var store = th.data.store_name; //门店
var bea_name = th.data.beautician_name; //选择的美容师
// var time = th.data.time; //选择服务的时间
// //提交预约前的判断
// if (store == "") {
// getApp().my_warnning("请选择服务门店", 0, th);
// return false;
// } else if (bea_name == "") {
// getApp().my_warnning("请选择美容师", 0, th);
// return false;
// } else if (time == "") {
// getApp().my_warnning("请选择预约时间", 0, th);
// return false;
// }
var url = "/api/weshop/marketing/reservation/reservation/insert";
getApp().request.post(url, {
data: {
projectID: "",
beauticianID: "",
buyType: "",
storeId: a.stoid,
storageID: "",
arrangeTime: "",
userId: d.user_id,
remark: "",
states: ""
}
}).then(res => {
if (res.data.code == 0) {
th.setData({
is_success: 1
})
wx.navigateTo({
url: "/pages/user/my_service/tment_details"
});
} else {
getApp().my_warnning(res.data.msg, 0, th);
}
})
},
goto: function(e) {
var th = this;
if (th.data.store_name == "") {
getApp().my_warnning("请选择服务门店", 0, th);
} else if (th.data.beautician_name == "") {
getApp().my_warnning("请选择美容师", 0, th);
} else {
var url = e.currentTarget.dataset.url;
getApp().goto(url);
}
},
//点击选择门店
choose_for_store: function(e) {
var th = this;
var index_c = e.currentTarget.dataset.ind;
var fir_pick_index = th.data.fir_pick_index;
//判断是否点击选中的门店,防止重复点击重复设置选中下标
if (index_c == fir_pick_index) {
return false;
} else {
th.setData({
fir_pick_index: index_c
})
}
},
//确认选择门店
choice_store: function() {
var th = this;
var index = th.data.fir_pick_index;
var store_name = th.data.store_list[index].StorageName;
var Id = th.data.store_list[index].Id;
th.setData({
store: 0,
store_name: store_name,
storageId: Id
})
},
onReachBottom: function() {
var th = this;
if (this.data.total <= th.data.pageSize) return;
if (this.data.ismore) return;
wx.showLoading({
title: '加载中...',
})
th.query_store();
},
//分页查询门店信息
query_store: function() {
var th = this;
// var itemId = th.data.itemId;//正式使用项目id
var itemId = "08AD49D5-BAFD-4B5E-ABBA-B180EB64EED6"; //测试的项目id
var url = "/api/weshop/marketing/reservation/storage/page";
var key_word = th.data.key_word;
getApp().request.promiseGet(url, {
data: {
storeId: a.stoid,
userId: d.user_id,
itemId: itemId,
page: th.data.curpage,
pageSize: th.data.pageSize,
KeyWord: key_word
}
}).then(res => {
if (res.data.code == 0) {
wx.hideLoading();
th.data.curpage++;
var arr1 = th.data.store_list;
var arr2 = res.data.data.pageData;
var arr3 = [...arr1, ...arr2];
var ismore = 0;
if (arr3.length == res.data.data.total) ismore = 1
th.setData({
store_list: arr3,
total: res.data.data.total,
ismore: ismore,
is_service_read: 1,
}), wx.stopPullDownRefresh(); //停止下拉刷新
} else {
getApp().my_warnning(res.data.msg, 0, th);
}
})
},
//查询
query_beautician: function() {
var th = this;
if (th.data.store_name == "") {
getApp().my_warnning("请选择服务门店", 0, th);
} else {
if (th.data.beautician == 0) {
th.setData({
beautician: 1
})
} else {
th.setData({
beautician: 0
})
}
var itemid = "08AD49D5-BAFD-4B5E-ABBA-B180EB64EED6"; //测试的项目id
// var itemid = th.data.itemId;//正式使用的项目id
// var storageId = th.data.storageId;//正式使用的线下门店id
var storageId = "FD8EC44A-6474-4BA1-A17C-A87306690E59"; //测试的线下门店id
var url = "/api/weshop/marketing/reservation/staff/page";
getApp().request.promiseGet(url, {
data: {
storeId: a.stoid,
userId: d.user_id,
itemId: itemid,
storageId: storageId
}
}).then(res => {
if (res.data.code == 0) {
th.setData({
beautician_list: res.data.data.pageData
}) //停止下拉刷新
}
})
}
},
choice_beautician: function(e) {
var th = this;
var bea_name = e.currentTarget.dataset.beaname;
th.setData({
beautician_name: bea_name,
beautician: 0
})
},
//获取搜索门店输入的值
input_store: function(e) {
this.setData({
key_word: e.detail.value
})
},
//搜索门店
search_store: function() {
var th = this;
var key_word = th.data.key_word;
var store_list = th.data.store_list;
if (key_word != "") {
th.setData({
curpage: 1,
is_search: 0,
store_list: []
})
th.query_store();
if (store_list.length < 1) {
th.setData({
is_search: 1
})
}
} else {
getApp().my_warnning("请输入门店名称", 0, th);
}
},
//美容师预约跳转页面
nav_bea: function() {
var th = this;
var storageId = th.data.storageId; //线下门店id
if (storageId == "") {
getApp().my_warnning("请选择服务门店", 0, th);
} else {
wx.navigateTo({
url: "/pages/user/my_service/cosmetology_list"
});
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
var th = this;
th.setData({
itemId: options.itemId
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
}
})