|
@ -5,6 +5,7 @@ import router from "../router" |
|
|
import store from "../store" |
|
|
import store from "../store" |
|
|
import { Notification } from "element-ui"; |
|
|
import { Notification } from "element-ui"; |
|
|
import qs from "qs" |
|
|
import qs from "qs" |
|
|
|
|
|
import { loginPc } from "@/api/login"; |
|
|
|
|
|
|
|
|
axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' |
|
|
axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' |
|
|
|
|
|
|
|
@ -31,7 +32,7 @@ const codeMessage = { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
axios.interceptors.request.use( |
|
|
axios.interceptors.request.use( |
|
|
config => { |
|
|
config => { |
|
|
const requestConfig = config; |
|
|
const requestConfig = config; |
|
|
if (!requestConfig.data) { |
|
|
if (!requestConfig.data) { |
|
|
requestConfig.data = {}; |
|
|
requestConfig.data = {}; |
|
@ -46,8 +47,9 @@ axios.interceptors.request.use( |
|
|
if (store.state.token) { |
|
|
if (store.state.token) { |
|
|
// requestConfig.headers["token"] = `${store.state.token}`;
|
|
|
// requestConfig.headers["token"] = `${store.state.token}`;
|
|
|
requestConfig.headers['jianwei'] = 'jwtech ' + `${store.state.token}` ; |
|
|
requestConfig.headers['jianwei'] = 'jwtech ' + `${store.state.token}` ; |
|
|
}else { |
|
|
} else { |
|
|
requestConfig.headers['jianwei'] = 'jwtech cf351e12-5418-456d-8934-d878d4f0147c' ; |
|
|
// requestConfig.headers['jianwei'] = 'jwtech ' + `${store.state.token}` ;
|
|
|
|
|
|
// requestConfig.headers['jianwei'] = 'jwtech cf351e12-5418-456d-8934-d878d4f0147c';
|
|
|
} |
|
|
} |
|
|
if (config.noSuffix) { |
|
|
if (config.noSuffix) { |
|
|
config.baseURL = window.g.noSuffixUrl |
|
|
config.baseURL = window.g.noSuffixUrl |
|
@ -74,30 +76,30 @@ axios.interceptors.response.use( |
|
|
// duration: 2000
|
|
|
// duration: 2000
|
|
|
// });
|
|
|
// });
|
|
|
} |
|
|
} |
|
|
if (response.data.code === 405 || response.data.code === 403) { |
|
|
// if (response.data.code === 405 || response.data.code === 403) {
|
|
|
Notification.closeAll() |
|
|
// Notification.closeAll()
|
|
|
Notification.warning({ |
|
|
// Notification.warning({
|
|
|
title: "系统提示", |
|
|
// title: "系统提示",
|
|
|
dangerouslyUseHTMLString: true, |
|
|
// dangerouslyUseHTMLString: true,
|
|
|
message: "检测用户未登录,即将跳转到登录页面", |
|
|
// message: "检测用户未登录,即将跳转到登录页面",
|
|
|
duration: 3000 |
|
|
// duration: 3000
|
|
|
}); |
|
|
// });
|
|
|
setTimeout(() => { |
|
|
// setTimeout(() => {
|
|
|
router.replace({ |
|
|
// router.replace({
|
|
|
path: 'login', |
|
|
// path: 'login',
|
|
|
query: { redirect: router.currentRoute.fullPath } |
|
|
// query: { redirect: router.currentRoute.fullPath }
|
|
|
}) |
|
|
// })
|
|
|
}, 2000) |
|
|
// }, 2000)
|
|
|
} else if (response.data.code === 500) { |
|
|
// } else if (response.data.code === 500) {
|
|
|
Notification.closeAll() |
|
|
// Notification.closeAll()
|
|
|
Notification.warning({ |
|
|
// Notification.warning({
|
|
|
title: "系统提示", |
|
|
// title: "系统提示",
|
|
|
dangerouslyUseHTMLString: true, |
|
|
// dangerouslyUseHTMLString: true,
|
|
|
message: response.data.msg, |
|
|
// message: response.data.msg,
|
|
|
duration: 3000 |
|
|
// duration: 3000
|
|
|
}); |
|
|
// });
|
|
|
return Promise.reject(new Error(response.data.msg)) |
|
|
// return Promise.reject(new Error(response.data.msg))
|
|
|
} |
|
|
// }
|
|
|
|
|
|
|
|
|
return response; |
|
|
return response; |
|
|
}, |
|
|
}, |
|
|