order.js
19 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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
"use strict";
const common_vendor = require("../../common/vendor.js");
const common_hotel = require("../../common/hotel.js");
require("../../common/login.js");
require("../../common/request.js");
require("../../config.js");
require("../../common/api.js");
if (!Array) {
const _easycom_uni_datetime_picker2 = common_vendor.resolveComponent("uni-datetime-picker");
const _easycom_uni_forms_item2 = common_vendor.resolveComponent("uni-forms-item");
const _easycom_uni_number_box2 = common_vendor.resolveComponent("uni-number-box");
const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
const _easycom_uni_data_select2 = common_vendor.resolveComponent("uni-data-select");
const _easycom_uni_data_checkbox2 = common_vendor.resolveComponent("uni-data-checkbox");
const _easycom_uni_forms2 = common_vendor.resolveComponent("uni-forms");
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
(_easycom_uni_datetime_picker2 + _easycom_uni_forms_item2 + _easycom_uni_number_box2 + _easycom_uni_easyinput2 + _easycom_uni_data_select2 + _easycom_uni_data_checkbox2 + _easycom_uni_forms2 + _easycom_uni_icons2 + _easycom_uni_popup2)();
}
const _easycom_uni_datetime_picker = () => "../../uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.js";
const _easycom_uni_forms_item = () => "../../uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.js";
const _easycom_uni_number_box = () => "../../uni_modules/uni-number-box/components/uni-number-box/uni-number-box.js";
const _easycom_uni_easyinput = () => "../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js";
const _easycom_uni_data_select = () => "../../uni_modules/uni-data-select/components/uni-data-select/uni-data-select.js";
const _easycom_uni_data_checkbox = () => "../../uni_modules/uni-data-checkbox/components/uni-data-checkbox/uni-data-checkbox.js";
const _easycom_uni_forms = () => "../../uni_modules/uni-forms/components/uni-forms/uni-forms.js";
const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
const _easycom_uni_popup = () => "../../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
if (!Math) {
(_easycom_uni_datetime_picker + _easycom_uni_forms_item + _easycom_uni_number_box + _easycom_uni_easyinput + _easycom_uni_data_select + _easycom_uni_data_checkbox + _easycom_uni_forms + _easycom_uni_icons + _easycom_uni_popup)();
}
const _sfc_main = {
__name: "order",
setup(__props) {
const {
proxy
} = common_vendor.getCurrentInstance();
const data = common_vendor.reactive({
form: {
roomNum: 0,
addNum: 0
},
popup: null,
roomInfo: {},
rzUserArr: [""],
choseRooms: [],
hotelName: "",
yesno: [{
text: " 是 ",
value: "1"
}, {
text: " 否 ",
value: "0"
}],
canOrderStart: "",
canOrderEnd: "",
timeRange: [
{
value: "09:00",
text: "09:00"
},
{
value: "09:30",
text: "09:30"
},
{
value: "10:00",
text: "10:00"
},
{
value: "10:30",
text: "10:30"
},
{
value: "11:00",
text: "11:00"
},
{
value: "11:30",
text: "11:30"
},
{
value: "12:00",
text: "12:00"
},
{
value: "12:30",
text: "12:30"
},
{
value: "13:00",
text: "13:00"
},
{
value: "13:30",
text: "13:30"
},
{
value: "14:00",
text: "14:00"
},
{
value: "14:30",
text: "14:30"
},
{
value: "15:00",
text: "15:00"
},
{
value: "15:30",
text: "15:30"
},
{
value: "16:00",
text: "16:00"
},
{
value: "16:30",
text: "16:30"
},
{
value: "17:00",
text: "17:00"
},
{
value: "17:30",
text: "17:30"
},
{
value: "18:00",
text: "18:00"
},
{
value: "18:30",
text: "18:30"
},
{
value: "19:00",
text: "19:00"
},
{
value: "19:30",
text: "19:30"
},
{
value: "20:00",
text: "20:00"
},
{
value: "20:30",
text: "20:30"
},
{
value: "21:00",
text: "21:00"
},
{
value: "21:30",
text: "21:30"
},
{
value: "22:00",
text: "22:00"
},
{
value: "22:30",
text: "22:30"
},
{
value: "23:00",
text: "23:00"
},
{
value: "23:30",
text: "23:30"
},
{
value: "00:00",
text: "00:00"
}
],
rzRange: [],
money: "",
canOrderNum: 0
});
const {
form,
roomInfo,
hotelName,
yesno,
canOrderStart,
canOrderEnd,
timeRange,
rzRange,
money,
rzUserArr,
choseRooms,
popup,
canOrderNum
} = common_vendor.toRefs(data);
let usedays = 0;
common_vendor.onLoad((options) => {
var _a;
if ("room" in options) {
roomInfo.value = JSON.parse(decodeURIComponent(options.room));
if (roomInfo.value.addBedFlag == "1") {
form.value.isAddbed = "0";
}
}
hotelName.value = options.hotelName;
money.value = 0;
for (var t in timeRange.value) {
if (options.checkInTime == ((_a = timeRange.value[t]) == null ? void 0 : _a.value)) {
timeRange.value = timeRange.value.slice(t, -1);
}
}
const currUser = common_vendor.index.getStorageSync("currUser");
if (currUser.realTelno) {
form.value.phone = currUser.realTelno;
}
init();
});
common_vendor.onShow(() => {
});
function init() {
const today = common_vendor.dayjs();
canOrderStart.value = today;
if (roomInfo.value.hqNewStart < canOrderStart.value) {
roomInfo.value.hqNewStart = canOrderStart.value;
}
}
function getDate(datestr) {
var temp = datestr.split("-");
if (temp[1] === "01") {
temp[0] = parseInt(temp[0], 10) - 1;
temp[1] = "12";
} else {
temp[1] = parseInt(temp[1], 10) - 1;
}
var date = new Date(temp[0], temp[1], temp[2]);
return date;
}
function getDaysBetween(e) {
if (e.length == 0) {
return;
}
var d1 = Date.parse(rzRange.value[0]);
var d2 = Date.parse(rzRange.value[1]);
if (d1 > d2) {
usedays = 0;
return;
}
if (d1 == d2) {
usedays = 0;
common_vendor.index.showToast({
title: "入住时间跨度需大于一天",
icon: "none",
duration: 2e3
});
proxy.$refs.rzRangeForm.clear();
return;
} else {
var days = (d2 - d1) / (1 * 24 * 60 * 60 * 1e3);
usedays = days;
}
countMoney();
var startTime = getDate(rzRange.value[0]);
var endTime = getDate(rzRange.value[1]);
var dateArr = [];
while (endTime.getTime() - startTime.getTime() > 0) {
var year = startTime.getFullYear();
var month = (startTime.getMonth() + 1).toString().length === 1 ? "0" + (parseInt(startTime.getMonth().toString(), 10) + 1) : startTime.getMonth() + 1;
var day = startTime.getDate().toString().length === 1 ? "0" + startTime.getDate() : startTime.getDate();
dateArr.push(year + "-" + month + "-" + day);
startTime.setDate(startTime.getDate() + 1);
}
choseRooms.value = dateArr;
checkreRooms();
}
function checkreRooms() {
var obj = {
ahrId: roomInfo.value.id,
rzStart: rzRange.value[0],
rzEnd: rzRange.value[1]
};
common_hotel.checkResidueRoom(obj).then((res) => {
canOrderNum.value = res.data.useCount;
});
}
function changeisAddbed() {
if (form.value.isAddbed == "1" && !form.value.addNum) {
form.value.addNum = 1;
}
if (form.value.isAddbed == "0") {
form.value.addNum = 0;
}
countMoney();
}
function changeBed() {
countMoney();
}
function countMoney() {
money.value = (roomInfo.value.roomPrice * form.value.roomNum * usedays + roomInfo.value.bedPrice * form.value.addNum * usedays).toFixed(2);
}
function submit() {
if (usedays == 0) {
common_vendor.index.showToast({
title: "入住时间跨度需大于一天",
icon: "none",
duration: 2e3
});
return;
}
if (form.value.roomNum == 0) {
common_vendor.index.showToast({
title: " 请选择房间数",
icon: "none",
duration: 2e3
});
return;
}
form.value.rzStart = rzRange.value[0];
form.value.rzEnd = rzRange.value[1];
if (!form.value.rzStart) {
common_vendor.index.showToast({
title: "请选择入住时间",
icon: "none",
duration: 2e3
});
return;
}
if (!form.value.ddDate) {
common_vendor.index.showToast({
title: "请选择预计到店时间",
icon: "none",
duration: 2e3
});
return;
}
var pattern = /^1[345789]\d{9}$/;
if (!pattern.test(form.value.phone)) {
common_vendor.index.showToast({
title: "请输入正确的手机号",
duration: 2e3,
icon: "none"
});
return;
}
let arr = [];
for (var n of rzUserArr.value) {
if (n == "" || n == void 0) {
common_vendor.index.showToast({
title: "请填写入住人信息",
icon: "none",
duration: 2e3
});
return;
} else {
arr.push(n);
}
}
form.value.rzUsers = arr.toString();
form.value.activeId = roomInfo.value.activityId;
form.value.ahId = roomInfo.value.hotelId;
form.value.ahrId = roomInfo.value.id;
form.value.orderName = hotelName.value;
form.value.roomName = roomInfo.value.roomType;
var str = "";
var str2 = "";
if (form.value.addNum && form.value.addNum > 0) {
str = `加床${form.value.addNum}张`;
} else {
str = `未加床`;
}
if (roomInfo.value.breakfastNum && roomInfo.value.breakfastNum > 0) {
str2 = `${roomInfo.value.breakfastNum}份早餐`;
} else {
str2 = `无早餐`;
}
form.value.roomInfo = `${form.value.roomNum} 间·${usedays}晚·${str}·${str2}`;
console.log(form.value.roomInfo);
common_vendor.index.showModal({
title: "提示",
content: "确定提交订单吗",
success: function(res) {
if (res.confirm) {
common_hotel.newsSubmitOrderHotel(form.value).then((res2) => {
if (res2.data) {
if (res2.data.roomNum == -100) {
common_vendor.index.showToast({
title: "剩余房间数不足",
icon: "none",
duration: 2e3
});
checkreRooms();
} else {
let path = `/pages_hotel/hotel/pay?money=${res2.data.total}&orderId=${res2.data.orderId}`;
common_vendor.index.redirectTo({
url: path
});
}
} else {
common_vendor.index.showToast({
title: " 无可预定的房间 ",
icon: "none",
duration: 2e3
});
}
});
} else if (res.cancel) {
console.log("用户点击取消");
}
}
});
}
function popChoose() {
popup.value.open();
}
function changeRoomNum(e) {
if (!usedays || usedays == 0) {
common_vendor.index.showToast({
title: "请先选择入住时间",
icon: "none",
duration: 2e3
});
return;
}
if (form.value.addNum > e) {
form.value.addNum = e;
}
rzUserArr.value.length = e;
countMoney();
}
function changeTimeRange() {
}
function initDate() {
if (proxy.$refs.rzRangeForm.$refs.mobile.aniMaskShow) {
return;
}
if (rzRange.value.length > 0) {
return;
}
proxy.$refs.rzRangeForm.$refs.mobile.init(roomInfo.value.hqNewStart);
}
return (_ctx, _cache) => {
return common_vendor.e({
a: common_vendor.t(common_vendor.unref(hotelName)),
b: common_vendor.t(common_vendor.unref(roomInfo).roomType),
c: common_vendor.t(common_vendor.unref(roomInfo).bedType),
d: common_vendor.t(common_vendor.unref(roomInfo).area),
e: common_vendor.t(common_vendor.unref(roomInfo).occupantsNum),
f: common_vendor.t(common_vendor.unref(roomInfo).breakfastNum),
g: common_vendor.unref(roomInfo).breakfastFlag == "1",
h: common_vendor.unref(roomInfo).breakfastFlag == "0",
i: common_vendor.unref(roomInfo).bathroomFlag == "1",
j: common_vendor.unref(roomInfo).windowFlag == "1",
k: common_vendor.unref(roomInfo).addBedFlag == "1",
l: common_vendor.sr("rzRangeForm", "2982ae37-2,2982ae37-1"),
m: common_vendor.o(getDaysBetween),
n: common_vendor.o(($event) => common_vendor.isRef(rzRange) ? rzRange.value = $event : null),
o: common_vendor.p({
type: "daterange",
start: common_vendor.unref(roomInfo).hqNewStart,
end: common_vendor.unref(roomInfo).hqNewEnd,
modelValue: common_vendor.unref(rzRange)
}),
p: common_vendor.p({
label: "入住时间",
required: true
}),
q: common_vendor.o(initDate),
r: common_vendor.unref(rzRange)[1]
}, common_vendor.unref(rzRange)[1] ? {
s: common_vendor.t(common_vendor.unref(canOrderNum))
} : {}, {
t: common_vendor.o(changeRoomNum),
v: common_vendor.o(($event) => common_vendor.unref(form).roomNum = $event),
w: common_vendor.p({
min: 0,
max: common_vendor.unref(canOrderNum),
modelValue: common_vendor.unref(form).roomNum
}),
x: common_vendor.p({
label: "房间数",
required: true
}),
y: common_vendor.f(common_vendor.unref(form).roomNum, (n, index, i0) => {
return {
a: "2982ae37-6-" + i0 + "," + ("2982ae37-5-" + i0),
b: common_vendor.o(($event) => common_vendor.unref(rzUserArr)[index] = $event, index),
c: common_vendor.p({
type: "text",
placeholder: "每间填一位住客姓名",
modelValue: common_vendor.unref(rzUserArr)[index]
}),
d: "2982ae37-5-" + i0 + ",2982ae37-0",
e: common_vendor.p({
label: `入住人${index + 1}`,
required: true
}),
f: index
};
}),
z: common_vendor.o(changeTimeRange),
A: common_vendor.o(($event) => common_vendor.unref(form).ddDate = $event),
B: common_vendor.p({
localdata: common_vendor.unref(timeRange),
modelValue: common_vendor.unref(form).ddDate
}),
C: common_vendor.p({
label: "预计到店",
clickable: true,
required: true
}),
D: common_vendor.o(($event) => common_vendor.unref(form).phone = $event),
E: common_vendor.p({
type: "number",
placeholder: "请输入联系电话",
modelValue: common_vendor.unref(form).phone
}),
F: common_vendor.p({
label: "联系电话",
required: true
}),
G: common_vendor.unref(roomInfo).addBedFlag == "1"
}, common_vendor.unref(roomInfo).addBedFlag == "1" ? common_vendor.e({
H: common_vendor.o(changeisAddbed),
I: common_vendor.o(($event) => common_vendor.unref(form).isAddbed = $event),
J: common_vendor.p({
localdata: common_vendor.unref(yesno),
modelValue: common_vendor.unref(form).isAddbed
}),
K: common_vendor.p({
label: "是否加床"
}),
L: common_vendor.unref(form).isAddbed == "1"
}, common_vendor.unref(form).isAddbed == "1" ? {
M: common_vendor.o(changeBed),
N: common_vendor.o(($event) => common_vendor.unref(form).addNum = $event),
O: common_vendor.p({
min: 1,
max: common_vendor.unref(form).roomNum,
modelValue: common_vendor.unref(form).addNum
}),
P: common_vendor.p({
label: "加床张数"
})
} : {}) : {}, {
Q: common_vendor.unref(form).isAddbed == "1"
}, common_vendor.unref(form).isAddbed == "1" ? {} : {}, {
R: common_vendor.t(common_vendor.unref(money)),
S: common_vendor.p({
type: "bottom",
size: "20"
}),
T: common_vendor.o(popChoose),
U: common_vendor.o(submit),
V: common_vendor.t((common_vendor.unref(roomInfo).roomPrice * common_vendor.unref(form).roomNum * common_vendor.unref(choseRooms).length).toFixed(2)),
W: common_vendor.f(common_vendor.unref(choseRooms), (c, index, i0) => {
return {
a: common_vendor.t(c),
b: index
};
}),
X: common_vendor.t(common_vendor.unref(form).roomNum),
Y: common_vendor.t(common_vendor.unref(roomInfo).roomPrice),
Z: common_vendor.unref(form).isAddbed == "1"
}, common_vendor.unref(form).isAddbed == "1" ? {
aa: common_vendor.t((common_vendor.unref(roomInfo).bedPrice * common_vendor.unref(form).addNum * common_vendor.unref(choseRooms).length).toFixed(2))
} : {}, {
ab: common_vendor.unref(form).isAddbed == "1"
}, common_vendor.unref(form).isAddbed == "1" ? {
ac: common_vendor.f(common_vendor.unref(choseRooms), (c, index, i0) => {
return {
a: common_vendor.t(c),
b: index
};
}),
ad: common_vendor.t(common_vendor.unref(form).addNum),
ae: common_vendor.t(common_vendor.unref(roomInfo).bedPrice)
} : {}, {
af: common_vendor.t(common_vendor.unref(money)),
ag: common_vendor.sr(popup, "2982ae37-16", {
"k": "popup"
}),
ah: common_vendor.p({
["background-color"]: "#fff",
type: "bottom"
})
});
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-2982ae37"], ["__file", "/Users/yangyang/project/j-mini/Venue/pages_hotel/hotel/order.vue"]]);
wx.createPage(MiniProgramPage);