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,

                        });
                    })
            
            },
原文地址:https://www.cnblogs.com/ydam/p/10983503.html