微信支付成功后,回调函数内wx.redirectTo没有关闭之前页面?

发布于 8 年前作者 natan15108 次浏览最后编辑 8 年前来自 ask

微信支付成功后,回调函数内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()
      },
    })
  },
1 回复
yong89
yong891 楼5 年前

你的支付成功判断是什么?这里的支付成功里是有状态的 res.errMsg == "requestPayment:ok"