"use strict"; var common_vendor = require("../common/vendor.js"); var api_pay = require("../api/pay.js"); require("../common/request.js"); const _sfc_main = { data() { return { payType: 2, order: null, orderId: null, payDelivery: 0, payMoney: 0, config: null, payType: 1, user: null, combinationOrderId: "", prescribeOrder: "" }; }, computed: { formattedDate() { var _a; return ((_a = this.order) == null ? void 0 : _a.createTime) ? common_vendor.dayjs(this.order.createTime).format("YYYY-MM-DD HH:mm:ss") : ""; }, payLimitTime() { var _a; return ((_a = this.order) == null ? void 0 : _a.updateTime) ? common_vendor.dayjs(this.order.updateTime).format("YYYY-MM-DD HH:mm:ss") : ""; } }, onLoad(options) { console.log("\u652F\u4ED8\u8BA2\u5355\u662F>>", options); if (options.orderList) { try { const decoded = decodeURIComponent(options.orderList); this.order = JSON.parse(decoded) || {}; } catch (e) { console.error("\u53C2\u6570\u89E3\u6790\u5931\u8D25:", e); this.order = {}; } } }, onShareAppMessage(res) { const combinationOrderId = this.combinationOrderId ? `&combinationOrderId=${encodeURIComponent(this.combinationOrderId)}` : ""; return { title: "\u5E2ETA\u652F\u4ED8", path: "/pages_user/user/otherPaymentOrder?orderId=" + this.orderId + combinationOrderId, imageUrl: "/static/images/logo.png" }; }, methods: { payOrder() { if (this.payType == 1) { this.doWechatPay(); } else if (this.payType == 2) { this.doAlipay(); } else { common_vendor.index.showToast({ title: "\u6682\u65F6\u65E0\u53EF\u7528\u652F\u4ED8", icon: "none" }); } }, handlePayTypeChange(e) { this.payType = e.detail.value; console.log("\u5F53\u524D\u9009\u4E2D:", this.payType); }, async doWechatPay() { try { common_vendor.index.showLoading({ title: "\u53D1\u8D77\u652F\u4ED8\u4E2D...", mask: true }); let data = { orderId: this.order.orderId }; await api_pay.weChatPayment(data); common_vendor.index.redirectTo({ url: "/pages_shop/success" }); } catch (err) { console.error("\u652F\u4ED8\u6D41\u7A0B\u5F02\u5E38:", err); } finally { common_vendor.index.hideLoading(); } }, doAlipay() { ({ orderId: this.order.orderId }); console.log("orderId>>", this.order.orderId); }, getUserInfo() { getUserInfo().then((res) => { if (res.code == 200) { if (res.user != null) { this.user = res.user; } } else { common_vendor.index.showToast({ icon: "none", title: "\u8BF7\u6C42\u5931\u8D25" }); } }, (rej) => { }); }, getStoreConfig() { getStoreConfig().then((res) => { if (res.code == 200) { this.config = res.data; console.log(this.config); } }, (rej) => { }); }, payTypeChange(e) { if (this.combinationOrderId) { this.editPayTypeByCombinationId(e.detail.value); } else { this.editPayType(e.detail.value); } }, copyOrderSn(text) { common_vendor.index.setClipboardData({ data: text, success: () => { common_vendor.index.showToast({ title: "\u5185\u5BB9\u5DF2\u6210\u529F\u590D\u5236\u5230\u526A\u5207\u677F", icon: "none" }); } }); }, editPayType(payType) { var data = { orderId: this.orderId, payType }; var that = this; common_vendor.index.showLoading(); editPayType(data).then((res) => { if (res.code == 200) { console.log(res); common_vendor.index.hideLoading(); that.order = res.order; that.order.orderCodes = that.order.orderCode ? [that.order.orderCode] : []; that.orderCode = that.order.orderCode; this.payMoney = this.order.payMoney; this.payDelivery = this.order.payDelivery; } else { common_vendor.index.showToast({ icon: "none", title: res.msg }); } }, (rej) => { }); }, otherPayOrder() { common_vendor.index.navigateTo({ url: "/pages_user/user/otherPaymentOrder?combinationOrderId=" + encodeURIComponent(this.combinationOrderId) }); }, payfun(res) { const that = this; console.log(res.result); if (res.payType == 1 || res.payType == 2) { common_vendor.index.requestPayment({ provider: "wxpay", timeStamp: res.result.timeStamp, nonceStr: res.result.nonceStr, package: res.result.packageStr, signType: res.result.signType, paySign: res.result.paySign, success: function(res2) { common_vendor.index.hideLoading(); common_vendor.index.redirectTo({ url: "success?order=" + JSON.stringify(that.order) }); }, fail: function(err) { common_vendor.index.showToast({ icon: "none", title: "fail:" + JSON.stringify(err) }); console.log("fail:" + JSON.stringify(err)); common_vendor.index.hideLoading(); } }); } else if (res.payType == 3) { common_vendor.index.hideLoading(); if (that.order.isPrescribe) { common_vendor.index.redirectTo({ url: "prescribe?orderId=" + that.prescribeOrder + "&combinationOrderId=" + encodeURIComponent(that.order.combinationOrderId) }); } else { common_vendor.index.redirectTo({ url: "success?order=" + JSON.stringify(that.order) }); } } } } }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { var _a; return common_vendor.e({ a: common_vendor.t($options.payLimitTime), b: common_vendor.t($data.order ? (Number($data.order.totalPrice) || 0).toFixed(2) : "0.00"), c: $data.payType === 1, d: common_vendor.o((...args) => $options.handlePayTypeChange && $options.handlePayTypeChange(...args)), e: common_vendor.t((_a = $data.order) == null ? void 0 : _a.orderCode), f: common_vendor.o(($event) => $options.copyOrderSn(_ctx.orderCode)), g: common_vendor.t($options.formattedDate), h: $data.order != null }, $data.order != null ? { i: common_vendor.t($data.order ? (Number($data.order.totalPrice) || 0).toFixed(2) : "0.00") } : {}, { j: common_vendor.o(($event) => $options.payOrder()) }); } var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "C:/Users/Administrator/Desktop/\u9879\u76EE/\u76F4\u64AD/liveH5-v3/pages_shop/paymentOrder.vue"]]); _sfc_main.__runtimeHooks = 2; wx.createPage(MiniProgramPage);