WeixinJSBridge.invoke时WeixinJSBridge未定义
[图片] $.post(request_url, {"orderId": orderId, "reqId": openid}, function (result) { console.log(result); var obj = result.data; var reqData = $.parseJSON(obj); if (typeof WeixinJSBridge == "undefined"){ if( document.addEventListener ){ document.addEventListener('WeixinJSBridgeReady', onBridgeReady(reqData), false); }else if (document.attachEvent){ document.attachEvent('WeixinJSBridgeReady', onBridgeReady(reqData)); document.attachEvent('onWeixinJSBridgeReady', onBridgeReady(reqData)); } }else{ onBridgeReady(reqData); } }); function onBridgeReady(reqData){ WeixinJSBridge.invoke( 'getBrandWCPayRequest', { "appId": reqData.appId, "timeStamp": reqData.timeStamp, "nonceStr": reqData.nonceStr, "package": reqData.package, "signType": reqData.signType, "paySign": reqData.paySign }, function(res){ if (res.err_msg == "get_brand_wcpay_request:ok") { layer.confirm('支付成功', { title: '温馨提示', btn: ['确定'] //按钮 }, function () { WeixinJSBridge.call('closeWindow'); }); } else { layer.confirm('支付失败', { title: '温馨提示', btn: ['确定'] //按钮 }, function () { WeixinJSBridge.call('closeWindow'); }); } }); }