Commit 5b45625178fd831a3d2ecfe52aa27a06d6862c74
1 parent
52f809e5
调取微信支付
Showing
1 changed file
with
18 additions
and
9 deletions
src/components/orderPay.vue
... | ... | @@ -144,13 +144,14 @@ export default { |
144 | 144 | } |
145 | 145 | |
146 | 146 | if (this.clientBrowser == '微信') { // 微信支付 |
147 | + var vm = this | |
147 | 148 | //第一步获取openid |
148 | 149 | var codeParams = { |
149 | 150 | code: this.webAppCode, |
150 | 151 | appId: this.$utils.myVxAppId |
151 | 152 | }; |
152 | - getOpenId(codeParams).then(res => { | |
153 | - if (res.code == 0) { | |
153 | + getOpenId(codeParams).then(resu => { | |
154 | + if (resu.code == 0) { | |
154 | 155 | // me.vxPay(res.data, this.orderId) |
155 | 156 | |
156 | 157 | var jsondata = { |
... | ... | @@ -162,18 +163,18 @@ export default { |
162 | 163 | orderActFee: this.arrearageActFee, |
163 | 164 | orderTotalFee: this.arrearageTotalFee, |
164 | 165 | orderDicountFee: this.arrearageDiscFee, |
165 | - payUserId: res.data, | |
166 | + payUserId: resu.data, | |
166 | 167 | terminalOS: this.isAndroid ? 'AND' : 'IOS', |
167 | 168 | couponType: 1, //优惠类型 |
168 | 169 | couponCode: this.arrearageDiscFee, |
169 | 170 | }; |
170 | 171 | |
171 | - doPay(jsondata).then(response => { | |
172 | - console.log(response) | |
172 | + doPay(jsondata).then(res => { | |
173 | + console.log(res) | |
173 | 174 | if (res.code == 0) { // |
174 | 175 | //alertMsg("出场成功"); |
175 | 176 | if (res.data) { |
176 | - var data = res.data; | |
177 | + var data = JSON.parse(res.data.jsPayRequest); | |
177 | 178 | console.log(JSON.stringify(data)); |
178 | 179 | if (typeof WeixinJSBridge === 'undefined') { // 微信浏览器内置对象。参考微信官方文档 |
179 | 180 | if (document.addEventListener) { |
... | ... | @@ -226,11 +227,19 @@ export default { |
226 | 227 | |
227 | 228 | }, |
228 | 229 | |
229 | - onBridgeReady(data) { | |
230 | + onBridgeReady(params) { | |
230 | 231 | console.log('调用微信支付WeixinJSBridge') |
231 | - var vm = this | |
232 | 232 | WeixinJSBridge.invoke( |
233 | - 'getBrandWCPayRequest', params, | |
233 | + 'getBrandWCPayRequest', { | |
234 | + "appId": params.appId, //公众号名称,由商户传入 | |
235 | + "timeStamp": params.timeStamp, //时间戳,自1970年以来的秒数 | |
236 | + "nonceStr": params.nonceStr, //随机串 | |
237 | + "package": params.package, | |
238 | + "signType": params.signType, //微信签名方式: | |
239 | + "paySign": params.paySign //微信签名 | |
240 | + }, | |
241 | + | |
242 | + // 'getBrandWCPayRequest', params, | |
234 | 243 | // |
235 | 244 | // 'getBrandWCPayRequest', { // 下面参数内容都是后台返回的 |
236 | 245 | // 'appId': data.appId, // 公众号名称,由商户传入 | ... | ... |