提交 74d25ab6 authored 作者: 钟是志's avatar 钟是志

接口报错验证

上级 a5ef21e3
import baseX from 'base-x';
import { apiRequest } from '../utils/request';
import { apiRequest, qqCw } from '../utils/request';
import { isJSON } from '@/webPublic/zyd_public/utils/utils';
import { queryApiActionPath, queryIsSafe } from '@/webPublic/one_stop_public/utils/queryConfig';
import { getToken, getUserInfo } from '@/webPublic/one_stop_public/utils/token';
......@@ -75,7 +75,7 @@ export function requestFileInfo(url, datas) {
for (let key in datas) {
formData.append(key, datas[key]);
}
if(!url || typeof url !== 'string'){
if (!url || typeof url !== 'string') {
console.log(url);
return false;
}
......@@ -90,33 +90,48 @@ export function requestFileInfo(url, datas) {
body: formData,
})
.then(res => {
if (res.status === 401) {
qqCw({
title: '登录过期401',
customErrMsg: '登录已过期,请重新登录',
});
return false;
}
console.log(res.status);
return res.json();
})
.then(res => {
// console.log(res);
if (res && res.errCode && res.message) {
qqCw({
msg: res.errMsg,
customErrMsg: res.customErrMsg,
});
return false;
}
return res;
});
}
export function giveFilePostDataInfoForTrue(datas, url){
export function giveFilePostDataInfoForTrue(datas, url) {
const getUserInfo = () => {
let x = localStorage.getItem('user');
if(isJSON(x)){
if (isJSON(x)) {
x = JSON.parse(x);
return x;
}else{
} else {
return {
groupsId: 'pub',
};
}
}
};
if(!window.CONFIG?.IS_SAFE){
if (!window.CONFIG?.IS_SAFE) {
return {
datas,
url,
}
};
}
datas = deepCopy(datas);
// console.log(datas);
......@@ -146,12 +161,11 @@ export function giveFilePostDataInfoForTrue(datas, url){
return {
datas,
url,
}
};
}
}
function giveFilePostData(datas, url) {
for (let i in datas) {
if (datas[i] === null || (Array.isArray(datas[i]) && datas[i].length === 0) || datas[i] === undefined) {
......
......@@ -42,7 +42,7 @@ const codeMessage = {
* return URL参数字符串
*/
const qqCw = ({
export const qqCw = ({
title = '请求错误',
msg = '',
customErrMsg = '',
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论