Skip to content

Let's use AI to Earn!

任务市场

DESKTOP-ZTS2NQJNAcb418c2d9bf5
diff --git a/src/views/task/carTask.tsx b/src/views/task/carTask.tsx
index 77abcb84..ff442227 100644
--- a/src/views/task/carTask.tsx
+++ b/src/views/task/carTask.tsx
@@ -80,9 +80,19 @@ export default function Page() {
return reward.toFixed(2);
};
+ // 刷新任务列表的函数
+ const refreshTaskList = () => {
+ setPageInfo({
+ pageSize: 9,
+ pageNo: 1,
+ totalCount: 0,
+ });
+ getTaskList();
+ };
+
return (
<div className={styles.taskListContainer}>
- <TaskInfo ref={Ref_TaskInfo} />
+ <TaskInfo ref={Ref_TaskInfo} onTaskApplied={refreshTaskList} />
<div className={styles.productGridContainer}>
<div className={styles.productGrid}>
@@ -164,7 +174,7 @@ export default function Page() {
className={styles.applyButton}
onClick={() => Ref_TaskInfo.current?.init(task)}
>
- 报名
+ 报名
</Button>
</div>
</div>
diff --git a/src/views/task/components/carInfo.tsx b/src/views/task/components/carInfo.tsx
index 1bcf00a3..40daae7c 100644
--- a/src/views/task/components/carInfo.tsx
+++ b/src/views/task/components/carInfo.tsx
@@ -21,6 +21,9 @@ const Com = forwardRef<TaskInfoRef>((props: any, ref) => {
const [isModalOpen, setIsModalOpen] = useState(false);
const [taskInfo, setTaskInfo] = useState<Task<TaskProduct> | null>();
+ // 从props中获取刷新函数
+ const { onTaskApplied } = props;
+
async function init(inTaskInfo: Task<TaskProduct>) {
setTaskInfo(inTaskInfo);
setIsModalOpen(true);
@@ -43,8 +46,11 @@ const Com = forwardRef<TaskInfoRef>((props: any, ref) => {
// 添加成功提示
message.success('任务接受成功,请前往我的任务查看');
-
+ // 调用父组件传递的刷新函数
+ if (onTaskApplied && typeof onTaskApplied === 'function') {
+ onTaskApplied();
+ }
} catch (error) {
console.error('接受任务失败:', error);
message.error('接受任务失败,请重试');
diff --git a/src/views/task/components/mineInfo.tsx b/src/views/task/components/mineInfo.tsx
index 962ef488..bb785792 100644
--- a/src/views/task/components/mineInfo.tsx
+++ b/src/views/task/components/mineInfo.tsx
@@ -59,6 +59,9 @@ const Com = forwardRef<MineTaskInfoRef>((props: any, ref) => {
const [form] = Form.useForm();
const [submitting, setSubmitting] = useState(false);
const [fileList, setFileList] = useState<any[]>([]);
+
+ // 从props中获取刷新函数
+ const { onTaskSubmitted } = props;
async function init(
inData: UserTask<Task<TaskProduct | TaskPromotion | TaskVideo>>,
@@ -130,6 +133,11 @@ const Com = forwardRef<MineTaskInfoRef>((props: any, ref) => {
message.success('任务提交成功!');
setIsModalOpen(false);
+
+ // 调用父组件传递的刷新函数
+ if (onTaskSubmitted && typeof onTaskSubmitted === 'function') {
+ onTaskSubmitted();
+ }
} catch (error) {
console.error('提交任务失败', error);
message.error('提交任务失败,请检查表单并重试');
diff --git a/src/views/task/components/popInfo.tsx b/src/views/task/components/popInfo.tsx
index 5f9ae0b0..732f2ab0 100644
--- a/src/views/task/components/popInfo.tsx
+++ b/src/views/task/components/popInfo.tsx
@@ -34,6 +34,9 @@ const Com = forwardRef<TaskInfoRef>((props: any, ref) => {
const [isModalOpen, setIsModalOpen] = useState(false);
const [taskInfo, setTaskInfo] = useState<Task<TaskPromotion> | null>();
+ // 从props中获取刷新函数
+ const { onTaskApplied } = props;
+
async function init(inTaskInfo: Task<TaskPromotion>) {
setTaskInfo(inTaskInfo);
setIsModalOpen(true);
@@ -54,6 +57,11 @@ const Com = forwardRef<TaskInfoRef>((props: any, ref) => {
setTaskInfo(res);
message.success('任务接受成功!');
setIsModalOpen(false);
+
+ // 调用父组件传递的刷新函数
+ if (onTaskApplied && typeof onTaskApplied === 'function') {
+ onTaskApplied();
+ }
} catch (error) {
message.error('接受任务失败,请稍后再试');
}
@@ -214,15 +222,29 @@ const Com = forwardRef<TaskInfoRef>((props: any, ref) => {
>
取消
</Button>
- <Button
- key="submit"
- type="primary"
- onClick={taskApply}
- className={styles.applyButton}
- style={{ backgroundColor: '#a66ae4' }}
- >
- 接受任务
- </Button>
+ {
+ taskInfo.isAccepted ? (
+ <Button
+ key="submit"
+ type="primary"
+ disabled
+ className={styles.applyButton}
+ style={{ backgroundColor: '#a66ae4' }}
+ >
+ 已经接受任务
+ </Button>
+ ) : (
+ <Button
+ key="submit"
+ type="primary"
+ onClick={taskApply}
+ className={styles.applyButton}
+ style={{ backgroundColor: '#a66ae4' }}
+ >
+ 接受任务
+ </Button>
+ )
+ }
</div>
</div>
</div>
diff --git a/src/views/task/components/videoInfo.tsx b/src/views/task/components/videoInfo.tsx
index 55823b06..4cabd3f1 100644
--- a/src/views/task/components/videoInfo.tsx
+++ b/src/views/task/components/videoInfo.tsx
@@ -59,6 +59,9 @@ const Com = forwardRef<TaskInfoRef>((props: any, ref) => {
taskId: string;
} | null>(null);
+ // 从props中获取刷新函数
+ const { onTaskApplied } = props;
+
async function init(inTaskInfo: Task<TaskVideo>) {
setTaskInfo(inTaskInfo);
setIsModalOpen(true);
@@ -82,6 +85,11 @@ const Com = forwardRef<TaskInfoRef>((props: any, ref) => {
message.success('任务接受成功!');
setIsModalOpen(false);
setChooseAccountOpen(true);
+
+ // 调用父组件传递的刷新函数
+ if (onTaskApplied && typeof onTaskApplied === 'function') {
+ onTaskApplied();
+ }
} else {
message.error(res.msg || '接受任务失败,请稍后再试?');
}
@@ -415,7 +423,7 @@ const Com = forwardRef<TaskInfoRef>((props: any, ref) => {
>
{taskInfo.isAccepted ? '已接受任务' : '接受任务'}
</Button>
- </div>
+ </div>
</div>
</div>
) : (
diff --git a/src/views/task/mineTask.tsx b/src/views/task/mineTask.tsx
index ee763d03..86b63fac 100644
--- a/src/views/task/mineTask.tsx
+++ b/src/views/task/mineTask.tsx
@@ -194,7 +194,7 @@ export default function Page() {
};
// 如果没有选择状态筛选,则不传status参数
- if (statusFilter === null) {
+ if (statusFilter === null) {
delete (params as any).status;
}
@@ -275,9 +275,19 @@ export default function Page() {
Ref_MineTaskInfo.current?.init(task);
};
+ // 刷新任务列表的函数
+ const refreshTaskList = () => {
+ setPageInfo({
+ pageSize: 10,
+ pageNo: 1,
+ totalCount: 0,
+ });
+ fetchTaskDetails();
+ };
+
return (
<div className={styles.mineTaskContainer}>
- <MineTaskInfo ref={Ref_MineTaskInfo} />
+ <MineTaskInfo ref={Ref_MineTaskInfo} onTaskSubmitted={refreshTaskList} />
<Withdraw ref={Ref_Withdraw} />
<div className={styles.pageHeader}>
diff --git a/src/views/task/popTask.tsx b/src/views/task/popTask.tsx
index ff95d578..6ece5154 100644
--- a/src/views/task/popTask.tsx
+++ b/src/views/task/popTask.tsx
@@ -50,7 +50,7 @@ export default function Page() {
setPageInfo((prev) => ({
...prev,
- totalCount: (res as any).totalCount,
+ totalCount: (res as any).totalCount,
}));
// 检查是否还有更多数据
@@ -93,9 +93,19 @@ export default function Page() {
});
};
+ // 刷新任务列表的函数
+ const refreshTaskList = () => {
+ setPageInfo({
+ pageSize: 10,
+ pageNo: 1,
+ totalCount: 0,
+ });
+ getTaskList();
+ };
+
return (
<div className={styles.popTaskContainer}>
- <TaskInfo ref={Ref_TaskInfo} />
+ <TaskInfo ref={Ref_TaskInfo} onTaskApplied={refreshTaskList} />
<div className={styles.taskList}>
{taskList.map((task) => (
diff --git a/src/views/task/videoTask.tsx b/src/views/task/videoTask.tsx
index 7ac50a4e..6b5163c3 100644
--- a/src/views/task/videoTask.tsx
+++ b/src/views/task/videoTask.tsx
@@ -164,9 +164,19 @@ export default function Page() {
setVideoPlayback((prev) => ({ ...prev, visible: false }));
};
+ // 刷新任务列表的函数
+ const refreshTaskList = () => {
+ setPageInfo({
+ pageSize: 10,
+ pageNo: 1,
+ totalCount: 0,
+ });
+ getTaskList();
+ };
+
return (
<div className={styles.videoTaskContainer}>
- <TaskInfo ref={Ref_TaskInfo} />
+ <TaskInfo ref={Ref_TaskInfo} onTaskApplied={refreshTaskList} />
{/* 添加视频播放组件 */}
<VideoPlayer
@@ -273,7 +283,7 @@ export default function Page() {
onClick={() => Ref_TaskInfo.current?.init(task)}
style={{ backgroundColor: '#a66ae4', borderColor: '#a66ae4' }}
>
- 去查看 <RightOutlined />
+ 去查看 <RightOutlined />
</Button>
</div>
</div>