// 调起h5支付接口 const that = this; function onBridgeReady() { WeixinJSBridge.invoke( 'getBrandWCPayRequest', { "appId":that.state.payData.appId, //公众号名称,由商户传入 "timeStamp":that.state.payData.timeStamp,//时间戳,自1970年以来的秒数 "nonceStr":that.state.payData.nonceStr, //随机串 "package":that.state.payData.package, //预支付交易码 "signType":that.state.payData.signType,//微信签名方式: "paySign":that.state.payData.paySign //微信签名 }, function(res){ if(res.err_msg == "get_brand_wcpay_request:ok" ){ that.toPaySuccessPage() //跳转到支付成功页 // 使用以上方式判断前端返回,微信团队郑重提示: //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。 }else{ that.toPayFalsePage() //跳转到支付失败页 } } ); }; 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{ onBridgeReady() }