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,6 +68,7 @@ const couponInfo = serverUrl + "/business/h5/wallet/detail/couponInfo"; | ||
| 68 | // 根据车牌号查询车牌号订单支付详情 | 68 | // 根据车牌号查询车牌号订单支付详情 |
| 69 | const queryParkingRecordByCarNumbers ="https://pay.jycrtc.com/queryParkOrder/queryParkingRecordPageByCarNumbersForBusiness"; | 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 | const requestSign = function (inputData) { | 74 | const requestSign = function (inputData) { |
| @@ -246,4 +247,5 @@ export default { | @@ -246,4 +247,5 @@ export default { | ||
| 246 | publicUnifiedOrder, | 247 | publicUnifiedOrder, |
| 247 | couponInfo, | 248 | couponInfo, |
| 248 | queryParkingRecordByCarNumbers, | 249 | queryParkingRecordByCarNumbers, |
| 250 | + getOpenIdByCode, | ||
| 249 | } | 251 | } |
pages/moneyRecharge/moneyRecharge.vue
| @@ -50,6 +50,7 @@ | @@ -50,6 +50,7 @@ | ||
| 50 | data() { | 50 | data() { |
| 51 | return { | 51 | return { |
| 52 | acctBalance: '0.00', | 52 | acctBalance: '0.00', |
| 53 | + wxopenId: '', | ||
| 53 | ListData: [], | 54 | ListData: [], |
| 54 | currentIndex: 0, | 55 | currentIndex: 0, |
| 55 | rechargeFee: 0, | 56 | rechargeFee: 0, |
| @@ -59,14 +60,53 @@ | @@ -59,14 +60,53 @@ | ||
| 59 | } | 60 | } |
| 60 | }, | 61 | }, |
| 61 | onLoad() { | 62 | onLoad() { |
| 63 | + uni.setStorageSync("wxCode", '') | ||
| 64 | + this.getCode(); | ||
| 65 | + this.recharge(); | ||
| 66 | + this.rechargeList(); | ||
| 67 | + | ||
| 62 | 68 | ||
| 63 | }, | 69 | }, |
| 64 | mounted() { | 70 | mounted() { |
| 65 | - this.recharge(); | ||
| 66 | - this.rechargeList(); | ||
| 67 | 71 | ||
| 68 | }, | 72 | }, |
| 73 | + onShow() { | ||
| 74 | + | ||
| 75 | + }, | ||
| 69 | methods: { | 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 | recharge() { | 110 | recharge() { |
| 71 | let that = this; | 111 | let that = this; |
| 72 | that.$myRequest({ | 112 | that.$myRequest({ |
| @@ -134,6 +174,13 @@ | @@ -134,6 +174,13 @@ | ||
| 134 | }); | 174 | }); |
| 135 | }, | 175 | }, |
| 136 | payClick() { | 176 | payClick() { |
| 177 | + | ||
| 178 | + let that = this; | ||
| 179 | + that.getOpenID() | ||
| 180 | + | ||
| 181 | + | ||
| 182 | + }, | ||
| 183 | + wxPayOrder(){ | ||
| 137 | let that = this; | 184 | let that = this; |
| 138 | let payMoney; | 185 | let payMoney; |
| 139 | if (that.isShowInput) { | 186 | if (that.isShowInput) { |
| @@ -141,11 +188,13 @@ | @@ -141,11 +188,13 @@ | ||
| 141 | } else { | 188 | } else { |
| 142 | payMoney = that.rechargeFee; | 189 | payMoney = that.rechargeFee; |
| 143 | } | 190 | } |
| 191 | + console.log(that.wxopenId) | ||
| 144 | let data = { | 192 | let data = { |
| 193 | + openId: that.wxopenId, | ||
| 145 | rechargeType: '2', | 194 | rechargeType: '2', |
| 146 | acctType: '1', | 195 | acctType: '1', |
| 147 | paySrcType: '204', | 196 | paySrcType: '204', |
| 148 | - payType:'12', | 197 | + payType: '12', |
| 149 | realPayMoney: payMoney, | 198 | realPayMoney: payMoney, |
| 150 | rechargeFee: payMoney, | 199 | rechargeFee: payMoney, |
| 151 | }; | 200 | }; |
| @@ -155,10 +204,10 @@ | @@ -155,10 +204,10 @@ | ||
| 155 | method: 'POST', | 204 | method: 'POST', |
| 156 | data: that.$common.requestSign(data) | 205 | data: that.$common.requestSign(data) |
| 157 | }).then(res => { | 206 | }).then(res => { |
| 158 | - | 207 | + |
| 159 | console.log(res) | 208 | console.log(res) |
| 160 | that.MakeWxPay(res) | 209 | that.MakeWxPay(res) |
| 161 | - | 210 | + |
| 162 | }) | 211 | }) |
| 163 | }, | 212 | }, |
| 164 | // 调用微信支付 | 213 | // 调用微信支付 |