booking.js
12 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
"use strict";
const common_vendor = require("../../common/vendor.js");
const common_assets = require("../../common/assets.js");
const common_api = require("../../common/api.js");
require("../../common/login.js");
require("../../common/request.js");
require("../../config.js");
if (!Array) {
const _easycom_uni_countdown2 = common_vendor.resolveComponent("uni-countdown");
const _easycom_uni_popup_dialog2 = common_vendor.resolveComponent("uni-popup-dialog");
const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
(_easycom_uni_countdown2 + _easycom_uni_popup_dialog2 + _easycom_uni_popup2)();
}
const _easycom_uni_countdown = () => "../../uni_modules/uni-countdown/components/uni-countdown/uni-countdown.js";
const _easycom_uni_popup_dialog = () => "../../uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.js";
const _easycom_uni_popup = () => "../../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
if (!Math) {
(_easycom_uni_countdown + _easycom_uni_popup_dialog + _easycom_uni_popup)();
}
const _sfc_main = {
__name: "booking",
setup(__props) {
const {
proxy
} = common_vendor.getCurrentInstance();
common_vendor.ref("/static/v1.png");
common_vendor.ref(["消费记录", "充值记录"]);
common_vendor.ref(0);
common_vendor.ref(false);
const lockPay = common_vendor.ref(false);
const isClick = common_vendor.ref(false);
const alertDialog = common_vendor.ref(null);
const alertPayOk = common_vendor.ref(null);
const alertPayWrong = common_vendor.ref(null);
const currUser = common_vendor.ref({});
const orderId = common_vendor.ref("");
const order = common_vendor.ref({});
const orderFrom = common_vendor.ref(0);
const orderInfo = common_vendor.ref([]);
const myBalance = common_vendor.ref(0);
const form = common_vendor.ref({
payType: "2"
});
const countdown = common_vendor.ref({
start: false,
minute: 0,
second: 0
});
common_vendor.onLoad((option) => {
common_vendor.index.showLoading({
title: "加载中"
});
if (option.id) {
orderFrom.value = 1;
common_api.getMaItemById(option.id).then((res) => {
common_vendor.index.hideLoading();
order.value = res.data;
form.value.orderId = option.id;
orderId.value = option.id;
form.value.orderAmount = res.data.useBalancePrice;
let leftTime = common_vendor.dayjs(res.data.createTime).add(15, "minute").valueOf() - common_vendor.dayjs().valueOf();
if (leftTime > 0) {
countdown.value = {
start: true,
minute: Math.floor(leftTime / 1e3 / 60),
second: Math.ceil(leftTime / 1e3) % 60
};
} else {
countdown.value = {
start: true
};
timeup();
}
});
} else {
const eventChannel = proxy.getOpenerEventChannel();
eventChannel.on("acceptDataFromOpenerPage", (data) => {
orderInfo.value = data.orderInfo;
orderId.value = data.order.id;
common_api.getMaItemById(orderId.value).then((res) => {
common_vendor.index.hideLoading();
order.value = res.data;
form.value.orderAmount = res.data.useBalancePrice;
});
eventChannel.emit("acceptDataFromOpenedPage");
countdown.value = {
start: true
};
});
}
currUser.value = common_vendor.index.getStorageSync("currUser");
common_api.getMyBalance().then((res) => {
myBalance.value = res.data;
});
});
function payChange(evt) {
form.value.payType = evt.detail.value;
}
function pay(n) {
if (lockPay.value == true) {
return;
} else {
lockPay.value = true;
}
if (n == "2" && parseFloat(myBalance.value) < parseFloat(order.value.useBalancePrice)) {
common_vendor.index.showToast({
title: "余额不足,无法支付",
icon: "none",
duration: 2e3
});
lockPay.value = false;
} else {
alertDialog.value.open();
}
}
function dialogConfirm() {
if (isClick.value == true) {
return;
} else {
isClick.value = true;
common_vendor.index.showLoading({
title: "支付中..."
});
goPayForOrder();
}
}
function goPayForOrder() {
if (form.value.payType != "2") {
form.value.orderAmount = order.value.unuseBalancePrice;
}
common_api.payForOrder(orderId.value, form.value).then((res) => {
isClick.value = false;
if (res.data.weixinData) {
wePay(res.data.weixinData);
} else {
alertPayOk.value.open();
subscribe();
lockPay.value = true;
}
}).catch(() => {
alertPayWrong.value.open();
}).finally(() => {
common_vendor.index.hideLoading();
});
}
function wePay(configdata) {
common_vendor.index.requestPayment({
"provider": "wxpay",
"appId": configdata.appId,
"nonceStr": configdata.nonceStr,
"package": configdata.packageValue,
// 随机字符串
"timeStamp": configdata.timeStamp,
// 时间戳(单位:秒)
"signType": configdata.signType,
// 签名,这里用的 MD5/RSA 签名
"paySign": configdata.paySign,
success(res) {
alertPayOk.value.open();
subscribe();
common_api.maPayConfirm({
orderId: orderId.value,
successFlag: true
}).then((res2) => {
lockPay.value = false;
});
},
fail(e) {
common_vendor.index.showToast({
title: "支付取消",
icon: "none",
duration: 2e3
});
common_api.maPayConfirm({
orderId: orderId.value,
successFlag: false
}).then((res) => {
lockPay.value = false;
});
}
});
}
function payCancel() {
common_vendor.index.showModal({
title: "提示",
content: "确定取消订单吗",
success: function(res) {
if (res.confirm) {
const eventChannel = proxy.getOpenerEventChannel();
common_api.cancelOrder(orderId.value).then((res2) => {
eventChannel.emit("acceptDataFromOpenedPage");
common_vendor.index.navigateBack();
});
} else if (res.cancel) {
console.log("用户点击取消");
}
}
});
}
function dialogClose() {
alertDialog.value.close();
lockPay.value = false;
}
function goBillDetail() {
common_vendor.index.redirectTo({
url: `/pages/usercenter/billsDetail?id=${orderId.value}`
});
}
function timeup() {
if (countdown.value.start) {
common_vendor.index.showModal({
title: "提示",
content: "订单支付已超时",
showCancel: false,
success: function(res) {
if (res.confirm) {
common_api.cancelOrder(orderId.value).then((res2) => {
common_vendor.index.navigateBack();
});
}
}
});
}
}
function subscribe() {
common_vendor.index.requestSubscribeMessage({
tmplIds: ["p7_a1SGyGvJeOdwx_GKl6UlrWiWpNnejUArbnEPf-k4"],
success: (res) => {
console.log("success:", res);
}
});
}
return (_ctx, _cache) => {
return common_vendor.e({
a: common_vendor.t(order.value.id),
b: orderFrom.value == 0
}, orderFrom.value == 0 ? {
c: common_vendor.t(common_vendor.unref(common_vendor.dayjs)().format("YYYY-MM-DD"))
} : {}, {
d: orderFrom.value == 1
}, orderFrom.value == 1 ? {
e: common_vendor.t(order.value.createTime)
} : {}, {
f: common_vendor.t(currUser.value.userName || order.value.orderName),
g: common_vendor.t(currUser.value.phonenumber || order.value.orderTelno),
h: order.value.projectName
}, order.value.projectName ? {
i: common_vendor.t(order.value.projectName)
} : order.value.sonList ? {
k: common_vendor.t(order.value.sonList[0].projectName)
} : {}, {
j: order.value.sonList,
l: order.value.sonList
}, order.value.sonList ? {
m: common_vendor.f(order.value.sonList, (info, index, i0) => {
return {
a: common_vendor.t(`明细 ${info.siteName} ${info.orderDate.substring(5, 10)} (${info.orderTimePeriod.replace(/,/, "-")} ) ${info.orderHour}小时`),
b: common_vendor.t(info.orderAmount),
c: info.id
};
})
} : {}, {
n: !order.value.sonList
}, !order.value.sonList ? {
o: common_vendor.t(`明细 ${order.value.siteName} ${order.value.orderDate.substring(5, 10)} (${order.value.orderTimePeriod.replace(/,/, "-")}) ${order.value.orderHour}小时`),
p: common_vendor.t(order.value.orderAmount)
} : {}, {
q: form.value.payType == "2"
}, form.value.payType == "2" ? {
r: common_vendor.t(order.value.unuseBalancePrice)
} : {}, {
s: form.value.payType == "2"
}, form.value.payType == "2" ? {
t: common_vendor.t(order.value.useBalancePrice)
} : {}, {
v: form.value.payType == "7"
}, form.value.payType == "7" ? {
w: common_vendor.t(order.value.unuseBalancePrice)
} : {}, {
x: form.value.remark,
y: common_vendor.o(($event) => form.value.remark = $event.detail.value),
z: common_assets._imports_0,
A: common_assets._imports_1,
B: common_vendor.t(myBalance.value),
C: common_vendor.o(payChange),
D: orderFrom.value == 0
}, orderFrom.value == 0 ? {
E: common_vendor.o(payCancel),
F: common_vendor.o(timeup),
G: common_vendor.p({
color: "#fff",
splitorColor: "#fff",
["show-day"]: false,
["show-hour"]: false,
minute: 15,
second: 0
}),
H: common_vendor.o(($event) => pay(form.value.payType))
} : {
I: common_vendor.o(timeup),
J: common_vendor.p({
color: "#fff",
splitorColor: "#fff",
["show-day"]: false,
["show-hour"]: false,
start: countdown.value.start,
minute: countdown.value.minute,
second: countdown.value.second
}),
K: common_vendor.o(($event) => pay(form.value.payType))
}, {
L: common_vendor.o(dialogConfirm),
M: common_vendor.o(dialogClose),
N: common_vendor.p({
type: "info",
cancelText: "取消",
confirmText: "确定",
content: "是否确认支付?"
}),
O: common_vendor.sr(alertDialog, "86691f90-2", {
"k": "alertDialog"
}),
P: common_vendor.p({
type: "dialog"
}),
Q: common_vendor.o(goBillDetail),
R: common_vendor.o(goBillDetail),
S: common_vendor.p({
type: "success",
confirmText: "查看订单详情",
content: "支付成功"
}),
T: common_vendor.sr(alertPayOk, "86691f90-4", {
"k": "alertPayOk"
}),
U: common_vendor.p({
type: "dialog"
}),
V: common_vendor.o(goBillDetail),
W: common_vendor.o(goBillDetail),
X: common_vendor.p({
type: "error",
confirmText: "查看订单详情",
content: "支付失败"
}),
Y: common_vendor.sr(alertPayWrong, "86691f90-6", {
"k": "alertPayWrong"
}),
Z: common_vendor.p({
type: "dialog"
})
});
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-86691f90"], ["__file", "/Users/yangyang/project/j-mini/Venue/pages/index/booking.vue"]]);
wx.createPage(MiniProgramPage);