From c80bc467a41daa6cbae4e5515a300a8ca98cfeaa Mon Sep 17 00:00:00 2001
From: WXL <wl_5969728@163.com>
Date: 星期二, 21 七月 2026 15:44:01 +0800
Subject: [PATCH] 维护

---
 stores/user.js |   28 ++++++++++++++++++++++------
 1 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/stores/user.js b/stores/user.js
index efa026e..3c4afea 100644
--- a/stores/user.js
+++ b/stores/user.js
@@ -7,8 +7,10 @@
   const userInfo = ref(null);
   const roleKeyInfo = ref(null);
   // const baseUrlHt =  ref(window.location.origin+'/api');
-  const baseUrlHt =  ref('http://www.qdopo.com:9095');
-  // const baseUrlHt =  ref('http://192.168.100.10:8080');
+  // const baseUrlHt =  ref('http://www.qdopo.com:9095');
+  // const baseUrlHt = ref("http://192.168.100.10:8080");
+  // const baseUrlHt = ref("http://localhost:8080");
+  const baseUrlHt = ref("https://opo.qduh.cn:443");
 
   // getters
   const isLoggedIn = computed(() => !!token.value);
@@ -28,8 +30,8 @@
     userInfo.value = info;
     uni.setStorageSync("userInfo", info);
   }
-  function setroleKey(roleKey) {    
-    // 鏇寸伒娲荤殑瑙掕壊鏉冮檺鏄犲皠
+  function setroleKey(roleKey) {
+    // 鏇寸伒娲荤殑瑙掕壊鏉冮檺鏄犲皠2
     if (ADMIN_ROLES.includes(roleKey)) {
       roleKeyInfo.value = 1; // 绠$悊鍛樻潈闄�
     } else if (DOCTOR_ROLES.includes(roleKey)) {
@@ -39,7 +41,7 @@
     } else {
       roleKeyInfo.value = 0; // 榛樿鏉冮檺
     }
-    uni.setStorageSync("roleKeyInfo", roleKeyInfo.value); 
+    uni.setStorageSync("roleKeyInfo", roleKeyInfo.value);
   }
   function clearUser() {
     token.value = null;
@@ -59,7 +61,20 @@
     if (localUser) userInfo.value = localUser;
     if (localroleKey) roleKeyInfo.value = localroleKey;
   }
-
+  async function refreshUserInfo() {
+    try {
+      const res = await uni.$uapi.get("/getInfo");
+      if (res && res.user) {
+        setUserInfo(res.user);
+        if (res.roles) setroleKey(res.roles);
+        return true;
+      }
+      return false;
+    } catch (error) {
+      console.error("鍒锋柊鐢ㄦ埛淇℃伅澶辫触", error);
+      return false;
+    }
+  }
   return {
     token,
     userInfo,
@@ -72,5 +87,6 @@
     clearUser,
     initFromStorage,
     setroleKey,
+    refreshUserInfo
   };
 });

--
Gitblit v1.9.3