From 8b2167ea567b4df3c86fc9207bcd3709827ca54a Mon Sep 17 00:00:00 2001 From: "jqtmviyu@gmail.com" Date: Sun, 7 Mar 2021 00:28:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8D=95=E8=8E=B7=E6=94=AF=E4=BB=98=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/pay/pay.vue | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/pages/pay/pay.vue b/src/pages/pay/pay.vue index 13e7823..2efc2d2 100644 --- a/src/pages/pay/pay.vue +++ b/src/pages/pay/pay.vue @@ -72,7 +72,7 @@ export default { uni.chooseAddress({ success: (res) => { uni.setStorageSync("address", res) - console.log(res) + // console.log(res) this.address = res } }) @@ -82,6 +82,7 @@ export default { if (!this.address.userName) { return uni.showToast({ title: "请选择收货地址", icon: "none" }); } else { + try{ // console.log("走支付逻辑"); // 创建订单 // 解构拿到goods参数 @@ -98,16 +99,16 @@ export default { consignee_addr: this.addressDetail, goods }) - console.log(order_number); + // console.log(order_number); // 获取支付参数 const {message: {pay}} = await this.$u.api.orderPayParams({order_number}) - console.log(pay); + // console.log(pay); // 调用支付接口 - // const res1 = await wx.requestPayment(pay) - // console.log(res1) + const res1 = await wx.requestPayment(pay) + console.log(res1) // 更新支付状态 - // const {message} = await this.$u.api.checkOrder(order_number) - // console.log(message); + const {message} = await this.$u.api.checkOrder({order_number}) + console.log(message); // 支付成功 await uni.showToast({ title: "支付成功", @@ -121,7 +122,13 @@ export default { uni.redirectTo({ url: "/pages/order/order" }) - }, 1500); + }, 1500) + }catch(err){ + uni.showToast({ + title: "支付异常", + icon: "none" + }) + } } }, },