From 0c994fd068adf276a3f7216dee0a843e78ae0a8c Mon Sep 17 00:00:00 2001
From: zhangchen <1652267879@qq.com>
Date: 星期二, 09 九月 2025 17:04:40 +0800
Subject: [PATCH] ID1766-暂存
---
src/views/mobile/bedsideAuxiliaryScreen/components/Login/userInfo.vue | 8 ++--
src/views/mobile/bedsideAuxiliaryScreen/components/Header.vue | 30 ++++++++++++++
src/store/type/bedsideAuxiliaryScreen.type.ts | 3 +
src/views/mobile/bedsideAuxiliaryScreen/components/Login/index.vue | 2
src/store/bedsideAuxiliaryScreen.ts | 25 +++---------
src/store/type/user.type.ts | 26 ++++++++-----
6 files changed, 59 insertions(+), 35 deletions(-)
diff --git a/src/store/bedsideAuxiliaryScreen.ts b/src/store/bedsideAuxiliaryScreen.ts
index de157fa..d3a6a9c 100644
--- a/src/store/bedsideAuxiliaryScreen.ts
+++ b/src/store/bedsideAuxiliaryScreen.ts
@@ -14,7 +14,7 @@
} from "./type/bedsideAuxiliaryScreen.type";
import { ElMessage } from "element-plus/es";
import { Local } from "@/utils/storage";
-import type { UserInfo } from './type/user.type';
+import type { DeviceLoginRecord } from './type/user.type';
export const useBedsideAuxiliaryScreenStore = defineStore(
"bedsideAuxiliaryScreen",
@@ -32,10 +32,7 @@
const taskData = ref<Task[]>([]);
/** 用户信息 */
- const userInfo = ref<UserInfo | null>(Local.get('userInfo'));
-
- /** 用户token */
- const token = ref<string>(Local.get('token'));
+ const userInfo = ref<DeviceLoginRecord | null>(null);
/** 设置副屏版本号 */
const setVersion = (val: string) => {
@@ -78,23 +75,14 @@
};
/** 设置用户信息 */
- const setUserInfo = (user: UserInfo) => {
+ const setUserInfo = (user: DeviceLoginRecord | null) => {
userInfo.value = user;
- Local.set('userInfo', user);
};
- /** 设置token */
- const setToken = (str: string) => {
- token.value = str;
- Local.set('token', str);
- }
/** 退出登录 */
const logout = () => {
- Local.remove('token');
- Local.remove('userInfo');
- token.value = '';
- userInfo.value = null;
+
};
// SSE 相关状态
@@ -185,6 +173,9 @@
}
deviceData.value = formatDeviceData(deviceData.value, dataBody);
+ // 当前登录的用户信息
+ setUserInfo(dataBody.当前登录状态);
+
// 判断本地的版本号与远程的版本号是否一致,如果不一致则执行刷新操作
if (dataBody.服务端版本号 !== version.value) {
refreshVersion(dataBody.服务端版本号);
@@ -249,9 +240,7 @@
setVersion,
refreshVersion,
userInfo,
- token,
setUserInfo,
- setToken,
logout,
};
}
diff --git a/src/store/type/bedsideAuxiliaryScreen.type.ts b/src/store/type/bedsideAuxiliaryScreen.type.ts
index 2415e3a..de90df1 100644
--- a/src/store/type/bedsideAuxiliaryScreen.type.ts
+++ b/src/store/type/bedsideAuxiliaryScreen.type.ts
@@ -1,6 +1,7 @@
import { tryConvertToInt, deepClone } from "@/utils/utils";
import { Local } from "@/utils/storage";
import dayjs from "dayjs";
+import type { DeviceLoginRecord } from './user.type';
export interface IotInfo {
属性历史列表: any[];
床号: string;
@@ -212,6 +213,7 @@
自定义配置项: Customconfiguration;
服务端版本号: string;
是否需要立即刷新: 0 | 1;
+ 当前登录状态: DeviceLoginRecord | null;
}
interface Customconfiguration {
@@ -513,7 +515,6 @@
signedIn: defaultSignedIn(), // 已签到时需要的数据
underTreatment: defaultUnderTreatment(), // 治疗中需要的数据
sphygmomanometer: defaultSphygmomanometer(), // 血压计传过来的数据
- 患者出生日期: '',
};
};
diff --git a/src/store/type/user.type.ts b/src/store/type/user.type.ts
index da40248..45408d9 100644
--- a/src/store/type/user.type.ts
+++ b/src/store/type/user.type.ts
@@ -1,11 +1,17 @@
-export interface UserInfo {
- 用户头像: string;
- 用户昵称: string;
-}
-
-export const defaultUserInfo = (): UserInfo => {
- return {
- 用户头像: '',
- 用户昵称: ''
- }
+export interface DeviceLoginRecord {
+ clientCode: string;
+ code: string;
+ createTime: string; // 格式:YYYY-MM-DD HH:mm:ss
+ createUser: string | null;
+ deletedTime: string | null;
+ deviceCode: string;
+ id: number;
+ isDeleted: number; // 0/1 标识
+ loginTime: string; // 格式:YYYY-MM-DD HH:mm:ss
+ remark: string | null;
+ token: string | null;
+ updateTime: string; // 格式:YYYY-MM-DD HH:mm:ss
+ updateUser: string | null;
+ userCode: string;
+ userName: string;
}
\ 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 cb20147..97c8608 100644
--- a/src/views/mobile/bedsideAuxiliaryScreen/components/Header.vue
+++ b/src/views/mobile/bedsideAuxiliaryScreen/components/Header.vue
@@ -65,7 +65,8 @@
alt=""
@click="openSettingDeviceDialog"
/>
- <img :src="userImg" class="btn-img" alt="" @click="openLoginDialog" />
+ <img v-if="userInfo?.code" :src="generateCircularAvatar(userInfo.userName)" class="btn-img" alt="" @click="openLoginDialog" />
+ <img v-else :src="userImg" class="btn-img" alt="" @click="openLoginDialog" />
</div>
</div>
<!-- 设置设备编号组件 -->
@@ -164,6 +165,11 @@
}
});
+
+const userInfo = computed(() => {
+ return bedsideAuxiliaryScreenStore.userInfo;
+});
+
watch(
() => bedsideAuxiliaryScreenStore.taskData?.[0]?.countdown,
(val) => {
@@ -246,6 +252,28 @@
loginDialogRef.value.openDialog();
};
+function generateCircularAvatar(name: string, size = 100): string {
+ const canvas = document.createElement('canvas');
+ canvas.width = size;
+ canvas.height = size;
+ const ctx = canvas.getContext('2d')!;
+
+ // 绘制圆形背景
+ ctx.fillStyle = '#dae5ec';
+ ctx.beginPath();
+ ctx.arc(size / 2, size / 2, size / 2, 0, Math.PI * 2);
+ ctx.fill();
+
+ // 绘制文字(第一个字)
+ ctx.fillStyle = '#70a3dd'; // 字体颜色
+ ctx.font = `${size * 0.5}px sans-serif`; // 字体大小为头像大小的一半
+ ctx.textAlign = 'center';
+ ctx.textBaseline = 'middle';
+ ctx.fillText(name.charAt(0), size / 2, size / 2);
+
+ return canvas.toDataURL('image/png'); // 返回 Base64 图片
+}
+
onUnmounted(() => {
clearTimer();
});
diff --git a/src/views/mobile/bedsideAuxiliaryScreen/components/Login/index.vue b/src/views/mobile/bedsideAuxiliaryScreen/components/Login/index.vue
index e39e982..767da55 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.token;
+ return !!bedsideAuxiliaryScreenStore.userInfo.code;
});
const qrCodeData = computed(() => {
diff --git a/src/views/mobile/bedsideAuxiliaryScreen/components/Login/userInfo.vue b/src/views/mobile/bedsideAuxiliaryScreen/components/Login/userInfo.vue
index f5e9fa2..05346b8 100644
--- a/src/views/mobile/bedsideAuxiliaryScreen/components/Login/userInfo.vue
+++ b/src/views/mobile/bedsideAuxiliaryScreen/components/Login/userInfo.vue
@@ -1,7 +1,7 @@
<template>
<div class="userinfo-container">
- <img :src="userInfo.用户头像" alt="" srcset="" class="user-avatar">
- <div class="user-text">当前账户:{{ userInfo.用户昵称 }}</div>
+ <!-- <img :src="userInfo.用户头像" alt="" srcset="" class="user-avatar"> -->
+ <div class="user-text">当前账户:{{ userInfo.userName }}</div>
<div class="user-text">床号:{{ userInfo.床号 }}</div>
<div class="user-text">设备号:{{ userInfo.设备编号 }}</div>
</div>
@@ -10,7 +10,6 @@
<script lang="ts">
import { computed } from "vue";
import { useBedsideAuxiliaryScreenStore } from "@/store/bedsideAuxiliaryScreen";
-import { defaultUserInfo } from '@/store/type/user.type';
export default {
name: "UserInfo",
@@ -18,7 +17,8 @@
const bedsideAuxiliaryScreenStore = useBedsideAuxiliaryScreenStore();
const userInfo = computed(() => {
- const userInfo = bedsideAuxiliaryScreenStore.userInfo || defaultUserInfo();
+ const userInfo = bedsideAuxiliaryScreenStore.userInfo;
+ if (!userInfo) return null;
return {
...userInfo,
床号: bedsideAuxiliaryScreenStore.deviceData.devicdeNo,
--
Gitblit v1.8.0