Commit e7895736a494b5e04a586a9bddc102c39e3dc62b
1 parent
ff4eb366
add 支付 接口联调
Showing
2 changed files
with
56 additions
and
5 deletions
common/common.js
| ... | ... | @@ -68,6 +68,7 @@ const couponInfo = serverUrl + "/business/h5/wallet/detail/couponInfo"; |
| 68 | 68 | // 根据车牌号查询车牌号订单支付详情 |
| 69 | 69 | const queryParkingRecordByCarNumbers ="https://pay.jycrtc.com/queryParkOrder/queryParkingRecordPageByCarNumbersForBusiness"; |
| 70 | 70 | |
| 71 | +const getOpenIdByCode = "https://pay.jycrtc.com/weixinPublicPay/getSmallRoutineOpenIdByCode" | |
| 71 | 72 | |
| 72 | 73 | |
| 73 | 74 | const requestSign = function (inputData) { |
| ... | ... | @@ -246,4 +247,5 @@ export default { |
| 246 | 247 | publicUnifiedOrder, |
| 247 | 248 | couponInfo, |
| 248 | 249 | queryParkingRecordByCarNumbers, |
| 250 | + getOpenIdByCode, | |
| 249 | 251 | } | ... | ... |
pages/moneyRecharge/moneyRecharge.vue
| ... | ... | @@ -50,6 +50,7 @@ |
| 50 | 50 | data() { |
| 51 | 51 | return { |
| 52 | 52 | acctBalance: '0.00', |
| 53 | + wxopenId: '', | |
| 53 | 54 | ListData: [], |
| 54 | 55 | currentIndex: 0, |
| 55 | 56 | rechargeFee: 0, |
| ... | ... | @@ -59,14 +60,53 @@ |
| 59 | 60 | } |
| 60 | 61 | }, |
| 61 | 62 | onLoad() { |
| 63 | + uni.setStorageSync("wxCode", '') | |
| 64 | + this.getCode(); | |
| 65 | + this.recharge(); | |
| 66 | + this.rechargeList(); | |
| 67 | + | |
| 62 | 68 | |
| 63 | 69 | }, |
| 64 | 70 | mounted() { |
| 65 | - this.recharge(); | |
| 66 | - this.rechargeList(); | |
| 67 | 71 | |
| 68 | 72 | }, |
| 73 | + onShow() { | |
| 74 | + | |
| 75 | + }, | |
| 69 | 76 | methods: { |
| 77 | + getCode() { | |
| 78 | + uni.login({ | |
| 79 | + provider: 'weixin', | |
| 80 | + success: function(loginRes) { | |
| 81 | + console.log('获取微信code-loginRes.code: ' + loginRes.code); | |
| 82 | + uni.setStorageSync("wxCode", loginRes.code) | |
| 83 | + | |
| 84 | + } | |
| 85 | + }); | |
| 86 | + }, | |
| 87 | + getOpenID() { | |
| 88 | + let that = this; | |
| 89 | + let code = uni.getStorageSync("wxCode"); | |
| 90 | + console.log(code) | |
| 91 | + let data = { | |
| 92 | + appId: that.$common.hs_wxPay_appId, | |
| 93 | + // appId:"wxadb8caee05ab2981", | |
| 94 | + code: code, | |
| 95 | + | |
| 96 | + }; | |
| 97 | + that.$myRequest({ | |
| 98 | + url: that.$common.getOpenIdByCode, | |
| 99 | + method: 'POST', | |
| 100 | + data: data | |
| 101 | + }).then(res => { | |
| 102 | + | |
| 103 | + | |
| 104 | + let data = res.data; | |
| 105 | + that.wxopenId = data.openid; | |
| 106 | + console.log(data.openid) | |
| 107 | + that.wxPayOrder() | |
| 108 | + }) | |
| 109 | + }, | |
| 70 | 110 | recharge() { |
| 71 | 111 | let that = this; |
| 72 | 112 | that.$myRequest({ |
| ... | ... | @@ -134,6 +174,13 @@ |
| 134 | 174 | }); |
| 135 | 175 | }, |
| 136 | 176 | payClick() { |
| 177 | + | |
| 178 | + let that = this; | |
| 179 | + that.getOpenID() | |
| 180 | + | |
| 181 | + | |
| 182 | + }, | |
| 183 | + wxPayOrder(){ | |
| 137 | 184 | let that = this; |
| 138 | 185 | let payMoney; |
| 139 | 186 | if (that.isShowInput) { |
| ... | ... | @@ -141,11 +188,13 @@ |
| 141 | 188 | } else { |
| 142 | 189 | payMoney = that.rechargeFee; |
| 143 | 190 | } |
| 191 | + console.log(that.wxopenId) | |
| 144 | 192 | let data = { |
| 193 | + openId: that.wxopenId, | |
| 145 | 194 | rechargeType: '2', |
| 146 | 195 | acctType: '1', |
| 147 | 196 | paySrcType: '204', |
| 148 | - payType:'12', | |
| 197 | + payType: '12', | |
| 149 | 198 | realPayMoney: payMoney, |
| 150 | 199 | rechargeFee: payMoney, |
| 151 | 200 | }; |
| ... | ... | @@ -155,10 +204,10 @@ |
| 155 | 204 | method: 'POST', |
| 156 | 205 | data: that.$common.requestSign(data) |
| 157 | 206 | }).then(res => { |
| 158 | - | |
| 207 | + | |
| 159 | 208 | console.log(res) |
| 160 | 209 | that.MakeWxPay(res) |
| 161 | - | |
| 210 | + | |
| 162 | 211 | }) |
| 163 | 212 | }, |
| 164 | 213 | // 调用微信支付 | ... | ... |