From e7895736a494b5e04a586a9bddc102c39e3dc62b Mon Sep 17 00:00:00 2001 From: chenbiao Date: Wed, 25 May 2022 10:11:20 +0800 Subject: [PATCH] add 支付 接口联调 --- common/common.js | 2 ++ pages/moneyRecharge/moneyRecharge.vue | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/common/common.js b/common/common.js index 856425b..8699040 100644 --- a/common/common.js +++ b/common/common.js @@ -68,6 +68,7 @@ const couponInfo = serverUrl + "/business/h5/wallet/detail/couponInfo"; // 根据车牌号查询车牌号订单支付详情 const queryParkingRecordByCarNumbers ="https://pay.jycrtc.com/queryParkOrder/queryParkingRecordPageByCarNumbersForBusiness"; +const getOpenIdByCode = "https://pay.jycrtc.com/weixinPublicPay/getSmallRoutineOpenIdByCode" const requestSign = function (inputData) { @@ -246,4 +247,5 @@ export default { publicUnifiedOrder, couponInfo, queryParkingRecordByCarNumbers, + getOpenIdByCode, } diff --git a/pages/moneyRecharge/moneyRecharge.vue b/pages/moneyRecharge/moneyRecharge.vue index 56f5fa5..89fa6b1 100644 --- a/pages/moneyRecharge/moneyRecharge.vue +++ b/pages/moneyRecharge/moneyRecharge.vue @@ -50,6 +50,7 @@ data() { return { acctBalance: '0.00', + wxopenId: '', ListData: [], currentIndex: 0, rechargeFee: 0, @@ -59,14 +60,53 @@ } }, onLoad() { + uni.setStorageSync("wxCode", '') + this.getCode(); + this.recharge(); + this.rechargeList(); + }, mounted() { - this.recharge(); - this.rechargeList(); }, + onShow() { + + }, methods: { + getCode() { + uni.login({ + provider: 'weixin', + success: function(loginRes) { + console.log('获取微信code-loginRes.code: ' + loginRes.code); + uni.setStorageSync("wxCode", loginRes.code) + + } + }); + }, + getOpenID() { + let that = this; + let code = uni.getStorageSync("wxCode"); + console.log(code) + let data = { + appId: that.$common.hs_wxPay_appId, + // appId:"wxadb8caee05ab2981", + code: code, + + }; + that.$myRequest({ + url: that.$common.getOpenIdByCode, + method: 'POST', + data: data + }).then(res => { + + + let data = res.data; + that.wxopenId = data.openid; + console.log(data.openid) + that.wxPayOrder() + }) + }, recharge() { let that = this; that.$myRequest({ @@ -134,6 +174,13 @@ }); }, payClick() { + + let that = this; + that.getOpenID() + + + }, + wxPayOrder(){ let that = this; let payMoney; if (that.isShowInput) { @@ -141,11 +188,13 @@ } else { payMoney = that.rechargeFee; } + console.log(that.wxopenId) let data = { + openId: that.wxopenId, rechargeType: '2', acctType: '1', paySrcType: '204', - payType:'12', + payType: '12', realPayMoney: payMoney, rechargeFee: payMoney, }; @@ -155,10 +204,10 @@ method: 'POST', data: that.$common.requestSign(data) }).then(res => { - + console.log(res) that.MakeWxPay(res) - + }) }, // 调用微信支付 -- libgit2 0.21.4