Skip to content

Let's use AI to Earn!

feat: 收入测试页面

Nevin819ce0448d63
diff --git a/.env.development b/.env.development
index 0c5b35ce..2f99e4dd 100644
--- a/.env.development
+++ b/.env.development
@@ -1,6 +1,6 @@
NEXT_PUBLIC_EVN=dev
-# NEXT_PUBLIC_API_URL=http://localhost:7000/api
+NEXT_PUBLIC_API_URL=/api
-NEXT_PUBLIC_API_URL=https://dev.aitoearn.ai/api
+# NEXT_PUBLIC_API_URL=https://dev.aitoearn.ai/api
NEXT_PUBLIC_HOST_URL=https://dev.aitoearn.ai
diff --git a/next.config.mjs b/next.config.mjs
index e5c3b2bb..6ccb227f 100644
--- a/next.config.mjs
+++ b/next.config.mjs
@@ -10,6 +10,14 @@ const nextConfig = {
},
output: 'standalone',
productionBrowserSourceMaps: process.env.NEXT_PUBLIC_EVN === 'dev',
+ rewrites: async () => ({
+ beforeFiles: [
+ {
+ source: `/api/:path*`,
+ destination: "http://127.0.0.1:8000/api/:path*",
+ },
+ ],
+ }),
};
const CorsHeaders = [
diff --git a/src/api/income.ts b/src/api/income.ts
new file mode 100644
index 00000000..6d32cf17
--- /dev/null
+++ b/src/api/income.ts
@@ -0,0 +1,18 @@
+import { request } from '@/utils/request';
+import { IncomeRecord } from './types/income';
+
+/**
+ * 获取收入列表
+ */
+export const apiGetIncomeList = (page: {
+ pageNo: number;
+ pageSize: number;
+}, params: {
+ status?: number
+}) => {
+ return request<{ list: IncomeRecord[], tatol: number }>({
+ url: `income/list/${page.pageNo}/${page.pageSize}`,
+ method: 'GET',
+ params
+ });
+};
\ No newline at end of file
diff --git a/src/api/types/income.ts b/src/api/types/income.ts
new file mode 100644
index 00000000..b9c528c8
--- /dev/null
+++ b/src/api/types/income.ts
@@ -0,0 +1,19 @@
+export enum IncomeType {
+ TASK = 'task', // 任务
+ TASK_BACK = 'task_back', // 任务回退
+ REWARD_BACK = 'reward_back', // 奖励回退
+}
+
+// 订单类型 (根据实际API返回结构)
+export interface IncomeRecord {
+ _id: string;
+ id: string;
+ userId: string;
+ amount: number;
+ relId?: string
+ type: IncomeType
+ desc?: string
+ metadata?: Record<string, unknown>
+ createdAt: Date
+ updatedAt: Date
+}
diff --git a/src/api/types/withdraw.ts b/src/api/types/withdraw.ts
new file mode 100644
index 00000000..e4b0eaf3
--- /dev/null
+++ b/src/api/types/withdraw.ts
@@ -0,0 +1,26 @@
+export enum WithdrawRecordType {
+ TASK = 'task', // 任务
+ REWARD = 'reward', // 奖励
+}
+
+export enum WithdrawRecordStatus {
+ WAIT = 0,
+ SUCCESS = 1,
+ FAIL = -1,
+}
+
+export interface WithdrawRecord {
+ _id: string;
+ id: string;
+ userId: string;
+ flowId?: string
+ type: WithdrawRecordType
+ amount: number;
+ incomeRecordId?: string
+ relId?: string
+ desc?: string
+ screenshotUrls?: string[] // 发放截图列表
+ status: WithdrawRecordStatus
+ createdAt: Date
+ updatedAt: Date
+}
diff --git a/src/api/withdraw.ts b/src/api/withdraw.ts
new file mode 100644
index 00000000..dede5058
--- /dev/null
+++ b/src/api/withdraw.ts
@@ -0,0 +1,13 @@
+import { request } from '@/utils/request';
+import { WithdrawRecord } from './types/withdraw';
+
+/**
+ * 获取提现列表
+ */
+export const apiGetWithdrawRecordList = (page: {pageNo: number, pageSize: number}, params: { status?: number }) => {
+ return request<{list: WithdrawRecord[], total: number}>({
+ url: `withdraw/list/${page.pageNo}/${page.pageSize}`,
+ method: 'GET',
+ params
+ });
+};
\ No newline at end of file
diff --git a/src/app/[lng]/demo/demoIncome.tsx b/src/app/[lng]/demo/demoIncome.tsx
new file mode 100644
index 00000000..f3320e53
--- /dev/null
+++ b/src/app/[lng]/demo/demoIncome.tsx
@@ -0,0 +1,66 @@
+"use client";
+import { apiGetIncomeList } from "@/api/income";
+import { apiAcceptTask, apiSubmitTask } from "@/api/task";
+import { IncomeRecord } from "@/api/types/income";
+import { apiGetWithdrawRecordList } from "@/api/withdraw";
+import { useState } from "react";
+
+export const DemoIncome = () => {
+ const [result, setResult] = useState<IncomeRecord[]>([]);
+ const [userTaskList, setUserTaskList] = useState<any[]>([]);
+
+ async function getIncomeList() {
+ const res = await apiGetIncomeList({ pageNo: 1, pageSize: 20 }, {});
+ console.log("------ createMaterialGroup ---- ", res);
+ if (!res) return;
+ setResult(res.data.list);
+ }
+
+ async function acceptTask(opportunityId: string) {
+ console.log(`----`, opportunityId);
+ const res = await apiAcceptTask(opportunityId)
+ console.log('----- res', res);
+ }
+
+
+ async function getWithdrawRecordList() {
+ const res = await apiGetWithdrawRecordList({ pageNo: 1, pageSize: 20 }, {});
+ console.log("------ getUserTaskList ---- ", res);
+ if (!res) return;
+ setUserTaskList(res.data.list);
+ }
+
+ return (
+ <div>
+ <div>
+ <button onClick={getIncomeList}>我的收入列表</button>
+
+ {/* 待接受任务列表 */}
+ <div>
+
+ {result.map((item) => (
+ <div key={item._id}>
+ <div>{item._id}</div>
+ <button onClick={() => acceptTask(item._id)}>申请提现</button>
+ </div>
+ ))}
+ </div>
+
+
+ <button onClick={getWithdrawRecordList}>获取我的提现列表</button>
+ {/* 已接受任务列表 */}
+ <div>
+
+ {userTaskList.map((item) => (
+ <div key={item._id}>
+ <div>{item._id}</div>
+ <div>{item.accountId}</div>
+ <div>{item.accountType}</div>
+ <div>{item.status}</div>
+ </div>
+ ))}
+ </div>
+ </div>
+ </div>
+ );
+};
diff --git a/src/app/[lng]/demo/page.tsx b/src/app/[lng]/demo/page.tsx
index c5c3e322..5adf5c45 100644
--- a/src/app/[lng]/demo/page.tsx
+++ b/src/app/[lng]/demo/page.tsx
@@ -8,6 +8,7 @@ import { DemoData } from "./demoData";
import { DemoInteract } from "./demoInteract";
import { DemoNotification } from "./demoNote";
import { DemoTask } from "./demoTask";
+import { DemoIncome } from "./demoIncome";
export async function generateMetadata({ params }: PageParams) {
const { lng } = await params;
@@ -27,6 +28,7 @@ export default async function Page({ params }: PageParams) {
return (
<>
<div>{t("demoText")} 1</div>
+ <DemoIncome />
<DemoTask />
<DemoNotification />
<DemoPageCore />