| 1 | /* |
| 2 | * @Author: nevin |
| 3 | * @Date: 2025-02-10 22:20:15 |
| 4 | * @LastEditTime: 2025-02-28 21:36:53 |
| 5 | * @LastEditors: nevin |
| 6 | * @Description: 任务页面 |
| 7 | */ |
| 8 | import { useState } from 'react'; |
| 9 | import { |
| 10 | ShoppingCartOutlined, |
| 11 | ShareAltOutlined, |
| 12 | VideoCameraOutlined, |
| 13 | HistoryOutlined, |
| 14 | WalletOutlined, |
| 15 | FileTextOutlined, |
| 16 | CommentOutlined, |
| 17 | } from '@ant-design/icons'; |
| 18 | import styles from './task.module.scss'; |
| 19 | |
| 20 | // 导入现有的任务组件 |
| 21 | import CarTask from './carTask'; |
| 22 | import PopTask from './popTask'; |
| 23 | import VideoTask from './videoTask'; |
| 24 | import MineTask from './mineTask'; |
| 25 | import ArticleTask from './articleTask'; |
| 26 | import InteractionTask from './interactionTask'; |
| 27 | |
| 28 | import { useNavigate } from 'react-router-dom'; |
| 29 | |
| 30 | // 任务类型定义 |
| 31 | interface Task { |
| 32 | id: string; |
| 33 | title: string; |
| 34 | price: number; |
| 35 | originalPrice?: number; |
| 36 | discount?: number; |
| 37 | image: string; |
| 38 | likes: number; |
| 39 | views: number; |
| 40 | level: string; |
| 41 | } |
| 42 | |
| 43 | export default function Task() { |
| 44 | const navigate = useNavigate(); |
| 45 | // 当前选中的任务类型 |
| 46 | const [activeTab, setActiveTab] = useState('article'); |
| 47 | |
| 48 | // 渲染对应的任务内容 |
| 49 | const renderTaskContent = () => { |
| 50 | switch (activeTab) { |
| 51 | case 'car': |
| 52 | return <CarTask />; |
| 53 | case 'pop': |
| 54 | return <PopTask />; |
| 55 | case 'video': |
| 56 | return <VideoTask />; |
| 57 | case 'mine': |
| 58 | return <MineTask />; |
| 59 | case 'article': |
| 60 | return <ArticleTask />; |
| 61 | case 'interaction': |
| 62 | return <InteractionTask />; |
| 63 | default: |
| 64 | return <CarTask />; |
| 65 | } |
| 66 | }; |
| 67 | |
| 68 | return ( |
| 69 | <div className={styles.taskPageContainer}> |
| 70 | {/* 顶部导航栏 */} |
| 71 | <div className={styles.taskHeader}> |
| 72 | <div className={styles.taskHeaderLeft}> |
| 73 | <div |
| 74 | className={`${styles.taskButton} ${activeTab === 'car' ? styles.activeTaskButton : ''}`} |
| 75 | onClick={() => setActiveTab('car')} |
| 76 | > |
| 77 | <ShoppingCartOutlined /> |
| 78 | <span>挂车市场任务</span> |
| 79 | </div> |
| 80 | <div |
| 81 | className={`${styles.taskButton} ${activeTab === 'pop' ? styles.activeTaskButton : ''}`} |
| 82 | onClick={() => setActiveTab('pop')} |
| 83 | > |
| 84 | <ShareAltOutlined /> |
| 85 | <span>推广任务</span> |
| 86 | </div> |
| 87 | <div |
| 88 | className={`${styles.taskButton} ${activeTab === 'video' ? styles.activeTaskButton : ''}`} |
| 89 | onClick={() => setActiveTab('video')} |
| 90 | > |
| 91 | <VideoCameraOutlined /> |
| 92 | <span>视频任务</span> |
| 93 | </div> |
| 94 | <div |
| 95 | className={`${styles.taskButton} ${activeTab === 'article' ? styles.activeTaskButton : ''}`} |
| 96 | onClick={() => setActiveTab('article')} |
| 97 | > |
| 98 | <FileTextOutlined /> |
| 99 | <span>文章任务</span> |
| 100 | </div> |
| 101 | <div |
| 102 | className={`${styles.taskButton} ${activeTab === 'interaction' ? styles.activeTaskButton : ''}`} |
| 103 | onClick={() => setActiveTab('interaction')} |
| 104 | > |
| 105 | <CommentOutlined /> |
| 106 | <span>互动任务</span> |
| 107 | </div> |
| 108 | <div |
| 109 | className={`${styles.taskButton} ${activeTab === 'mine' ? styles.activeTaskButton : ''}`} |
| 110 | onClick={() => setActiveTab('mine')} |
| 111 | > |
| 112 | <HistoryOutlined /> |
| 113 | <span>已参与过任务</span> |
| 114 | </div> |
| 115 | </div> |
| 116 | <div className={styles.taskHeaderRight}> |
| 117 | <div |
| 118 | className={styles.withdrawText} |
| 119 | onClick={() => navigate('/finance')} |
| 120 | > |
| 121 | <WalletOutlined /> |
| 122 | <span>钱包</span> |
| 123 | </div> |
| 124 | </div> |
| 125 | </div> |
| 126 | |
| 127 | {/* 任务内容 */} |
| 128 | <div className={styles.taskContent}>{renderTaskContent()}</div> |
| 129 | </div> |
| 130 | ); |
| 131 | } |
| 132 |