Browse Source

修改接口判断

develop
zhaoguoqiang 3 years ago
parent
commit
55e7917153
  1. 5
      src/utils/request.js
  2. 18
      src/views/login.vue

5
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 未登录
// 未登录则跳转登录页面,并携带当前页面的路径
// 在登录成功后返回当前页面,这一步需要在登录页操作。

18
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"

Loading…
Cancel
Save