ddeaf1c0 by lihua

封装通用的接口定义函数

1 parent fa334d63
...@@ -2,6 +2,7 @@ import { ElMessage } from 'element-plus' ...@@ -2,6 +2,7 @@ import { ElMessage } from 'element-plus'
2 import { getDownloadUrl, download } from "@/utils/common"; 2 import { getDownloadUrl, download } from "@/utils/common";
3 import { getImageContent } from "@/api/modules/queryService"; 3 import { getImageContent } from "@/api/modules/queryService";
4 import { getDownFileSignByUrl, obsDownloadRequest, parseAndDecodeUrl } from './obsService'; 4 import { getDownFileSignByUrl, obsDownloadRequest, parseAndDecodeUrl } from './obsService';
5 import request from '@/utils/request';
5 6
6 // export const onUploadFilePreview = (file) => { 7 // export const onUploadFilePreview = (file) => {
7 // let url = file.url; 8 // let url = file.url;
...@@ -133,3 +134,25 @@ export const chunk = (array, size) => { ...@@ -133,3 +134,25 @@ export const chunk = (array, size) => {
133 //输出新数组 134 //输出新数组
134 return result; 135 return result;
135 } 136 }
137
138
139 /** 封装查询API接口,公共处理错误提示。 */
140 export const requestAPI = (urlParams, loadingCallback?: (loading: boolean) => void) => {
141 loadingCallback?.(true);
142 return new Promise((resolve, reject) => {
143 request(urlParams)
144 .then((res: any) => {
145 loadingCallback?.(false);
146 if (res?.code == '00000') {
147 resolve(res)
148 } else {
149 res?.msg && ElMessage.error(res?.msg)
150 reject(res)
151 }
152 })
153 .catch((error: Error) => {
154 loadingCallback?.(false);
155 reject(error)
156 })
157 })
158 }
...\ No newline at end of file ...\ 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!