Commit 49201aa2a0d6dfe491a0c4271f193dbc235bf7e3
1 parent
bb75b0a6
add 我的钱包 微信支付 接口联调
Showing
1 changed file
with
74 additions
and
10 deletions
pages/moneyRecharge/moneyRecharge.vue
| @@ -52,6 +52,7 @@ | @@ -52,6 +52,7 @@ | ||
| 52 | acctBalance: '0.00', | 52 | acctBalance: '0.00', |
| 53 | ListData: [], | 53 | ListData: [], |
| 54 | currentIndex: 0, | 54 | currentIndex: 0, |
| 55 | + rechargeFee: 0, | ||
| 55 | isShowInput: false, | 56 | isShowInput: false, |
| 56 | rechargeNum: '', | 57 | rechargeNum: '', |
| 57 | maxlength: 6 //默认一个长度 | 58 | maxlength: 6 //默认一个长度 |
| @@ -91,6 +92,7 @@ | @@ -91,6 +92,7 @@ | ||
| 91 | console.log(res) | 92 | console.log(res) |
| 92 | let data = res.data; | 93 | let data = res.data; |
| 93 | that.ListData = data; | 94 | that.ListData = data; |
| 95 | + that.rechargeFee = that.ListData[0].rechargeCode | ||
| 94 | 96 | ||
| 95 | }) | 97 | }) |
| 96 | }, | 98 | }, |
| @@ -107,6 +109,7 @@ | @@ -107,6 +109,7 @@ | ||
| 107 | that.rechargeNum = '' | 109 | that.rechargeNum = '' |
| 108 | } else { | 110 | } else { |
| 109 | that.isShowInput = false; | 111 | that.isShowInput = false; |
| 112 | + that.rechargeFee = that.ListData[index].rechargeCode; | ||
| 110 | } | 113 | } |
| 111 | 114 | ||
| 112 | }, | 115 | }, |
| @@ -127,9 +130,69 @@ | @@ -127,9 +130,69 @@ | ||
| 127 | detailCell() { | 130 | detailCell() { |
| 128 | uni.navigateTo({ | 131 | uni.navigateTo({ |
| 129 | url: '../rechargeDetail/rechargeDetail' | 132 | url: '../rechargeDetail/rechargeDetail' |
| 130 | - | 133 | + |
| 131 | }); | 134 | }); |
| 132 | - } | 135 | + }, |
| 136 | + payClick() { | ||
| 137 | + let that = this; | ||
| 138 | + let payMoney; | ||
| 139 | + if (that.isShowInput) { | ||
| 140 | + payMoney = that.rechargeNum; | ||
| 141 | + } else { | ||
| 142 | + payMoney = that.rechargeFee; | ||
| 143 | + } | ||
| 144 | + let data = { | ||
| 145 | + rechargeType: '2', | ||
| 146 | + acctType: '1', | ||
| 147 | + paySrcType: '204', | ||
| 148 | + realPayMoney: payMoney, | ||
| 149 | + rechargeFee: payMoney, | ||
| 150 | + }; | ||
| 151 | + console.log(data) | ||
| 152 | + that.$myRequest({ | ||
| 153 | + url: that.$common.publicUnifiedOrder, | ||
| 154 | + method: 'POST', | ||
| 155 | + data: that.$common.requestSign(data) | ||
| 156 | + }).then(res => { | ||
| 157 | + | ||
| 158 | + console.log(res) | ||
| 159 | + that.MakeWxPay(that.$common.requestSign(data)) | ||
| 160 | + | ||
| 161 | + }) | ||
| 162 | + }, | ||
| 163 | + // 调用微信支付 | ||
| 164 | + MakeWxPay(mydata) { | ||
| 165 | + console.log('wxpay') | ||
| 166 | + var me = this; | ||
| 167 | + uni.requestPayment({ | ||
| 168 | + provider: 'wxpay', | ||
| 169 | + timeStamp: mydata.timeStamp, | ||
| 170 | + //随机字符串,长度为32个字符以下 | ||
| 171 | + nonceStr: mydata.nonceStr, | ||
| 172 | + //统一下单接口返回的 prepay_id 参数值,提交格式如:prepay_id=xx。 | ||
| 173 | + package: mydata.package, | ||
| 174 | + signType: mydata.signType, | ||
| 175 | + paySign: mydata.paySign, | ||
| 176 | + success: function(res) { | ||
| 177 | + console.log('success:' + JSON.stringify(res)); | ||
| 178 | + | ||
| 179 | + }, | ||
| 180 | + fail: function(err) { | ||
| 181 | + console.log('fail:' + JSON.stringify(err)); | ||
| 182 | + uni.showModal({ | ||
| 183 | + title: '提示', | ||
| 184 | + content: '支付失败/取消', | ||
| 185 | + showCancel: false, | ||
| 186 | + success: function(res) { | ||
| 187 | + if (res.confirm) { | ||
| 188 | + console.log('支付失败'); | ||
| 189 | + } | ||
| 190 | + } | ||
| 191 | + }); | ||
| 192 | + } | ||
| 193 | + }); | ||
| 194 | + }, | ||
| 195 | + | ||
| 133 | } | 196 | } |
| 134 | } | 197 | } |
| 135 | </script> | 198 | </script> |
| @@ -247,14 +310,15 @@ | @@ -247,14 +310,15 @@ | ||
| 247 | margin-top: 40px; | 310 | margin-top: 40px; |
| 248 | 311 | ||
| 249 | } | 312 | } |
| 250 | - .payInut{ | 313 | + |
| 314 | + .payInut { | ||
| 251 | display: flex; | 315 | display: flex; |
| 252 | - box-sizing: border-box; | ||
| 253 | - flex-direction: row; | ||
| 254 | - align-items: center; | ||
| 255 | - border: 1px solid #DCDFE6; | ||
| 256 | - border-radius: 4px; | ||
| 257 | - min-height: 36px; | ||
| 258 | - padding-left: 10px; | 316 | + box-sizing: border-box; |
| 317 | + flex-direction: row; | ||
| 318 | + align-items: center; | ||
| 319 | + border: 1px solid #DCDFE6; | ||
| 320 | + border-radius: 4px; | ||
| 321 | + min-height: 36px; | ||
| 322 | + padding-left: 10px; | ||
| 259 | } | 323 | } |
| 260 | </style> | 324 | </style> |