响应拦截bug处理
parent
9039cff63b
commit
a5c39ea1f6
25
src/main.js
25
src/main.js
|
@ -26,17 +26,22 @@ axios.interceptors.request.use(config => {
|
||||||
return config
|
return config
|
||||||
})
|
})
|
||||||
|
|
||||||
// 添加响应拦截器
|
//返回状态判断(添加响应拦截器)
|
||||||
axios.interceptors.response.use(response => {
|
axios.interceptors.response.use(res =>{
|
||||||
// console.log(response);
|
console.log(res,'响应数据')
|
||||||
let res = {}
|
//对响应数据做些事
|
||||||
res.status = response.status
|
if(res.data.code == 0){
|
||||||
res.data = response.data
|
if (res.config.headers.Authorization) {
|
||||||
return res;
|
localStorage.token = JSON.stringify(res.config.headers.Authorization);
|
||||||
}, function(err) {
|
|
||||||
return Promise.reject(err)
|
|
||||||
}
|
}
|
||||||
);
|
}else if(res.data.code == 6002 || res.data.code == 6001){
|
||||||
|
router.push({
|
||||||
|
path:'/login',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Vue.use(VueAxios, axios)
|
Vue.use(VueAxios, axios)
|
||||||
|
|
|
@ -111,6 +111,10 @@
|
||||||
created() {
|
created() {
|
||||||
this.isScroll = true;
|
this.isScroll = true;
|
||||||
window.addEventListener("scroll", this.eventScrollTop);
|
window.addEventListener("scroll", this.eventScrollTop);
|
||||||
|
if(JSON.parse(localStorage.getItem("ddEntrance")) == 'yes'){
|
||||||
|
// 网页向小程序 postMessage 消息
|
||||||
|
dd.postMessage({name:"clearAll"});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
mounted(){
|
mounted(){
|
||||||
this.defaultPhoneHeight = window.innerHeight
|
this.defaultPhoneHeight = window.innerHeight
|
||||||
|
|
|
@ -143,7 +143,7 @@
|
||||||
},
|
},
|
||||||
handleInput() {
|
handleInput() {
|
||||||
this.$refs.input.value = this.value;
|
this.$refs.input.value = this.value;
|
||||||
if (this.value.length >= this.number) {
|
if (this.value.length == this.number) {
|
||||||
this.hideKeyboard();
|
this.hideKeyboard();
|
||||||
}
|
}
|
||||||
this.handleSubmit();
|
this.handleSubmit();
|
||||||
|
|
Loading…
Reference in New Issue