diff --git a/apps/miniprogram/src/pages/appointment/index.tsx b/apps/miniprogram/src/pages/appointment/index.tsx index 1a94eb6..89ec36f 100644 --- a/apps/miniprogram/src/pages/appointment/index.tsx +++ b/apps/miniprogram/src/pages/appointment/index.tsx @@ -1,7 +1,7 @@ import React, { useState, useCallback, useRef } from 'react'; import { View, Text } from '@tarojs/components'; import Taro, { useDidShow, useReachBottom, usePullDownRefresh } from '@tarojs/taro'; -import { listAppointments, cancelAppointment } from '../../services/appointment'; +import { listAppointments } from '../../services/appointment'; import type { Appointment } from '../../services/appointment'; import EmptyState from '../../components/EmptyState'; import Loading from '../../components/Loading'; @@ -64,10 +64,6 @@ export default function AppointmentList() { }; const goDetail = (id: string) => { - const item = appointments.find((a) => a.id === id); - if (item) { - Taro.setStorageSync('appointment_detail_cache', item); - } Taro.navigateTo({ url: `/pages/appointment/detail/index?id=${id}` }); }; diff --git a/apps/miniprogram/src/pages/health/input/index.tsx b/apps/miniprogram/src/pages/health/input/index.tsx index bbd0637..649c0bb 100644 --- a/apps/miniprogram/src/pages/health/input/index.tsx +++ b/apps/miniprogram/src/pages/health/input/index.tsx @@ -51,13 +51,25 @@ export default function HealthInput() { const currentIndicator = INDICATORS[indicatorIdx].value; + if (currentIndicator === 'blood_pressure') { + if (!systolic || !diastolic) { + Taro.showToast({ title: '请填写收缩压和舒张压', icon: 'none' }); + return; + } + } else { + if (!value) { + Taro.showToast({ title: '请输入数值', icon: 'none' }); + return; + } + } + const input = currentIndicator === 'blood_pressure' ? { indicator_type: 'blood_pressure' as const, value: parseFloat(systolic), extra: { systolic: parseFloat(systolic), diastolic: parseFloat(diastolic) } } : { indicator_type: currentIndicator as any, value: parseFloat(value) }; const result = vitalSignSchema.safeParse(input); if (!result.success) { - Taro.showToast({ title: result.error.errors[0].message, icon: 'none' }); + Taro.showToast({ title: result.error.issues[0].message, icon: 'none' }); return; } @@ -77,7 +89,7 @@ export default function HealthInput() { }); clearCache(); Taro.showToast({ title: '录入成功', icon: 'success' }); - trackEvent('health_data_input', { type: indicatorType }); + trackEvent('health_data_input', { type: currentIndicator }); setTimeout(() => Taro.navigateBack(), 1000); } catch (e: unknown) { const msg = e instanceof Error ? e.message : '录入失败'; diff --git a/apps/miniprogram/src/pages/profile/followups/index.tsx b/apps/miniprogram/src/pages/profile/followups/index.tsx index 2e2be7b..8f4790d 100644 --- a/apps/miniprogram/src/pages/profile/followups/index.tsx +++ b/apps/miniprogram/src/pages/profile/followups/index.tsx @@ -35,7 +35,6 @@ export default function MyFollowUps() { const handleTabChange = (key: string) => { setActiveTab(key); - setTasks([]); fetchTasks(key); }; diff --git a/apps/miniprogram/src/pages/profile/reports/index.tsx b/apps/miniprogram/src/pages/profile/reports/index.tsx index e5cbd28..eb67c96 100644 --- a/apps/miniprogram/src/pages/profile/reports/index.tsx +++ b/apps/miniprogram/src/pages/profile/reports/index.tsx @@ -6,8 +6,6 @@ import EmptyState from '../../../components/EmptyState'; import Loading from '../../../components/Loading'; import './index.scss'; -const PAGE_SIZE = 20; - export default function MyReports() { const [reports, setReports] = useState([]); const [page, setPage] = useState(1); @@ -16,7 +14,10 @@ export default function MyReports() { const fetchData = useCallback(async (p: number, append = false) => { const patientId = Taro.getStorageSync('current_patient_id') || ''; - if (!patientId) return; + if (!patientId) { + setReports([]); + return; + } setLoading(true); try { const res = await listReports(patientId, p); @@ -80,7 +81,7 @@ export default function MyReports() { {reports.length === 0 && !loading && ( - + )} {loading && ( diff --git a/apps/miniprogram/src/pages/profile/settings/index.tsx b/apps/miniprogram/src/pages/profile/settings/index.tsx index 00e12cb..2052ac3 100644 --- a/apps/miniprogram/src/pages/profile/settings/index.tsx +++ b/apps/miniprogram/src/pages/profile/settings/index.tsx @@ -13,23 +13,21 @@ export default function Settings() { content: '确定要清除本地缓存数据吗?不会影响账号信息。', }).then((res) => { if (res.confirm) { - // 保留登录态和核心设置 - const token = Taro.getStorageSync('access_token'); - const refreshToken = Taro.getStorageSync('refresh_token'); - const user = Taro.getStorageSync('user'); - const currentPatient = Taro.getStorageSync('current_patient'); - const currentPatientId = Taro.getStorageSync('current_patient_id'); - const tenantId = Taro.getStorageSync('tenant_id'); + // 保留登录态和核心设置(使用明确的 key 列表,不依赖明文 token) + const preservedKeys = ['user', 'current_patient', 'current_patient_id', 'tenant_id', 'wechat_openid']; + const preservedData: Record = {}; + for (const key of preservedKeys) { + const val = Taro.getStorageSync(key); + if (val) preservedData[key] = val; + } Taro.clearStorageSync(); - // 恢复登录态 - if (token) Taro.setStorageSync('access_token', token); - if (refreshToken) Taro.setStorageSync('refresh_token', refreshToken); - if (user) Taro.setStorageSync('user', user); - if (currentPatient) Taro.setStorageSync('current_patient', currentPatient); - if (currentPatientId) Taro.setStorageSync('current_patient_id', currentPatientId); - if (tenantId) Taro.setStorageSync('tenant_id', tenantId); + // 恢复非敏感数据 + for (const [key, val] of Object.entries(preservedData)) { + Taro.setStorageSync(key, val); + } + // 安全存储的 token 由 auth store restore() 在下次页面显示时自动恢复 Taro.showToast({ title: '缓存已清除', icon: 'success' }); }