diff --git a/src/main.js b/src/main.js index 3dc988f..f308dd6 100644 --- a/src/main.js +++ b/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) diff --git a/src/views/login.vue b/src/views/login.vue index 7d737d3..180fae4 100644 --- a/src/views/login.vue +++ b/src/views/login.vue @@ -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 diff --git a/src/views/login/verification.vue b/src/views/login/verification.vue index 43d61bf..40fe9c9 100644 --- a/src/views/login/verification.vue +++ b/src/views/login/verification.vue @@ -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();