fix(miniprogram): 预约详情/随访详情改为 API 获取数据,移除 Storage 缓存传递
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user