From bff8bd8dd03a2f3d065d7c2334209a7f06f76dbf Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 4 Jul 2023 23:42:48 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E8=AE=A2=E5=8D=95=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E9=A1=B5=E3=80=91=201.=20=E5=92=8C=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E7=BB=93=E6=9E=9C=E7=9A=84=E5=9B=9E=E8=B0=83=E6=89=93?= =?UTF-8?q?=E9=80=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/goods/cashier/index.vue | 37 ++++++++++++++++++++++------- pages/order_details/index.vue | 3 ++- pages/order_pay_status/index.vue | 11 +++++---- pages/users/order_confirm/index.vue | 3 ++- pages/users/order_list/index.vue | 3 ++- 5 files changed, 41 insertions(+), 16 deletions(-) diff --git a/pages/goods/cashier/index.vue b/pages/goods/cashier/index.vue index 0805eb82..e53d7a5c 100644 --- a/pages/goods/cashier/index.vue +++ b/pages/goods/cashier/index.vue @@ -32,7 +32,7 @@ 确认支付 - 暂不支付 + 暂不支付 @@ -108,6 +108,21 @@ }); PayOrderApi.getOrder(this.orderId).then(res => { // TODO 芋艿:如果已支付,则跳转回 + if (res.data.status === 10) { + uni.showToast({ + title: '支付成功' + }) + this.goReturnUrl('success'); + uni.hideLoading(); + return; + } else if (res.data.status === 20) { + uni.showToast({ + title: '无法支付,原因:订单已关闭' + }) + this.goReturnUrl('close'); + uni.hideLoading(); + return; + } console.log(res) this.payPrice = res.data.price @@ -374,7 +389,6 @@ // #endif break; } - }).catch(err => { uni.hideLoading(); return that.$util.Tips({ @@ -409,21 +423,26 @@ */ getPayReturnUrl() { // #ifdef H5 - return location.port - ? location.protocol + '//' + location.hostname + ':' + location.port + '/pages/goods/cashier/index?order_id=' + this.orderId - : location.protocol + '//' + location.hostname + '/pages/goods/cashier/index?order_id=' + this.orderId; - // #endif + return location.href + // #endif // #ifdef APP-PLUS - return '/pages/goods/order_details/index?order_id=' + this.orderId; + return '/pages/goods/order_details/index?order_id=' + this.orderId + '&returnUrl=' + this.returnUrl; // #endif return ''; }, /** * 回到业务的 URL + * + * @param payResult 支付结果 + * ① success:支付成功 + * ② cancel:取消支付 + * ③ close:支付已关闭 */ - goReturnUrl() { + goReturnUrl(payResult) { uni.reLaunch({ - url: this.returnUrl + url: this.returnUrl.indexOf('?') >= 0 + ? this.returnUrl + '&payResult=' + payResult + : this.returnUrl + '?payResult=' + payResult }) }, } diff --git a/pages/order_details/index.vue b/pages/order_details/index.vue index 7173f7d8..5affdf56 100644 --- a/pages/order_details/index.vue +++ b/pages/order_details/index.vue @@ -425,8 +425,9 @@ * 打开支付组件 */ goPay() { + const returnUrl = '/pages/order_pay_status/index?order_id=' + this.orderInfo.id; uni.navigateTo({ - url: `/pages/goods/cashier/index?order_id=${this.orderInfo.payOrderId}&from_type=order` + url: `/pages/goods/cashier/index?order_id=${this.orderInfo.payOrderId}&returnUrl=${returnUrl}` }) }, /** diff --git a/pages/order_pay_status/index.vue b/pages/order_pay_status/index.vue index 268cea27..97f03ca8 100644 --- a/pages/order_pay_status/index.vue +++ b/pages/order_pay_status/index.vue @@ -16,7 +16,7 @@ 下单时间 {{ order_pay_info.createTime ? formatDate(order_pay_info.createTime) : '-' }} - + 支付方式 {{ order_pay_info.payChannelName }} @@ -27,7 +27,10 @@ 失败原因 - {{ msg || '取消支付' }} + 获取支付结果失败,请稍后刷新 + 支付已关闭 + 取消支付 + 未知原因 @@ -63,7 +66,7 @@ payStatus: true, }, status: 0, - msg: '' + payResult: '' }; }, computed: mapGetters(['isLogin']), @@ -92,7 +95,7 @@ }); } this.orderId = options.order_id; - this.msg = options.msg || ''; + this.payResult = options.payResult; this.getOrderPayInfo(); }, methods: { diff --git a/pages/users/order_confirm/index.vue b/pages/users/order_confirm/index.vue index b91b9dd0..77340d66 100644 --- a/pages/users/order_confirm/index.vue +++ b/pages/users/order_confirm/index.vue @@ -337,8 +337,9 @@ ...this.getSettlementReqVO(), mark: this.mark, }).then(res => { + const returnUrl = '/pages/order_pay_status/index?order_id=' + res.data.id; uni.navigateTo({ - url: `/pages/goods/cashier/index?order_id=${res.data.payOrderId}&from_type=order` + url: `/pages/goods/cashier/index?order_id=${res.data.payOrderId}&returnUrl=${returnUrl}` }); }).catch(err => { uni.hideLoading(); diff --git a/pages/users/order_list/index.vue b/pages/users/order_list/index.vue index 1c4b2b90..3745ec45 100644 --- a/pages/users/order_list/index.vue +++ b/pages/users/order_list/index.vue @@ -217,8 +217,9 @@ * 打开支付组件 */ goPay(id, payOrderId) { + const returnUrl = '/pages/order_pay_status/index?order_id=' + id; uni.navigateTo({ - url: `/pages/goods/cashier/index?order_id=${payOrderId}&from_type=order` + url: `/pages/goods/cashier/index?order_id=${payOrderId}&returnUrl=${returnUrl}` }) }, /**