捕获支付异常

This commit is contained in:
jqtmviyu@gmail.com 2021-03-07 00:28:53 +08:00
parent 0597bdbcb0
commit 8b2167ea56

View File

@ -72,7 +72,7 @@ export default {
uni.chooseAddress({ uni.chooseAddress({
success: (res) => { success: (res) => {
uni.setStorageSync("address", res) uni.setStorageSync("address", res)
console.log(res) // console.log(res)
this.address = res this.address = res
} }
}) })
@ -82,6 +82,7 @@ export default {
if (!this.address.userName) { if (!this.address.userName) {
return uni.showToast({ title: "请选择收货地址", icon: "none" }); return uni.showToast({ title: "请选择收货地址", icon: "none" });
} else { } else {
try{
// console.log(""); // console.log("");
// //
// goods // goods
@ -98,16 +99,16 @@ export default {
consignee_addr: this.addressDetail, consignee_addr: this.addressDetail,
goods goods
}) })
console.log(order_number); // console.log(order_number);
// //
const {message: {pay}} = await this.$u.api.orderPayParams({order_number}) const {message: {pay}} = await this.$u.api.orderPayParams({order_number})
console.log(pay); // console.log(pay);
// //
// const res1 = await wx.requestPayment(pay) const res1 = await wx.requestPayment(pay)
// console.log(res1) console.log(res1)
// //
// const {message} = await this.$u.api.checkOrder(order_number) const {message} = await this.$u.api.checkOrder({order_number})
// console.log(message); console.log(message);
// //
await uni.showToast({ await uni.showToast({
title: "支付成功", title: "支付成功",
@ -121,7 +122,13 @@ export default {
uni.redirectTo({ uni.redirectTo({
url: "/pages/order/order" url: "/pages/order/order"
}) })
}, 1500); }, 1500)
}catch(err){
uni.showToast({
title: "支付异常",
icon: "none"
})
}
} }
}, },
}, },