diff --git a/src/main.js b/src/main.js index 148aa5a..0bae490 100644 --- a/src/main.js +++ b/src/main.js @@ -11,11 +11,11 @@ Vue.prototype.HOME = '/api' // 添加请求拦截器具 axios.interceptors.request.use(config => { if (config.url != "/api/api/user/login-by-Phone" && config.url != "/api/api/common/send-sms-captcha" &&config.url !='/api/api/user/has-phone-user') { - if (!localStorage.userData) { + if (!localStorage.token) { router.replace('/login'); return config } else { - config.headers.Authorization = "Bearer " + JSON.parse(localStorage.userData).token + config.headers.Authorization = "Bearer " + JSON.parse(localStorage.token) } } return config diff --git a/src/views/consultant/index.vue b/src/views/consultant/index.vue index c32324c..e789819 100644 --- a/src/views/consultant/index.vue +++ b/src/views/consultant/index.vue @@ -71,6 +71,10 @@ } }, created() { + if(this.$route.query.token){ + let token = this.$route.query.token; + localStorage.token = JSON.stringify(token); + } this.isScroll = true; window.addEventListener("scroll", this.eventScrollTop); }, diff --git a/src/views/index/index.vue b/src/views/index/index.vue index 1854c20..c98cb4d 100644 --- a/src/views/index/index.vue +++ b/src/views/index/index.vue @@ -171,9 +171,9 @@ }; }, created() { - if(this.$route.query.userData){ - let userData = this.$route.query.userData; - localStorage.userData = userData; + if(this.$route.query.token){ + let token = this.$route.query.token; + localStorage.token = JSON.stringify(token); } diff --git a/src/views/login/verification.vue b/src/views/login/verification.vue index 3ad25c5..886ad96 100644 --- a/src/views/login/verification.vue +++ b/src/views/login/verification.vue @@ -110,6 +110,7 @@ .then(function(res) { console.log(res.data,252525) localStorage.userData = JSON.stringify(res.data.data); + localStorage.token = JSON.stringify(res.data.data); if (res.data.code == 0) { that.getUserData(); if(res.data.data.userType == 1){