uni-app支付宝支付成功以后返回很多代码,我简单梳理一下,提出trade_no数据

uni.requestPayment({
        provider: 'alipay',
        orderInfo: order_data, //微信、支付宝订单数据
        success: function(res_alipay) {
            //成功。。
            console.log(JSON.stringify(res_alipay));
            console.log(res_alipay);
            console.log(res_alipay.rawdata);
            // 取对象中的rawdata
            let rawData = JSON.parse(res_alipay.rawdata) 
            // 取出result字符串 
            let resultStr = rawData.result 
             // 分号分割,取第0个 
            let resultList = resultStr.split(';')  
            // 将取出来的第0个字符串的最后一位花括号去掉
            let finalRes = resultList[0].substring(0, resultList[0].length - 1) 
              // 正常转义  
            let finalObject = JSON.parse(finalRes)
            // 取出订单号
            let trade_no = finalObject.alipay_trade_app_pay_response.trade_no
            //输出
            console.log(trade_no);
            
            //后台修改订单状态
            // mythis.to_payment();
        },
        fail: function(err) {
            console.log('fail:' + JSON.stringify(err));
    }
});

 

相关文章:

  • 2021-12-14
  • 2020-02-24
  • 2021-10-28
  • 2018-09-10
  • 2018-06-21
  • 2021-07-13
  • 2021-12-16
  • 2019-06-11
猜你喜欢
  • 2020-09-29
  • 2021-10-26
  • 2021-08-07
  • 2018-06-21
  • 2021-10-14
  • 2021-10-30
  • 2021-12-14
  • 2021-08-03
相关资源
相似解决方案