fix(mp): 小程序页面优化 + E2E 测试报告更新

- 小程序各页面优化和修复
- 更新联调报告和 E2E 测试报告
- 更新 miniprogram wiki
This commit is contained in:
iven
2026-05-15 23:03:21 +08:00
parent ced1c0ad0c
commit c06e986090
24 changed files with 905 additions and 441 deletions

View File

@@ -5,6 +5,8 @@ import { usePageData } from '@/hooks/usePageData';
import { listPatientAlerts, type Alert } from '@/services/alert';
import { useAuthStore } from '@/stores/auth';
import Loading from '@/components/Loading';
import ErrorState from '@/components/ErrorState';
import SegmentTabs from '@/components/SegmentTabs';
import { useElderClass } from '../../../hooks/useElderClass';
import './index.scss';
@@ -30,11 +32,13 @@ export default function PatientAlerts() {
const [page, setPage] = useState(1);
const [status, setStatus] = useState('');
const [loading, setLoading] = useState(false);
const [error, setError] = useState(false);
const fetchAlerts = useCallback(
async (pageNum: number, s: string, isRefresh = false) => {
if (!currentPatient) return;
setLoading(true);
setError(false);
try {
const res = await listPatientAlerts(currentPatient.id, {
page: pageNum,
@@ -50,6 +54,7 @@ export default function PatientAlerts() {
setTotal(res.total);
setPage(pageNum);
} catch {
setError(true);
Taro.showToast({ title: '加载失败', icon: 'none' });
} finally {
setLoading(false);
@@ -74,35 +79,26 @@ export default function PatientAlerts() {
if (!currentPatient) {
return (
<View className={`alerts-page ${modeClass}`}>
<View className='alerts-empty'>
<Text className='alerts-empty-text'></Text>
<View className='alerts-empty-action' onClick={() => Taro.navigateTo({ url: '/pages/pkg-profile/family-add/index' })}>
<Text className='alerts-empty-action-text'></Text>
</View>
</View>
<ErrorState text='请先完善个人档案' onRetry={() => Taro.navigateTo({ url: '/pages/pkg-profile/family-add/index' })} />
</View>
);
}
if (error) {
return (
<View className={`alerts-page ${modeClass}`}>
<SegmentTabs tabs={STATUS_TABS} activeKey={status} onChange={handleTabChange} variant="pill" />
<ErrorState onRetry={() => fetchAlerts(1, status, true)} />
</View>
);
}
return (
<View className={`alerts-page ${modeClass}`}>
<View className='alerts-tabs'>
{STATUS_TABS.map((tab) => (
<View
key={tab.key}
className={`alerts-tab ${status === tab.key ? 'active' : ''}`}
onClick={() => handleTabChange(tab.key)}
>
<Text className={`alerts-tab-text ${status === tab.key ? 'active' : ''}`}>{tab.label}</Text>
</View>
))}
</View>
<SegmentTabs tabs={STATUS_TABS} activeKey={status} onChange={handleTabChange} variant="pill" />
{alerts.length === 0 && !loading ? (
<View className='alerts-empty'>
<Text className='alerts-empty-text'></Text>
<Text className='alerts-empty-hint'></Text>
</View>
<ErrorState text='暂无告警记录' hint='您的各项指标正常' />
) : (
<View className='alerts-list'>
{alerts.map((item) => {

View File

@@ -5,7 +5,9 @@ import { usePageData } from '@/hooks/usePageData';
import { useHealthStore } from '@/stores/health';
import TrendChart from '@/components/TrendChart';
import Loading from '@/components/Loading';
import ErrorState from '@/components/ErrorState';
import EmptyState from '@/components/EmptyState';
import SegmentTabs from '@/components/SegmentTabs';
import { useElderClass } from '../../../hooks/useElderClass';
import './index.scss';
@@ -32,14 +34,17 @@ export default function Trend() {
const [range, setRange] = useState('7d');
const [points, setPoints] = useState<{ date: string; value: number }[]>([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(false);
const getTrend = useHealthStore((s) => s.getTrend);
const fetchTrend = useCallback(async () => {
setLoading(true);
setError(false);
try {
const data = await getTrend(indicator, range);
setPoints(data);
} catch {
setError(true);
setPoints([]);
} finally {
setLoading(false);
@@ -72,25 +77,17 @@ export default function Trend() {
</View>
{/* 时间范围切换 */}
<View className='trange-wrap'>
{RANGE_OPTIONS.map((opt) => (
<View
key={opt.value}
className={`trange-tab ${range === opt.value ? 'trange-tab-active' : ''}`}
onClick={() => setRange(opt.value)}
>
<Text className={`trange-tab-text ${range === opt.value ? 'trange-tab-text-active' : ''}`}>
{opt.label}
</Text>
</View>
))}
</View>
<SegmentTabs tabs={RANGE_OPTIONS.map(o => ({ key: o.value, label: o.label }))} activeKey={range} onChange={setRange} variant="pill" />
{/* ECharts 折线图 */}
{loading ? (
<View className='trend-chart-card'>
<Loading />
</View>
) : error ? (
<View className='trend-chart-card'>
<ErrorState onRetry={fetchTrend} />
</View>
) : points.length === 0 ? (
<View className='trend-chart-card'>
<EmptyState text='暂无趋势数据' />