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 文件)
This commit is contained in:
iven
2026-05-15 11:22:51 +08:00
parent 18fa6ce6d4
commit 2c567bd772
147 changed files with 36561 additions and 564 deletions

View File

@@ -0,0 +1,89 @@
<template>
<view class="device-card" @tap="handleSync">
<view class="device-icon">{{ icon }}</view>
<view class="device-info">
<text class="device-name">{{ deviceName }}</text>
<text class="device-status" :class="statusClass">{{ statusLabel }}</text>
<text v-if="lastSyncAt" class="last-sync">最近同步: {{ lastSyncAt }}</text>
</view>
<view class="sync-btn">同步</view>
</view>
</template>
<script setup lang="ts">
import { computed } from 'vue'
const DEVICE_ICONS: Record<string, string> = {
blood_pressure: '🩺',
blood_glucose: '💉',
heart_rate: '❤️',
blood_oxygen: '🫁',
}
const props = defineProps<{
deviceName: string
deviceType: string
lastSyncAt?: string
status: 'connected' | 'disconnected' | 'never'
}>()
const icon = computed(() => DEVICE_ICONS[props.deviceType] || '📱')
const statusLabel = computed(() => {
const map: Record<string, string> = { connected: '已连接', disconnected: '未连接', never: '未配对' }
return map[props.status] || props.status
})
const statusClass = computed(() => props.status === 'connected' ? 'connected' : 'idle')
function handleSync() {
uni.navigateTo({ url: '/pages-sub/device-sync/index' })
}
</script>
<style lang="scss" scoped>
.device-card {
display: flex;
align-items: center;
background: $card;
border-radius: $r;
padding: 20px 24px;
box-shadow: $shadow-sm;
}
.device-icon {
font-size: 40px;
margin-right: 20px;
}
.device-info {
flex: 1;
}
.device-name {
display: block;
font-size: var(--tk-font-body);
font-weight: 600;
color: $tx;
margin-bottom: 4px;
}
.device-status {
font-size: var(--tk-font-cap);
margin-bottom: 2px;
&.connected { color: $acc; }
&.idle { color: $tx3; }
}
.last-sync {
font-size: var(--tk-font-micro);
color: $tx3;
}
.sync-btn {
background: $pri;
color: $white;
border-radius: $r-pill;
padding: 8px 24px;
font-size: var(--tk-font-body-sm);
}
</style>

View File

@@ -0,0 +1,58 @@
<template>
<view class="ec-canvas-wrap">
<canvas id="ec-canvas" class="ec-canvas" type="2d"
:style="{ width: canvasWidth + 'px', height: canvasHeight + 'px' }" />
</view>
</template>
<script setup lang="ts">
import { onMounted, ref, watch } from 'vue'
const props = withDefaults(defineProps<{
option?: Record<string, any>
width?: number
height?: number
}>(), {
width: 350,
height: 250,
})
const emit = defineEmits<{
(e: 'init', chart: any): void
}>()
const canvasWidth = ref(props.width)
const canvasHeight = ref(props.height)
// Minimal ECharts bridge — for full ECharts, use lime-echart plugin
// This is a placeholder that renders a basic canvas with the option's title
onMounted(() => {
nextTick(initCanvas)
})
function nextTick(fn: () => void) {
setTimeout(fn, 50)
}
function initCanvas() {
const query = uni.createSelectorQuery()
query.select('#ec-canvas').fields({ node: true, size: true }).exec((res) => {
if (!res || !res[0] || !res[0].node) return
emit('init', { canvas: res[0].node, width: res[0].width, height: res[0].height })
})
}
watch(() => props.option, () => {
nextTick(initCanvas)
}, { deep: true })
</script>
<style lang="scss" scoped>
.ec-canvas-wrap {
@include flex-center;
}
.ec-canvas {
display: block;
}
</style>

View File

@@ -0,0 +1,53 @@
<template>
<view class="empty-wrap">
<text class="empty-icon">{{ icon }}</text>
<text class="empty-title">{{ title }}</text>
<text v-if="description" class="empty-desc">{{ description }}</text>
<view v-if="actionText" class="empty-action" @tap="$emit('action')">
{{ actionText }}
</view>
</view>
</template>
<script setup lang="ts">
defineProps<{
icon?: string
title: string
description?: string
actionText?: string
}>()
defineEmits<{ action: [] }>()
</script>
<style lang="scss" scoped>
.empty-wrap {
@include flex-center;
flex-direction: column;
padding: 80px 40px;
}
.empty-icon {
font-size: var(--tk-font-hero);
margin-bottom: 16px;
}
.empty-title {
font-size: var(--tk-font-h2);
color: $tx2;
margin-bottom: 8px;
}
.empty-desc {
font-size: var(--tk-font-body-sm);
color: $tx3;
text-align: center;
}
.empty-action {
@include btn-primary;
margin-top: 32px;
width: auto;
padding: 0 48px;
}
</style>

