async submitPay () { // 立即购买
let params = {
billCode: this.$route.query.billCode || this.selectPayData.code,
payment: (this.selectPayData.registeredFeeShow || this.selectPayData.originMoney) + '',
openId: JSON.parse(window.localStorage.getItem('wxData')).openId || null
}
let res = await wxOrders({data: params})
this.resData = res.data
if (typeof WeixinJSBridge == "undefined"){ // 微信验证是否可以调起支付
if( document.addEventListener ){
document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
}else if (document.attachEvent){
document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
}
}else{
this.onBridgeReady()
}
},
onBridgeReady() { // 微信支付
let _this = this
WeixinJSBridge.invoke(
'getBrandWCPayRequest', {
"appId": this.resData.appId, //公众号名称,由商户传入
"timeStamp": this.resData.timeStamp, //时间戳,自1970年以来的秒数
"nonceStr": this.resData.nonceStr, //随机串
"package": this.resData.packageValue,
"signType": this.resData.signType, //微信签名方式:
"paySign": this.resData.paySign //微信签名
},
function(res){
if(res.err_msg == "get_brand_wcpay_request:ok" ){ // 支付成功则会为true
_this.$router.push({path: '/registorManage/paySuccess'})
// 使用以上方式判断前端返回,微信团队郑重提示:
//res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
}
}
)
},
网友评论