vue bomb timer + box to jump to the landing page


1. Make a request for interception, and after playing the prompt box a few seconds, then jump to the landing or home page and click OK to jump directly
to intercept took this. $ Axios.interceptors.response
bomb box components on a page with a vux components
vux address: https://doc.vux.li/zh-CN/
<Model = Confirm-V "errorsToken" 
Theme = "Android"
Confirm-text = "OK"
: Cancel Show-Button-= "to false"
@ ON-Confirm = "$ router.push ({path: '/'}) ">
<the p-style =" font-size: .34rem "> token has expired, please login again (after 3 seconds automatically jump to the landing page) </ the p->
</ Confirm the>


拦截
this.$axios.interceptors.response.use((response) => {
afterLoad.push(response);
if (response.data && response.data.msg === 'error_landed') {
this.errorsTip = true;
this.$router.push({path: '/'});
}
if (response.data && (response.data.status === 'error' && response.data.msg === 'ERROR_TOKEN_INVALID') && response.config.url.indexOf('/app/login') < 0) {
source.cancel('请求失败请重新登入');
     // 用于开启弹框的confirm组件
this.errorsToken = true;
if (!this.timer) {
this.timer = setInterval(() => {
clearInterval(this.timer);
this.= null Timer;
// for opening elastic block
                this.errorsToken = false;
//跳转的页面写在此处
this.$router.push({path: '/'});
}, 3000);
if (this.errorsToken === false) {
this.$router.push({path: '/'});
}
}

CancelToken = this.$axios.CancelToken;
source = CancelToken.source();
window.sessionStorage.clear();
window.localStorage.clear();
return response;
}
if (afterLoad.length === berferLoad.length) { //加载全部完成后
loadingEnd();
}
return response;
}, (error) => {
    // do something wrong response 
CancelToken the this $ = axios.CancelToken;.
Source = CancelToken.source ();
return Promise.reject (error);
});

Effect

 

 

Guess you like

Origin www.cnblogs.com/d0minic/p/11281977.html