View File

@@ -0,0 +1,76 @@
<template>
<slot v-if="!hasError" />
<view v-else class="error-boundary">
<view class="error-icon-wrap">
<text class="error-icon-text">!</text>
</view>
<text class="error-title">页面出了点问题</text>
<text class="error-desc">请返回重试</text>
<view class="error-retry-btn" @tap="handleRetry">
<text class="error-retry-text">重新加载</text>
</view>
</view>
</template>
<script setup lang="ts">
import { ref, onErrorCaptured } from 'vue'
const hasError = ref(false)
onErrorCaptured((err) => {
console.error('[ErrorBoundary]', err)
hasError.value = true
return false
})
function handleRetry() {
hasError.value = false
}
</script>
<style lang="scss" scoped>
.error-boundary {
@include flex-center;
flex-direction: column;
padding: 80px 40px;
}
.error-icon-wrap {
width: 80px;
height: 80px;
border-radius: 50%;
background: $dan-l;
@include flex-center;
margin-bottom: 24px;
}
.error-icon-text {
font-size: 40px;
font-weight: bold;
color: $dan;
}
.error-title {
font-size: var(--tk-font-body-lg);
font-weight: 600;
color: $tx;
margin-bottom: 8px;
}
.error-desc {
font-size: var(--tk-font-body-sm);
color: $tx3;
margin-bottom: 32px;
}
.error-retry-btn {
background: $pri;
border-radius: $r-pill;
padding: 16px 48px;
}
.error-retry-text {
color: $white;
font-size: var(--tk-font-body);
}
</style>

View File

@@ -0,0 +1,48 @@
<template>
<view class="error-state">
<text class="error-state-icon">&#x26A0;&#xFE0F;</text>
<text class="error-state-text">{{ text }}</text>
<view v-if="onRetry" class="error-state-retry" @tap="onRetry">
<text class="error-state-retry-text">重新加载</text>
</view>
</view>
</template>
<script setup lang="ts">
withDefaults(defineProps<{
text?: string
onRetry?: () => void
}>(), {
text: '加载失败,请稍后重试',
})
</script>
<style lang="scss" scoped>
.error-state {
@include flex-center;
flex-direction: column;
padding: 80px 40px;
}
.error-state-icon {
font-size: 48px;
margin-bottom: 16px;
}
.error-state-text {
font-size: var(--tk-font-body-sm);
color: $tx3;
margin-bottom: 24px;
}
.error-state-retry {
background: $pri;
border-radius: $r-pill;
padding: 12px 40px;
}
.error-state-retry-text {
color: $white;
font-size: var(--tk-font-body-sm);
}
</style>

View File

@@ -0,0 +1,39 @@
<template>
<view v-if="!authStore.user" class="guest-wrap">
<slot name="guest">
<text class="guest-text">请先登录</text>
<view class="guest-login-btn" @tap="goLogin">去登录</view>
</slot>
</view>
<slot v-else />
</template>
<script setup lang="ts">
import { useAuthStore } from '@/stores/auth'
const authStore = useAuthStore()
function goLogin() {
uni.navigateTo({ url: '/pages/login/index' })
}
</script>
<style lang="scss" scoped>
.guest-wrap {
@include flex-center;
flex-direction: column;
padding: 80px 40px;
}
.guest-text {
font-size: var(--tk-font-body);
color: $tx3;
margin-bottom: 24px;
}
.guest-login-btn {
@include btn-primary;
width: auto;
padding: 0 48px;
}
</style>

View File

