Commit 4b0f9098d0aa687b31d7e977d7010a9f3e7cce34
1 parent
d9ca78b1
支付的修改
Showing
1 changed file
with
52 additions
and
38 deletions
utils/pay.js
| @@ -52,46 +52,60 @@ module.exports = { | @@ -52,46 +52,60 @@ module.exports = { | ||
| 52 | }); | 52 | }); |
| 53 | }, | 53 | }, |
| 54 | weixinPay: function(n, e, a) { | 54 | weixinPay: function(n, e, a) { |
| 55 | - if(!n) return false; | ||
| 56 | - /*-- | ||
| 57 | - wx.requestPayment({ | ||
| 58 | - timeStamp: String(n.timeStamp), | ||
| 59 | - nonceStr: n.nonceStr, | ||
| 60 | - package: n.packageValue, | ||
| 61 | - signType: n.signType, | ||
| 62 | - paySign: n.paySign, | ||
| 63 | - success: function(n) { | ||
| 64 | - console.log(n), t.showSuccess("支付成功!", e); | ||
| 65 | - }, | ||
| 66 | - fail: function(n) { | ||
| 67 | - console.log(n), "requestPayment:fail" == n.errMsg ? t.showWarning("支付失败") : "requestPayment:fail cancel" == n.errMsg ? t.showWarning("您已取消支付") : | ||
| 68 | - t.confirmBox("支付失败:" + n.errMsg.substr("requestPayment:fail ".length)), | ||
| 69 | - "function" == typeof a && a(); | ||
| 70 | - } | ||
| 71 | - });--*/ | 55 | + if(!n) return false; |
| 56 | + //有的话用最新的支付方式 | ||
| 57 | + if(n.orderInfo) { | ||
| 58 | + wx.requestOrderPayment({ | ||
| 59 | + timeStamp: String(n.timeStamp), | ||
| 60 | + nonceStr: n.nonceStr, | ||
| 61 | + package: n.packageValue, | ||
| 62 | + signType: n.signType, | ||
| 63 | + paySign: n.paySign, | ||
| 64 | + orderInfo: n.orderInfo, // 需要新增的 订单 信息 | ||
| 65 | + success (n) { | ||
| 66 | + t.showSuccess("支付成功!", e); | ||
| 67 | + }, | ||
| 68 | + fail (n) { | ||
| 69 | + if(!n.errMsg ) { | ||
| 70 | + getApp().showWarning("支付失败"); | ||
| 71 | + "function" == typeof fail && fail(); | ||
| 72 | + return false; | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + console.log(n), "requestOrderPayment:fail" == n.errMsg ? t.showWarning("支付失败") : "requestOrderPayment:fail cancel" == n.errMsg ? t.showWarning("您已取消支付") : | ||
| 76 | + t.confirmBox("支付失败:" + n.errMsg.substr("requestOrderPayment:fail ".length)), | ||
| 77 | + "function" == typeof a && a(); | ||
| 78 | + } | ||
| 79 | + }) | ||
| 80 | + | ||
| 81 | + }else{ | ||
| 82 | + wx.requestOrderPayment({ | ||
| 83 | + timeStamp: String(n.timeStamp), | ||
| 84 | + nonceStr: n.nonceStr, | ||
| 85 | + package: n.packageValue, | ||
| 86 | + signType: n.signType, | ||
| 87 | + paySign: n.paySign, | ||
| 88 | + success (n) { | ||
| 89 | + t.showSuccess("支付成功!", e); | ||
| 90 | + }, | ||
| 91 | + fail (n) { | ||
| 92 | + if(!n.errMsg ) { | ||
| 93 | + getApp().showWarning("支付失败"); | ||
| 94 | + "function" == typeof fail && fail(); | ||
| 95 | + return false; | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + console.log(n), "requestOrderPayment:fail" == n.errMsg ? t.showWarning("支付失败") : "requestOrderPayment:fail cancel" == n.errMsg ? t.showWarning("您已取消支付") : | ||
| 99 | + t.confirmBox("支付失败:" + n.errMsg.substr("requestOrderPayment:fail ".length)), | ||
| 100 | + "function" == typeof a && a(); | ||
| 101 | + } | ||
| 102 | + }) | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + | ||
| 106 | + | ||
| 72 | 107 | ||
| 73 | - wx.requestOrderPayment({ | ||
| 74 | - timeStamp: String(n.timeStamp), | ||
| 75 | - nonceStr: n.nonceStr, | ||
| 76 | - package: n.packageValue, | ||
| 77 | - signType: n.signType, | ||
| 78 | - paySign: n.paySign, | ||
| 79 | - orderInfo: n.orderInfo, // 需要新增的 订单 信息 | ||
| 80 | - success (n) { | ||
| 81 | - t.showSuccess("支付成功!", e); | ||
| 82 | - }, | ||
| 83 | - fail (n) { | ||
| 84 | - if(!n.errMsg ) { | ||
| 85 | - getApp().showWarning("支付失败"); | ||
| 86 | - "function" == typeof fail && fail(); | ||
| 87 | - return false; | ||
| 88 | - } | ||
| 89 | 108 | ||
| 90 | - console.log(n), "requestOrderPayment:fail" == n.errMsg ? t.showWarning("支付失败") : "requestOrderPayment:fail cancel" == n.errMsg ? t.showWarning("您已取消支付") : | ||
| 91 | - t.confirmBox("支付失败:" + n.errMsg.substr("requestOrderPayment:fail ".length)), | ||
| 92 | - "function" == typeof a && a(); | ||
| 93 | - } | ||
| 94 | - }) | ||
| 95 | 109 | ||
| 96 | 110 | ||
| 97 | 111 |