From 5b45625178fd831a3d2ecfe52aa27a06d6862c74 Mon Sep 17 00:00:00 2001 From: liuqimichale <123456lq> Date: Thu, 4 Feb 2021 23:00:23 +0800 Subject: [PATCH] 调取微信支付 --- src/components/orderPay.vue | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/components/orderPay.vue b/src/components/orderPay.vue index 372ee93..ee16f4d 100644 --- a/src/components/orderPay.vue +++ b/src/components/orderPay.vue @@ -144,13 +144,14 @@ export default { } if (this.clientBrowser == '微信') { // 微信支付 + var vm = this //第一步获取openid var codeParams = { code: this.webAppCode, appId: this.$utils.myVxAppId }; - getOpenId(codeParams).then(res => { - if (res.code == 0) { + getOpenId(codeParams).then(resu => { + if (resu.code == 0) { // me.vxPay(res.data, this.orderId) var jsondata = { @@ -162,18 +163,18 @@ export default { orderActFee: this.arrearageActFee, orderTotalFee: this.arrearageTotalFee, orderDicountFee: this.arrearageDiscFee, - payUserId: res.data, + payUserId: resu.data, terminalOS: this.isAndroid ? 'AND' : 'IOS', couponType: 1, //优惠类型 couponCode: this.arrearageDiscFee, }; - doPay(jsondata).then(response => { - console.log(response) + doPay(jsondata).then(res => { + console.log(res) if (res.code == 0) { // //alertMsg("出场成功"); if (res.data) { - var data = res.data; + var data = JSON.parse(res.data.jsPayRequest); console.log(JSON.stringify(data)); if (typeof WeixinJSBridge === 'undefined') { // 微信浏览器内置对象。参考微信官方文档 if (document.addEventListener) { @@ -226,11 +227,19 @@ export default { }, - onBridgeReady(data) { + onBridgeReady(params) { console.log('调用微信支付WeixinJSBridge') - var vm = this WeixinJSBridge.invoke( - 'getBrandWCPayRequest', params, + 'getBrandWCPayRequest', { + "appId": params.appId, //公众号名称,由商户传入 + "timeStamp": params.timeStamp, //时间戳,自1970年以来的秒数 + "nonceStr": params.nonceStr, //随机串 + "package": params.package, + "signType": params.signType, //微信签名方式: + "paySign": params.paySign //微信签名 + }, + + // 'getBrandWCPayRequest', params, // // 'getBrandWCPayRequest', { // 下面参数内容都是后台返回的 // 'appId': data.appId, // 公众号名称,由商户传入 -- libgit2 0.21.4