From 53bf1e11c46964e15ab2d334457066ed3b68c98d Mon Sep 17 00:00:00 2001
From: baoshiwei <baoshiwei@shlanbao.cn>
Date: 星期五, 06 六月 2025 12:57:57 +0800
Subject: [PATCH] refactor(lb-eims):调整代码和更新配置- 注释掉 EimsEquImportVo 中的 @ExcelProperty 注解 - 优化 EimsEquImportListener 中的异常日志输出- 更新 snailjob 监控页面的 iframe 源地址- 修改移动端项目的 API 基础 URL - 优化移动端页面跳转逻辑 - 改进维修请求列表的接单操作流程

---
 eims-ui-mobile/src/utils/http.ts |   49 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/eims-ui-mobile/src/utils/http.ts b/eims-ui-mobile/src/utils/http.ts
index 246cc7e..b9f2ada 100644
--- a/eims-ui-mobile/src/utils/http.ts
+++ b/eims-ui-mobile/src/utils/http.ts
@@ -1,6 +1,10 @@
 import { CustomRequestOptions } from '@/interceptors/request'
+import { useUserStore, useAccessStore } from '@/store'
 
 export const http = <T>(options: CustomRequestOptions) => {
+  uni.showLoading({
+    title: '鍔犺浇涓�',
+  })
   // 1. 杩斿洖 Promise 瀵硅薄
   return new Promise<IResData<T>>((resolve, reject) => {
     uni.request({
@@ -11,20 +15,38 @@
       // #endif
       // 鍝嶅簲鎴愬姛
       success(res) {
+        uni.hideLoading()
         // 鐘舵�佺爜 2xx锛屽弬鑰� axios 鐨勮璁�
         if (res.statusCode >= 200 && res.statusCode < 300) {
           // 2.1 鎻愬彇鏍稿績鏁版嵁 res.data
           if ((res.data as IResData<T>).code === 200) {
-            resolve((res.data as IResData<T>).data as IResData<T>)
+            resolve(((res.data as IResData<T>).data || res.data) as IResData<T>)
+          } else if ((res.data as IResData<T>).code === 401) {
+            uni.showToast({
+              icon: 'none',
+              title: '鐧诲綍瓒呮椂锛岃閲嶆柊鐧诲綍锛�',
+            })
+            // 401閿欒  -> 娓呯悊鐢ㄦ埛淇℃伅锛岃烦杞埌鐧诲綍椤�
+            useAccessStore().clearAccessInfo()
+            useUserStore().clearUserInfo()
+            const loginRoute = '/pages/login/index'
+            // 閲嶆柊鐧诲綍鍚庤繑鍥為〉闈�
+            const url = '/pages/home/index'
+            const redirectRoute = `${loginRoute}?redirect=${encodeURIComponent(url)}`
+            uni.navigateTo({ url: redirectRoute })
+            reject(res)
           } else {
+            // 鍏朵粬閿欒 -> 鏍规嵁鍚庣閿欒淇℃伅杞绘彁绀�
             uni.showToast({
               icon: 'none',
               title: (res.data as IResData<T>).msg || '璇锋眰閿欒',
             })
+            reject(res)
           }
         } else if (res.statusCode === 401) {
           // 401閿欒  -> 娓呯悊鐢ㄦ埛淇℃伅锛岃烦杞埌鐧诲綍椤�
-          // userStore.clearUserInfo()
+          useAccessStore().clearAccessInfo()
+          useUserStore().clearUserInfo()
           uni.navigateTo({ url: '/pages/login/index' })
           reject(res)
         } else {
@@ -44,6 +66,7 @@
           title: '缃戠粶閿欒锛屾崲涓綉缁滆瘯璇�',
         })
         reject(err)
+        uni.hideLoading()
       },
     })
   })
@@ -83,5 +106,27 @@
   })
 }
 
+export const httpPut = <T>(
+  url: string,
+  data?: Record<string, any>,
+  query?: Record<string, any>,
+) => {
+  return http<T>({
+    url,
+    query,
+    data,
+    method: 'PUT',
+  })
+}
+
+export const httpDel = <T>(url: string) => {
+  return http<T>({
+    url,
+    method: 'DELETE',
+  })
+}
+
 http.get = httpGet
 http.post = httpPost
+http.put = httpPut
+http.del = httpDel

--
Gitblit v1.9.3