question:
in the case of the second page within WeChat Pay ios in h5, after canceling the payment for the first time, there is a probability that the same page will trigger WeixinJSBridge = "undefined",WeixinJSBridgeReady will not continue, resulting in the failure of the payment cashier.
WeChat Pay source code:
const onBridgeReady = (config, success, fail) => {
WeixinJSBridge.invoke( // eslint-disable-line
"getBrandWCPayRequest", config,
(res) => {
if (res.err_msg === "get_brand_wcpay_request:ok") {
success(res)
} else {
fail()
}
}
)
}
export const wxRealPay = (config, success, fail) => {
if (typeof WeixinJSBridge === "undefined") {
if (document.addEventListener) {
document.addEventListener("WeixinJSBridgeReady", () => onBridgeReady(config, success, fail), false)
} else if (document.attachEvent) {
document.attachEvent("WeixinJSBridgeReady", () => onBridgeReady(config, success, fail))
document.attachEvent("onWeixinJSBridgeReady", () => onBridgeReady(config, success, fail))
}
} else {
onBridgeReady(config, success, fail)
}
}
payment has been online for some time, so there is no problem under normal circumstances. It feels like both WeixinJSBridge and WeixinJSBridgeReady are invalid.
at first I thought it was the ios cache problem. Through this link , I used both timestamps and < html manifest=" IGNORE.manifest "> methods, but to no avail.
now we can only let him refresh in place, hoping to find a better way