From e1d337a86c48054512f8f64812e6c06181b29204 Mon Sep 17 00:00:00 2001 From: Lee-1203 <342694918@qq.com> Date: Wed, 9 Mar 2022 18:24:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E8=B7=B3=E8=BD=ACiphone=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.js | 4 ++-- src/views/consultant/index.vue | 4 ++++ src/views/index/index.vue | 6 +++--- src/views/login/verification.vue | 1 + 4 files changed, 10 insertions(+), 5 deletions(-) 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){