Files
hms/apps/miniprogram-uniapp/src/pages/profile/index.vue
iven 2c567bd772 fix(mp): T40 UI 审查全量修复 + 设计体系一致性优化
Phase 0 基础设施:
- statusTag.ts: getStatusInlineStyle() 移除内联 borderRadius/padding/fontSize,仅返回 {background, color}
- 新增 SEVERITY_COLORS + getSeverityStyle() + getSeverityLabel() 统一告警严重程度样式
- variables.scss: 新增 9 个语义颜色别名 ($success/$danger/$warning/$info 等)
- mixins.scss: 新增 status-inline mixin 统一状态标签样式
- 7 个消费者页面添加 @include status-inline CSS 补偿

Phase 1 HIGH 修复 (4 页面):
- P46 随访管理: 移除 getTypeStyle() 硬编码 fontSize,替换文字 Loading 为组件
- P45 咨询详情医护: 添加 Loading/ErrorState 三态模板 + error ref
- P02 健康数据: 添加 loading ref + Loading 组件 + 错误 toast 提示
- P48 告警中心: 替换本地 SEVERITY_COLORS/SEVERITY_LABELS 为 statusTag.ts 导出

Phase 2 全局一致性:
- 2.1 触控补全: 17 页面为可点击元素添加 min-height: $touch-min
- 2.2 字号替换: 19 文件 31 处硬编码 px → Design Token CSS 变量
- 2.3 颜色替换: 18 文件 ~50 处硬编码十六进制 → SCSS 语义变量
- 2.4 elder-mode.scss: 新增 9 个选择器到触控放大清单

Phase 3 LOW 修复:
- 3.1 统一 Loading: 21 页面旧式文字加载 → <Loading> 组件
- 3.2 useElderClass: 8 页面补全长者模式 class 绑定
- 3.3 零散修复: 按钮 44px→48px,诊断记录添加 scroll-view 无限加载

同时新增 UniApp (Vue 3 + Vite) 小程序完整代码库 (146 文件)
2026-05-15 11:22:51 +08:00

232 lines
5.4 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<scroll-view scroll-y class="profile-scroll">
<view :class="['profile-page', elderClass]">
<!-- 已登录 -->
<template v-if="authStore.user">
<!-- 用户信息卡片 -->
<view class="profile-card">
<view class="avatar">
<text class="avatar-text">{{ (authStore.user.display_name || authStore.user.username || '?')[0] }}</text>
</view>
<text class="profile-name">{{ authStore.user.display_name || authStore.user.username }}</text>
<text class="profile-phone">{{ authStore.user.phone || '' }}</text>
</view>
<!-- 患者切换 -->
<view v-if="authStore.patients.length > 0" class="card patient-card">
<text class="section-title">就诊人</text>
<view v-for="p in authStore.patients" :key="p.id"
:class="['patient-item', { active: authStore.currentPatient?.id === p.id }]"
@tap="authStore.setCurrentPatient(p)"
>
<text class="patient-name">{{ p.name }}</text>
<text class="patient-relation">{{ p.relation }}</text>
</view>
</view>
<!-- 菜单 -->
<view class="card menu-card">
<view class="menu-item" @tap="navigateTo('/pages-sub/appointment/index')">
<text class="menu-label">我的预约</text>
<text class="menu-arrow"></text>
</view>
<view class="menu-item" @tap="navigateTo('/pages-sub/consultation/index')">
<text class="menu-label">我的咨询</text>
<text class="menu-arrow"></text>
</view>
<view class="menu-item" @tap="navigateTo('/pages-sub/mall/index')">
<text class="menu-label">积分商城</text>
<text class="menu-arrow"></text>
</view>
<view class="menu-item" @tap="navigateTo('/pages-sub/article/index')">
<text class="menu-label">健康文章</text>
<text class="menu-arrow"></text>
</view>
<view class="menu-item" @tap="uiStore.toggleElderMode()">
<text class="menu-label">{{ uiStore.elderMode ? '退出关怀模式' : '关怀模式' }}</text>
<text class="menu-arrow">{{ uiStore.elderMode ? '✓' : '' }}</text>
</view>
</view>
<!-- 退出登录 -->
<view class="logout-btn" @tap="handleLogout">
退出登录
</view>
</template>
<!-- 未登录 -->
<template v-else>
<view class="guest-profile">
<view class="avatar avatar-placeholder">
<text class="avatar-text">?</text>
</view>
<text class="guest-text">未登录</text>
<view class="guest-login-btn" @tap="navigateTo('/pages/login/index')">
去登录
</view>
</view>
</template>
</view>
</scroll-view>
</template>
<script setup lang="ts">
import { onMounted } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { useAuthStore } from '@/stores/auth'
import { useUIStore } from '@/stores/ui'
import { useElderClass } from '@/composables/useElderClass'
const authStore = useAuthStore()
const uiStore = useUIStore()
const { elderClass } = useElderClass()
function navigateTo(url: string) {
uni.navigateTo({ url })
}
function handleLogout() {
uni.showModal({
title: '确认退出',
content: '确定要退出登录吗?',
success: (res: any) => {
if (res.confirm) authStore.logout()
},
})
}
onShow(() => {
authStore.restore()
if (authStore.user) authStore.loadPatients()
})
</script>
<style lang="scss" scoped>
.profile-scroll {
height: 100vh;
background: $bg;
}
.profile-page {
padding: 28px 24px 120px;
}
.profile-card {
@include flex-center;
flex-direction: column;
background: $card;
border-radius: $r-lg;
padding: 36px 24px;
margin-bottom: 24px;
box-shadow: $shadow-md;
}
.avatar {
width: 96px;
height: 96px;
border-radius: 50%;
background: $pri;
@include flex-center;
margin-bottom: 16px;
}
.avatar-text {
font-size: var(--tk-font-h1);
color: $white;
font-weight: bold;
}
.avatar-placeholder {
background: $bd;
}
.profile-name {
font-size: var(--tk-font-h2);
font-weight: bold;
color: $tx;
}
.profile-phone {
font-size: var(--tk-font-body-sm);
color: $tx3;
margin-top: 4px;
}
.card {
@include card;
}
.section-title {
@include section-title;
}
.patient-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 14px 0;
min-height: $touch-min;
border-bottom: 1px solid $bd-l;
&:last-child { border-bottom: none; }
&.active {
.patient-name { color: $pri; font-weight: 600; }
}
}
.patient-name {
font-size: var(--tk-font-body);
color: $tx;
}
.patient-relation {
font-size: var(--tk-font-body-sm);
color: $tx3;
}
.menu-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 18px 0;
border-bottom: 1px solid $bd-l;
min-height: $menu-item-h;
&:last-child { border-bottom: none; }
}
.menu-label {
font-size: var(--tk-font-body);
color: $tx;
}
.menu-arrow {
font-size: var(--tk-font-h2);
color: $tx3;
}
.logout-btn {
@include btn-outline;
margin-top: 32px;
}
// 未登录
.guest-profile {
@include flex-center;
flex-direction: column;
padding: 80px 0 40px;
}
.guest-text {
font-size: var(--tk-font-body);
color: $tx3;
margin: 16px 0 32px;
}
.guest-login-btn {
@include btn-primary;
width: 200px;
}
</style>