From 49201aa2a0d6dfe491a0c4271f193dbc235bf7e3 Mon Sep 17 00:00:00 2001 From: chenbiao Date: Tue, 17 May 2022 14:52:26 +0800 Subject: [PATCH] add 我的钱包 微信支付 接口联调 --- pages/moneyRecharge/moneyRecharge.vue | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 74 insertions(+), 10 deletions(-) diff --git a/pages/moneyRecharge/moneyRecharge.vue b/pages/moneyRecharge/moneyRecharge.vue index 7b0d719..9ebb0db 100644 --- a/pages/moneyRecharge/moneyRecharge.vue +++ b/pages/moneyRecharge/moneyRecharge.vue @@ -52,6 +52,7 @@ acctBalance: '0.00', ListData: [], currentIndex: 0, + rechargeFee: 0, isShowInput: false, rechargeNum: '', maxlength: 6 //默认一个长度 @@ -91,6 +92,7 @@ console.log(res) let data = res.data; that.ListData = data; + that.rechargeFee = that.ListData[0].rechargeCode }) }, @@ -107,6 +109,7 @@ that.rechargeNum = '' } else { that.isShowInput = false; + that.rechargeFee = that.ListData[index].rechargeCode; } }, @@ -127,9 +130,69 @@ detailCell() { uni.navigateTo({ url: '../rechargeDetail/rechargeDetail' - + }); - } + }, + payClick() { + let that = this; + let payMoney; + if (that.isShowInput) { + payMoney = that.rechargeNum; + } else { + payMoney = that.rechargeFee; + } + let data = { + rechargeType: '2', + acctType: '1', + paySrcType: '204', + realPayMoney: payMoney, + rechargeFee: payMoney, + }; + console.log(data) + that.$myRequest({ + url: that.$common.publicUnifiedOrder, + method: 'POST', + data: that.$common.requestSign(data) + }).then(res => { + + console.log(res) + that.MakeWxPay(that.$common.requestSign(data)) + + }) + }, + // 调用微信支付 + MakeWxPay(mydata) { + console.log('wxpay') + var me = this; + uni.requestPayment({ + provider: 'wxpay', + timeStamp: mydata.timeStamp, + //随机字符串,长度为32个字符以下 + nonceStr: mydata.nonceStr, + //统一下单接口返回的 prepay_id 参数值,提交格式如:prepay_id=xx。 + package: mydata.package, + signType: mydata.signType, + paySign: mydata.paySign, + success: function(res) { + console.log('success:' + JSON.stringify(res)); + + }, + fail: function(err) { + console.log('fail:' + JSON.stringify(err)); + uni.showModal({ + title: '提示', + content: '支付失败/取消', + showCancel: false, + success: function(res) { + if (res.confirm) { + console.log('支付失败'); + } + } + }); + } + }); + }, + } } @@ -247,14 +310,15 @@ margin-top: 40px; } - .payInut{ + + .payInut { display: flex; - box-sizing: border-box; - flex-direction: row; - align-items: center; - border: 1px solid #DCDFE6; - border-radius: 4px; - min-height: 36px; - padding-left: 10px; + box-sizing: border-box; + flex-direction: row; + align-items: center; + border: 1px solid #DCDFE6; + border-radius: 4px; + min-height: 36px; + padding-left: 10px; } -- libgit2 0.21.4