|
@@ -27,11 +27,12 @@ axios.interceptors.request.use((config) => {
|
|
|
config.headers = {
|
|
|
'Content-Type': 'application/json',
|
|
|
};
|
|
|
- }else if(config.url.indexOf('https://beta.api.cocorobo.cn/api') !==-1 || config.url.indexOf('https://cloud.api.cocorobo.hk/api') !==-1 || config.url.indexOf('https://beta.api.cocorobo.cn/api') !==-1){
|
|
|
- config.headers = {
|
|
|
+ }else if(config.url.indexOf('https://beta.api.cocorobo.cn/api') !==-1 ||
|
|
|
+ config.url.indexOf('https://cloud.api.cocorobo.hk/api') !==-1){
|
|
|
+ config.headers = {
|
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
};
|
|
|
- }else if (config.data && config.data[0].post === '1' && config.method === 'post') {
|
|
|
+ }else if (config.data && config.data[0].post === '1' && config.method === 'post') {
|
|
|
// 如果 data 的第一个元素 post 值为 '1',则进行自定义序列化
|
|
|
config.data = 'mode=' + Object.values(config.data[0]).join(',');
|
|
|
} else if (config.method === 'post' && config.url.indexOf('https://api.edu.cocorobo.cn/edu/admin/selectorganize') !==-1 && config.data) {
|
|
@@ -43,8 +44,7 @@ axios.interceptors.request.use((config) => {
|
|
|
}
|
|
|
}
|
|
|
config.data = encoded; // 使用 qs 序列化数据
|
|
|
- }
|
|
|
- else if (config.method === 'post' && config.data) {
|
|
|
+ } else if (config.method === 'post' && config.data) {
|
|
|
// 处理其他 post 请求的参数序列化
|
|
|
const encoded = {};
|
|
|
for (const key in config.data[0]) {
|
|
@@ -94,6 +94,8 @@ axios.interceptors.response.use((res) => {
|
|
|
});
|
|
|
//返回一个Promise(发送post请求)
|
|
|
function post(url, params, source) {
|
|
|
+ console.log('paramsparamsparamsparams',url,params,source);
|
|
|
+
|
|
|
return new Promise((resolve, reject) => {
|
|
|
axios.post(url, params, source ? { cancelToken: source.token } : '')
|
|
|
.then(response => {
|