@@ -0,0 +1,37 @@
<template>
<view class="loading-wrap">
<view class="loading-spinner" />
<text class="loading-text">{{ text }}</text>
</view>
</template>
<script setup lang="ts">
defineProps<{ text?: string }>()
</script>
<style lang="scss" scoped>
.loading-wrap {
@include flex-center;
flex-direction: column;
padding: 80px 0;
}
.loading-spinner {
width: 48px;
height: 48px;
border: 4px solid $bd;
border-top-color: $pri;
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
.loading-text {
margin-top: 20px;
color: $tx3;
font-size: var(--tk-font-body-sm);
}
@keyframes spin {
to { transform: rotate(360deg); }
}
</style>

View File

@@ -0,0 +1,67 @@
<template>
<view class="progress-ring" :style="{ width: size + 'px', height: size + 'px' }">
<svg :width="size" :height="size" :viewBox="`0 0 ${size} ${size}`">
<circle
:cx="size / 2" :cy="size / 2" :r="radius"
fill="none" :stroke="bgColor" :stroke-width="strokeWidth"
/>
<circle
:cx="size / 2" :cy="size / 2" :r="radius"
fill="none" :stroke="color" :stroke-width="strokeWidth"
:stroke-dasharray="circumference"
:stroke-dashoffset="offset"
stroke-linecap="round"
:transform="`rotate(-90 ${size / 2} ${size / 2})`"
/>
</svg>
<view class="progress-text">
<text class="progress-value">{{ Math.round(percent) }}</text>
<text class="progress-unit">%</text>
</view>
</view>
</template>
<script setup lang="ts">
import { computed } from 'vue'
const props = withDefaults(defineProps<{
percent: number
size?: number
strokeWidth?: number
color?: string
bgColor?: string
}>(), {
size: 120,
strokeWidth: 8,
color: '#C4623A',
bgColor: '#E8E2DC',
})
const radius = computed(() => (props.size - props.strokeWidth) / 2)
const circumference = computed(() => 2 * Math.PI * radius.value)
const offset = computed(() => circumference.value * (1 - props.percent / 100))
</script>
<style lang="scss" scoped>
.progress-ring {
position: relative;
@include flex-center;
}
.progress-text {
position: absolute;
@include flex-center;
}
.progress-value {
font-size: var(--tk-font-num);
font-weight: bold;
color: $tx;
}
.progress-unit {
font-size: var(--tk-font-body-sm);
color: $tx3;
margin-left: 2px;
}
</style>

View File

@@ -0,0 +1,96 @@
<template>
<view class="step-indicator">
<view v-for="(step, idx) in steps" :key="step.label" class="step-item">
<view v-if="idx > 0" class="step-line" :class="{ 'step-line-done': idx < current }" />
<view class="step-dot"
:class="{ 'step-current': idx === current, 'step-done': idx < current }"
@tap="idx < current && onChange && onChange(idx)">
<text v-if="idx < current" class="step-check">&#x2713;</text>
<text v-else class="step-num">{{ idx + 1 }}</text>
</view>
<text class="step-label" :class="{ 'step-current': idx === current, 'step-done': idx < current }">
{{ step.label }}
</text>
</view>
</view>
</template>
<script setup lang="ts">
defineProps<{
steps: { label: string }[]
current: number
onChange?: (index: number) => void
}>()
</script>
<style lang="scss" scoped>
.step-indicator {
display: flex;
align-items: flex-start;
justify-content: center;
padding: 16px 0;
}
.step-item {
@include flex-center;
flex-direction: column;
align-items: center;
flex: 1;
position: relative;
}
.step-line {
position: absolute;
top: 18px;
left: -50%;
width: 100%;
height: 2px;
background: $bd-l;
}
.step-line-done {
background: $pri;
}
.step-dot {
width: 36px;
height: 36px;
border-radius: 50%;
border: 2px solid $bd-l;
@include flex-center;
margin-bottom: 8px;
background: $white;
}
.step-current {
border-color: $pri;
&.step-dot { background: $pri; }
&.step-label { color: $pri; font-weight: 600; }
}
.step-done {
border-color: $pri;
background: $pri;
&.step-label { color: $acc; }
}
.step-check {
color: $white;
font-size: 18px;
}
.step-num {
font-size: var(--tk-font-body-sm);
color: $tx3;
}
.step-label {
font-size: var(--tk-font-micro);
color: $tx3;
text-align: center;
max-width: 80px;
white-space: nowrap;
}
</style>

View File

@@ -0,0 +1,175 @@
<template>
<view v-if="!data || data.length === 0" class="trend-chart-empty">
<text class="trend-chart-empty-text">暂无数据</text>
</view>
<view v-else class="trend-chart" :style="{ height: (height || 500) + 'rpx' }">
<canvas type="2d" id="trend-chart-canvas" class="trend-canvas"
:style="{ width: '100%', height: '100%' }" />
</view>
</template>
<script setup lang="ts">
import { watch, onMounted, nextTick, ref } from 'vue'
const props = withDefaults(defineProps<{
data: { date: string; value: number }[]
referenceMin?: number
referenceMax?: number
unit?: string
height?: number
}>(), {
unit: '',
height: 500,
})
const canvasReady = ref(false)
function drawLine(ctx: any, points: { x: number; y: number }[]) {
if (points.length < 2) return
ctx.beginPath()
ctx.moveTo(points[0].x, points[0].y)
for (let i = 1; i < points.length; i++) {
const prev = points[i - 1]
const curr = points[i]
const cpx = (prev.x + curr.x) / 2
ctx.bezierCurveTo(cpx, prev.y, cpx, curr.y, curr.x, curr.y)
}
ctx.stroke()
}
function draw() {
if (!props.data || props.data.length === 0) return
const query = uni.createSelectorQuery()
query.select('#trend-chart-canvas').fields({ node: true, size: true }).exec((res) => {
if (!res || !res[0] || !res[0].node) return
const canvas = res[0].node
const ctx = canvas.getContext('2d')
const dpr = uni.getSystemInfoSync().pixelRatio || 2
const w = res[0].width
const h = res[0].height
canvas.width = w * dpr
canvas.height = h * dpr
ctx.scale(dpr, dpr)
const pad = { top: 20, right: 16, bottom: 32, left: 48 }
const cw = w - pad.left - pad.right
const ch = h - pad.top - pad.bottom
const values = props.data.map(d => d.value)
let yMin = Math.min(...values)
let yMax = Math.max(...values)
if (props.referenceMin !== undefined) yMin = Math.min(yMin, props.referenceMin)
if (props.referenceMax !== undefined) yMax = Math.max(yMax, props.referenceMax)
const yPad = (yMax - yMin) * 0.1 || 1
yMin -= yPad
yMax += yPad
ctx.clearRect(0, 0, w, h)
// Reference band
if (props.referenceMin !== undefined && props.referenceMax !== undefined) {
const ry1 = pad.top + ch * (1 - (props.referenceMax - yMin) / (yMax - yMin))
const ry2 = pad.top + ch * (1 - (props.referenceMin - yMin) / (yMax - yMin))
ctx.fillStyle = 'rgba(91, 122, 94, 0.1)'
ctx.fillRect(pad.left, ry1, cw, ry2 - ry1)
}
// Grid lines
ctx.strokeStyle = '#e5e5e5'
ctx.lineWidth = 0.5
for (let i = 0; i <= 4; i++) {
const y = pad.top + (ch / 4) * i
ctx.beginPath()
ctx.moveTo(pad.left, y)
ctx.lineTo(pad.left + cw, y)
ctx.stroke()
const val = yMax - ((yMax - yMin) / 4) * i
ctx.fillStyle = '#78716C'
ctx.font = '10px sans-serif'
ctx.textAlign = 'right'
ctx.fillText(val.toFixed(1), pad.left - 6, y + 3)
}
// X labels
ctx.textAlign = 'center'
ctx.fillStyle = '#78716C'
ctx.font = '10px sans-serif'
const step = Math.max(1, Math.floor(props.data.length / 6))
for (let i = 0; i < props.data.length; i += step) {
const x = pad.left + (cw / Math.max(1, props.data.length - 1)) * i
ctx.fillText(props.data[i].date.slice(5), x, h - 8)
}
// Data points
const points = props.data.map((d, i) => ({
x: pad.left + (cw / Math.max(1, props.data.length - 1)) * i,
y: pad.top + ch * (1 - (d.value - yMin) / (yMax - yMin)),
}))
// Area fill
ctx.beginPath()
ctx.moveTo(points[0].x, points[0].y)
for (let i = 1; i < points.length; i++) {
const cpx = (points[i - 1].x + points[i].x) / 2
ctx.bezierCurveTo(cpx, points[i - 1].y, cpx, points[i].y, points[i].x, points[i].y)
}
ctx.lineTo(points[points.length - 1].x, pad.top + ch)
ctx.lineTo(points[0].x, pad.top + ch)
ctx.closePath()
const grad = ctx.createLinearGradient(0, pad.top, 0, pad.top + ch)
grad.addColorStop(0, 'rgba(196, 98, 58, 0.3)')
grad.addColorStop(1, 'rgba(196, 98, 58, 0.02)')
ctx.fillStyle = grad
ctx.fill()
// Line
ctx.strokeStyle = '#C4623A'
ctx.lineWidth = 2
drawLine(ctx, points)
// Dots
for (let i = 0; i < points.length; i++) {
const d = props.data[i]
const outOfRange =
(props.referenceMin !== undefined && d.value < props.referenceMin) ||
(props.referenceMax !== undefined && d.value > props.referenceMax)
ctx.beginPath()
ctx.arc(points[i].x, points[i].y, outOfRange ? 5 : 3, 0, Math.PI * 2)
ctx.fillStyle = outOfRange ? '#B54A4A' : '#C4623A'
ctx.fill()
}
})
}
onMounted(() => {
nextTick(() => { canvasReady.value = true; draw() })
})
watch(() => [props.data, props.referenceMin, props.referenceMax], () => {
if (canvasReady.value) nextTick(draw)
})
</script>
<style lang="scss" scoped>
.trend-chart {
background: $card;
border-radius: $r;
padding: 16px;
box-shadow: $shadow-sm;
}
.trend-canvas {
display: block;
}
.trend-chart-empty {
@include flex-center;
padding: 40px;
}
.trend-chart-empty-text {
font-size: var(--tk-font-body-sm);
color: $tx3;
}
</style>

View File

@@ -0,0 +1,152 @@
<template>
<view class="week-calendar">
<view class="week-nav">
<text class="week-arrow" @tap="weekOffset--">&#x25C0;</text>
<text class="week-label">{{ dates[0]?.slice(5) }} ~ {{ dates[6]?.slice(5) }}</text>
<text class="week-arrow" @tap="weekOffset++">&#x25B6;</text>
</view>
<view class="week-grid">
<view v-for="(day, idx) in WEEKDAYS" :key="dates[idx]"
class="week-cell"
:class="{
'cell-selected': dates[idx] === selectedDate,
'cell-empty': !isScheduled(dates[idx]),
'cell-past': dates[idx] < today
}"
@tap="onCellTap(dates[idx])">
<text class="cell-weekday">{{ day }}</text>
<text class="cell-date" :class="{ 'cell-today': dates[idx] === today }">
{{ parseInt(dates[idx]?.slice(8) || '0') }}
</text>
<view v-if="isScheduled(dates[idx])" class="cell-dot" />
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { ref, computed } from 'vue'
const props = defineProps<{
scheduledDates: string[]
selectedDate: string
}>()
const emit = defineEmits<{
(e: 'selectDate', date: string): void
}>()
const WEEKDAYS = ['一', '二', '三', '四', '五', '六', '日']
const weekOffset = ref(0)
const today = computed(() => {
const d = new Date()
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`
})
const dates = computed(() => {
const result: string[] = []
const now = new Date()
const monday = new Date(now)
monday.setDate(now.getDate() - ((now.getDay() + 6) % 7) + weekOffset.value * 7)
for (let i = 0; i < 7; i++) {
const d = new Date(monday)
d.setDate(monday.getDate() + i)
result.push(`${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`)
}
return result
})
function isScheduled(date: string): boolean {
return props.scheduledDates.includes(date)
}
function onCellTap(date: string) {
if (isScheduled(date) && date >= today.value) {
emit('selectDate', date)
}
}
</script>
<style lang="scss" scoped>
.week-calendar {
background: $card;
border-radius: $r;
padding: 20px 16px;
box-shadow: $shadow-sm;
}
.week-nav {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
}
.week-arrow {
font-size: 28px;
color: $pri;
padding: 8px 16px;
}
.week-label {
font-size: var(--tk-font-body-sm);
color: $tx2;
font-weight: 600;
}
.week-grid {
display: flex;
justify-content: space-around;
}
.week-cell {
@include flex-center;
flex-direction: column;
flex: 1;
padding: 8px 0;
border-radius: $r-sm;
transition: background 0.2s;
}
.cell-weekday {
font-size: var(--tk-font-micro);
color: $tx3;
margin-bottom: 4px;
}
.cell-date {
font-size: var(--tk-font-body-sm);
color: $tx;
font-weight: 600;
margin-bottom: 4px;
}
.cell-today {
color: $pri;
}
.cell-dot {
width: 6px;
height: 6px;
border-radius: 50%;
background: $pri;
}
.cell-selected {
background: $pri-l;
.cell-date { color: $pri-d; }
.cell-dot { background: $pri-d; }
}
.cell-empty {
opacity: 0.4;
}
.cell-past {
opacity: 0.5;
.cell-dot { background: $tx3; }
}
</style>