Skip to content

Let's use AI to Earn!

刷新问题和赚钱模式等

daoyianf69d46dd8f58
diff --git a/src/views/task/mineTask.tsx b/src/views/task/mineTask.tsx
index cd8537e0..81fa1170 100644
--- a/src/views/task/mineTask.tsx
+++ b/src/views/task/mineTask.tsx
@@ -189,11 +189,11 @@ export default function Page() {
}
}, [inView, hasMore, loading]);
- const fetchTaskDetails = async (isLoadMore = false) => {
+ const fetchTaskDetails = async (isLoadMore = false, pageInfoParam: any) => {
setLoading(true);
try {
const params = {
- ...pageInfo,
+ ...(pageInfoParam || pageInfo),
status: statusFilter,
};
@@ -239,17 +239,18 @@ export default function Page() {
page: prev.page + 1,
}));
console.log('pageInfo', pageInfo)
- await fetchTaskDetails(true);
+ await fetchTaskDetails(true, false);
};
// 刷新数据
- const refreshData = () => {
- setPageInfo({
- pageSize: 10,
+ const refreshData = async () => {
+ let pageInfo = {
+ pageSize: 10,
page: 1,
totalCount: 0,
- });
- fetchTaskDetails();
+ }
+ setPageInfo(pageInfo);
+ await fetchTaskDetails(false, pageInfo);
message.success('数据已刷新');
};
@@ -281,15 +282,6 @@ export default function Page() {
Ref_MineTaskInfo.current?.init(task);
};
- // 刷新任务列表的函数
- const refreshTaskList = () => {
- setPageInfo({
- pageSize: 10,
- page: 1,
- totalCount: 0,
- });
- fetchTaskDetails();
- };
return (
<div className={styles.mineTaskContainer}>
diff --git a/src/views/user/mine/UserProfile.tsx b/src/views/user/mine/UserProfile.tsx
index e0fab014..15500636 100644
--- a/src/views/user/mine/UserProfile.tsx
+++ b/src/views/user/mine/UserProfile.tsx
@@ -1,8 +1,9 @@
import { useEffect, useState } from 'react';
-import { Card, Descriptions, Spin, Typography, Space, Avatar } from 'antd';
+import { Card, Descriptions, Spin, Typography, Space, Avatar, Switch, Slider, Button, Alert } from 'antd';
import { userApi } from '@/api/user';
import styles from './userProfile.module.scss';
import { UserOutlined, PhoneOutlined, IdcardOutlined, QrcodeOutlined, ClockCircleOutlined, SafetyOutlined, WechatOutlined } from '@ant-design/icons';
+import { message } from 'antd';
const { Title } = Typography;
@@ -16,12 +17,19 @@ interface UserInfo {
updateTime: string;
wxOpenid: string;
_id: string;
+ earnInfo?: {
+ status: number;
+ cycleInterval: number;
+ };
}
const UserProfile = () => {
const [loading, setLoading] = useState(false);
const [userInfo, setUserInfo] = useState<UserInfo | null>(null);
const [popularizeCode, setPopularizeCode] = useState<string>('');
+ const [earnStatus, setEarnStatus] = useState<boolean>(false);
+ const [cycleInterval, setCycleInterval] = useState<number>(30);
+ const [earnLoading, setEarnLoading] = useState<boolean>(false);
const fetchUserInfo = async () => {
try {
@@ -35,6 +43,13 @@ const UserProfile = () => {
} else {
setPopularizeCode(res.popularizeCode);
}
+ if (res.earnInfo) {
+ setEarnStatus(res.earnInfo.status === 1);
+ setCycleInterval(res.earnInfo.cycleInterval || 30);
+ } else {
+ setEarnStatus(false);
+ setCycleInterval(30);
+ }
} catch (error) {
console.error('获取用户信息失败:', error);
} finally {
@@ -46,6 +61,30 @@ const UserProfile = () => {
fetchUserInfo();
}, []);
+ const handleSaveEarn = async () => {
+ setEarnLoading(true);
+ try {
+ await userApi.updateUserInfo({
+ earnInfo: {
+ status: earnStatus ? 1 : 0,
+ cycleInterval,
+ },
+ });
+ message.success('设置已保存');
+ fetchUserInfo();
+ } catch (e) {
+ message.error('保存失败');
+ } finally {
+ setEarnLoading(false);
+ }
+ };
+
+ const getIntervalLabel = (val: number) => {
+ if (val < 60) return `${val} 分钟`;
+ if (val % 60 === 0) return `${val / 60} 小时`;
+ return `${Math.floor(val / 60)} 小时${val % 60} 分钟`;
+ };
+
return (
<div className={styles.profileContainer}>
<Spin spinning={loading}>
@@ -59,6 +98,7 @@ const UserProfile = () => {
</div>
<div className={styles.profileContent}>
+
<Card className={styles.profileCard}>
<Space direction="vertical" size="large" className={styles.infoSection}>
<div className={styles.infoGroup}>
@@ -138,6 +178,41 @@ const UserProfile = () => {
</div>
</Space>
</Card>
+
+ <Card className={styles.profileCard} style={{ marginTop: 24 }}>
+ <Title level={5} style={{ marginBottom: 16 }}>赚钱模式设置</Title>
+ <div style={{ marginBottom: 16, display: 'flex', alignItems: 'center', gap: 16 }}>
+ <span>赚钱模式</span>
+ <Switch checked={earnStatus} onChange={setEarnStatus} />
+ </div>
+ <div style={{ marginBottom: 8, display: 'flex', alignItems: 'center', gap: 16 }}>
+ <span>检查频率</span>
+ <Slider
+ min={5}
+ max={1440}
+ step={1}
+ value={cycleInterval}
+ onChange={setCycleInterval}
+ style={{ flex: 1, marginRight: 16 }}
+ disabled={!earnStatus}
+ />
+ <span style={{ minWidth: 70, textAlign: 'right' }}>{getIntervalLabel(cycleInterval)}</span>
+ </div>
+ <div style={{ color: '#999', fontSize: 12, marginBottom: 12 }}>
+ 可设置 5分钟~24小时 区间
+ </div>
+ <Alert
+ type="info"
+ showIcon
+ style={{ background: '#fafaff', border: 'none', marginBottom: 16 }}
+ message={
+ <span>
+ 开启赚钱模式后,系统将自动接取并完成互动需求,确保您能获得最大收益。
+ </span>
+ }
+ />
+ </Card>
+
</div>
</Spin>
</div>