vue.js 微信支付前端代码分享
实例如下所示:
onBridgeReady: function () { const openId = localStorage.getItem('openId') payService.payment(this.$route.params.orderId, 1, openId).then(rt => { //1:支付类型,可不填 this.message = rt.t WeixinJSBridge.invoke( 'getBrandWCPayRequest', { 'appId': this.message.appId, 'timeStamp': this.message.timeStamp, 'nonceStr': this.message.nonceStr, 'package': this.message.package, 'signType': this.message.signType, 'paySign': this.message.paySign }, function (res) { console.log(res) if (res.err_msg === 'get_brand_wcpay_request:ok') { Toast('微信支付成功') this.$router.push('/MineOrder') } else if (res.err_msg === 'get_brand_wcpay_request:cancel') { Toast('用户取消支付') // window.location.href = 'gift_failview.do?out_trade_no=' + this.orderId } else if (res.err_msg === 'get_brand_wcpay_request:fail') { Toast('网络异常,请重试') } } ) }) }, callpay: function () { if (typeof WeixinJSBridge === 'undefined') { if (document.addEventListener) { document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(), false) } else if (document.attachEvent) { document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady()) document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady()) } } else { this.onBridgeReady() } }
相关推荐
zuoliangzhu 2020-05-16
蓝色深海 2020-03-24
cbao 2020-05-12
caiyiii 2020-04-29
cdkey 2020-05-04
powderhose 2020-04-25
zengfanpei 2020-04-22
powderhose 2019-12-13
zengfanpei 2019-11-02
CodeAndroid 2019-05-05
资源分享 2019-04-29
newhappy 2019-04-10
czsong 2011-06-13
small 2019-07-01
klshige 2019-06-30
Donutsapps 2019-06-30