微信支付成功后,回调函数内wx.redirectTo没有关闭之前页面?
微信支付成功后,回调函数内wx.redirectTo不起作用,没有关闭之前页面,还是有返回按钮可以返回上一页。
支付失败回调,wx.redirectTo起作用了。
callPay: function (orderID, leaderOrderID) {
var that = this
wx.cloud.callFunction({
name: 'payment',
data: {
req_type: "CallPay",
body: that.data.shopName, //商品描述
outTradeNo: orderID, //商户订单号
subMchId: that.data.subMchId, //子商户号
totalFee: that.data.total, //总金额,单位为分
shopID: that.data.shopID, //店铺ID
shopName: that.data.shopName, //店铺名
},
success: res => {
console.log(res)
const payment = res.result.payment
wx.requestPayment({
...payment,
success(res) {
console.log('支付成功', res)
wx.hideLoading()
wx.redirectTo({
url: '/pages/smallShop/orderDetail/orderStatus/orderStatus?orderID=' + leaderOrderID + '&payType=' + 'success' + '&userType=' + that.data.userType,
})
},
fail(err) {
wx.hideLoading()
wx.redirectTo({
url: '/pages/smallShop/orderDetail/orderStatus/orderStatus?orderID=' + leaderOrderID + '&payType=' + 'fail' + '&userType=' + that.data.userType,
})
}
})
},
fail: error => {
console.log(error)
wx.hideLoading()
},
})
},