响应拦截bug处理
parent
9039cff63b
commit
a5c39ea1f6
25
src/main.js
25
src/main.js
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue