let ST = null;
router.beforeEach((to, from, next) => {
// if (location.href.includes(‘code‘) && location.href.includes(‘state‘)) {
// if (!localStorage.through) return
// next()
// delete localStorage.through
// }
// else if (!localStorage.rollback) {
// next()
// localStorage.rollback = true
// } else if (localStorage.rollback) {
// RouterClass.back()
// }
// 这边是 关闭逻辑 : 都是只走一种的
if(from.name==to.name || to.name ==null){// 第一次进的页面 返回情况
window._page=1;
}else if(from.name =="orders" && to.name == "confirmorder"){// 订单支付取消跳转到订单列表 返回的清空
window._page=1;
}else if(from.name =="mine" && to.name == "address-setting" && to.query.effect=="remove"){// 订单支付取消跳转到订单列表 返回的清空
window._page=1;
}else{
window._page=2;
}
// 这边是 跳转逻辑
if(from.name =="address" && to.name == "address-setting" && to.query.effect=="remove"){// 地址修改删除 然后返回的清空
window._page="mine";
}
if(typeof(window._page)==‘string‘ || window._page===1){
ST = setTimeout(()=>{
next()
},0)
}else{
next()
}
})
window.addEventListener("popstate", ()=>{
if(typeof(window._page)==‘string‘){
clearTimeout(ST);
router.push({name:window._page})
}
if(_page===1){
// RouterClass.back();
clearTimeout(ST);
wx.closeWindow()
return false;
}
window._page=1;
}, false);