vue调起微信支付

           
affirmPay() {
if(typeof WeixinJSBridge == "undefined") { if(document.addEventListener) { document.addEventListener('WeixinJSBridgeReady', this.jsApiCall, false); } else if(document.attachEvent) { document.attachEvent('WeixinJSBridgeReady', this.jsApiCall); document.attachEvent('onWeixinJSBridgeReady', this.jsApiCall); } } else { this.jsApiCall(this.id); } }, jsApiCall($orderNo) { this.$dialog.loading.open('正在连接支付接口...'); var jsondata = { pay_type: "wechatJsApi", order_sn: this.id, }; this.$http.post(this.getApiUrl() + "Payment/pay", jsondata, { emulateJSON: true }).then(function(datas) { this.$dialog.loading.close(); var Jsonparse = JSON.parse(datas.bodyText); if(Jsonparse.status == "1") { //成功 WeixinJSBridge.invoke( 'getBrandWCPayRequest', JSON.parse(Jsonparse.data), function(res) { if(res.err_msg == "get_brand_wcpay_request:ok") { alert('支付成功'); location.href = ''; //支付成功后的跳转地址 } //WeixinJSBridge.log(res.err_msg); //alert(res.err_code+res.err_desc+res.err_msg); } ); } else { this.$dialog.toast({ mes: Jsonparse.msg, timeout: 1500, }); } }, function(response) { this.$dialog.loading.close(); this.$dialog.toast({ mes: '网络请求超时 - ' + response.status, timeout: 1500, }); }) },

 

posted @ 2018-09-29 15:27  印度阿铭  阅读(1399)  评论(0编辑  收藏  举报