|
@@ -1,7 +1,7 @@
|
|
|
/*
|
|
|
* @Author: your name
|
|
|
* @Date: 2022-01-06 09:45:17
|
|
|
- * @LastEditTime: 2022-01-07 16:46:06
|
|
|
+ * @LastEditTime: 2022-02-27 14:58:22
|
|
|
* @LastEditors: Please set LastEditors
|
|
|
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
|
* @FilePath: \vue-admin-template\src\utils\request.js
|
|
@@ -9,7 +9,7 @@
|
|
|
import axios from 'axios'
|
|
|
import { MessageBox, Message } from 'element-ui'
|
|
|
import store from '@/store'
|
|
|
-import { getToken, getUserId } from '@/utils/auth'
|
|
|
+import { getToken, getUserId, getCodeToken } from '@/utils/auth'
|
|
|
import { Loading } from 'element-ui'
|
|
|
// create an axios instance
|
|
|
const service = axios.create({
|
|
@@ -18,7 +18,7 @@ const service = axios.create({
|
|
|
baseURL: `${PLATFROM_CONFIG.baseUrl}`,
|
|
|
// withCredentials: true, // send cookies when cross-domain requests
|
|
|
timeout: 30000, // request timeout
|
|
|
- headers:{
|
|
|
+ headers: {
|
|
|
'Content-Type': 'application/json'
|
|
|
},
|
|
|
})
|
|
@@ -28,10 +28,13 @@ const loadingInstance = Loading.service({
|
|
|
// request interceptor
|
|
|
service.interceptors.request.use(
|
|
|
config => {
|
|
|
- // config.headers.common["content-type"] = "application/json"
|
|
|
+ // config.headers.common["content-type"] = "application/json"
|
|
|
if (config.data) {
|
|
|
config.data['OperatorId'] = getUserId()
|
|
|
}
|
|
|
+ if (getCodeToken() && !config.istoken) {
|
|
|
+ config.headers['code'] = getCodeToken()
|
|
|
+ }
|
|
|
// do something before request is sent
|
|
|
// config.headers['Content-Type'] = 'text/plain'
|
|
|
if (store.getters.token) {
|