From 4245164cae1bf4f2509b990c9bef720e9620846c Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 12 Dec 2023 22:23:33 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E6=94=B6=E9=93=B6=E5=8F=B0?= =?UTF-8?q?=EF=BC=9A=E6=8E=A5=E5=85=A5=E6=94=B6=E9=93=B6=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/pay/index.vue | 36 ++++++------ pages/pay/result.vue | 120 ++++++++++++++++++++------------------- sheep/api/pay/order.js | 8 +++ sheep/api/trade/order.js | 34 +++++++---- sheep/platform/pay.js | 37 ++++++------ 5 files changed, 132 insertions(+), 103 deletions(-) diff --git a/pages/pay/index.vue b/pages/pay/index.vue index 804c2cd1..7ea40be6 100644 --- a/pages/pay/index.vue +++ b/pages/pay/index.vue @@ -87,10 +87,11 @@ // 检测支付环境 const state = reactive({ - payment: '', - orderInfo: {}, + orderType: 'goods', // 订单类型; goods - 商品订单, recharge - 充值订单 + orderInfo: {}, // 支付单信息 payStatus: 0, // 0=检测支付环境, -2=未查询到支付单信息, -1=支付已过期, 1=待支付,2=订单已支付 - payMethods: [], + payMethods: [], // 可选的支付方式 + payment: '', // 选中的支付方式 }); const onPay = () => { @@ -104,12 +105,12 @@ content: '确定要支付吗?', success: function (res) { if (res.confirm) { - sheep.$platform.pay(state.payment, state.orderType, state.orderInfo.order_sn); + sheep.$platform.pay(state.payment, state.orderType, state.orderInfo.id); } }, }); } else { - sheep.$platform.pay(state.payment, state.orderType, state.orderInfo.order_sn); + sheep.$platform.pay(state.payment, state.orderType, state.orderInfo.id); } }; @@ -134,15 +135,16 @@ // 状态转换:payOrder.status => payStatus function checkPayStatus() { - if (state.orderInfo.status === 10) { + if (state.orderInfo.status === 10 + || state.orderInfo.status === 20 ) { // 支付成功 state.payStatus = 2; return; } - if (state.orderInfo.status === 20) { + if (state.orderInfo.status === 30) { // 支付关闭 state.payStatus = -1; return; } - state.payStatus = 1; + state.payStatus = 1; // 待支付 } // 切换支付方式 @@ -167,24 +169,25 @@ // 获得支付方式 async function setPayMethods() { - const { data, code } = await PayChannelApi.getEnableChannelCodeList(state.orderInfo.appId); + const { data, code } = await PayChannelApi.getEnableChannelCodeList(state.orderInfo.appId) if (code !== 0) { - return; + return } - state.payMethods = getPayMethods(data); + state.payMethods = getPayMethods(data) } onLoad((options) => { - if ( - sheep.$platform.name === 'WechatOfficialAccount' && - sheep.$platform.os === 'ios' && - !sheep.$platform.landingPage.includes('pages/pay/index') - ) { + if (sheep.$platform.name === 'WechatOfficialAccount' + && sheep.$platform.os === 'ios' + && !sheep.$platform.landingPage.includes('pages/pay/index')) { location.reload(); return; } // 获得支付订单信息 let id = options.id; + if (options.orderType) { + state.orderType = options.orderType; + } setOrder(id); }); @@ -203,6 +206,7 @@ position: relative; padding: 60rpx 20rpx 40rpx; + .money-text { color: $red; font-size: 46rpx; diff --git a/pages/pay/result.vue b/pages/pay/result.vue index 5b18ba8e..82943712 100644 --- a/pages/pay/result.vue +++ b/pages/pay/result.vue @@ -2,34 +2,27 @@