Skip to content

Let's use AI to Earn!

zujian

bulaienaofutuojiesenzhange4425d96df9d
diff --git a/src/api/types/income.ts b/src/api/types/income.ts
index b9c528c8..fd7465a0 100644
--- a/src/api/types/income.ts
+++ b/src/api/types/income.ts
@@ -14,6 +14,8 @@ export interface IncomeRecord {
type: IncomeType
desc?: string
metadata?: Record<string, unknown>
+ // 提现状态:1=可提现,0=已申请
+ status?: number
createdAt: Date
updatedAt: Date
}
diff --git a/src/app/[lng]/income/income.module.css b/src/app/[lng]/income/income.module.css
index bb619070..601c9cde 100644
--- a/src/app/[lng]/income/income.module.css
+++ b/src/app/[lng]/income/income.module.css
@@ -83,6 +83,10 @@
.headerRight {
position: relative;
z-index: 1;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 8px;
}
.balanceCard {
@@ -97,6 +101,23 @@
min-width: 200px;
}
+
+.walletLink {
+ display: inline-flex;
+ align-items: center;
+ padding: 6px 8px;
+ color: #ffffff;
+ opacity: 0.9;
+ cursor: pointer;
+ border-radius: 8px;
+ transition: all 0.2s ease;
+}
+
+.walletLink:hover {
+ background: rgba(255, 255, 255, 0.18);
+ opacity: 1;
+}
+
.balanceIcon {
width: 48px;
height: 48px;
diff --git a/src/app/[lng]/income/page.tsx b/src/app/[lng]/income/page.tsx
index 13f4b31f..14a7f1cd 100644
--- a/src/app/[lng]/income/page.tsx
+++ b/src/app/[lng]/income/page.tsx
@@ -1,7 +1,7 @@
"use client";
import { useEffect, useState } from "react";
-import { Card, Table, Button, message, Modal, Tabs, Tag, Space, Popconfirm, Descriptions, Input, Select } from "antd";
+import { Card, Table, Button, message, Modal, Tabs, Tag, Space, Popconfirm, Descriptions, Input, Select, Form } from "antd";
import { DollarOutlined, HistoryOutlined, WalletOutlined, CheckCircleOutlined, ClockCircleOutlined, CloseCircleOutlined } from "@ant-design/icons";
import { useParams, useRouter } from "next/navigation";
import { useUserStore } from "@/store/user";
@@ -11,6 +11,7 @@ import { IncomeRecord } from "@/api/types/income";
import { WithdrawRecord, WithdrawRecordStatus } from "@/api/types/withdraw";
import { useTransClient } from "@/app/i18n/client";
import styles from "./income.module.css";
+import WalletAccountSelect from "@/components/WalletAccountSelect";
const { TabPane } = Tabs;
const { Option } = Select;
@@ -95,12 +96,17 @@ export default function IncomePage() {
};
// 确认提现申请
+ const [form] = Form.useForm<{ userWalletAccountId: string }>();
+
const handleConfirmWithdraw = async () => {
if (!selectedIncomeRecord) return;
+ // 仅 status = 1 的收入记录可提现(按需求说明:1=可提现,0=已申请)
+ // 如果后端收入列表中没有 status 字段,这里按前端约定:仅当类型为 task 时允许(已有逻辑),并在提现接口前再行校验
setWithdrawSubmitting(true);
try {
- const response = await apiSubmitWithdraw(selectedIncomeRecord._id);
+ const values = await form.validateFields();
+ const response = await apiSubmitWithdraw(selectedIncomeRecord._id, values.userWalletAccountId);
if (response) {
message.success(t('messages.withdrawSubmitted'));
setWithdrawModalVisible(false);
@@ -185,14 +191,15 @@ export default function IncomePage() {
key: 'action',
render: (_: any, record: IncomeRecord) => (
<Space>
- <Button
- type="primary"
- size="small"
- onClick={() => handleWithdraw(record)}
- disabled={record.type !== 'task'} // 只有任务收入可以提现
- >
- {t('applyWithdraw')}
- </Button>
+ {record.type === 'task' && record.status === 1 ? (
+ <Button
+ type="primary"
+ size="small"
+ onClick={() => handleWithdraw(record)}
+ >
+ {t('applyWithdraw')}
+ </Button>
+ ) : null}
</Space>
),
},
@@ -279,11 +286,13 @@ export default function IncomePage() {
<div className={styles.balanceAmount}>¥ {userInfo?.income || 0}</div>
</div>
</div>
- <div style={{ marginLeft: 12 }}>
- <Button type="primary" onClick={() => router.push(`/${lng}/wallet`)}>
- {t('myWallet')}
- </Button>
- </div>
+ <span
+ className={styles.walletLink}
+ role="button"
+ onClick={() => router.push(`/${lng}/wallet`)}
+ >
+ {t('myWallet')}
+ </span>
</div>
</div>
</div>
@@ -412,6 +421,13 @@ export default function IncomePage() {
</div>
)}
</div>
+
+ <Form form={form} layout="vertical">
+ <Form.Item name="userWalletAccountId" label={t('myWallet')} rules={[{ required: true, message: t('messages.pleaseLoginFirst') }]}>
+ <WalletAccountSelect />
+ </Form.Item>
+ </Form>
+
<div className={styles.withdrawWarning}>
<p>{t('withdrawWarning')}</p>
<p>{t('withdrawWarning2')}</p>
diff --git a/src/app/[lng]/page.tsx b/src/app/[lng]/page.tsx
index 8e8839ff..12a6942e 100644
--- a/src/app/[lng]/page.tsx
+++ b/src/app/[lng]/page.tsx
@@ -109,6 +109,8 @@ function Header({ currentModule, onModuleChange }: { currentModule: string, onMo
<a href="https://status.aitoearn.ai/" target="_blank" rel="noopener noreferrer" className={styles.navLink} style={{ paddingTop: '3px' }}>{t('header.nav.status' as any)}</a>
<a href="https://docs.aitoearn.ai/" target="_blank" rel="noopener noreferrer" className={styles.navLink} style={{ paddingTop: '3px' }}>{t('header.nav.docs' as any)}</a>
<a href="https://blog.aitoearn.ai/" target="_blank" rel="noopener noreferrer" className={styles.navLink} style={{ paddingTop: '3px' }}>{t('header.nav.blog' as any)}</a>
+ <a href="https://docs.aitoearn.ai/zh/downloads" target="_blank" rel="noopener noreferrer" className={styles.navLink} style={{ paddingTop: '3px' }}>{t('header.nav.download' as any)}</a>
+
{/* <a href="#docs" className={styles.navLink}>{t('header.nav.docs')}</a> */}
{/* <a href="#blog" className={styles.navLink}>{t('header.nav.blog')}</a> */}
</nav>
diff --git a/src/app/i18n/locales/en/home.json b/src/app/i18n/locales/en/home.json
index 1f64d111..1aa8c840 100644
--- a/src/app/i18n/locales/en/home.json
+++ b/src/app/i18n/locales/en/home.json
@@ -10,7 +10,9 @@
"pricing": "Pricing",
"status": "Status",
"docs": "Docs",
- "blog": "Blog"
+ "blog": "Blog",
+ "download": "Downloads"
+
},
"getStarted": "Get Started"
},
@@ -215,6 +217,7 @@
"links": {
"docs": "Documentation",
"blog": "Blog",
+ "download": "Downloads",
"education": "Education",
"partner": "Partners",
"support": "Support",
diff --git a/src/components/WalletAccountSelect/index.tsx b/src/components/WalletAccountSelect/index.tsx
new file mode 100644
index 00000000..6bc624b7
--- /dev/null
+++ b/src/components/WalletAccountSelect/index.tsx
@@ -0,0 +1,74 @@
+"use client";
+
+import { useEffect, useMemo, useState } from "react";
+import { Select, Spin, Empty } from "antd";
+import { getUserWalletAccountList, UserWalletAccount } from "@/api/userWalletAccount";
+
+type Props = {
+ value?: string;
+ onChange?: (val?: string) => void;
+ pageSize?: number;
+ disabled?: boolean;
+};
+
+const { Option } = Select;
+
+export default function WalletAccountSelect(props: Props) {
+ const { value, onChange, pageSize = 50, disabled } = props;
+ const [loading, setLoading] = useState(false);
+ const [list, setList] = useState<UserWalletAccount[]>([]);
+ const [pageNo, setPageNo] = useState(1);
+ const [total, setTotal] = useState(0);
+
+ const hasMore = useMemo(() => list.length < total, [list.length, total]);
+
+ useEffect(() => {
+ fetchPage(1);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+
+ async function fetchPage(nextPage: number) {
+ setLoading(true);
+ try {
+ const res = await getUserWalletAccountList(nextPage, pageSize);
+ if (res?.data) {
+ const newList = nextPage === 1 ? (res.data.list || []) : [...list, ...(res.data.list || [])];
+ setList(newList);
+ setTotal(res.data.total || 0);
+ setPageNo(nextPage);
+ }
+ } finally {
+ setLoading(false);
+ }
+ }
+
+ function onPopupScroll(e: any) {
+ const target = e.target;
+ if (!loading && hasMore && target.scrollTop + target.offsetHeight + 24 >= target.scrollHeight) {
+ fetchPage(pageNo + 1);
+ }
+ }
+
+ return (
+ <Select
+ showSearch
+ placeholder="选择提现钱包账户"
+ optionFilterProp="children"
+ value={value}
+ onChange={onChange}
+ disabled={disabled}
+ style={{ width: "100%" }}
+ onPopupScroll={onPopupScroll}
+ notFoundContent={loading ? <Spin size="small" /> : <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无账户" />}
+ filterOption={(input, option) => (option?.children as string)?.toLowerCase().includes(input.toLowerCase())}
+ >
+ {list.map((item) => (
+ <Option key={item._id} value={item._id}>
+ {item.userName || item.mail} · {item.type} · {item.account}
+ </Option>
+ ))}
+ </Select>
+ );
+}
+
+