我们有一个结果通知页,成功会跳转到微信客服页面进行对话,但是我用微信js操作关闭页面失效,会一直重复跳转微信客服,手机端正常,PC端会有问题
页面部分代码
setTimeout(function () {
let ua = window.navigator.userAgent.toLocaleLowerCase();
let isWeChat = ua.includes('micromessenger');
if (isWeChat) {
if (typeof WeixinJSBridge !== 'undefined') {
setTimeout(function () {
window.location.href = zlp_redirect;
}, 100);
if (ua.includes('iphone') || ua.includes('ipad') || ua.includes('ipod')) {
WeixinJSBridge.invoke('closeWindow');
WeixinJSBridge.call('closeWindow');
}
} else {
// 监听 WeixinJSBridgeReady 事件确保 WeixinJSBridge 加载完毕后调用
document.addEventListener('WeixinJSBridgeReady', function () {
setTimeout(function () {
WeixinJSBridge.invoke('closeWindow');
WeixinJSBridge.call('closeWindow');
}, 100);
}, false);
}
}
}, 500)
取消这段判断也是一样的效果
if (ua.includes('iphone') || ua.includes('ipad') || ua.includes('ipod')) {
WeixinJSBridge.invoke('closeWindow');
WeixinJSBridge.call('closeWindow');
}