实例如下所示:
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() } }
上面是我整理给大家的,希望今后会对大家有帮助。
相关文章:
在angularjs中如何实现table增加tr的方法
在angular中如何使用json对象push到数组中的方法
在angularjs数组中如何判断是否含有某个元素
以上就是通过vue.js实现微信支付的详细内容。