56af7d44 by lihua

封装通用的接口定义函数

1 parent 90d55548
......@@ -2,6 +2,7 @@ import { ElMessage } from 'element-plus'
import { getDownloadUrl, download } from "@/utils/common";
import { getImageContent } from "@/api/modules/queryService";
import { getDownFileSignByUrl, obsDownloadRequest, parseAndDecodeUrl } from './obsService';
import request from '@/utils/request';
// export const onUploadFilePreview = (file) => {
// let url = file.url;
......@@ -133,3 +134,25 @@ export const chunk = (array, size) => {
//输出新数组
return result;
}
/** 封装查询API接口,公共处理错误提示。 */
export const requestAPI = (urlParams, loadingCallback?: (loading: boolean) => void) => {
loadingCallback?.(true);
return new Promise((resolve, reject) => {
request(urlParams)
.then((res: any) => {
loadingCallback?.(false);
if (res?.code == '00000') {
resolve(res)
} else {
res?.msg && ElMessage.error(res?.msg)
reject(res)
}
})
.catch((error: Error) => {
loadingCallback?.(false);
reject(error)
})
})
}
\ No newline at end of file
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!