收藏
回答

微信支付成功后,回调函数内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()
      },
    })
  },
最后一次编辑于  2020-08-23
回答关注问题邀请回答
收藏

1 个回答

  • .
    .
    2020-08-23

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


    2020-08-23
    有用
    回复 2
    • Qiu (吉²)
      Qiu (吉²)
      2020-08-23
      你好,这里判断了,但还是不行。
      2020-08-23
      回复
    • .
      .
      2020-08-24回复Qiu (吉²)
      里面你随便写个console。看执行了没
      2020-08-24
      回复
登录 后发表内容
问题标签