99d742df by simon

默认提交

1 parent 6e10fcf8
NODE_ENV = 'development'
VUE_APP_TITLE = 'development'
VUE_APP_BASE_URL= 'https://ow.go.qudone.com'
VUE_APP_RSA_PUBLIC_KEY = 'B5FE03847F02046C47292AF0FF2DE88977241483DD40C123046EB39CBE4C48167B120096CFF12CD16559322884A3C56FA92B07B89AB51FC8C91A75127622151DDD730DFF1F993D5A290CEAC0BBA7FC88285D8994ACBAFF50101EDE9A0925AD5DFFAFE96D53C370E9C5B37DF2F871F81C4D7CA6B7EC37FF459C07975AD9A74A95'
VUE_APP_RSA_KEY_INDEX = '10001'
......
NODE_ENV = 'production'
VUE_APP_TITLE = 'dist'
VUE_APP_BASE_URL= 'https://ow.go.qudone.com'
VUE_APP_RSA_PUBLIC_KEY = 'B5FE03847F02046C47292AF0FF2DE88977241483DD40C123046EB39CBE4C48167B120096CFF12CD16559322884A3C56FA92B07B89AB51FC8C91A75127622151DDD730DFF1F993D5A290CEAC0BBA7FC88285D8994ACBAFF50101EDE9A0925AD5DFFAFE96D53C370E9C5B37DF2F871F81C4D7CA6B7EC37FF459C07975AD9A74A95'
VUE_APP_RSA_KEY_INDEX = '10001'
......
NODE_ENV = 'sandbox'
VUE_APP_TITLE = 'sandbox'
REQUEST_DOMAIN= 'https://ow.go.qudone.com'
RSA_PUBLIC_KEY = 'B5FE03847F02046C47292AF0FF2DE88977241483DD40C123046EB39CBE4C48167B120096CFF12CD16559322884A3C56FA92B07B89AB51FC8C91A75127622151DDD730DFF1F993D5A290CEAC0BBA7FC88285D8994ACBAFF50101EDE9A0925AD5DFFAFE96D53C370E9C5B37DF2F871F81C4D7CA6B7EC37FF459C07975AD9A74A95'
RSA_KEY_INDEX = '10001'
\ No newline at end of file
VUE_APP_BASE_URL= 'https://ow.go.qudone.com'
VUE_APP_RSA_PUBLIC_KEY = 'B5FE03847F02046C47292AF0FF2DE88977241483DD40C123046EB39CBE4C48167B120096CFF12CD16559322884A3C56FA92B07B89AB51FC8C91A75127622151DDD730DFF1F993D5A290CEAC0BBA7FC88285D8994ACBAFF50101EDE9A0925AD5DFFAFE96D53C370E9C5B37DF2F871F81C4D7CA6B7EC37FF459C07975AD9A74A95'
VUE_APP_RSA_KEY_INDEX = '10001'
......
import axios from 'axios';
import axiosIns from 'axios';
// import {
// Toast
// } from 'vant';
function Toast(msg) {
console.log("msg:", msg);
console.log("msg:", msg);
}
// axios的默认url
// axios.defaults.baseURL = ""
// 服务器地址
let base = process.env.REQUEST_DOMAIN || "http://localhost:9101";
// let base = process.env.REQUEST_DOMAIN || "http://localhost:9101";
// let base = COM.baseUrl;
let base = ""
console.log("process.env:", process.env);
const axios = axiosIns.create({
baseURL: process.env.VUE_APP_BASE_URL || "http://localhost:9101",
timeout: 5000
})
// 请求拦截器
// axios.interceptors.request.use(
......@@ -29,82 +35,82 @@ let base = process.env.REQUEST_DOMAIN || "http://localhost:9101";
// 响应拦截器
axios.interceptors.response.use(
response => {
if (response.status === 200) {
if (response.data.code === 200) {
return Promise.resolve(response);
} else {
Toast(response.data.bizMsg);
return Promise.reject(response);
}
} else {
return Promise.reject(response);
}
},
// 服务器状态码不是200的情况
error => {
if (error.response.status) {
switch (error.response.status) {
// 401: 未登录
// 未登录则跳转登录页面,并携带当前页面的路径
// 在登录成功后返回当前页面,这一步需要在登录页操作。
case 401:
router.replace({
path: '/login',
query: {
redirect: router.currentRoute.fullPath
}
});
break;
// 403 token过期
// 登录过期对用户进行提示
// 清除本地token和清空vuex中token对象
// 跳转登录页面
case 403:
Toast({
message: '登录过期,请重新登录',
duration: 1000,
forbidClick: true
});
// 清除token
localStorage.removeItem('token');
store.commit('loginSuccess', null);
// 跳转登录页面,并将要浏览的页面fullPath传过去,登录成功后跳转需要访问的页面
setTimeout(() => {
router.replace({
path: '/login',
query: {
redirect: router.currentRoute.fullPath
}
});
}, 1000);
break;
// 404请求不存在
case 404:
Toast({
message: '网络请求不存在',
duration: 1500,
forbidClick: true
});
break;
// 其他错误,直接抛出错误提示
default:
Toast({
message: error.response.data.message,
duration: 1500,
forbidClick: true
});
}
return Promise.reject(error.response);
}
}
response => {
if (response.status === 200) {
if (response.data.code === 200) {
return Promise.resolve(response);
} else {
Toast(response.data.bizMsg);
return Promise.reject(response);
}
} else {
return Promise.reject(response);
}
},
// 服务器状态码不是200的情况
error => {
if (error.response.status) {
switch (error.response.status) {
// 401: 未登录
// 未登录则跳转登录页面,并携带当前页面的路径
// 在登录成功后返回当前页面,这一步需要在登录页操作。
case 401:
router.replace({
path: '/login',
query: {
redirect: router.currentRoute.fullPath
}
});
break;
// 403 token过期
// 登录过期对用户进行提示
// 清除本地token和清空vuex中token对象
// 跳转登录页面
case 403:
Toast({
message: '登录过期,请重新登录',
duration: 1000,
forbidClick: true
});
// 清除token
localStorage.removeItem('token');
store.commit('loginSuccess', null);
// 跳转登录页面,并将要浏览的页面fullPath传过去,登录成功后跳转需要访问的页面
setTimeout(() => {
router.replace({
path: '/login',
query: {
redirect: router.currentRoute.fullPath
}
});
}, 1000);
break;
// 404请求不存在
case 404:
Toast({
message: '网络请求不存在',
duration: 1500,
forbidClick: true
});
break;
// 其他错误,直接抛出错误提示
default:
Toast({
message: error.response.data.message,
duration: 1500,
forbidClick: true
});
}
return Promise.reject(error.response);
}
}
);
//formDataHeaders设置
let formDataHeaders = {
headers: {
"Content-Type": "multipart/form-data"
}
headers: {
"Content-Type": "multipart/form-data"
}
}
/**
......@@ -112,13 +118,13 @@ let formDataHeaders = {
* @param {*} params
*/
export const httpGet = params => {
let {
url,
data
} = params;
return axios.get(`${base}${url}`, {
params: data
}).then(res => res.data.content);
let {
url,
data
} = params;
return axios.get(`${base}${url}`, {
params: data
}).then(res => res.data.content);
}
/**
......@@ -126,11 +132,11 @@ export const httpGet = params => {
* @param {*} params
*/
export const httpPost = params => {
let {
url,
data
} = params;
return axios.post(`${base}${url}`, data).then(res => res.data.content);
let {
url,
data
} = params;
return axios.post(`${base}${url}`, data).then(res => res.data.content);
}
......@@ -145,9 +151,9 @@ export const httpPost = params => {
data.append('file', file.file)
*/
export const formdata = params => {
let {
url,
data
} = params;
return axios.post(`${base}${url}`, data, formDataHeaders).then(res => res.data);
}
\ No newline at end of file
let {
url,
data
} = params;
return axios.post(`${base}${url}`, data, formDataHeaders).then(res => res.data);
}
......
......@@ -45,8 +45,8 @@ export default {
showImageCode: false,
agreeProtocol: false
},
PK: process.env.RSA_PUBLIC_KEY || PK,
E: process.env.RSA_KEY_INDEX || E,
PK: process.env.VUE_APP_RSA_PUBLIC_KEY || PK,
E: process.env.VUE_APP_RSA_KEY_INDEX || E,
}
},
components: {},
......
......@@ -39,8 +39,8 @@ export default {
remain: 0, // 剩余时间
tip: "" // 显示的文字
},
PK: process.env.RSA_PUBLIC_KEY || PK,
E: process.env.RSA_KEY_INDEX || E,
PK: process.env.VUE_APP_RSA_PUBLIC_KEY || PK,
E: process.env.VUE_APP_RSA_KEY_INDEX || E,
}
},
components: {},
......