From 4b0f9098d0aa687b31d7e977d7010a9f3e7cce34 Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Thu, 2 Sep 2021 10:27:49 +0800 Subject: [PATCH] 支付的修改 --- utils/pay.js | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------- 1 file changed, 52 insertions(+), 38 deletions(-) diff --git a/utils/pay.js b/utils/pay.js index 5725f43..f96afff 100644 --- a/utils/pay.js +++ b/utils/pay.js @@ -52,46 +52,60 @@ module.exports = { }); }, weixinPay: function(n, e, a) { - if(!n) return false; - /*-- - wx.requestPayment({ - timeStamp: String(n.timeStamp), - nonceStr: n.nonceStr, - package: n.packageValue, - signType: n.signType, - paySign: n.paySign, - success: function(n) { - console.log(n), t.showSuccess("支付成功!", e); - }, - fail: function(n) { - console.log(n), "requestPayment:fail" == n.errMsg ? t.showWarning("支付失败") : "requestPayment:fail cancel" == n.errMsg ? t.showWarning("您已取消支付") : - t.confirmBox("支付失败:" + n.errMsg.substr("requestPayment:fail ".length)), - "function" == typeof a && a(); - } - });--*/ + if(!n) return false; + //有的话用最新的支付方式 + if(n.orderInfo) { + wx.requestOrderPayment({ + timeStamp: String(n.timeStamp), + nonceStr: n.nonceStr, + package: n.packageValue, + signType: n.signType, + paySign: n.paySign, + orderInfo: n.orderInfo, // 需要新增的 订单 信息 + success (n) { + t.showSuccess("支付成功!", e); + }, + fail (n) { + if(!n.errMsg ) { + getApp().showWarning("支付失败"); + "function" == typeof fail && fail(); + return false; + } + + console.log(n), "requestOrderPayment:fail" == n.errMsg ? t.showWarning("支付失败") : "requestOrderPayment:fail cancel" == n.errMsg ? t.showWarning("您已取消支付") : + t.confirmBox("支付失败:" + n.errMsg.substr("requestOrderPayment:fail ".length)), + "function" == typeof a && a(); + } + }) + + }else{ + wx.requestOrderPayment({ + timeStamp: String(n.timeStamp), + nonceStr: n.nonceStr, + package: n.packageValue, + signType: n.signType, + paySign: n.paySign, + success (n) { + t.showSuccess("支付成功!", e); + }, + fail (n) { + if(!n.errMsg ) { + getApp().showWarning("支付失败"); + "function" == typeof fail && fail(); + return false; + } + + console.log(n), "requestOrderPayment:fail" == n.errMsg ? t.showWarning("支付失败") : "requestOrderPayment:fail cancel" == n.errMsg ? t.showWarning("您已取消支付") : + t.confirmBox("支付失败:" + n.errMsg.substr("requestOrderPayment:fail ".length)), + "function" == typeof a && a(); + } + }) + } + + + - wx.requestOrderPayment({ - timeStamp: String(n.timeStamp), - nonceStr: n.nonceStr, - package: n.packageValue, - signType: n.signType, - paySign: n.paySign, - orderInfo: n.orderInfo, // 需要新增的 订单 信息 - success (n) { - t.showSuccess("支付成功!", e); - }, - fail (n) { - if(!n.errMsg ) { - getApp().showWarning("支付失败"); - "function" == typeof fail && fail(); - return false; - } - console.log(n), "requestOrderPayment:fail" == n.errMsg ? t.showWarning("支付失败") : "requestOrderPayment:fail cancel" == n.errMsg ? t.showWarning("您已取消支付") : - t.confirmBox("支付失败:" + n.errMsg.substr("requestOrderPayment:fail ".length)), - "function" == typeof a && a(); - } - }) -- libgit2 0.21.4