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()
}
}另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
网页标题:vue.js微信支付前端代码分享-创新互联
本文路径:http://www.scyingshan.cn/article/ddsshs.html


咨询
建站咨询
