From 5d83068d616b0a64e0817ad9d0eb3a68d7fcee1b Mon Sep 17 00:00:00 2001 From: GaoHao <1210693421@qq.com> Date: Wed, 11 Sep 2024 09:17:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=94=AF=E4=BB=98=E5=AE=9D?= =?UTF-8?q?=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/order/order.vue | 27 ++++++++++++++++++ pages/order_food/confirm_order.vue | 46 +++++++++++++++++++++++++++--- 2 files changed, 69 insertions(+), 4 deletions(-) diff --git a/pages/order/order.vue b/pages/order/order.vue index 6a5ddaf..580b62b 100644 --- a/pages/order/order.vue +++ b/pages/order/order.vue @@ -367,6 +367,33 @@ } }); // #endif + // #ifdef MP-ALIPAY + uni.requestPayment({ + provider: 'alipay', //支付类型-固定值 + orderInfo: item.id, // 微信支付商户号 + + success: (res) => { + let _this = this + uni.requestSubscribeMessage({ + tmplIds: ['z0fUG7-jhSfYCrw6poOvSRzh4_hgnPkm_5C7E5s5bCQ'], + complete() { + uni.showToast({ + title: "支付成功" + }) + // uni.cache.set('shopUser', '') //删除shopUser + _this.paymodfiyOrderInfo() + uni.redirectTo({ + url: '/pages/order/order_detail?orderId=' + _this + .listinfoid + }); + }, + }) + }, + fail: () => { + uni.hideLoading() + } + }); + // #endif } }, /** diff --git a/pages/order_food/confirm_order.vue b/pages/order_food/confirm_order.vue index 1abf4cd..3d61575 100644 --- a/pages/order_food/confirm_order.vue +++ b/pages/order_food/confirm_order.vue @@ -171,7 +171,12 @@ ], paymentMethodList:[ { name: "余额支付", type: "1", url: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/drder/wechat.png"}, + // #ifdef MP-WEIXIN { name: "微信支付", type: "2", url: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/weChat.png"}, + // #endif + // #ifdef MP-ALIPAY + { name: "支付宝支付", type: "3", url: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/alipay.png"}, + // #endif ], order: { phone: "", @@ -193,6 +198,7 @@ listinfoid: null, paymentBtnText: "余额支付", isSocket: false, + socketTicket: null, } }, computed: { @@ -202,13 +208,17 @@ }, onUnload() { console.log(this) - this.socketTicket.Close() - uni.$off('getMessage') + if (this.socketTicket) { + this.socketTicket.Close() + uni.$off('message') + } this.ispws = false }, onHide() { - this.socketTicket.Close() - uni.$off('message') + if (this.socketTicket) { + this.socketTicket.Close() + uni.$off('message') + } }, onLoad(e) { console.log(JSON.parse(e.cartList)) @@ -499,6 +509,34 @@ } }); // #endif + + // #ifdef MP-ALIPAY + uni.requestPayment({ + provider: 'alipay', //支付类型-固定值 + orderInfo: res.data.appId, // 微信支付商户号 + + success: (res) => { + let _this = this + uni.requestSubscribeMessage({ + tmplIds: ['z0fUG7-jhSfYCrw6poOvSRzh4_hgnPkm_5C7E5s5bCQ'], + complete() { + uni.showToast({ + title: "支付成功" + }) + // uni.cache.set('shopUser', '') //删除shopUser + _this.paymodfiyOrderInfo() + uni.redirectTo({ + url: '/pages/order/order_detail?orderId=' + _this + .listinfoid + }); + }, + }) + }, + fail: () => { + uni.hideLoading() + } + }); + // #endif uni.hideLoading() } },