不要直接去調(diào)用這個(gè)方法锈锤,通過(guò)demo的方式去調(diào)用
paymentWxMpPay({ orderId: res['data'].data }).then(value => {
if (value['data'].status == 200) {
let params = {
"appId": value['data'].data.appId, //公眾號(hào)名稱银酬,由商戶傳入
"timeStamp": value['data'].data.timeStamp, //時(shí)間戳,自1970年以來(lái)的秒數(shù)
"nonceStr": value['data'].data.nonceStr, //隨機(jī)串
"package": value['data'].data.package,
"signType": value['data'].data.signType, //微信簽名方式:
"paySign": value['data'].data.paySign //微信簽名
}
// 支持回調(diào)必要方法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
})
}
})
//微信公眾號(hào)支付
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';
}
}
);
}