响应拦截bug处理

master
Lee-1203 2022-03-25 09:12:33 +08:00
parent 9039cff63b
commit a5c39ea1f6
3 changed files with 20 additions and 11 deletions

View File

@ -26,17 +26,22 @@ axios.interceptors.request.use(config => {
return config
})
// 添加响应拦截器
axios.interceptors.response.use(response => {
// console.log(response);
let res = {}
res.status = response.status
res.data = response.data
return res;
}, function(err) {
return Promise.reject(err)
//返回状态判断(添加响应拦截器)
axios.interceptors.response.use(res =>{
console.log(res,'响应数据')
//对响应数据做些事
if(res.data.code == 0){
if (res.config.headers.Authorization) {
localStorage.token = JSON.stringify(res.config.headers.Authorization);
}
}else if(res.data.code == 6002 || res.data.code == 6001){
router.push({
path:'/login',
})
}
);
return res
})
Vue.use(VueAxios, axios)

View File

@ -111,6 +111,10 @@
created() {
this.isScroll = true;
window.addEventListener("scroll", this.eventScrollTop);
if(JSON.parse(localStorage.getItem("ddEntrance")) == 'yes'){
// postMessage
dd.postMessage({name:"clearAll"});
}
},
mounted(){
this.defaultPhoneHeight = window.innerHeight

View File

@ -143,7 +143,7 @@
},
handleInput() {
this.$refs.input.value = this.value;
if (this.value.length >= this.number) {
if (this.value.length == this.number) {
this.hideKeyboard();
}
this.handleSubmit();