|
|
|
@ -10,17 +10,17 @@ let vm = new Vue();
|
|
|
|
|
|
|
|
|
|
// 接口请求域名参数 3.8
|
|
|
|
|
const api = {
|
|
|
|
|
// pro: 'https://cx.api.zanhr.com/', // 生产
|
|
|
|
|
// test: 'https://cx.api.zanhr.com/', // 生产
|
|
|
|
|
// pro: 'http://121.196.150.59:9000/', // 测试环境
|
|
|
|
|
// test: 'http://121.196.150.59:9000/', // 测试环境
|
|
|
|
|
// test: 'http://192.168.31.185:9999/', // 高老板本地
|
|
|
|
|
// test: 'http://192.168.31.182:9999/', //大鱼本地
|
|
|
|
|
// test: 'http://192.168.31.104:8081/', // 王泽本地
|
|
|
|
|
// test: 'http://192.168.31.165:9000/', // 吴阳本地
|
|
|
|
|
// test: 'http://192.168.31.22:9999/', //吴老板本地
|
|
|
|
|
}
|
|
|
|
|
// 打包测试环境就直接取测试服务器地址 baseURL,
|
|
|
|
|
// pro: 'https://cx.api.zanhr.com/', // 生产
|
|
|
|
|
// test: 'https://cx.api.zanhr.com/', // 生产
|
|
|
|
|
// pro: 'http://121.196.150.59:9000/', // 测试环境
|
|
|
|
|
// test: 'http://121.196.150.59:9000/', // 测试环境
|
|
|
|
|
// test: 'http://192.168.31.185:9999/', // 高老板本地
|
|
|
|
|
// test: 'http://192.168.31.182:9999/', //大鱼本地
|
|
|
|
|
// test: 'http://192.168.31.104:8081/', // 王泽本地
|
|
|
|
|
// test: 'http://192.168.31.165:9000/', // 吴阳本地
|
|
|
|
|
// test: 'http://192.168.31.22:9999/', //吴老板本地
|
|
|
|
|
}
|
|
|
|
|
// 打包测试环境就直接取测试服务器地址 baseURL,
|
|
|
|
|
// process.env.NODE_ENV === 'test' && (api.test = 'http://121.196.150.59:9999/');
|
|
|
|
|
// export const baseURL = process.env.NODE_ENV === 'production' ? api.pro : api.test;
|
|
|
|
|
let instance = axios.create({
|
|
|
|
@ -37,11 +37,15 @@ instance.interceptors.request.use(
|
|
|
|
|
// 基础请求参数
|
|
|
|
|
const tokenInfo = vm.getSession('CX_Common_UserInfo'),
|
|
|
|
|
base = {},
|
|
|
|
|
postData = {...base, ...config.data };
|
|
|
|
|
tokenInfo.access_token && (config.headers[`Authorization`] = `Bearer:${tokenInfo.access_token}`);
|
|
|
|
|
postData = { ...base,
|
|
|
|
|
...config.data
|
|
|
|
|
};
|
|
|
|
|
tokenInfo.access_token && (config.headers[`Authorization`] = `Bearer${tokenInfo.platform === 'front' ? ' ' : ':'}${tokenInfo.access_token}`);
|
|
|
|
|
config.method === 'post' ?
|
|
|
|
|
config.data = config.headers['Content-Type'] == 'application/x-www-form-urlencoded' ? qs.stringify(postData) : JSON.stringify(postData) :
|
|
|
|
|
config.params = {...base, ...config.params };
|
|
|
|
|
config.params = { ...base,
|
|
|
|
|
...config.params
|
|
|
|
|
};
|
|
|
|
|
return config;
|
|
|
|
|
},
|
|
|
|
|
error => Promise.error(error))
|
|
|
|
@ -99,14 +103,14 @@ const abutment = () => {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
let apiOne = 0
|
|
|
|
|
const specialApi = ["auth/auth/form", "auth/auth/mobile", `${httpUrl.basUrl.member}myMember/getUploadingResult`, httpUrl.basUrl.member+'myMember/getInsertToTabResult']
|
|
|
|
|
const specialApi = ["auth/auth/form", "auth/auth/mobile", `${httpUrl.basUrl.member}myMember/getUploadingResult`, httpUrl.basUrl.member + 'myMember/getInsertToTabResult']
|
|
|
|
|
instance.interceptors.response.use(
|
|
|
|
|
// 请求成功-属于登录页2个特殊接口的的特殊处理,其他接口判断code为200就是成功了,其他走错误提示逻辑
|
|
|
|
|
res =>
|
|
|
|
|
res.status === 200 ? (specialApi.includes(res.config.url) ? Promise.resolve(res.data) : res.data.code == 200 ? (Promise.resolve(res.data)) : (
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
resHandler(res.data.code, res.data.msg || '系统忙')
|
|
|
|
|
}, 300) , Promise.reject(res.data)
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
resHandler(res.data.code, res.data.msg || '系统忙')
|
|
|
|
|
}, 300), Promise.reject(res.data)
|
|
|
|
|
)) : Promise.reject(res.data),
|
|
|
|
|
// 请求失败
|
|
|
|
|
error => {
|
|
|
|
@ -119,7 +123,9 @@ instance.interceptors.response.use(
|
|
|
|
|
// vm.$message.error(other)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const { response } = error;
|
|
|
|
|
const {
|
|
|
|
|
response
|
|
|
|
|
} = error;
|
|
|
|
|
if (response.status == 500 && apiOne == 1) {
|
|
|
|
|
let id = JSON.parse(sessionStorage.getItem('CX_CoopUserInfo')).id
|
|
|
|
|
instance.get(`/auth/token/checkTokenIsExesists?clientId=${id}`).then(res => {
|
|
|
|
@ -147,4 +153,4 @@ instance.interceptors.response.use(
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default instance;
|
|
|
|
|
export default instance;
|