H5 when WeChat Pay's iPhone opens the page for the second time, the payment cashier will not be able to adjust.

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


after searching for a long time, I didn't find the reason, but finally let him refresh it every time he came in, and he could indeed adjust the payment cashier

.
window.onload = function() {
    if(!window.location.hash) {
        window.location = window.location + '-sharploaded';
        window.location.reload();
    }
}

there is a better way. You are welcome to leave the answer

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1cde1ee-3939b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1cde1ee-3939b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?