fix(miniprogram): 预约详情/随访详情改为 API 获取数据,移除 Storage 缓存传递

This commit is contained in:
iven
2026-04-24 12:24:49 +08:00
parent 2dc280a401
commit f75bc191e6
4 changed files with 61 additions and 47 deletions

View File

@@ -1,7 +1,10 @@
import React, { useState, useEffect } from 'react';
import { View, Text, Textarea } from '@tarojs/components';
import Taro, { useRouter } from '@tarojs/taro';
import { listTasks, submitRecord, FollowUpTask } from '../../../services/followup';
import { getTaskDetail, submitRecord } from '../../../services/followup';
import type { FollowUpTask } from '../../../services/followup';
import Loading from '../../../components/Loading';
import ErrorState from '../../../components/ErrorState';
import './index.scss';
export default function FollowUpDetail() {
@@ -12,16 +15,17 @@ export default function FollowUpDetail() {
const [content, setContent] = useState('');
const [submitting, setSubmitting] = useState(false);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(false);
useEffect(() => {
if (!id) return;
setLoading(true);
listTasks()
.then((res) => {
const found = (res.data || []).find((t) => t.id === id);
setTask(found || null);
getTaskDetail(id)
.then((data) => setTask(data))
.catch((err) => {
console.error('[FollowUpDetail]', err);
setError(true);
})
.catch(() => Taro.showToast({ title: '加载失败', icon: 'none' }))
.finally(() => setLoading(false));
}, [id]);
@@ -54,19 +58,15 @@ export default function FollowUpDetail() {
if (loading) {
return (
<View className='detail-page'>
<View className='loading-state'>
<Text className='loading-text'>...</Text>
</View>
<Loading />
</View>
);
}
if (!task) {
if (error || !task) {
return (
<View className='detail-page'>
<View className='empty-state'>
<Text className='empty-text'></Text>
</View>
<ErrorState message='任务不存在' />
</View>
);
}
@@ -75,7 +75,6 @@ export default function FollowUpDetail() {
return (
<View className='detail-page'>
{/* 任务详情 */}
<View className='detail-card'>
<Text className='detail-title'>{task.task_type}</Text>
<View className='detail-row'>
@@ -93,7 +92,6 @@ export default function FollowUpDetail() {
)}
</View>
{/* 提交表单 */}
{!isCompleted && (
<View className='submit-card'>
<Text className='section-title'>访</Text>