| | |
| | | // 封装网络请求 |
| | | import axios from "axios"; |
| | | import { Message } from "element-ui"; |
| | | export const baseUrl = process.env.VUE_APP_API_URL; |
| | | // 创建请求实例 |
| | | const req = axios.create({ |
| | | // baseURL: '/api' |
| | | // baseURL: '/account/verification' |
| | | baseURL: "http://icmm.test.xyinde.com/api", |
| | | baseURL: baseUrl, |
| | | timeout: 10000 |
| | | }); |
| | | |
| | |
| | | (config) => { |
| | | // 携带token参数,一般会加载header Authorization |
| | | config.headers.Authorization = localStorage.getItem("access_token"); |
| | | config.headers.token = localStorage.getItem("access_token"); |
| | | return config; |
| | | }, |
| | | (error) => { |
| | |
| | | res.data.errorText == "需要验证身份" && |
| | | res.data.errorCode == "11" |
| | | ) { |
| | | console.log("token过期了"); |
| | | Message.error(res.data.errorText || ""); |
| | | // 清楚token |
| | | uni.getStorageSync("access_token"); |
| | | uni.clearStorageSync(); |
| | | uni.showToast({ |
| | | title: "请重新登录", |
| | | icon: "none" |
| | | }); |
| | | uni.reLaunch({ |
| | | url: "/pages/Login/Login" |
| | | }); |