From 55e791715385692f9c2a53e1191d3aa8558a87e9 Mon Sep 17 00:00:00 2001 From: zhaoguoqiang <849348323@qq.com> Date: Sat, 31 Jul 2021 11:43:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A5=E5=8F=A3=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/request.js | 5 +++-- src/views/login.vue | 18 +++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/utils/request.js b/src/utils/request.js index 70a97ee..ef5e825 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -1,5 +1,6 @@ import axios from 'axios' import {Toast} from 'vant' +import router from "../router"; // axios.defaults.baseURL = 'http://test.qingweilai888.xyz' //测试环境 // axios.defaults.baseURL = 'http://qwlapi.qwljk.com' //正式环境 axios.defaults.baseURL= process.env.VUE_APP_BASE_URL @@ -48,8 +49,8 @@ axios.interceptors.response.use( }, // 服务状态码不是200的情况 error => { - if (error.response.data.http_code) { - switch (error.response.data.http_code) { + if (error.response.status) { + switch (error.response.status) { // 401 未登录 // 未登录则跳转登录页面,并携带当前页面的路径 // 在登录成功后返回当前页面,这一步需要在登录页操作。 diff --git a/src/views/login.vue b/src/views/login.vue index 7b02c46..f277a52 100644 --- a/src/views/login.vue +++ b/src/views/login.vue @@ -6,15 +6,15 @@ let url = this.$route.query; let token; let url_string = JSON.stringify(url); - // if (url_string == "{}") { - // this.$toast('请先登录') - // } else { - // token = url.token_type + " " + url.access_token; - // this.$store.commit("user/setToken", token); - // this.$router.push({ - // path: "/home", - // }); - // } + if (url_string == "{}") { + this.$toast('请先登录') + } else { + token = url.token_type + " " + url.access_token; + this.$store.commit("user/setToken", token); + this.$router.push({ + path: "/home", + }); + } token = "bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC90ZXN0LnFpbmd3ZWlsYWk4ODgueHl6XC9hZG1pblwvbG9naW4iLCJpYXQiOjE2Mjc0NjU1ODksImV4cCI6MTk4NzQ2NTU4OSwibmJmIjoxNjI3NDY1NTg5LCJqdGkiOiJ6clVHYnJCOXlPWkpRanRUIiwic3ViIjoxNjEsInBydiI6IjBiMzZjMGUwMjMyZGVlZTlkOTZhZDA0NGY3YWE2MjQ2YTUwYTU3ZmEifQ.aFc5fCUffmDN7zBRn-D13kx1LuLNG1Ej7vQOu4O2_AA"