From c980edafe5bf00f9cfe5d999896bb3bb971c8943 Mon Sep 17 00:00:00 2001
From: zhangchen <1652267879@qq.com>
Date: 星期三, 10 九月 2025 19:49:28 +0800
Subject: [PATCH] ID1766-暂存

---
 src/views/mobile/bedsideAuxiliaryScreen/components/Header.vue      |    1 +
 src/views/mobile/bedsideAuxiliaryScreen/components/Login/index.vue |   16 +++++++++++++---
 src/utils/httpApi.ts                                               |   18 ++++++++++++++++++
 src/store/bedsideAuxiliaryScreen.ts                                |    6 ++++--
 4 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/src/store/bedsideAuxiliaryScreen.ts b/src/store/bedsideAuxiliaryScreen.ts
index d3a6a9c..edf2057 100644
--- a/src/store/bedsideAuxiliaryScreen.ts
+++ b/src/store/bedsideAuxiliaryScreen.ts
@@ -15,6 +15,7 @@
 import { ElMessage } from "element-plus/es";
 import { Local } from "@/utils/storage";
 import type { DeviceLoginRecord } from './type/user.type';
+import { logoutForSubScreen } from "@/utils/httpApi";
 
 export const useBedsideAuxiliaryScreenStore = defineStore(
   "bedsideAuxiliaryScreen",
@@ -81,8 +82,9 @@
 
 
     /** 退出登录 */
-    const logout = () => {
-
+    const logout = async (deviceCode: string) => {
+      await logoutForSubScreen(deviceCode);
+      setUserInfo(null);
     };
 
     // SSE 相关状态
diff --git a/src/utils/httpApi.ts b/src/utils/httpApi.ts
index d8f0c2e..632b95f 100644
--- a/src/utils/httpApi.ts
+++ b/src/utils/httpApi.ts
@@ -93,4 +93,22 @@
     } catch (error) {
         throw error;
     }
+}
+
+/**
+ * 推出登录
+ * @param deviceCode 
+ * @returns 
+ */
+export const logoutForSubScreen = async(deviceCode: string) => {
+    try {
+        const response = await axios.post(`${apiBaseUrl}/user/info/logoutForSubScreen`, { deviceCode }, {
+            headers: {
+                'Content-Type': 'application/x-www-form-urlencoded'
+            }
+        });
+        return response.data
+    } catch (error) {
+        throw error;
+    }
 }
\ No newline at end of file
diff --git a/src/views/mobile/bedsideAuxiliaryScreen/components/Header.vue b/src/views/mobile/bedsideAuxiliaryScreen/components/Header.vue
index 97c8608..6617912 100644
--- a/src/views/mobile/bedsideAuxiliaryScreen/components/Header.vue
+++ b/src/views/mobile/bedsideAuxiliaryScreen/components/Header.vue
@@ -249,6 +249,7 @@
     !bedsideAuxiliaryScreenStore.deviceData.deviceCode
   )
     return ElMessage.warning("未初始化或正在进行初始化操作中");
+    console.log(loginDialogRef)
     loginDialogRef.value.openDialog();
 };
 
diff --git a/src/views/mobile/bedsideAuxiliaryScreen/components/Login/index.vue b/src/views/mobile/bedsideAuxiliaryScreen/components/Login/index.vue
index 767da55..27dc92f 100644
--- a/src/views/mobile/bedsideAuxiliaryScreen/components/Login/index.vue
+++ b/src/views/mobile/bedsideAuxiliaryScreen/components/Login/index.vue
@@ -59,7 +59,7 @@
     });
 
     const isLoginng = computed(() => {
-      return !!bedsideAuxiliaryScreenStore.userInfo.code;
+      return !!bedsideAuxiliaryScreenStore.userInfo?.code;
     });
 
     const qrCodeData = computed(() => {
@@ -78,13 +78,23 @@
     };
 
     const onLogout = () => {
+      if (state.loading) return ElMessage.warning('正在退出中...')
       ElMessageBox.confirm("是否确认退出当前登录用户?", "提示", {
         confirmButtonText: "确认",
         cancelButtonText: "取消",
         type: "warning",
       })
-        .then(() => {
-            bedsideAuxiliaryScreenStore.logout();
+        .then(async() => {
+            state.loading = true
+            try {
+              await bedsideAuxiliaryScreenStore.logout(bedsideAuxiliaryScreenStore.deviceCode);
+              handleCancel();
+              ElMessage.success('退出登录成功')
+            } catch (error) {
+              ElMessage.success('退出登录失败')
+            } finally {
+              state.loading = false;
+            }
           ElMessage({
             type: "success",
             message: "退出成功!",

--
Gitblit v1.8.0