Skip to content

Let's use AI to Earn!

任务样式流程

DESKTOP-ZTS2NQJNA45cad5ccd4d4
diff --git a/src/views/task/components/mineInfo.module.scss b/src/views/task/components/mineInfo.module.scss
new file mode 100644
index 00000000..8f71f9eb
--- /dev/null
+++ b/src/views/task/components/mineInfo.module.scss
@@ -0,0 +1,169 @@
+.taskInfoModal {
+ :global {
+ .ant-modal-content {
+ padding: 0;
+ overflow: hidden;
+ border-radius: 8px;
+ }
+
+ .ant-modal-body {
+ padding: 0;
+ }
+
+ .ant-modal-close {
+ color: #999;
+
+ &:hover {
+ color: #333;
+ }
+ }
+ }
+}
+
+.taskInfoContainer {
+ display: flex;
+ flex-direction: column;
+}
+
+.taskInfoHeader {
+ padding: 20px 24px;
+ background-color: #f9f9f9;
+ border-bottom: 1px solid #f0f0f0;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ flex-wrap: wrap;
+ gap: 12px;
+}
+
+.taskTitle {
+ font-size: 20px;
+ font-weight: 500;
+ color: #333;
+ margin: 0;
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+}
+
+.taskId {
+ font-size: 14px;
+ color: #999;
+ font-weight: normal;
+ margin-left: 12px;
+}
+
+.statusTag {
+ font-size: 14px;
+}
+
+.taskInfoContent {
+ padding: 24px;
+ flex: 1;
+}
+
+.taskDetails {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 24px;
+ margin-bottom: 16px;
+}
+
+.taskDetail {
+ display: flex;
+ align-items: center;
+ font-size: 14px;
+}
+
+.detailIcon {
+ margin-right: 8px;
+ color: #999;
+ font-size: 16px;
+}
+
+.detailLabel {
+ color: #666;
+ margin-right: 8px;
+}
+
+.detailValue {
+ color: #333;
+ font-weight: 500;
+}
+
+.sectionTitle {
+ font-size: 16px;
+ font-weight: 500;
+ color: #333;
+ margin-bottom: 16px;
+ display: flex;
+ align-items: center;
+}
+
+.infoIcon {
+ margin-left: 8px;
+ color: #faad14;
+ font-size: 16px;
+}
+
+.taskDescription {
+ margin-bottom: 24px;
+}
+
+.descriptionContent {
+ color: #666;
+ line-height: 1.6;
+
+ p {
+ margin-bottom: 12px;
+ }
+
+ img {
+ max-width: 100%;
+ border-radius: 4px;
+ margin: 8px 0;
+ }
+}
+
+.submissionSection {
+ margin-bottom: 24px;
+}
+
+.uploadTips {
+ background-color: #f9f9f9;
+ padding: 12px 16px;
+ border-radius: 4px;
+ margin-top: 16px;
+
+ p {
+ font-weight: 500;
+ color: #333;
+ margin-bottom: 8px;
+ }
+
+ ul {
+ padding-left: 20px;
+ margin: 0;
+
+ li {
+ color: #666;
+ margin-bottom: 4px;
+ font-size: 13px;
+ }
+ }
+}
+
+.taskInfoFooter {
+ padding: 16px 24px;
+ background-color: #f9f9f9;
+ border-top: 1px solid #f0f0f0;
+ display: flex;
+ justify-content: flex-end;
+}
+
+.noDataContainer {
+ padding: 40px;
+ text-align: center;
+ color: #999;
+ font-size: 16px;
+}
\ No newline at end of file
diff --git a/src/views/task/components/mineInfo.tsx b/src/views/task/components/mineInfo.tsx
index c5640989..a494de16 100644
--- a/src/views/task/components/mineInfo.tsx
+++ b/src/views/task/components/mineInfo.tsx
@@ -5,17 +5,32 @@
* @LastEditors: nevin
* @Description: 用户任务信息
*/
-import { Button, Modal } from 'antd';
+import { Button, Modal, Form, Input, Upload, message, Tag, Divider, Space, Tooltip } from 'antd';
import {
Task,
TaskProduct,
TaskPromotion,
+ TaskStatusName,
TaskTypeName,
TaskVideo,
} from '@@/types/task';
import { forwardRef, useImperativeHandle, useState } from 'react';
import { taskApi } from '@/api/task';
-import { UserTask } from '@/api/types/task';
+import { UserTask, UserTaskStatus } from '@/api/types/task';
+import styles from './mineInfo.module.scss';
+import {
+ UploadOutlined,
+ LinkOutlined,
+ QrcodeOutlined,
+ ClockCircleOutlined,
+ FileTextOutlined,
+ DollarOutlined,
+ InfoCircleOutlined,
+ PictureOutlined
+} from '@ant-design/icons';
+import dayjs from 'dayjs';
+
+const FILE_BASE_URL = import.meta.env.VITE_APP_FILE_HOST;
export interface MineTaskInfoRef {
init: (
@@ -23,26 +38,48 @@ export interface MineTaskInfoRef {
) => Promise<void>;
}
+// 可以提交的任务状态
+const SUBMITTABLE_STATUSES = [
+ UserTaskStatus.DODING,
+ UserTaskStatus.REJECTED
+];
+
const Com = forwardRef<MineTaskInfoRef>((props: any, ref) => {
const [isModalOpen, setIsModalOpen] = useState(false);
const [mineTaskInfo, setMineTaskInfo] = useState<UserTask<
Task<TaskProduct | TaskPromotion | TaskVideo>
> | null>();
- const [doneInfo, setDoneInfo] = useState<{
- submissionUrl?: string;
- qrCodeScanResult?: string;
- screenshotUrls?: string[];
- }>({
- submissionUrl: 'http://1112',
- qrCodeScanResult: 'http://wewqe',
- screenshotUrls: ['img1', 'img2'],
- });
+ const [form] = Form.useForm();
+ const [submitting, setSubmitting] = useState(false);
+ const [fileList, setFileList] = useState<any[]>([]);
async function init(
inData: UserTask<Task<TaskProduct | TaskPromotion | TaskVideo>>,
) {
setMineTaskInfo(inData);
setIsModalOpen(true);
+
+ // 重置表单
+ form.resetFields();
+ setFileList([]);
+
+ // 如果有已提交的数据,填充表单
+ if (inData.submissionUrl || inData.qrCodeScanResult || inData.screenshotUrls?.length) {
+ form.setFieldsValue({
+ submissionUrl: inData.submissionUrl || '',
+ qrCodeScanResult: inData.qrCodeScanResult || '',
+ });
+
+ if (inData.screenshotUrls?.length) {
+ const initialFileList = inData.screenshotUrls.map((url, index) => ({
+ uid: `-${index}`,
+ name: `截图${index + 1}.jpg`,
+ status: 'done',
+ url: url.startsWith('http') ? url : `${FILE_BASE_URL}/${url}`,
+ }));
+ setFileList(initialFileList);
+ }
+ }
}
useImperativeHandle(ref, () => ({
@@ -51,52 +88,239 @@ const Com = forwardRef<MineTaskInfoRef>((props: any, ref) => {
async function taskDone() {
if (!mineTaskInfo) return;
- const res = await taskApi.taskDone(mineTaskInfo.id, doneInfo);
- setMineTaskInfo({
- ...mineTaskInfo,
- status: res.status, // 更新为待审核
- });
+
+ try {
+ await form.validateFields();
+ const values = form.getFieldsValue();
+
+ setSubmitting(true);
+
+ // 处理截图文件
+ const screenshotUrls = fileList
+ .filter(file => file.status === 'done')
+ .map(file => file.url || file.response?.url);
+
+ const doneInfo = {
+ submissionUrl: values.submissionUrl,
+ qrCodeScanResult: values.qrCodeScanResult,
+ screenshotUrls,
+ };
+
+ const res = await taskApi.taskDone(mineTaskInfo.id, doneInfo);
+
+ setMineTaskInfo({
+ ...mineTaskInfo,
+ status: res.status, // 更新为待审核
+ ...doneInfo, // 更新提交的信息
+ });
+
+ message.success('任务提交成功!');
+ setIsModalOpen(false);
+ } catch (error) {
+ console.error('提交任务失败', error);
+ message.error('提交任务失败,请检查表单并重试');
+ } finally {
+ setSubmitting(false);
+ }
}
const handleCancel = () => {
setIsModalOpen(false);
};
+
+ // 格式化日期
+ const formatDate = (dateString?: string) => {
+ if (!dateString) return '暂无日期';
+ return dayjs(dateString).format('YYYY/MM/DD HH:mm');
+ };
+
+ // 判断任务是否可提交
+ const canSubmitTask = () => {
+ if (!mineTaskInfo) return false;
+ return SUBMITTABLE_STATUSES.includes(mineTaskInfo.status as UserTaskStatus);
+ };
+
+ // 处理上传图片变化
+ const handleUploadChange = ({ fileList }: any) => {
+ setFileList(fileList);
+ };
+
+ // 上传前检查
+ const beforeUpload = (file: any) => {
+ const isImage = file.type.startsWith('image/');
+ if (!isImage) {
+ message.error('只能上传图片文件!');
+ }
+
+ const isLt5M = file.size / 1024 / 1024 < 5;
+ if (!isLt5M) {
+ message.error('图片大小不能超过5MB!');
+ }
+
+ return isImage && isLt5M;
+ };
return (
- <>
- <Modal
- title="我的任务"
- open={isModalOpen}
- onCancel={handleCancel}
- footer={[
- <Button key="back" onClick={handleCancel}>
- 取消
- </Button>,
- <Button key="submit" type="primary" onClick={taskDone}>
- 提交
- </Button>,
- ]}
- >
- <div>
- {mineTaskInfo ? (
- <div>
- <p>任务标题:{mineTaskInfo.taskId.title}</p>
- <p>任务描述:{mineTaskInfo.taskId.description}</p>
- <p>任务类型:{TaskTypeName.get(mineTaskInfo.taskId.type)}</p>
- <p>任务图片:{mineTaskInfo.taskId.imageUrl}</p>
+ <Modal
+ title={null}
+ open={isModalOpen}
+ onCancel={handleCancel}
+ footer={null}
+ width={800}
+ destroyOnClose
+ className={styles.taskInfoModal}
+ >
+ {mineTaskInfo ? (
+ <div className={styles.taskInfoContainer}>
+ <div className={styles.taskInfoHeader}>
+ <h2 className={styles.taskTitle}>
+ {mineTaskInfo.taskId?.title || '未知任务'}
+ <span className={styles.taskId}>
+ 订单号: {mineTaskInfo._id}
+ </span>
+ </h2>
+ <Tag
+ color={mineTaskInfo.status === UserTaskStatus.DODING ? 'processing' :
+ mineTaskInfo.status === UserTaskStatus.PENDING ? 'warning' :
+ mineTaskInfo.status === UserTaskStatus.APPROVED ? 'success' :
+ mineTaskInfo.status === UserTaskStatus.REJECTED ? 'error' : 'default'}
+ className={styles.statusTag}
+ >
+ {mineTaskInfo.status === UserTaskStatus.DODING ? '进行中' :
+ mineTaskInfo.status === UserTaskStatus.PENDING ? '待审核' :
+ mineTaskInfo.status === UserTaskStatus.APPROVED ? '已通过' :
+ mineTaskInfo.status === UserTaskStatus.REJECTED ? '已拒绝' : '未知状态'}
+ </Tag>
+ </div>
+
+ <div className={styles.taskInfoContent}>
+ <div className={styles.taskDetails}>
+ <div className={styles.taskDetail}>
+ <ClockCircleOutlined className={styles.detailIcon} />
+ <span className={styles.detailLabel}>接单时间:</span>
+ <span className={styles.detailValue}>{formatDate(mineTaskInfo.createTime)}</span>
+ </div>
+
+ <div className={styles.taskDetail}>
+ <FileTextOutlined className={styles.detailIcon} />
+ <span className={styles.detailLabel}>任务类型:</span>
+ <span className={styles.detailValue}>
+ {TaskTypeName.get(mineTaskInfo.taskId?.type) || '未知类型'}
+ </span>
+ </div>
+
+ <div className={styles.taskDetail}>
+ <DollarOutlined className={styles.detailIcon} />
+ <span className={styles.detailLabel}>任务奖励:</span>
+ <span className={styles.detailValue}>¥{mineTaskInfo.taskId?.reward || 5}</span>
+ </div>
</div>
- ) : (
- <div>暂无任务信息</div>
- )}
- </div>
- <div>
- <h2>完成任务信息:</h2>
- <p>结果URL:{doneInfo.submissionUrl}</p>
- <p>结果URL:{doneInfo.qrCodeScanResult}</p>
- <p>完成截图列表:{doneInfo.screenshotUrls}</p>
+
+ <Divider />
+
+ <div className={styles.taskDescription}>
+ <h3 className={styles.sectionTitle}>任务描述</h3>
+ <div
+ className={styles.descriptionContent}
+ dangerouslySetInnerHTML={{ __html: mineTaskInfo.taskId?.description || '暂无描述' }}
+ />
+ </div>
+
+ <Divider />
+
+ <div className={styles.submissionSection}>
+ <h3 className={styles.sectionTitle}>
+ 提交任务
+ {!canSubmitTask() && (
+ <Tooltip title="当前任务状态不允许提交">
+ <InfoCircleOutlined className={styles.infoIcon} />
+ </Tooltip>
+ )}
+ </h3>
+
+ <Form
+ form={form}
+ layout="vertical"
+ disabled={!canSubmitTask() || submitting}
+ >
+ <Form.Item
+ name="submissionUrl"
+ label="提交链接"
+ rules={[{ required: true, message: '请输入提交链接' }]}
+ >
+ <Input
+ placeholder="请输入任务完成后的链接"
+ prefix={<LinkOutlined />}
+ />
+ </Form.Item>
+
+ <Form.Item
+ name="qrCodeScanResult"
+ label="二维码扫描结果"
+ rules={[{ required: false, message: '请输入二维码扫描结果' }]}
+ >
+ <Input
+ placeholder="请输入二维码扫描结果(如有)"
+ prefix={<QrcodeOutlined />}
+ />
+ </Form.Item>
+
+ <Form.Item
+ name="screenshotUrls"
+ label="任务截图"
+ rules={[{ required: true, message: '请上传任务截图' }]}
+ >
+ <Upload
+ listType="picture-card"
+ fileList={fileList}
+ onChange={handleUploadChange}
+ beforeUpload={beforeUpload}
+ action="/api/upload"
+ multiple
+ maxCount={5}
+ >
+ {fileList.length >= 5 ? null : (
+ <div>
+ <PictureOutlined />
+ <div style={{ marginTop: 8 }}>上传截图</div>
+ </div>
+ )}
+ </Upload>
+ </Form.Item>
+
+ <div className={styles.uploadTips}>
+ <p>提示:</p>
+ <ul>
+ <li>请上传清晰的任务完成截图,最多5张</li>
+ <li>图片格式支持JPG、PNG,单张大小不超过5MB</li>
+ <li>截图应包含任务完成的关键信息,如发布内容、评论等</li>
+ </ul>
+ </div>
+ </Form>
+ </div>
+ </div>
+
+ <div className={styles.taskInfoFooter}>
+ <Space>
+ <Button onClick={handleCancel}>
+ 关闭
+ </Button>
+ {canSubmitTask() && (
+ <Button
+ type="primary"
+ onClick={taskDone}
+ loading={submitting}
+ >
+ 提交任务
+ </Button>
+ )}
+ </Space>
+ </div>
</div>
- </Modal>
- </>
+ ) : (
+ <div className={styles.noDataContainer}>暂无任务信息</div>
+ )}
+ </Modal>
);
});
diff --git a/src/views/task/components/popInfo.module.scss b/src/views/task/components/popInfo.module.scss
new file mode 100644
index 00000000..7f427128
--- /dev/null
+++ b/src/views/task/components/popInfo.module.scss
@@ -0,0 +1,219 @@
+.taskInfoModal {
+ :global {
+ .ant-modal-content {
+ padding: 0;
+ overflow: hidden;
+ border-radius: 8px;
+ }
+
+ .ant-modal-body {
+ padding: 0;
+ }
+
+ .ant-modal-close {
+ color: #999;
+
+ &:hover {
+ color: #333;
+ }
+ }
+ }
+}
+
+.taskInfoContainer {
+ display: flex;
+ flex-direction: column;
+}
+
+.taskInfoHeader {
+ padding: 20px 24px;
+ background-color: #f9f9f9;
+ border-bottom: 1px solid #f0f0f0;
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ gap: 12px;
+}
+
+.taskTitle {
+ font-size: 20px;
+ font-weight: 500;
+ color: #333;
+ margin: 0;
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+}
+
+.taskId {
+ font-size: 14px;
+ color: #999;
+ font-weight: normal;
+ margin-left: 12px;
+ display: flex;
+ align-items: center;
+}
+
+.copyIcon {
+ margin-left: 4px;
+ cursor: pointer;
+ color: #1890ff;
+
+ &:hover {
+ color: #40a9ff;
+ }
+}
+
+.taskTag {
+ font-size: 12px;
+}
+
+.taskInfoContent {
+ padding: 24px;
+ flex: 1;
+}
+
+.taskImageContainer {
+ width: 100%;
+ height: 240px;
+ background-color: #f5f5f5;
+ border-radius: 8px;
+ overflow: hidden;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+
+.taskImage {
+ width: 100%;
+ height: 100%;
+ object-fit: contain;
+}
+
+.taskDetails {
+ display: flex;
+ flex-direction: column;
+ gap: 16px;
+ height: 100%;
+}
+
+.taskDetail {
+ display: flex;
+ align-items: center;
+ font-size: 14px;
+}
+
+.detailIcon {
+ margin-right: 8px;
+ color: #999;
+ font-size: 16px;
+}
+
+.detailLabel {
+ color: #666;
+ margin-right: 8px;
+ min-width: 70px;
+}
+
+.detailValue {
+ color: #333;
+ font-weight: 500;
+}
+
+.sectionTitle {
+ font-size: 16px;
+ font-weight: 500;
+ color: #333;
+ margin-bottom: 16px;
+}
+
+.taskDescription {
+ margin-bottom: 24px;
+}
+
+.descriptionContent {
+ color: #666;
+ line-height: 1.6;
+
+ p {
+ margin-bottom: 12px;
+ }
+
+ img {
+ max-width: 100%;
+ border-radius: 4px;
+ margin: 8px 0;
+ }
+}
+
+.appDetails {
+ margin-bottom: 24px;
+}
+
+.appInfo {
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+}
+
+.appInfoItem {
+ display: flex;
+ align-items: flex-start;
+}
+
+.appInfoLabel {
+ color: #666;
+ margin-right: 8px;
+ min-width: 70px;
+}
+
+.appInfoValue {
+ color: #333;
+ flex: 1;
+}
+
+.taskInfoFooter {
+ padding: 16px 24px;
+ background-color: #f9f9f9;
+ border-top: 1px solid #f0f0f0;
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+}
+
+.taskStatus {
+ display: flex;
+ align-items: center;
+}
+
+.statusLabel {
+ color: #666;
+ margin-right: 8px;
+}
+
+.taskActions {
+ display: flex;
+ gap: 12px;
+}
+
+.cancelButton {
+ min-width: 80px;
+}
+
+.applyButton {
+ min-width: 100px;
+ background-color: #52c41a;
+ border-color: #52c41a;
+
+ &:hover {
+ background-color: #73d13d;
+ border-color: #73d13d;
+ }
+}
+
+.noDataContainer {
+ padding: 40px;
+ text-align: center;
+ color: #999;
+ font-size: 16px;
+}
\ No newline at end of file
diff --git a/src/views/task/components/popInfo.tsx b/src/views/task/components/popInfo.tsx
index 797bf7f7..26367f6c 100644
--- a/src/views/task/components/popInfo.tsx
+++ b/src/views/task/components/popInfo.tsx
@@ -5,7 +5,7 @@
* @LastEditors: nevin
* @Description: pop
*/
-import { Button, Modal } from 'antd';
+import { Button, Modal, Tag, Divider, Row, Col, message } from 'antd';
import {
Task,
TaskPromotion,
@@ -14,6 +14,17 @@ import {
} from '@@/types/task';
import { forwardRef, useImperativeHandle, useState } from 'react';
import { taskApi } from '@/api/task';
+import styles from './popInfo.module.scss';
+import {
+ ClockCircleOutlined,
+ TeamOutlined,
+ TagOutlined,
+ DollarOutlined,
+ QrcodeOutlined,
+ CopyOutlined
+} from '@ant-design/icons';
+
+const FILE_BASE_URL = import.meta.env.VITE_APP_FILE_HOST;
export interface TaskInfoRef {
init: (pubRecord: Task<TaskPromotion>) => Promise<void>;
@@ -38,44 +49,176 @@ const Com = forwardRef<TaskInfoRef>((props: any, ref) => {
async function taskApply() {
if (!taskInfo) return;
- const res = await taskApi.taskApply(taskInfo?.id);
- setTaskInfo(res);
- setIsModalOpen(false);
+ try {
+ const res = await taskApi.taskApply(taskInfo?.id);
+ setTaskInfo(res);
+ message.success('任务接受成功!');
+ setIsModalOpen(false);
+ } catch (error) {
+ message.error('接受任务失败,请稍后再试');
+ }
}
const handleCancel = () => {
setIsModalOpen(false);
};
+
+ // 复制任务ID
+ const copyTaskId = (id: string) => {
+ navigator.clipboard.writeText(id)
+ .then(() => {
+ message.success('任务ID已复制到剪贴板');
+ })
+ .catch(() => {
+ message.error('复制失败,请手动复制');
+ });
+ };
return (
<>
<Modal
- title="Basic Modal"
+ title={null}
open={isModalOpen}
onCancel={handleCancel}
- footer={[
- <Button key="back" onClick={handleCancel}>
- 取消
- </Button>,
- <Button key="submit" type="primary" onClick={taskApply}>
- 接受
- </Button>,
- ]}
+ footer={null}
+ width={800}
+ className={styles.taskInfoModal}
+ destroyOnClose
>
- <div>
- {taskInfo ? (
- <div>
- <p>任务标题:{taskInfo.title}</p>
- <p>任务描述:{taskInfo.description}</p>
- <p>任务类型:{TaskTypeName.get(taskInfo.type)}</p>
- <p>任务图片:{taskInfo.imageUrl}</p>
- <p>任务奖励金额:{taskInfo.reward}</p>
- <p>任务状态:{TaskStatusName.get(taskInfo.status)}</p>
+ {taskInfo ? (
+ <div className={styles.taskInfoContainer}>
+ <div className={styles.taskInfoHeader}>
+ <h2 className={styles.taskTitle}>
+ {taskInfo.title}
+ <span className={styles.taskId}>
+ ID: {taskInfo.id}
+ <CopyOutlined
+ className={styles.copyIcon}
+ onClick={() => copyTaskId(taskInfo.id)}
+ />
+ </span>
+ </h2>
+ <Tag color="#108ee9" className={styles.taskTag}>
+ {taskInfo.dataInfo?.type || 'AI对话APP'}
+ </Tag>
+ </div>
+
+ <div className={styles.taskInfoContent}>
+ <Row gutter={24}>
+ <Col span={12}>
+ <div className={styles.taskImageContainer}>
+ <img
+ src={`${FILE_BASE_URL}${taskInfo.imageUrl}`}
+ alt={taskInfo.title}
+ className={styles.taskImage}
+ />
+ </div>
+ </Col>
+
+ <Col span={12}>
+ <div className={styles.taskDetails}>
+ <div className={styles.taskDetail}>
+ <TagOutlined className={styles.detailIcon} />
+ <span className={styles.detailLabel}>任务类型:</span>
+ <span className={styles.detailValue}>
+ {TaskTypeName.get(taskInfo.type) || '推广任务'}
+ </span>
+ </div>
+
+ <div className={styles.taskDetail}>
+ <ClockCircleOutlined className={styles.detailIcon} />
+ <span className={styles.detailLabel}>截止时间:</span>
+ <span className={styles.detailValue}>
+ {taskInfo.deadline || '2025/03/17'}
+ </span>
+ </div>
+
+ <div className={styles.taskDetail}>
+ <TeamOutlined className={styles.detailIcon} />
+ <span className={styles.detailLabel}>招募人数:</span>
+ <span className={styles.detailValue}>
+ {taskInfo.maxRecruits || 100}
+ </span>
+ </div>
+
+ <div className={styles.taskDetail}>
+ <DollarOutlined className={styles.detailIcon} />
+ <span className={styles.detailLabel}>任务奖励:</span>
+ <span className={styles.detailValue}>
+ ¥{taskInfo.reward || 5}
+ </span>
+ </div>
+
+ <div className={styles.taskDetail}>
+ <QrcodeOutlined className={styles.detailIcon} />
+ <span className={styles.detailLabel}>任务要求:</span>
+ <span className={styles.detailValue}>
+ {taskInfo.requirement || '扫二维码下载APP并完成注册'}
+ </span>
+ </div>
+ </div>
+ </Col>
+ </Row>
+
+ <Divider />
+
+ <div className={styles.taskDescription}>
+ <h3 className={styles.sectionTitle}>任务描述</h3>
+ <div
+ className={styles.descriptionContent}
+ dangerouslySetInnerHTML={{ __html: taskInfo.description || '暂无描述' }}
+ />
+ </div>
+
+ {taskInfo.dataInfo && (
+ <>
+ <Divider />
+ <div className={styles.appDetails}>
+ <h3 className={styles.sectionTitle}>APP详情</h3>
+ <div className={styles.appInfo}>
+ <div className={styles.appInfoItem}>
+ <span className={styles.appInfoLabel}>APP名称:</span>
+ <span className={styles.appInfoValue}>{taskInfo.dataInfo.title || '未知'}</span>
+ </div>
+
+ <div className={styles.appInfoItem}>
+ <span className={styles.appInfoLabel}>APP描述:</span>
+ <span className={styles.appInfoValue}>{taskInfo.dataInfo.desc || '暂无描述'}</span>
+ </div>
+ </div>
+ </div>
+ </>
+ )}
+ </div>
+
+ <div className={styles.taskInfoFooter}>
+ <div className={styles.taskStatus}>
+ <span className={styles.statusLabel}>任务状态:</span>
+ <Tag color="#87d068">{TaskStatusName.get(taskInfo.status) || '进行中'}</Tag>
+ </div>
+
+ <div className={styles.taskActions}>
+ <Button
+ key="back"
+ onClick={handleCancel}
+ className={styles.cancelButton}
+ >
+ 取消
+ </Button>
+ <Button
+ key="submit"
+ type="primary"
+ onClick={taskApply}
+ className={styles.applyButton}
+ >
+ 接受任务
+ </Button>
+ </div>
</div>
- ) : (
- <div>暂无任务信息</div>
- )}
- </div>
+ </div>
+ ) : (
+ <div className={styles.noDataContainer}>暂无任务信息</div>
+ )}
</Modal>
</>
);
diff --git a/src/views/task/components/videoInfo.module.scss b/src/views/task/components/videoInfo.module.scss
new file mode 100644
index 00000000..86fc06ac
--- /dev/null
+++ b/src/views/task/components/videoInfo.module.scss
@@ -0,0 +1,261 @@
+.taskInfoModal {
+ :global {
+ .ant-modal-content {
+ padding: 0;
+ overflow: hidden;
+ border-radius: 8px;
+ }
+
+ .ant-modal-body {
+ padding: 0;
+ }
+
+ .ant-modal-close {
+ color: #999;
+
+ &:hover {
+ color: #333;
+ }
+ }
+ }
+}
+
+.taskInfoContainer {
+ display: flex;
+ flex-direction: column;
+}
+
+.taskInfoHeader {
+ padding: 20px 24px;
+ background-color: #f9f9f9;
+ border-bottom: 1px solid #f0f0f0;
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ gap: 12px;
+}
+
+.taskTitle {
+ font-size: 20px;
+ font-weight: 500;
+ color: #333;
+ margin: 0;
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+}
+
+.taskId {
+ font-size: 14px;
+ color: #999;
+ font-weight: normal;
+ margin-left: 12px;
+ display: flex;
+ align-items: center;
+}
+
+.copyIcon {
+ margin-left: 4px;
+ cursor: pointer;
+ color: #1890ff;
+
+ &:hover {
+ color: #40a9ff;
+ }
+}
+
+.taskTag {
+ font-size: 12px;
+}
+
+.taskInfoContent {
+ padding: 24px;
+ flex: 1;
+}
+
+.videoContainer {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+}
+
+.taskImageContainer {
+ width: 100%;
+ height: 240px;
+ background-color: #000;
+ border-radius: 8px;
+ overflow: hidden;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ position: relative;
+}
+
+.taskImage {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+}
+
+.videoOverlay {
+ position: absolute;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background-color: rgba(0, 0, 0, 0.3);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ transition: background-color 0.2s;
+
+ &:hover {
+ background-color: rgba(0, 0, 0, 0.5);
+ }
+}
+
+.playIcon {
+ font-size: 48px;
+ color: #fff;
+ opacity: 0.8;
+ transition: opacity 0.2s, transform 0.2s;
+
+ &:hover {
+ opacity: 1;
+ transform: scale(1.1);
+ }
+}
+
+.videoCaption {
+ margin-top: 8px;
+ color: #666;
+ font-size: 14px;
+}
+
+.taskDetails {
+ display: flex;
+ flex-direction: column;
+ gap: 16px;
+ height: 100%;
+}
+
+.taskDetail {
+ display: flex;
+ align-items: center;
+ font-size: 14px;
+}
+
+.detailIcon {
+ margin-right: 8px;
+ color: #999;
+ font-size: 16px;
+}
+
+.detailLabel {
+ color: #666;
+ margin-right: 8px;
+ min-width: 70px;
+}
+
+.detailValue {
+ color: #333;
+ font-weight: 500;
+}
+
+.sectionTitle {
+ font-size: 16px;
+ font-weight: 500;
+ color: #333;
+ margin-bottom: 16px;
+}
+
+.taskDescription {
+ margin-bottom: 24px;
+}
+
+.descriptionContent {
+ color: #666;
+ line-height: 1.6;
+
+ p {
+ margin-bottom: 12px;
+ }
+
+ img {
+ max-width: 100%;
+ border-radius: 4px;
+ margin: 8px 0;
+ }
+}
+
+.videoDetails {
+ margin-bottom: 24px;
+}
+
+.videoInfo {
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+}
+
+.videoInfoItem {
+ display: flex;
+ align-items: flex-start;
+}
+
+.videoInfoLabel {
+ color: #666;
+ margin-right: 8px;
+ min-width: 70px;
+}
+
+.videoInfoValue {
+ color: #333;
+ flex: 1;
+}
+
+.taskInfoFooter {
+ padding: 16px 24px;
+ background-color: #f9f9f9;
+ border-top: 1px solid #f0f0f0;
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+}
+
+.taskStatus {
+ display: flex;
+ align-items: center;
+}
+
+.statusLabel {
+ color: #666;
+ margin-right: 8px;
+}
+
+.taskActions {
+ display: flex;
+ gap: 12px;
+}
+
+.cancelButton {
+ min-width: 80px;
+}
+
+.applyButton {
+ min-width: 100px;
+ background-color: #52c41a;
+ border-color: #52c41a;
+
+ &:hover {
+ background-color: #73d13d;
+ border-color: #73d13d;
+ }
+}
+
+.noDataContainer {
+ padding: 40px;
+ text-align: center;
+ color: #999;
+ font-size: 16px;
+}
\ No newline at end of file
diff --git a/src/views/task/components/videoInfo.tsx b/src/views/task/components/videoInfo.tsx
index 48db7ccb..e2e62ecc 100644
--- a/src/views/task/components/videoInfo.tsx
+++ b/src/views/task/components/videoInfo.tsx
@@ -5,10 +5,21 @@
* @LastEditors: nevin
* @Description: video
*/
-import { Button, Modal } from 'antd';
+import { Button, Modal, Tag, Divider, Row, Col, message } from 'antd';
import { Task, TaskStatusName, TaskTypeName, TaskVideo } from '@@/types/task';
import { forwardRef, useImperativeHandle, useState } from 'react';
import { taskApi } from '@/api/task';
+import styles from './videoInfo.module.scss';
+import {
+ ClockCircleOutlined,
+ TeamOutlined,
+ TagOutlined,
+ DollarOutlined,
+ PlayCircleOutlined,
+ CopyOutlined
+} from '@ant-design/icons';
+
+const FILE_BASE_URL = import.meta.env.VITE_APP_FILE_HOST;
export interface TaskInfoRef {
init: (pubRecord: Task<TaskVideo>) => Promise<void>;
@@ -33,44 +44,181 @@ const Com = forwardRef<TaskInfoRef>((props: any, ref) => {
async function taskApply() {
if (!taskInfo) return;
- const res = await taskApi.taskApply<TaskVideo>(taskInfo?.id);
- setTaskInfo(res);
- setIsModalOpen(false);
+ try {
+ const res = await taskApi.taskApply<TaskVideo>(taskInfo?.id);
+ setTaskInfo(res);
+ message.success('任务接受成功!');
+ setIsModalOpen(false);
+ } catch (error) {
+ message.error('接受任务失败,请稍后再试');
+ }
}
const handleCancel = () => {
setIsModalOpen(false);
};
+
+ // 复制任务ID
+ const copyTaskId = (id: string) => {
+ navigator.clipboard.writeText(id)
+ .then(() => {
+ message.success('任务ID已复制到剪贴板');
+ })
+ .catch(() => {
+ message.error('复制失败,请手动复制');
+ });
+ };
return (
<>
<Modal
- title="Basic Modal"
+ title={null}
open={isModalOpen}
onCancel={handleCancel}
- footer={[
- <Button key="back" onClick={handleCancel}>
- 取消
- </Button>,
- <Button key="submit" type="primary" onClick={taskApply}>
- 接受
- </Button>,
- ]}
+ footer={null}
+ width={800}
+ className={styles.taskInfoModal}
+ destroyOnClose
>
- <div>
- {taskInfo ? (
- <div>
- <p>任务标题:{taskInfo.title}</p>
- <p>任务描述:{taskInfo.description}</p>
- <p>任务类型:{TaskTypeName.get(taskInfo.type)}</p>
- <p>任务图片:{taskInfo.imageUrl}</p>
- <p>任务奖励金额:{taskInfo.reward}</p>
- <p>任务状态:{TaskStatusName.get(taskInfo.status)}</p>
+ {taskInfo ? (
+ <div className={styles.taskInfoContainer}>
+ <div className={styles.taskInfoHeader}>
+ <h2 className={styles.taskTitle}>
+ {taskInfo.title}
+ <span className={styles.taskId}>
+ ID: {taskInfo.id}
+ <CopyOutlined
+ className={styles.copyIcon}
+ onClick={() => copyTaskId(taskInfo.id)}
+ />
+ </span>
+ </h2>
+ <Tag color="#f50" className={styles.taskTag}>
+ {taskInfo.dataInfo?.type || '视频任务'}
+ </Tag>
+ </div>
+
+ <div className={styles.taskInfoContent}>
+ <Row gutter={24}>
+ <Col span={12}>
+ <div className={styles.videoContainer}>
+ <div className={styles.taskImageContainer}>
+ <img
+ src={`${FILE_BASE_URL}${taskInfo.imageUrl}`}
+ alt={taskInfo.title}
+ className={styles.taskImage}
+ />
+ <div className={styles.videoOverlay}>
+ <PlayCircleOutlined className={styles.playIcon} />
+ </div>
+ </div>
+ <div className={styles.videoCaption}>视频封面预览</div>
+ </div>
+ </Col>
+
+ <Col span={12}>
+ <div className={styles.taskDetails}>
+ <div className={styles.taskDetail}>
+ <TagOutlined className={styles.detailIcon} />
+ <span className={styles.detailLabel}>任务类型:</span>
+ <span className={styles.detailValue}>
+ {TaskTypeName.get(taskInfo.type) || '视频任务'}
+ </span>
+ </div>
+
+ <div className={styles.taskDetail}>
+ <ClockCircleOutlined className={styles.detailIcon} />
+ <span className={styles.detailLabel}>截止时间:</span>
+ <span className={styles.detailValue}>
+ {taskInfo.deadline || '2025/03/17'}
+ </span>
+ </div>
+
+ <div className={styles.taskDetail}>
+ <TeamOutlined className={styles.detailIcon} />
+ <span className={styles.detailLabel}>招募人数:</span>
+ <span className={styles.detailValue}>
+ {taskInfo.maxRecruits || 100}
+ </span>
+ </div>
+
+ <div className={styles.taskDetail}>
+ <DollarOutlined className={styles.detailIcon} />
+ <span className={styles.detailLabel}>任务奖励:</span>
+ <span className={styles.detailValue}>
+ ¥{taskInfo.reward || 5}
+ </span>
+ </div>
+
+ <div className={styles.taskDetail}>
+ <span className={styles.detailLabel}>任务要求:</span>
+ <span className={styles.detailValue}>
+ {taskInfo.requirement || '不许删文'}
+ </span>
+ </div>
+ </div>
+ </Col>
+ </Row>
+
+ <Divider />
+
+ <div className={styles.taskDescription}>
+ <h3 className={styles.sectionTitle}>任务描述</h3>
+ <div
+ className={styles.descriptionContent}
+ dangerouslySetInnerHTML={{ __html: taskInfo.description || '暂无描述' }}
+ />
+ </div>
+
+ {taskInfo.dataInfo && (
+ <>
+ <Divider />
+ <div className={styles.videoDetails}>
+ <h3 className={styles.sectionTitle}>视频详情</h3>
+ <div className={styles.videoInfo}>
+ <div className={styles.videoInfoItem}>
+ <span className={styles.videoInfoLabel}>视频标题:</span>
+ <span className={styles.videoInfoValue}>{taskInfo.dataInfo.title || '未知'}</span>
+ </div>
+
+ <div className={styles.videoInfoItem}>
+ <span className={styles.videoInfoLabel}>视频描述:</span>
+ <span className={styles.videoInfoValue}>{taskInfo.dataInfo.desc || '暂无描述'}</span>
+ </div>
+ </div>
+ </div>
+ </>
+ )}
+ </div>
+
+ <div className={styles.taskInfoFooter}>
+ <div className={styles.taskStatus}>
+ <span className={styles.statusLabel}>任务状态:</span>
+ <Tag color="#87d068">{TaskStatusName.get(taskInfo.status) || '进行中'}</Tag>
+ </div>
+
+ <div className={styles.taskActions}>
+ <Button
+ key="back"
+ onClick={handleCancel}
+ className={styles.cancelButton}
+ >
+ 取消
+ </Button>
+ <Button
+ key="submit"
+ type="primary"
+ onClick={taskApply}
+ className={styles.applyButton}
+ >
+ 接受任务
+ </Button>
+ </div>
</div>
- ) : (
- <div>暂无任务信息</div>
- )}
- </div>
+ </div>
+ ) : (
+ <div className={styles.noDataContainer}>暂无任务信息</div>
+ )}
</Modal>
</>
);
diff --git a/src/views/task/mineTask.module.scss b/src/views/task/mineTask.module.scss
index dc7b7e26..f6981784 100644
--- a/src/views/task/mineTask.module.scss
+++ b/src/views/task/mineTask.module.scss
@@ -5,231 +5,198 @@
min-height: 100%;
}
-.loadingContainer {
+.pageHeader {
display: flex;
- justify-content: center;
+ justify-content: space-between;
align-items: center;
- min-height: 300px;
+ margin-bottom: 24px;
+ padding-bottom: 16px;
+ border-bottom: 1px solid #f0f0f0;
}
-.taskGrid {
- display: grid;
- grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
- gap: 16px;
+.pageTitle {
+ font-size: 20px;
+ font-weight: 500;
+ color: #333;
+ margin: 0;
}
-.taskCard {
- border-radius: 8px;
- overflow: hidden;
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
- transition: transform 0.2s;
+.pageActions {
+ display: flex;
+ align-items: center;
+}
+
+.statusFilter {
+ :global {
+ .ant-select-selector {
+ border-radius: 4px;
+ }
+ }
+}
+
+.refreshButton {
+ border-radius: 4px;
&:hover {
- transform: translateY(-3px);
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
+ color: #1890ff;
+ border-color: #1890ff;
}
}
-.cardTitle {
+.taskList {
display: flex;
- justify-content: space-between;
- align-items: center;
+ flex-direction: column;
+ gap: 16px;
}
-.taskStatus {
- font-size: 12px;
- color: #1890ff;
- font-weight: normal;
+.taskCard {
+ border-radius: 8px;
+ overflow: hidden;
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
+ transition: transform 0.2s, box-shadow 0.2s;
+
+ &:hover {
+ transform: translateY(-3px);
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
+ }
}
-.cardContent {
+.taskCardContent {
display: flex;
- flex-direction: column;
- height: 100%;
+ align-items: stretch;
}
.taskInfo {
flex: 1;
+ padding: 16px;
+ display: flex;
+ flex-direction: column;
+ text-align: left;
}
-.taskDescription {
- color: #666;
- margin-bottom: 12px;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- overflow: hidden;
-}
-
-.taskDetails {
- margin-top: 16px;
+.taskHeader {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ margin-bottom: 16px;
}
-.detailItem {
+.taskTitle {
+ font-size: 18px;
+ font-weight: 500;
+ color: #333;
+ margin: 0;
display: flex;
- margin-bottom: 8px;
- font-size: 12px;
+ align-items: center;
+ flex-wrap: wrap;
}
-.detailLabel {
+.taskId {
+ font-size: 12px;
color: #999;
- margin-right: 8px;
- min-width: 70px;
+ font-weight: normal;
+ margin-left: 12px;
}
-.detailValue {
- color: #666;
+.statusTag {
+ font-size: 12px;
}
-.taskActions {
- margin-top: 16px;
+.taskDetails {
display: flex;
- justify-content: flex-end;
-}
-
-.actionButton {
- background-color: #52c41a;
- border-color: #52c41a;
-
- &:hover {
- background-color: #73d13d;
- border-color: #73d13d;
- }
+ flex-direction: column;
+ gap: 12px;
}
-/* 空状态样式 */
-.emptyContainer {
+.taskDetail {
display: flex;
- flex-direction: column;
align-items: center;
- padding: 40px 20px;
- text-align: center;
-}
-
-.emptyImage {
- width: 120px;
- height: 120px;
- margin-bottom: 24px;
-}
-
-.emptyText {
- margin-bottom: 40px;
-
- h3 {
- font-size: 16px;
- color: #333;
- margin-bottom: 8px;
- }
-
- p {
- font-size: 14px;
- color: #999;
- }
+ font-size: 14px;
+ color: #666;
}
-.guideContainer {
- width: 100%;
- max-width: 800px;
+.detailIcon {
+ margin-right: 8px;
+ color: #999;
+ font-size: 16px;
}
-.guideStep {
- margin-bottom: 40px;
-
- h4 {
- font-size: 16px;
- color: #333;
- margin-bottom: 24px;
- text-align: center;
- }
+.detailLabel {
+ margin-right: 8px;
+ min-width: 70px;
}
-.qrCodeContainer {
- display: flex;
- justify-content: center;
- gap: 60px;
+.detailValue {
+ color: #333;
}
-.qrCodeItem {
+.taskAction {
+ width: 160px;
+ flex-shrink: 0;
display: flex;
flex-direction: column;
align-items: center;
+ justify-content: center;
+ padding: 16px;
+ border-left: 1px solid #f0f0f0;
+ gap: 12px;
}
-.qrCodeWrapper {
- width: 160px;
- height: 160px;
- padding: 8px;
- border: 1px solid #eee;
- margin-bottom: 12px;
-}
-
-.qrCode {
+.withdrawButton {
width: 100%;
- height: 100%;
-}
-
-.qrCodeText {
- font-size: 14px;
- color: #333;
- margin-bottom: 4px;
-}
-
-.qrCodeSubtext {
- font-size: 12px;
- color: #999;
-}
-
-.processContainer {
- margin-top: 40px;
+ background-color: #ff4d4f;
+ border-color: #ff4d4f;
+
+ &:hover {
+ background-color: #ff7875;
+ border-color: #ff7875;
+ }
}
-.processTitle {
- font-size: 16px;
- color: #333;
- margin-bottom: 24px;
- text-align: center;
+.viewButton {
+ width: 100%;
+
+ &:hover {
+ color: #1890ff;
+ border-color: #1890ff;
+ }
}
-.processSteps {
+.loadingContainer {
display: flex;
justify-content: center;
- align-items: center;
-}
-
-.processStep {
- display: flex;
- flex-direction: column;
- align-items: center;
- width: 120px;
+ padding: 32px 0;
}
-.processIcon {
- width: 60px;
- height: 60px;
- background-color: #f5f5f5;
- border-radius: 50%;
+.loadMoreContainer {
display: flex;
justify-content: center;
- align-items: center;
- margin-bottom: 12px;
-}
-
-.stepIcon {
- width: 30px;
- height: 30px;
+ margin-top: 16px;
+ margin-bottom: 16px;
+
+ button {
+ padding: 0 32px;
+ }
}
-.stepText {
- font-size: 12px;
- color: #666;
+.emptyContainer {
+ padding: 40px 0;
text-align: center;
}
-.processDivider {
- width: 60px;
- height: 1px;
- background-color: #e8e8e8;
- margin: 0 8px;
+.emptyText {
+ margin-top: 16px;
+ color: #666;
+
+ h3 {
+ font-size: 16px;
+ font-weight: normal;
+ margin-bottom: 8px;
+ }
+
+ p {
+ color: #999;
+ }
}
.guideLink {
@@ -359,4 +326,43 @@
}
}
}
+}
+
+.qrCodeContainer {
+ display: flex;
+ justify-content: center;
+ gap: 40px;
+ margin: 24px 0;
+}
+
+.qrCodeItem {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+}
+
+.qrCodeWrapper {
+ width: 120px;
+ height: 120px;
+ border: 1px solid #eee;
+ border-radius: 4px;
+ padding: 8px;
+ background-color: #fff;
+ margin-bottom: 12px;
+}
+
+.qrCode {
+ width: 100%;
+ height: 100%;
+}
+
+.qrCodeText {
+ font-weight: 500;
+ color: #333;
+ margin-bottom: 4px;
+}
+
+.qrCodeSubtext {
+ font-size: 12px;
+ color: #999;
}
\ No newline at end of file
diff --git a/src/views/task/mineTask.tsx b/src/views/task/mineTask.tsx
index 50eb398d..7b187981 100644
--- a/src/views/task/mineTask.tsx
+++ b/src/views/task/mineTask.tsx
@@ -5,7 +5,7 @@
* @LastEditors: nevin
* @Description: 我的任务列表
*/
-import { Button, Card, Spin, Modal } from 'antd';
+import { Button, Card, Spin, Modal, Select, Space, Tag, Empty, message, Tooltip } from 'antd';
import { useState, useEffect, useRef } from 'react';
import { taskApi } from '@/api/task';
import { UserTask, UserTaskStatus } from '@/api/types/task';
@@ -14,6 +14,16 @@ import MineTaskInfo, { MineTaskInfoRef } from './components/mineInfo';
import { WithdrawRef } from './components/withdraw';
import Withdraw from './components/withdraw';
import styles from './mineTask.module.scss';
+import {
+ ReloadOutlined,
+ FilterOutlined,
+ ClockCircleOutlined,
+ DollarOutlined,
+ FileTextOutlined,
+ RightOutlined,
+ QuestionCircleOutlined
+} from '@ant-design/icons';
+import dayjs from 'dayjs';
import bindTaskImg from '@/assets/task/binds.png';
import checkTaskImg from '@/assets/task/waits.png';
@@ -33,6 +43,18 @@ const UserTaskStatusNameMap = new Map<UserTaskStatus, string>([
[UserTaskStatus.REWARDED, '已发放奖励'],
]);
+// 状态对应的颜色
+const UserTaskStatusColorMap = new Map<UserTaskStatus, string>([
+ [UserTaskStatus.DODING, 'processing'],
+ [UserTaskStatus.PENDING, 'warning'],
+ [UserTaskStatus.APPROVED, 'success'],
+ [UserTaskStatus.REJECTED, 'error'],
+ [UserTaskStatus.COMPLETED, 'success'],
+ [UserTaskStatus.CANCELLED, 'default'],
+ [UserTaskStatus.PENDING_REWARD, 'warning'],
+ [UserTaskStatus.REWARDED, 'success'],
+]);
+
export default function Page() {
const [taskList, setTaskList] = useState<UserTask<Task<TaskDataInfo>>[]>([]);
const [pageInfo, setPageInfo] = useState({
@@ -42,26 +64,68 @@ export default function Page() {
});
const [loading, setLoading] = useState(true);
const [isGuideModalVisible, setIsGuideModalVisible] = useState(false);
-
- useEffect(() => {
- const fetchTaskDetails = async () => {
- setLoading(true);
- try {
- const tasks = await taskApi.getMineTaskList(pageInfo);
+ const [statusFilter, setStatusFilter] = useState<UserTaskStatus | null>(null);
+ const [hasMore, setHasMore] = useState(true);
+
+ const fetchTaskDetails = async (isLoadMore = false) => {
+ setLoading(true);
+ try {
+ const params = {
+ ...pageInfo,
+ status: statusFilter,
+ };
+
+ // 如果没有选择状态筛选,则不传status参数
+ if (statusFilter === null) {
+ delete params.status;
+ }
+
+ const tasks = await taskApi.getMineTaskList(params);
+
+ if (isLoadMore) {
+ setTaskList(prev => [...prev, ...tasks.items]);
+ } else {
setTaskList(tasks.items);
- setPageInfo((prev) => ({
- ...prev,
- totalCount: (tasks as any).totalCount,
- }));
- } catch (error) {
- console.error('获取任务列表失败', error);
- } finally {
- setLoading(false);
}
- };
+
+ setPageInfo(prev => ({
+ ...prev,
+ totalCount: (tasks as any).totalCount,
+ }));
+
+ // 检查是否还有更多数据
+ setHasMore(pageInfo.pageNo * pageInfo.pageSize < (tasks as any).totalCount);
+ } catch (error) {
+ console.error('获取任务列表失败', error);
+ message.error('获取任务列表失败,请稍后再试');
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ useEffect(() => {
+ fetchTaskDetails();
+ }, [statusFilter]);
+
+ // 加载更多数据
+ const loadMore = () => {
+ setPageInfo(prev => ({
+ ...prev,
+ pageNo: prev.pageNo + 1,
+ }));
+ fetchTaskDetails(true);
+ };
+ // 刷新数据
+ const refreshData = () => {
+ setPageInfo({
+ pageSize: 10,
+ pageNo: 1,
+ totalCount: 0,
+ });
fetchTaskDetails();
- }, []);
+ message.success('数据已刷新');
+ };
const Ref_MineTaskInfo = useRef<MineTaskInfoRef>(null);
const Ref_Withdraw = useRef<WithdrawRef>(null);
@@ -79,250 +143,194 @@ export default function Page() {
const closeGuideModal = () => {
setIsGuideModalVisible(false);
};
-
- // 渲染空状态
- const renderEmptyState = () => {
- return (
- <div className={styles.emptyContainer}>
- <div className={styles.emptyText}>
- <h3>
- 接单前请务必先浏览
- <span className={styles.guideLink} onClick={openGuideModal}>
- 《接单须知与常见问题解答》
- </span>
- </h3>
- <p>所有关于接单的秘诀都在这里,请不要错过</p>
- </div>
-
- <div className={styles.guideContainer}>
- <div className={styles.guideStep}>
- <h4>接单前完成以下步骤,接单快人一步</h4>
-
- <div className={styles.qrCodeContainer}>
- <div className={styles.qrCodeItem}>
- <div className={styles.qrCodeWrapper}>
- <img
- src={qr1}
- alt="扫码加入账号招募群"
- className={styles.qrCode}
- />
- </div>
- <p className={styles.qrCodeText}>扫码加入账号招募群</p>
- <p className={styles.qrCodeSubtext}>不可在群内天打扰他人</p>
- </div>
-
- <div className={styles.qrCodeItem}>
- <div className={styles.qrCodeWrapper}>
- <img
- src={qr2}
- alt="扫码开启更多权益"
- className={styles.qrCode}
- />
- </div>
- <p className={styles.qrCodeText}>扫码开启更多权益</p>
- <p className={styles.qrCodeSubtext}>手机发文付打款通知</p>
- </div>
- </div>
- </div>
-
- <div className={styles.processContainer}>
- <h4 className={styles.processTitle}>接单流程</h4>
-
- <div className={styles.processSteps}>
- <div className={styles.processStep}>
- <div className={styles.processIcon}>
- <img
- src={bindTaskImg}
- alt="前往管理中心绑定账号"
- className={styles.stepIcon}
- />
- </div>
- <p className={styles.stepText}>前往管理中心绑定账号</p>
- </div>
-
- <div className={styles.processDivider}></div>
-
- <div className={styles.processStep}>
- <div className={styles.processIcon}>
- <img
- src={checkTaskImg}
- alt="等待平台验证通过"
- className={styles.stepIcon}
- />
- </div>
- <p className={styles.stepText}>等待平台验证通过</p>
- </div>
-
- <div className={styles.processDivider}></div>
-
- <div className={styles.processStep}>
- <div className={styles.processIcon}>
- <img
- src={publishTaskImg}
- alt="一键发文"
- className={styles.stepIcon}
- />
- </div>
- <p className={styles.stepText}>一键发文</p>
- </div>
-
- <div className={styles.processDivider}></div>
-
- <div className={styles.processStep}>
- <div className={styles.processIcon}>
- <img
- src={rewardTaskImg}
- alt="成功发文等待结算"
- className={styles.stepIcon}
- />
- </div>
- <p className={styles.stepText}>成功发文等待结算</p>
- </div>
- </div>
- </div>
- </div>
- </div>
- );
+
+ // 格式化日期
+ const formatDate = (dateString?: string) => {
+ if (!dateString) return '暂无日期';
+ return dayjs(dateString).format('YYYY/MM/DD HH:mm');
+ };
+
+ // 查看任务详情
+ const viewTaskDetail = (task: UserTask<Task<TaskDataInfo>>) => {
+ Ref_MineTaskInfo.current?.init(task);
};
return (
<div className={styles.mineTaskContainer}>
<MineTaskInfo ref={Ref_MineTaskInfo} />
<Withdraw ref={Ref_Withdraw} />
-
- {loading ? (
+
+ <div className={styles.pageHeader}>
+ <h2 className={styles.pageTitle}>我的任务</h2>
+ <div className={styles.pageActions}>
+ <Space size={12}>
+ <Select
+ className={styles.statusFilter}
+ placeholder="筛选任务状态"
+ allowClear
+ style={{ width: 150 }}
+ onChange={(value) => setStatusFilter(value)}
+ value={statusFilter}
+ options={Array.from(UserTaskStatusNameMap).map(([value, label]) => ({
+ value,
+ label,
+ }))}
+ suffixIcon={<FilterOutlined />}
+ />
+ <Button
+ className={styles.refreshButton}
+ icon={<ReloadOutlined />}
+ onClick={refreshData}
+ >
+ 刷新
+ </Button>
+ <Button
+ type="primary"
+ onClick={openGuideModal}
+ icon={<QuestionCircleOutlined />}
+ >
+ 接单指南
+ </Button>
+ </Space>
+ </div>
+ </div>
+
+ {loading && taskList.length === 0 ? (
<div className={styles.loadingContainer}>
<Spin size="large" />
</div>
- ) : taskList.length > 3 ? (
- <div className={styles.taskGrid}>
- {taskList.map((task) => (
- <Card
- key={task.id}
- className={styles.taskCard}
- title={
- <div className={styles.cardTitle}>
- <span>{task.taskId.title}</span>
- <span className={styles.taskStatus}>
- {UserTaskStatusNameMap.get(task.status)}
- </span>
- </div>
- }
- >
- <div className={styles.cardContent}>
- <div className={styles.taskInfo}>
- <p className={styles.taskDescription}>
- {task.taskId.description}
- </p>
- <div className={styles.taskDetails}>
- <div className={styles.detailItem}>
- <span className={styles.detailLabel}>接受时间:</span>
- <span className={styles.detailValue}>
- {task.createTime}
- </span>
- </div>
- {task.submissionTime && (
- <div className={styles.detailItem}>
- <span className={styles.detailLabel}>提交时间:</span>
- <span className={styles.detailValue}>
- {task.submissionTime}
+ ) : taskList.length === 0 ? (
+ <div className={styles.emptyContainer}>
+ <Empty description={false} />
+ <div className={styles.emptyText}>
+ <h3>暂无任务</h3>
+ <p>您还没有接受任何任务,可以前往任务市场查看更多任务</p>
+ </div>
+ <Button type="primary" onClick={openGuideModal} style={{ marginTop: 16 }}>
+ 查看接单指南
+ </Button>
+ </div>
+ ) : (
+ <div className={styles.taskList}>
+ {taskList.map((task) => {
+ // 获取任务详情,处理可能的undefined情况
+ const taskDetail = task.taskId || {};
+
+ return (
+ <Card key={task._id} className={styles.taskCard} bordered={false}>
+ <div className={styles.taskCardContent}>
+ <div className={styles.taskInfo}>
+ <div className={styles.taskHeader}>
+ <h3 className={styles.taskTitle}>
+ {taskDetail.title || '未知任务'}
+ <span className={styles.taskId}>
+ 订单号: {task._id}
</span>
+ </h3>
+ <Tag
+ color={UserTaskStatusColorMap.get(task.status as UserTaskStatus) || 'default'}
+ className={styles.statusTag}
+ >
+ {UserTaskStatusNameMap.get(task.status as UserTaskStatus) || '未知状态'}
+ </Tag>
+ </div>
+
+ <div className={styles.taskDetails}>
+ <div className={styles.taskDetail}>
+ <ClockCircleOutlined className={styles.detailIcon} />
+ <span className={styles.detailLabel}>接单时间:</span>
+ <span className={styles.detailValue}>{formatDate(task.createTime)}</span>
</div>
- )}
- {task.rewardTime && (
- <div className={styles.detailItem}>
- <span className={styles.detailLabel}>完成时间:</span>
- <span className={styles.detailValue}>
- {task.rewardTime}
- </span>
+
+ <div className={styles.taskDetail}>
+ <FileTextOutlined className={styles.detailIcon} />
+ <span className={styles.detailLabel}>任务要求:</span>
+ <span className={styles.detailValue}>{taskDetail.requirement || '不许删文'}</span>
</div>
- )}
+
+ <div className={styles.taskDetail}>
+ <DollarOutlined className={styles.detailIcon} />
+ <span className={styles.detailLabel}>任务奖励:</span>
+ <span className={styles.detailValue}>¥{taskDetail.reward || 5}</span>
+ </div>
+ </div>
</div>
- </div>
-
- <div className={styles.taskActions}>
- {task.status === UserTaskStatus.DODING && (
- <Button
- type="primary"
- className={styles.actionButton}
- onClick={() => Ref_MineTaskInfo.current?.init(task)}
- >
- 去完成
- </Button>
- )}
-
- {task.status === UserTaskStatus.APPROVED && (
+
+ <div className={styles.taskAction}>
+ {(task.status === UserTaskStatus.APPROVED ||
+ task.status === UserTaskStatus.COMPLETED ||
+ task.status === UserTaskStatus.REWARDED) && (
+ <Button
+ type="primary"
+ danger
+ className={styles.withdrawButton}
+ onClick={() => withdraw(task)}
+ >
+ 提现
+ </Button>
+ )}
+
<Button
- type="primary"
- className={styles.actionButton}
- onClick={() => withdraw(task)}
+ className={styles.viewButton}
+ onClick={() => viewTaskDetail(task)}
>
- 提现
+ 查看详情 <RightOutlined />
</Button>
- )}
+ </div>
</div>
- </div>
- </Card>
- ))}
+ </Card>
+ );
+ })}
+
+ {loading && (
+ <div className={styles.loadingContainer}>
+ <Spin size="large" />
+ </div>
+ )}
+
+ {!loading && hasMore && (
+ <div className={styles.loadMoreContainer}>
+ <Button onClick={loadMore}>加载更多</Button>
+ </div>
+ )}
</div>
- ) : (
- renderEmptyState()
)}
-
- {/* 接单须知与常见问题解答弹窗 */}
+
<Modal
- title="接单须知与常见问题解答"
+ title="接单指南"
open={isGuideModalVisible}
onCancel={closeGuideModal}
- footer={[
- <Button key="close" onClick={closeGuideModal}>
- 关闭
- </Button>,
- ]}
+ footer={null}
width={800}
className={styles.guideModal}
>
- <div className={styles.guideModalContent}>
+ <div className={styles.guideContainer}>
<div className={styles.guideHeader}>
- <h2>接单步骤&常见问答</h2>
- <p className={styles.guideDate}>新榜有赚 2024-08-23</p>
+ <h2>如何接单赚钱</h2>
+ <div className={styles.guideDate}>更新时间: 2025年3月1日</div>
</div>
-
+
<div className={styles.guideIntro}>
<p>
- 欢迎使用爱团团AiToEarn任务市场,爱团团是新榜开发的一款新媒体多账号运营工具,爱团团任务市场目前支持小红书、抖音、视频号、B站、微博、知乎、公众号、快手、携程等新媒体账号接单变现。
- </p>
- <p>
- 任务属于派单制,如果您的号满足当前广告主的要求,则会被派单,每个人得到的任务是不同的。如果您想要接单,可以把自己有的流量资源绑定到爱团团当中耐心等待。请按照下列步骤进行:
+ 欢迎使用任务市场!本指南将帮助您了解如何通过接单赚取额外收入。请仔细阅读以下步骤,确保您能顺利完成任务并获得奖励。
</p>
</div>
-
+
<div className={styles.guideSection}>
<h3>操作步骤</h3>
<ol className={styles.guideSteps}>
<li>
<p>
- 扫描下方二维码,有符合您账号的项目出现时,【新榜有赚】会第一时间通知您。如果您的爱团团电脑端保持在线即可通过手机端完成发布。
+ 关注公众号"任务市场",获取最新任务通知和平台动态。
</p>
- <div className={styles.guideImageContainer}>
- <img
- src={qr1}
- alt="扫码接收项目上新通知"
- className={styles.guideImage}
- />
- <p className={styles.guideImageCaption}>
- 扫码接收项目上新通知
- </p>
- </div>
- <div className={styles.guideImageContainer}>
- <img
- src={qr2}
- alt="点击该模板消息可手机发文"
- className={styles.guideImage}
- />
- <p className={styles.guideImageCaption}>
- 点击该模板消息可手机发文
- </p>
+ <div className={styles.qrCodeContainer}>
+ <div className={styles.qrCodeItem}>
+ <div className={styles.qrCodeWrapper}>
+ <img src={qr1} alt="任务市场公众号" className={styles.qrCode} />
+ </div>
+ <div className={styles.qrCodeText}>任务市场公众号</div>
+ <div className={styles.qrCodeSubtext}>获取最新任务通知</div>
+ </div>
</div>
</li>
<li>
diff --git a/src/views/task/popTask.module.scss b/src/views/task/popTask.module.scss
new file mode 100644
index 00000000..059398a0
--- /dev/null
+++ b/src/views/task/popTask.module.scss
@@ -0,0 +1,212 @@
+.popTaskContainer {
+ padding: 16px;
+ background-color: #fff;
+ border-radius: 8px;
+ min-height: 100%;
+}
+
+.taskList {
+ display: flex;
+ flex-direction: column;
+ gap: 16px;
+}
+
+.taskCard {
+ border-radius: 8px;
+ overflow: hidden;
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
+ transition: transform 0.2s, box-shadow 0.2s;
+
+ &:hover {
+ transform: translateY(-3px);
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
+ }
+}
+
+.taskCardContent {
+ display: flex;
+ align-items: stretch;
+}
+
+.taskImageContainer {
+ width: 120px;
+ height: 120px;
+ flex-shrink: 0;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background-color: #f5f5f5;
+ border-radius: 4px;
+ overflow: hidden;
+ margin: 16px;
+}
+
+.taskImage {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+}
+
+.taskInfo {
+ flex: 1;
+ padding: 16px 0;
+ display: flex;
+ flex-direction: column;
+ text-align: left;
+}
+
+.taskHeader {
+ display: flex;
+ align-items: center;
+ margin-bottom: 8px;
+}
+
+.taskTitle {
+ font-size: 18px;
+ font-weight: 500;
+ color: #333;
+ margin: 0 12px 0 0;
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+}
+
+.taskId {
+ font-size: 12px;
+ color: #999;
+ font-weight: normal;
+ margin-left: 8px;
+ display: flex;
+ align-items: center;
+}
+
+.copyIcon {
+ margin-left: 4px;
+ cursor: pointer;
+ color: #1890ff;
+
+ &:hover {
+ color: #40a9ff;
+ }
+}
+
+.taskTag {
+ font-size: 12px;
+}
+
+.taskDescription {
+ color: #666;
+ font-size: 14px;
+ margin-bottom: 12px;
+ display: -webkit-box;
+ -webkit-line-clamp: 2;
+ -webkit-box-orient: vertical;
+ overflow: hidden;
+ text-align: left;
+
+ p {
+ margin-bottom: 0;
+ }
+}
+
+.taskDetails {
+ display: flex;
+ gap: 24px;
+ margin-bottom: 12px;
+}
+
+.taskDetail {
+ display: flex;
+ align-items: center;
+ font-size: 13px;
+ color: #666;
+}
+
+.detailIcon {
+ margin-right: 4px;
+ color: #999;
+}
+
+.detailLabel {
+ margin-right: 4px;
+}
+
+.detailValue {
+ color: #333;
+}
+
+.taskRequirement {
+ font-size: 13px;
+ color: #666;
+ text-align: left;
+}
+
+.requirementLabel {
+ margin-right: 4px;
+}
+
+.requirementValue {
+ color: #333;
+}
+
+.taskAction {
+ width: 160px;
+ flex-shrink: 0;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ padding: 16px;
+ border-left: 1px solid #f0f0f0;
+}
+
+.taskStatus {
+ margin-bottom: 12px;
+}
+
+.taskReward {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ margin-bottom: 16px;
+}
+
+.rewardLabel {
+ font-size: 12px;
+ color: #999;
+ margin-bottom: 4px;
+}
+
+.rewardValue {
+ font-size: 24px;
+ font-weight: 500;
+ color: #ff4d4f;
+}
+
+.viewButton {
+ width: 100%;
+ background-color: #52c41a;
+ border-color: #52c41a;
+
+ &:hover {
+ background-color: #73d13d;
+ border-color: #73d13d;
+ }
+}
+
+.loadingContainer {
+ display: flex;
+ justify-content: center;
+ padding: 32px 0;
+}
+
+.loadMoreContainer {
+ display: flex;
+ justify-content: center;
+ margin-top: 16px;
+ margin-bottom: 16px;
+
+ button {
+ padding: 0 32px;
+ }
+}
\ No newline at end of file
diff --git a/src/views/task/popTask.tsx b/src/views/task/popTask.tsx
index ef0f75e2..9ae946e1 100644
--- a/src/views/task/popTask.tsx
+++ b/src/views/task/popTask.tsx
@@ -5,12 +5,21 @@
* @LastEditors: nevin
* @Description: 推广任务
*/
-import { Button, Card, Col, Row } from 'antd';
+import { Button, Card, Tag, Spin, message, Tooltip } from 'antd';
import { useState, useEffect, useRef } from 'react';
import { Task, TaskPromotion, TaskType } from '@@/types/task';
import { taskApi } from '@/api/task';
import { TaskInfoRef } from './components/popInfo';
import TaskInfo from './components/popInfo';
+import styles from './popTask.module.scss';
+import {
+ ClockCircleOutlined,
+ TeamOutlined,
+ RightOutlined,
+ CopyOutlined
+} from '@ant-design/icons';
+import dayjs from 'dayjs';
+
const FILE_BASE_URL = import.meta.env.VITE_APP_FILE_HOST;
export default function Page() {
@@ -20,76 +29,162 @@ export default function Page() {
pageNo: 1,
totalCount: 0,
});
+ const [loading, setLoading] = useState(true);
+ const [hasMore, setHasMore] = useState(true);
const Ref_TaskInfo = useRef<TaskInfoRef>(null);
- async function getTaskList() {
- const res = await taskApi.getTaskList({
- ...pageInfo,
- type: TaskType.PROMOTION,
- });
- setTaskList(res.items);
+ async function getTaskList(isLoadMore = false) {
+ setLoading(true);
+ try {
+ const res = await taskApi.getTaskList({
+ ...pageInfo,
+ type: TaskType.PROMOTION,
+ });
+
+ if (isLoadMore) {
+ setTaskList(prev => [...prev, ...res.items]);
+ } else {
+ setTaskList(res.items);
+ }
+
+ setPageInfo(prev => ({
+ ...prev,
+ totalCount: (res as any).totalCount,
+ }));
+
+ // 检查是否还有更多数据
+ setHasMore(pageInfo.pageNo * pageInfo.pageSize < (res as any).totalCount);
+ } catch (error) {
+ console.error('获取任务列表失败', error);
+ } finally {
+ setLoading(false);
+ }
}
useEffect(() => {
getTaskList();
}, []);
+
+ // 加载更多数据
+ const loadMore = () => {
+ setPageInfo(prev => ({
+ ...prev,
+ pageNo: prev.pageNo + 1,
+ }));
+ getTaskList(true);
+ };
+
+ // 格式化日期
+ const formatDate = (dateString: string) => {
+ if (!dateString) return '2025/03/17';
+ return dayjs(dateString).format('YYYY/MM/DD');
+ };
+
+ // 复制任务ID
+ const copyTaskId = (id: string) => {
+ navigator.clipboard.writeText(id)
+ .then(() => {
+ message.success('任务ID已复制到剪贴板');
+ })
+ .catch(() => {
+ message.error('复制失败,请手动复制');
+ });
+ };
return (
- <div >
+ <div className={styles.popTaskContainer}>
<TaskInfo ref={Ref_TaskInfo} />
- <div className="flex flex-wrap gap-4">
- {taskList.map((v) => {
- return (
- <Card
- key={v.id}
- className="box-border w-full p-4 sm:w-1/2 md:w-1/3"
- >
- <Row>
- <Col span={12}>
- <div>
- <img
- src={`${FILE_BASE_URL}${v.imageUrl}`}
- alt=""
- className="w-full h-full"
- />
+
+ <div className={styles.taskList}>
+ {taskList.map((task) => (
+ <Card key={task.id} className={styles.taskCard}>
+ <div className={styles.taskCardContent}>
+ <div className={styles.taskImageContainer}>
+ <img
+ src={`${FILE_BASE_URL}${task.imageUrl}`}
+ alt={task.title}
+ className={styles.taskImage}
+ />
+ </div>
+
+ <div className={styles.taskInfo}>
+ <div className={styles.taskHeader}>
+ <h3 className={styles.taskTitle}>
+ {task.title}
+ <span className={styles.taskId}>
+ ID: {task._id}
+ <Tooltip title="复制任务ID">
+ <CopyOutlined
+ className={styles.copyIcon}
+ onClick={() => copyTaskId(task._id)}
+ />
+ </Tooltip>
+ </span>
+ </h3>
+ <Tag color="#108ee9" className={styles.taskTag}>
+ {task.dataInfo?.type || 'AI对话APP'}
+ </Tag>
+ </div>
+
+ <div
+ className={styles.taskDescription}
+ dangerouslySetInnerHTML={{ __html: task.description || '扫二维码下载APP并完成注册任务' }}
+ />
+
+ <div className={styles.taskDetails}>
+ <div className={styles.taskDetail}>
+ <ClockCircleOutlined className={styles.detailIcon} />
+ <span className={styles.detailLabel}>截止时间:</span>
+ <span className={styles.detailValue}>{formatDate(task.deadline)}</span>
+ </div>
+
+ <div className={styles.taskDetail}>
+ <TeamOutlined className={styles.detailIcon} />
+ <span className={styles.detailLabel}>招募人数:</span>
+ <span className={styles.detailValue}>{task.maxRecruits || 100}</span>
</div>
- </Col>
- <Col span={12}>
- <h3>{v.title}</h3>
- <Row>
- <Col span={12}>
- {!v.dataInfo ? (
- <div>暂无数据</div>
- ) : (
- <>
- <p> {v.dataInfo.title}</p>
- </>
- )}
- </Col>
- <Col span={12}>
- <p>招募人数: {v.maxRecruits}</p>
- <p>截至日期: {v.deadline}</p>
- </Col>
- </Row>
- </Col>
- </Row>
- <Row>
- <Row>
- <Col span={12}>-----</Col>
- <Col span={12}>
- <Button
- type="primary"
- onClick={() => Ref_TaskInfo.current?.init(v)}
- >
- 查看
- </Button>
- </Col>
- </Row>
- </Row>
- </Card>
- );
- })}
+ </div>
+
+ <div className={styles.taskRequirement}>
+ <span className={styles.requirementLabel}>任务要求:</span>
+ <span className={styles.requirementValue}>{task.requirement || '扫二维码'}</span>
+ </div>
+ </div>
+
+ <div className={styles.taskAction}>
+ <div className={styles.taskStatus}>
+ <Tag color="#87d068">进行中</Tag>
+ </div>
+
+ <div className={styles.taskReward}>
+ <span className={styles.rewardLabel}>每篇可赚</span>
+ <span className={styles.rewardValue}>¥{task.reward || 5}</span>
+ </div>
+
+ <Button
+ type="primary"
+ className={styles.viewButton}
+ onClick={() => Ref_TaskInfo.current?.init(task)}
+ >
+ 去查看 <RightOutlined />
+ </Button>
+ </div>
+ </div>
+ </Card>
+ ))}
+
+ {loading && (
+ <div className={styles.loadingContainer}>
+ <Spin size="large" />
+ </div>
+ )}
+
+ {!loading && hasMore && (
+ <div className={styles.loadMoreContainer}>
+ <Button onClick={loadMore}>查看更多任务</Button>
+ </div>
+ )}
</div>
</div>
);
diff --git a/src/views/task/videoTask.module.scss b/src/views/task/videoTask.module.scss
new file mode 100644
index 00000000..5558424a
--- /dev/null
+++ b/src/views/task/videoTask.module.scss
@@ -0,0 +1,242 @@
+.videoTaskContainer {
+ padding: 16px;
+ background-color: #fff;
+ border-radius: 8px;
+ min-height: 100%;
+}
+
+.taskList {
+ display: flex;
+ flex-direction: column;
+ gap: 16px;
+}
+
+.taskCard {
+ border-radius: 8px;
+ overflow: hidden;
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
+ transition: transform 0.2s, box-shadow 0.2s;
+
+ &:hover {
+ transform: translateY(-3px);
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
+ }
+}
+
+.taskCardContent {
+ display: flex;
+ align-items: stretch;
+}
+
+.taskImageContainer {
+ width: 180px;
+ height: 120px;
+ flex-shrink: 0;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background-color: #000;
+ position: relative;
+ overflow: hidden;
+ margin: 16px;
+ border-radius: 4px;
+}
+
+.taskImage {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+}
+
+.videoOverlay {
+ position: absolute;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background-color: rgba(0, 0, 0, 0.3);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ transition: background-color 0.2s;
+
+ &:hover {
+ background-color: rgba(0, 0, 0, 0.5);
+ }
+}
+
+.playIcon {
+ font-size: 36px;
+ color: #fff;
+ opacity: 0.8;
+ transition: opacity 0.2s, transform 0.2s;
+
+ &:hover {
+ opacity: 1;
+ transform: scale(1.1);
+ }
+}
+
+.taskInfo {
+ flex: 1;
+ padding: 16px 0;
+ display: flex;
+ flex-direction: column;
+ text-align: left;
+}
+
+.taskHeader {
+ display: flex;
+ align-items: center;
+ margin-bottom: 8px;
+}
+
+.taskTitle {
+ font-size: 18px;
+ font-weight: 500;
+ color: #333;
+ margin: 0 12px 0 0;
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+}
+
+.taskId {
+ font-size: 12px;
+ color: #999;
+ font-weight: normal;
+ margin-left: 8px;
+ display: flex;
+ align-items: center;
+}
+
+.copyIcon {
+ margin-left: 4px;
+ cursor: pointer;
+ color: #1890ff;
+
+ &:hover {
+ color: #40a9ff;
+ }
+}
+
+.taskTag {
+ font-size: 12px;
+}
+
+.taskDescription {
+ color: #666;
+ font-size: 14px;
+ margin-bottom: 12px;
+ display: -webkit-box;
+ -webkit-line-clamp: 2;
+ -webkit-box-orient: vertical;
+ overflow: hidden;
+ text-align: left;
+
+ p {
+ margin-bottom: 0;
+ }
+}
+
+.taskDetails {
+ display: flex;
+ gap: 24px;
+ margin-bottom: 12px;
+}
+
+.taskDetail {
+ display: flex;
+ align-items: center;
+ font-size: 13px;
+ color: #666;
+}
+
+.detailIcon {
+ margin-right: 4px;
+ color: #999;
+}
+
+.detailLabel {
+ margin-right: 4px;
+}
+
+.detailValue {
+ color: #333;
+}
+
+.taskRequirement {
+ font-size: 13px;
+ color: #666;
+ text-align: left;
+}
+
+.requirementLabel {
+ margin-right: 4px;
+}
+
+.requirementValue {
+ color: #333;
+}
+
+.taskAction {
+ width: 160px;
+ flex-shrink: 0;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ padding: 16px;
+ border-left: 1px solid #f0f0f0;
+}
+
+.taskStatus {
+ margin-bottom: 12px;
+}
+
+.taskReward {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ margin-bottom: 16px;
+}
+
+.rewardLabel {
+ font-size: 12px;
+ color: #999;
+ margin-bottom: 4px;
+}
+
+.rewardValue {
+ font-size: 24px;
+ font-weight: 500;
+ color: #ff4d4f;
+}
+
+.viewButton {
+ width: 100%;
+ background-color: #52c41a;
+ border-color: #52c41a;
+
+ &:hover {
+ background-color: #73d13d;
+ border-color: #73d13d;
+ }
+}
+
+.loadingContainer {
+ display: flex;
+ justify-content: center;
+ padding: 32px 0;
+}
+
+.loadMoreContainer {
+ display: flex;
+ justify-content: center;
+ margin-top: 16px;
+ margin-bottom: 16px;
+
+ button {
+ padding: 0 32px;
+ }
+}
\ No newline at end of file
diff --git a/src/views/task/videoTask.tsx b/src/views/task/videoTask.tsx
index 82a90098..09eaa26a 100644
--- a/src/views/task/videoTask.tsx
+++ b/src/views/task/videoTask.tsx
@@ -5,12 +5,22 @@
* @LastEditors: nevin
* @Description: 视频任务
*/
-import { Button, Card, Col, Row } from 'antd';
+import { Button, Card, Tag, Spin, message, Tooltip } from 'antd';
import { useState, useEffect, useRef } from 'react';
import { Task, TaskType, TaskVideo } from '@@/types/task';
import { taskApi } from '@/api/task';
import { TaskInfoRef } from './components/popInfo';
import TaskInfo from './components/videoInfo';
+import styles from './videoTask.module.scss';
+import {
+ ClockCircleOutlined,
+ TeamOutlined,
+ RightOutlined,
+ PlayCircleOutlined,
+ CopyOutlined
+} from '@ant-design/icons';
+import dayjs from 'dayjs';
+
const FILE_BASE_URL = import.meta.env.VITE_APP_FILE_HOST;
export default function Page() {
@@ -20,75 +30,169 @@ export default function Page() {
pageNo: 1,
totalCount: 0,
});
+ const [loading, setLoading] = useState(true);
+ const [hasMore, setHasMore] = useState(true);
const Ref_TaskInfo = useRef<TaskInfoRef>(null);
- async function getTaskList() {
- const res = await taskApi.getTaskList<TaskVideo>({
- ...pageInfo,
- type: TaskType.VIDEO,
- });
- setTaskList(res.items);
+ async function getTaskList(isLoadMore = false) {
+ setLoading(true);
+ try {
+ const res = await taskApi.getTaskList<TaskVideo>({
+ ...pageInfo,
+ type: TaskType.VIDEO,
+ });
+
+ if (isLoadMore) {
+ setTaskList(prev => [...prev, ...res.items]);
+ } else {
+ setTaskList(res.items);
+ }
+
+ setPageInfo(prev => ({
+ ...prev,
+ totalCount: (res as any).totalCount,
+ }));
+
+ // 检查是否还有更多数据
+ setHasMore(pageInfo.pageNo * pageInfo.pageSize < (res as any).totalCount);
+ } catch (error) {
+ console.error('获取任务列表失败', error);
+ } finally {
+ setLoading(false);
+ }
}
useEffect(() => {
getTaskList();
}, []);
+
+ // 加载更多数据
+ const loadMore = () => {
+ setPageInfo(prev => ({
+ ...prev,
+ pageNo: prev.pageNo + 1,
+ }));
+ getTaskList(true);
+ };
+
+ // 格式化日期
+ const formatDate = (dateString?: string) => {
+ if (!dateString) return '2025/03/17';
+ return dayjs(dateString).format('YYYY/MM/DD');
+ };
+
+ // 复制任务ID
+ const copyTaskId = (id: string, e: React.MouseEvent) => {
+ e.stopPropagation();
+ navigator.clipboard.writeText(id)
+ .then(() => {
+ message.success('任务ID已复制到剪贴板');
+ })
+ .catch(() => {
+ message.error('复制失败,请手动复制');
+ });
+ };
return (
- <div >
+ <div className={styles.videoTaskContainer}>
<TaskInfo ref={Ref_TaskInfo} />
- <div className="flex flex-wrap gap-4">
- {taskList.map((v) => {
- return (
- <Card
- key={v.id}
- className="box-border w-full p-4 sm:w-1/2 md:w-1/3"
- >
- <Row>
- <Col span={12}>
- <div>
- <img
- src={`${FILE_BASE_URL}${v.imageUrl}`}
- alt=""
- className="w-full h-full"
- />
+ <div className={styles.taskList}>
+ {taskList.map((task) => (
+ <Card
+ key={task.id}
+ className={styles.taskCard}
+ bodyStyle={{ padding: 0 }}
+ >
+ <div className={styles.taskCardContent}>
+ <div className={styles.taskImageContainer}>
+ <img
+ src={`${FILE_BASE_URL}${task.imageUrl}`}
+ alt={task.title}
+ className={styles.taskImage}
+ />
+ <div className={styles.videoOverlay}>
+ <PlayCircleOutlined className={styles.playIcon} />
+ </div>
+ </div>
+
+ <div className={styles.taskInfo}>
+ <div className={styles.taskHeader}>
+ <h3 className={styles.taskTitle}>
+ {task.title}
+ <span className={styles.taskId}>
+ ID: {task.id}
+ <Tooltip title="复制任务ID">
+ <CopyOutlined
+ className={styles.copyIcon}
+ onClick={(e) => copyTaskId(task.id, e)}
+ />
+ </Tooltip>
+ </span>
+ </h3>
+ <Tag color="#f50" className={styles.taskTag}>
+ {task.dataInfo?.type || '视频任务'}
+ </Tag>
+ </div>
+
+ <div
+ className={styles.taskDescription}
+ dangerouslySetInnerHTML={{ __html: task.description || '不许删文' }}
+ />
+
+ <div className={styles.taskDetails}>
+ <div className={styles.taskDetail}>
+ <ClockCircleOutlined className={styles.detailIcon} />
+ <span className={styles.detailLabel}>截止时间:</span>
+ <span className={styles.detailValue}>{formatDate(task.deadline)}</span>
+ </div>
+
+ <div className={styles.taskDetail}>
+ <TeamOutlined className={styles.detailIcon} />
+ <span className={styles.detailLabel}>招募人数:</span>
+ <span className={styles.detailValue}>{task.maxRecruits || 100}</span>
</div>
- </Col>
- <Col span={12}>
- <h3>{v.title}</h3>
- <Row>
- <Col span={12}>
- {!v.dataInfo ? (
- <div>暂无数据</div>
- ) : (
- <>
- <p> {v.dataInfo.title}</p>
- </>
- )}
- </Col>
- <Col span={12}>
- <p>招募人数: {v.maxRecruits}</p>
- </Col>
- </Row>
- </Col>
- </Row>
- <Row>
- <Row>
- <Col span={12}>-----</Col>
- <Col span={12}>
- <Button
- type="primary"
- onClick={() => Ref_TaskInfo.current?.init(v)}
- >
- 查看
- </Button>
- </Col>
- </Row>
- </Row>
- </Card>
- );
- })}
+ </div>
+
+ <div className={styles.taskRequirement}>
+ <span className={styles.requirementLabel}>任务要求:</span>
+ <span className={styles.requirementValue}>{task.requirement || '不许删文'}</span>
+ </div>
+ </div>
+
+ <div className={styles.taskAction}>
+ <div className={styles.taskStatus}>
+ <Tag color="#87d068">进行中</Tag>
+ </div>
+
+ <div className={styles.taskReward}>
+ <span className={styles.rewardLabel}>每篇可赚</span>
+ <span className={styles.rewardValue}>¥{task.reward || 5}</span>
+ </div>
+
+ <Button
+ type="primary"
+ className={styles.viewButton}
+ onClick={() => Ref_TaskInfo.current?.init(task)}
+ >
+ 去查看 <RightOutlined />
+ </Button>
+ </div>
+ </div>
+ </Card>
+ ))}
+
+ {loading && (
+ <div className={styles.loadingContainer}>
+ <Spin size="large" />
+ </div>
+ )}
+
+ {!loading && hasMore && (
+ <div className={styles.loadMoreContainer}>
+ <Button onClick={loadMore}>查看更多任务</Button>
+ </div>
+ )}
</div>
</div>
);