Files
hms/apps/miniprogram-uniapp/src/pages-sub/pkg-profile/family/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

240 lines
5.0 KiB
Vue

<template>
<scroll-view scroll-y class="page-scroll">
<view :class="['family-page', elderClass]">
<text class="family-page-title">就诊人管理</text>
<view class="family-list">
<view
v-for="p in patients"
:key="p.id"
:class="['family-item', { active: authStore.currentPatient?.id === p.id }]"
@tap="handleSelect(p)"
>
<view class="family-avatar">
<text class="family-avatar-text">{{ relationInitial(p.relation || '本人') }}</text>
</view>
<view class="family-info">
<view class="family-name-row">
<text class="family-name">{{ p.name }}</text>
<text v-if="authStore.currentPatient?.id === p.id" class="family-current-tag">当前</text>
</view>
<view class="family-meta">
<text class="family-relation-tag">{{ p.relation || '本人' }}</text>
<text class="family-gender">{{ genderText(p.gender) }}</text>
</view>
</view>
<view class="family-edit" @tap.stop="goToEdit(p)">
<text class="family-edit-text">编辑</text>
</view>
</view>
</view>
<EmptyState v-if="patients.length === 0 && !loading" text="暂无就诊人" />
<view class="family-add-btn" @tap="goToAdd">
<text class="family-add-text">添加就诊人</text>
</view>
</view>
</scroll-view>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { listPatients, Patient } from '@/services/patient'
import { useAuthStore } from '@/stores/auth'
import { useElderClass } from '@/composables/useElderClass'
import EmptyState from '@/components/EmptyState.vue'
const authStore = useAuthStore()
const { elderClass } = useElderClass()
const patients = ref<Patient[]>([])
const loading = ref(false)
async function fetchPatients() {
loading.value = true
try {
const res = await listPatients()
patients.value = res.data || []
} catch {
uni.showToast({ title: '加载失败', icon: 'none' })
} finally {
loading.value = false
}
}
function handleSelect(patient: Patient) {
authStore.setCurrentPatient({
id: patient.id,
name: patient.name,
gender: patient.gender,
birth_date: patient.birth_date,
relation: patient.relation || '本人',
})
uni.showToast({ title: `已切换为 ${patient.name}`, icon: 'success' })
}
function goToAdd() {
uni.navigateTo({ url: '/pages-sub/pkg-profile/family-add/index' })
}
function goToEdit(patient: Patient) {
uni.setStorageSync('edit_patient', patient)
uni.navigateTo({ url: `/pages-sub/pkg-profile/family-add/index?id=${patient.id}` })
}
function genderText(g?: string) {
if (g === 'male') return '男'
if (g === 'female') return '女'
return '未知'
}
function relationInitial(relation: string) {
return relation ? relation.charAt(0) : '本'
}
onShow(() => {
fetchPatients()
})
</script>
<style lang="scss" scoped>
.page-scroll {
height: 100vh;
background: $bg;
}
.family-page {
padding: 32px 24px;
padding-bottom: 160px;
}
.family-page-title {
@include section-title;
padding-left: 4px;
}
.family-list {
display: flex;
flex-direction: column;
gap: 16px;
}
.family-item {
display: flex;
align-items: center;
background: $card;
border-radius: $r;
padding: 24px;
box-shadow: $shadow-sm;
transition: box-shadow 0.2s;
&:active {
box-shadow: $shadow-md;
}
&.active {
box-shadow: $shadow-md;
}
}
.family-avatar {
@include flex-center;
width: 80px;
height: 80px;
border-radius: $r;
background: $pri-l;
flex-shrink: 0;
margin-right: 20px;
}
.family-avatar-text {
font-family: 'Georgia', 'Times New Roman', serif;
font-size: var(--tk-font-num-lg);
font-weight: bold;
color: $pri-d;
}
.family-info {
flex: 1;
display: flex;
flex-direction: column;
min-width: 0;
}
.family-name-row {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 8px;
}
.family-name {
font-size: var(--tk-font-num);
font-weight: bold;
color: $tx;
}
.family-current-tag {
@include tag($pri, $white);
font-size: var(--tk-font-body-sm);
padding: 2px 10px;
}
.family-meta {
display: flex;
align-items: center;
gap: 12px;
}
.family-relation-tag {
@include tag($pri-l, $pri-d);
font-size: var(--tk-font-body);
padding: 2px 12px;
}
.family-gender {
font-size: var(--tk-font-h2);
color: $tx2;
}
.family-edit {
flex-shrink: 0;
margin-left: 16px;
padding: 14px 24px;
border: 1px solid $bd;
border-radius: $r-pill;
min-height: 48px;
@include flex-center;
&:active {
background: $bd-l;
}
}
.family-edit-text {
font-size: var(--tk-font-h2);
color: $tx2;
}
.family-add-btn {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: $pri;
padding: 28px;
text-align: center;
box-shadow: 0 -2px 12px rgba(196, 98, 58, 0.15);
}
.family-add-text {
font-family: 'Georgia', 'Times New Roman', serif;
font-size: var(--tk-font-num);
color: $white;
font-weight: bold;
letter-spacing: 2px;
}
</style>