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" + }) + } } }, },