不要直接去调用这个方法,通过demo的方式去调用
paymentWxMpPay({ orderId: res['data'].data }).then(value => {
if (value['data'].status == 200) {
let params = {
"appId": value['data'].data.appId, //公众号名称,由商户传入
"timeStamp": value['data'].data.timeStamp, //时间戳,自1970年以来的秒数
"nonceStr": value['data'].data.nonceStr, //随机串
"package": value['data'].data.package,
"signType": value['data'].data.signType, //微信签名方式:
"paySign": value['data'].data.paySign //微信签名
}
// 支持回调必要方法start
if (typeof WeixinJSBridge == "undefined") {
if (document.addEventListener) {
document.addEventListener('WeixinJSBridgeReady', function () { this.onBridgeReady(params, res['data'].data); }, false);
} else if (document['attachEvent']) {
document['attachEvent']('WeixinJSBridgeReady', function () { this.onBridgeReady(params, res['data'].data); });
document['attachEvent']('onWeixinJSBridgeReady', function () { this.onBridgeReady(params, res['data'].data); });
}
} else {
this.onBridgeReady(params, res['data'].data);
}
} else {
Taro.showToast({
title: value['data'].message,
icon: 'none',
duration: 2000
})
}
})
//微信公众号支付
onBridgeReady(Data,id) {
const _this = this
WeixinJSBridge.invoke(
'getBrandWCPayRequest',
Data,
function (res) {
// Taro.showToast({title:JSON.stringify(res),icon:'none',duration:50000})
if (res.err_msg == "get_brand_wcpay_request:ok") {
_this.payResult({ payLogId: id })
} else {
Taro.showToast({title:'支付失败',icon:'none',duration:50000})
// window.location.href = '&payStatus=cancel';
}
}
);
}
网友评论