From af1ec6c61f8c5a3b206f5fcf3e05428f8f9fa46f Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期三, 14 二月 2024 18:32:13 +0800
Subject: [PATCH] #

---
 zy-asrs-flow/src/utils/http.js |   67 +++++++++++++++++++++++++++++++++
 1 files changed, 67 insertions(+), 0 deletions(-)

diff --git a/zy-asrs-flow/src/utils/http.js b/zy-asrs-flow/src/utils/http.js
index b988b19..4743ae6 100644
--- a/zy-asrs-flow/src/utils/http.js
+++ b/zy-asrs-flow/src/utils/http.js
@@ -1 +1,68 @@
 import { request } from '@umijs/max';
+import { message, Modal } from 'antd';
+
+const doGet = (url, params, fn) => {
+    return request(url, {
+        method: 'GET',
+        params
+    }).then((res) => {
+        if (res.code === 200) {
+            if (fn) {
+                return fn(res);
+            } else {
+                return res;
+            }
+        } else {
+            message.error(res.msg)
+        }
+    });
+}
+
+const doGetSync = async (url, params) => {
+    const res = await request(url, {
+        method: 'GET',
+        params
+    });
+    if (res.code === 200) {
+        return res;
+    }
+    message.error(res.msg)
+}
+
+const doPost = (url, params, fn) => {
+    return request(url, {
+        method: 'POST',
+        headers: {
+            'Content-Type': 'application/json'
+        },
+        data: { ...params }
+    }).then((res) => {
+        if (res.code === 200) {
+            if (fn) {
+                return fn(res);
+            } else {
+                return res;
+            }
+        } else {
+            message.error(res.msg)
+        }
+    });
+}
+
+const doPostSync = async (url, params) => {
+    const res = await request(url, {
+        method: 'POST',
+        headers: {
+            'Content-Type': 'application/json'
+        },
+        data: { ...params }
+    });
+    if (res.code === 200) {
+        return res;
+    }
+    message.error(res.msg)
+}
+
+const Http = { doGet, doGetSync, doPost, doPostSync }
+
+export default Http;
\ No newline at end of file

--
Gitblit v1.9.1