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

接口报错验证

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