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:
29
apps/miniprogram-uniapp/src/utils/date.ts
Normal file
29
apps/miniprogram-uniapp/src/utils/date.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
export function formatDate(date: string | Date, fmt = 'YYYY-MM-DD'): string {
|
||||
const d = typeof date === 'string' ? new Date(date) : date
|
||||
const map: Record<string, string> = {
|
||||
'YYYY': String(d.getFullYear()),
|
||||
'MM': String(d.getMonth() + 1).padStart(2, '0'),
|
||||
'DD': String(d.getDate()).padStart(2, '0'),
|
||||
'HH': String(d.getHours()).padStart(2, '0'),
|
||||
'mm': String(d.getMinutes()).padStart(2, '0'),
|
||||
}
|
||||
let result = fmt
|
||||
for (const [k, v] of Object.entries(map)) {
|
||||
result = result.replace(k, v)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
export function getRelativeTime(date: string): string {
|
||||
const now = Date.now()
|
||||
const target = new Date(date).getTime()
|
||||
const diff = now - target
|
||||
const minutes = Math.floor(diff / 60000)
|
||||
if (minutes < 1) return '刚刚'
|
||||
if (minutes < 60) return `${minutes}分钟前`
|
||||
const hours = Math.floor(minutes / 60)
|
||||
if (hours < 24) return `${hours}小时前`
|
||||
const days = Math.floor(hours / 24)
|
||||
if (days < 30) return `${days}天前`
|
||||
return formatDate(date)
|
||||
}
|
||||
17
apps/miniprogram-uniapp/src/utils/elder-toast.ts
Normal file
17
apps/miniprogram-uniapp/src/utils/elder-toast.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { useUIStore } from '../stores/ui'
|
||||
|
||||
export function showToast(options: {
|
||||
title: string
|
||||
icon?: 'success' | 'error' | 'loading' | 'none'
|
||||
duration?: number
|
||||
mask?: boolean
|
||||
}) {
|
||||
const { elderMode } = useUIStore()
|
||||
const duration = options.duration ?? (elderMode ? 3000 : 1500)
|
||||
|
||||
if (elderMode) {
|
||||
try { uni.vibrateShort({ type: 'light' } as any) } catch { /* ignore */ }
|
||||
}
|
||||
|
||||
uni.showToast({ ...options, duration, icon: options.icon ?? 'none' } as any)
|
||||
}
|
||||
15
apps/miniprogram-uniapp/src/utils/navigate.ts
Normal file
15
apps/miniprogram-uniapp/src/utils/navigate.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
export function navigateTo(url: string) {
|
||||
uni.navigateTo({ url })
|
||||
}
|
||||
|
||||
export function redirectTo(url: string) {
|
||||
uni.redirectTo({ url })
|
||||
}
|
||||
|
||||
export function switchTab(url: string) {
|
||||
uni.switchTab({ url })
|
||||
}
|
||||
|
||||
export function goBack(delta = 1) {
|
||||
uni.navigateBack({ delta })
|
||||
}
|
||||
28
apps/miniprogram-uniapp/src/utils/secure-storage.ts
Normal file
28
apps/miniprogram-uniapp/src/utils/secure-storage.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* 安全存储工具 — 小程序版本
|
||||
* 当加密密钥未配置时,降级为明文存储(与 Storage 直接操作一致)
|
||||
* 如需加密,可接入微信小程序原生加密 API 或后端加密
|
||||
*/
|
||||
|
||||
function encrypt(plaintext: string): string {
|
||||
// 小程序环境暂不启用客户端加密,敏感数据通过 HTTPS 传输 + 后端加密保护
|
||||
return plaintext
|
||||
}
|
||||
|
||||
function decrypt(ciphertext: string): string | null {
|
||||
return ciphertext
|
||||
}
|
||||
|
||||
export function secureSet(key: string, value: string): void {
|
||||
uni.setStorageSync(key, encrypt(value))
|
||||
}
|
||||
|
||||
export function secureGet(key: string): string {
|
||||
const raw = uni.getStorageSync(key)
|
||||
if (!raw || typeof raw !== 'string') return ''
|
||||
return decrypt(raw) ?? ''
|
||||
}
|
||||
|
||||
export function secureRemove(key: string): void {
|
||||
uni.removeStorageSync(key)
|
||||
}
|
||||
101
apps/miniprogram-uniapp/src/utils/statusTag.ts
Normal file
101
apps/miniprogram-uniapp/src/utils/statusTag.ts
Normal file
@@ -0,0 +1,101 @@
|
||||
const COLORS = {
|
||||
pri: '#C4623A',
|
||||
priLight: '#F0DDD4',
|
||||
acc: '#5B7A5E',
|
||||
accLight: '#E8F0E8',
|
||||
wrn: '#C4873A',
|
||||
wrnLight: '#FFF3E0',
|
||||
dan: '#B54A4A',
|
||||
danLight: '#FDEAEA',
|
||||
tx3: '#78716C',
|
||||
neutralBg: '#F1F5F9',
|
||||
} as const
|
||||
|
||||
export interface StatusStyle {
|
||||
background: string
|
||||
color: string
|
||||
}
|
||||
|
||||
const STATUS_COLORS: Record<string, StatusStyle> = {
|
||||
pending: { background: COLORS.wrnLight, color: COLORS.wrn },
|
||||
confirmed: { background: COLORS.priLight, color: COLORS.pri },
|
||||
completed: { background: COLORS.accLight, color: COLORS.acc },
|
||||
cancelled: { background: COLORS.neutralBg, color: COLORS.tx3 },
|
||||
no_show: { background: COLORS.danLight, color: COLORS.dan },
|
||||
overdue: { background: COLORS.danLight, color: COLORS.dan },
|
||||
in_progress: { background: COLORS.priLight, color: COLORS.pri },
|
||||
waiting: { background: COLORS.wrnLight, color: COLORS.wrn },
|
||||
active: { background: COLORS.accLight, color: COLORS.acc },
|
||||
closed: { background: COLORS.neutralBg, color: COLORS.tx3 },
|
||||
info: { background: COLORS.neutralBg, color: COLORS.tx3 },
|
||||
warning: { background: COLORS.wrnLight, color: COLORS.wrn },
|
||||
medium: { background: COLORS.wrnLight, color: COLORS.wrn },
|
||||
critical: { background: COLORS.danLight, color: COLORS.dan },
|
||||
high: { background: COLORS.danLight, color: COLORS.dan },
|
||||
urgent: { background: COLORS.danLight, color: COLORS.dan },
|
||||
acknowledged: { background: COLORS.priLight, color: COLORS.pri },
|
||||
resolved: { background: COLORS.accLight, color: COLORS.acc },
|
||||
dismissed: { background: COLORS.neutralBg, color: COLORS.tx3 },
|
||||
online: { background: COLORS.accLight, color: COLORS.acc },
|
||||
offline: { background: COLORS.neutralBg, color: COLORS.tx3 },
|
||||
paired: { background: COLORS.priLight, color: COLORS.pri },
|
||||
error: { background: COLORS.danLight, color: COLORS.dan },
|
||||
verified: { background: COLORS.accLight, color: COLORS.acc },
|
||||
inactive: { background: COLORS.neutralBg, color: COLORS.tx3 },
|
||||
deceased: { background: COLORS.neutralBg, color: COLORS.tx3 },
|
||||
rejected: { background: COLORS.danLight, color: COLORS.dan },
|
||||
}
|
||||
|
||||
const DEFAULT_STYLE: StatusStyle = { background: COLORS.neutralBg, color: COLORS.tx3 }
|
||||
|
||||
export function getStatusStyle(status: string): StatusStyle {
|
||||
return STATUS_COLORS[status] || DEFAULT_STYLE
|
||||
}
|
||||
|
||||
export function getStatusInlineStyle(status: string) {
|
||||
const s = getStatusStyle(status)
|
||||
return { background: s.background, color: s.color }
|
||||
}
|
||||
|
||||
// ─── 严重程度(告警用) ───
|
||||
|
||||
export interface SeverityStyle {
|
||||
background: string
|
||||
color: string
|
||||
}
|
||||
|
||||
export const SEVERITY_COLORS: Record<string, SeverityStyle> = {
|
||||
info: { background: COLORS.neutralBg, color: COLORS.tx3 },
|
||||
warning: { background: COLORS.wrnLight, color: COLORS.wrn },
|
||||
critical: { background: COLORS.danLight, color: COLORS.dan },
|
||||
urgent: { background: COLORS.dan, color: '#FFFFFF' },
|
||||
}
|
||||
|
||||
export function getSeverityStyle(severity: string) {
|
||||
const s = SEVERITY_COLORS[severity] || SEVERITY_COLORS.info
|
||||
return { background: s.background, color: s.color }
|
||||
}
|
||||
|
||||
const SEVERITY_LABELS: Record<string, string> = {
|
||||
info: '提示', warning: '警告', critical: '严重', urgent: '紧急',
|
||||
}
|
||||
|
||||
export function getSeverityLabel(severity: string): string {
|
||||
return SEVERITY_LABELS[severity] || severity
|
||||
}
|
||||
|
||||
const STATUS_LABELS: Record<string, string> = {
|
||||
pending: '待确认', confirmed: '已确认', completed: '已完成',
|
||||
cancelled: '已取消', no_show: '未到诊', overdue: '逾期',
|
||||
in_progress: '进行中', waiting: '等待中', active: '进行中',
|
||||
closed: '已关闭', info: '提示', warning: '警告',
|
||||
medium: '中等', critical: '严重', high: '严重', urgent: '紧急',
|
||||
acknowledged: '已确认', resolved: '已恢复', dismissed: '已忽略',
|
||||
online: '在线', offline: '离线', paired: '已配对', error: '异常',
|
||||
verified: '已认证', inactive: '停用', deceased: '已故',
|
||||
rejected: '已拒绝',
|
||||
}
|
||||
|
||||
export function getStatusLabel(status: string): string {
|
||||
return STATUS_LABELS[status] || status
|
||||
}
|
||||
49
apps/miniprogram-uniapp/src/utils/validate.ts
Normal file
49
apps/miniprogram-uniapp/src/utils/validate.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
interface NumRule {
|
||||
min?: number
|
||||
max?: number
|
||||
minMsg?: string
|
||||
maxMsg?: string
|
||||
posMsg?: string
|
||||
optional?: boolean
|
||||
}
|
||||
|
||||
interface ValidateResult {
|
||||
ok: boolean
|
||||
message: string
|
||||
}
|
||||
|
||||
export function num(rule: NumRule) {
|
||||
return {
|
||||
safeParse(value: number | undefined): ValidateResult {
|
||||
if (value === undefined || value === null) {
|
||||
return rule.optional ? { ok: true, message: '' } : { ok: false, message: rule.posMsg || '请输入有效数值' }
|
||||
}
|
||||
if (isNaN(value)) return { ok: false, message: '请输入有效数值' }
|
||||
if (rule.min !== undefined && value < rule.min) return { ok: false, message: rule.minMsg || `数值不能低于${rule.min}` }
|
||||
if (rule.max !== undefined && value > rule.max) return { ok: false, message: rule.maxMsg || `数值不能高于${rule.max}` }
|
||||
return { ok: true, message: '' }
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
interface FieldRule {
|
||||
min?: number
|
||||
max?: number
|
||||
minMsg?: string
|
||||
maxMsg?: string
|
||||
optional?: boolean
|
||||
}
|
||||
|
||||
export function validateNum(value: number | undefined, label: string, rule: FieldRule): string | null {
|
||||
if (value === undefined || value === null) return rule.optional ? null : `${label}: 请输入有效数值`
|
||||
if (isNaN(value)) return `${label}: 请输入有效数值`
|
||||
if (rule.min !== undefined && value < rule.min) return `${label}: ${rule.minMsg ?? `数值不能低于${rule.min}`}`
|
||||
if (rule.max !== undefined && value > rule.max) return `${label}: ${rule.maxMsg ?? `数值不能高于${rule.max}`}`
|
||||
return null
|
||||
}
|
||||
|
||||
export function validateStr(value: string | undefined, maxLen: number, label: string): string | null {
|
||||
if (!value) return null
|
||||
if (value.length > maxLen) return `${label}不能超过${maxLen}字`
|
||||
return null
|
||||
}
|
||||
Reference in New Issue
Block a user