vue.js 微信支付前端代码分享
程序员文章站
2022-04-22 20:45:38
实例如下所示:
onbridgeready: function () {
const openid = localstorage.getitem('open...
实例如下所示:
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() } }
以上这篇vue.js 微信支付前端代码分享就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。