"use strict"; const common_vendor = require("../common/vendor.js"); const api_pay = require("../api/pay.js"); const common_assets = require("../common/assets.js"); const _sfc_main = { data() { return { payType: 2, order: null, // formattedDate: '', orderId: null, payDelivery: 0, payMoney: 0, config: null, payType: 1, // payLimitTime: null, user: null, combinationOrderId: "", // 需要开处方的订单id 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("支付订单是>>", options); if (options.orderList) { try { const decoded = decodeURIComponent(options.orderList); this.order = JSON.parse(decoded) || {}; } catch (e) { console.error("参数解析失败:", e); this.order = {}; } } }, //发送给朋友 onShareAppMessage(res) { const combinationOrderId = this.combinationOrderId ? `&combinationOrderId=${encodeURIComponent(this.combinationOrderId)}` : ""; return { title: "帮TA支付", path: "/pages_user/user/otherPaymentOrder?orderId=" + this.orderId + combinationOrderId, imageUrl: "/static/images/logo.png" //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4 }; }, methods: { payOrder() { if (this.payType == 1) { this.doWechatPay(); } else if (this.payType == 2) { this.doAlipay(); } else { common_vendor.index.showToast({ title: "暂时无可用支付", icon: "none" }); } }, // 选微信支付或者支付宝支付 handlePayTypeChange(e) { this.payType = e.detail.value; console.log("当前选中:", this.payType); }, async doWechatPay() { try { common_vendor.index.showLoading({ title: "发起支付中...", 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("支付流程异常:", err); } finally { common_vendor.index.hideLoading(); } }, // doWechatPay(){ // weChatPayment(data).then(res => { // if (res.code == 200) { // } // }) // }, // 支付宝支付 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: "请求失败" }); } }, (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: "内容已成功复制到剪切板", icon: "none" }); } }); }, // getStoreOrderById(){ // var data = {orderId:this.orderId}; // var that=this; // uni.showLoading(); // getStoreOrderById(data).then( // res => { // if(res.code==200){ // console.log(res); // uni.hideLoading(); // that.order=res.order; // that.order.orderCodes = that.order.orderCode ? [that.order.orderCode]:[] // that.orderCode = that.order.orderCode // that.payLimitTime=res.payLimitTime; // //套餐订单处理 // if(res.productPackage!=null){ // this.payType=res.productPackage.payType; // console.log(this.payType) // if(this.order.payType==4){ // this.order.payType=1; // } // } // this.editPayType(this.order.payType) // }else{ // uni.showToast({ // icon:'none', // title: res.msg, // }); // } // }, // rej => {} // ); // }, 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) => { } ); }, // getStoreOrderByCombinationId() { // var data = {combinationId:this.combinationOrderId}; // var that=this; // uni.showLoading(); // getStoreOrderByCombinationId(data).then( // res => { // if(res.code==200){ // console.log(res); // uni.hideLoading(); // that.order=res.order; // that.orderCode = res.order.orderCodes ? res.order.orderCodes.join(',') : ""; // that.payLimitTime=res.payLimitTime; // //套餐订单处理 // if(res.productPackage!=null){ // this.payType=res.productPackage.payType; // console.log(this.payType) // if(this.order.payType==4){ // this.order.payType=1; // } // } // that.prescribeOrder = res.prescribeOrder; // this.editPayTypeByCombinationId(this.order.payType) // }else{ // uni.showToast({ // icon:'none', // title: res.msg, // }); // } // }, // rej => {} // ); // }, // editPayTypeByCombinationId(payType){ // var data = {combinationOrderId:this.combinationOrderId,payType:payType}; // var that=this; // uni.showLoading(); // editPayTypeByCombinationId(data).then( // res => { // if(res.code==200){ // console.log(res); // uni.hideLoading(); // that.order=res.order; // that.orderCode = res.order.orderCodes ? res.order.orderCodes.join(',') : ""; // //this.payType=this.order.payType // this.payMoney=this.order.payMoney; // this.payDelivery=this.order.payDelivery; // that.prescribeOrder = res.prescribeOrder; // }else{ // uni.showToast({ // icon:'none', // title: res.msg, // }); // } // }, // rej => {} // ); // }, otherPayOrder() { common_vendor.index.navigateTo({ url: "/pages_user/user/otherPaymentOrder?combinationOrderId=" + encodeURIComponent(this.combinationOrderId) }); }, // payOrder() { // if (this.combinationOrderId) { // let data = { // combinationOrderId: this.combinationOrderId, // payType: this.order.payType // }; // let that = this; // uni.showLoading(); // payByCombinationId(data).then( // res => { // if (res.code == 200) { // this.payfun(res) // } else { // uni.showToast({ // icon: 'none', // title: res.msg, // }); // } // }, // rej => {} // ); // } else { // let data = { // orderId: this.order.id, // payType: this.order.payType // }; // let that = this; // uni.showLoading(); // pay(data).then( // res => { // if (res.code == 200) { // this.payfun(res) // } else { // uni.showToast({ // icon: 'none', // title: res.msg, // }); // } // }, // rej => {} // ); // } // }, 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.packageValue, 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: common_assets._imports_0$12, d: $data.payType === 1, e: common_vendor.o((...args) => $options.handlePayTypeChange && $options.handlePayTypeChange(...args)), f: common_vendor.t((_a = $data.order) == null ? void 0 : _a.orderCode), g: common_vendor.o(($event) => $options.copyOrderSn(_ctx.orderCode)), h: common_vendor.t($options.formattedDate), i: $data.order != null }, $data.order != null ? { j: common_vendor.t($data.order ? (Number($data.order.totalPrice) || 0).toFixed(2) : "0.00") } : {}, { k: common_vendor.o(($event) => $options.payOrder()) }); } const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]); _sfc_main.__runtimeHooks = 2; wx.createPage(MiniProgramPage);