返回 AiToEarn
userWalletAccount.tsx
根目录 / project / aitoearn-electron / src / views / finance / userWalletAccount.tsx
1 /*
2 * @Author: nevin
3 * @Date: 2025-02-10 22:20:15
4 * @LastEditTime: 2025-03-01 19:39:12
5 * @LastEditors: nevin
6 * @Description: 用户的钱包账户 userWalletAccount
7 */
8 import { Button, Table, Tag, message } from 'antd';
9 import { useState, useEffect, useRef } from 'react';
10 import AddWalletAccount from './components/addWalletAccount';
11 import { UserWalletAccount } from '@/api/types/userWalletAccount';
12 import { financeApi } from '@/api/finance';
13 import { AddWalletAccountRef } from './components/addWalletAccount';
14 import { PlusOutlined } from '@ant-design/icons';
15
16 export default function Page() {
17 const [walletAccountList, setWalletAccountList] = useState<
18 UserWalletAccount[]
19 >([]);
20 const [loading, setLoading] = useState(false);
21 const Ref_AddWalletAccountRef = useRef<AddWalletAccountRef>(null);
22
23 async function getTaskList() {
24 setLoading(true);
25 try {
26 const res = await financeApi.getUserWalletAccountList();
27 setWalletAccountList(res);
28 } catch (error) {
29 console.error('获取钱包账户列表失败:', error);
30 message.error('获取钱包账户列表失败');
31 } finally {
32 setLoading(false);
33 }
34 }
35
36 // 新建
37 async function createUserWalletAccount() {
38 Ref_AddWalletAccountRef.current?.init();
39 }
40
41 useEffect(() => {
42 getTaskList();
43 }, []);
44
45 const columns = [
46 {
47 title: '手机号',
48 dataIndex: 'phone',
49 key: 'phone',
50 },
51
52 {
53 title: '真实姓名',
54 dataIndex: 'userName',
55 key: 'userName',
56 },
57 {
58 title: '身份证号',
59 dataIndex: 'cardNum',
60 key: 'cardNum',
61 },
62 {
63 title: '备注名',
64 dataIndex: 'account',
65 key: 'account',
66 },
67 {
68 title: '账号类型',
69 dataIndex: 'type',
70 key: 'type',
71 render: (type: string) => (
72 <Tag color={type === 'ZFB' ? 'blue' : 'green'}>
73 {type === 'ZFB' ? '支付宝' : '微信'}
74 </Tag>
75 ),
76 },
77
78 // {
79 // title: '操作',
80 // key: 'action',
81 // render: (_: any, record: UserWalletAccount) => (
82 // <Space size="middle">
83 // <Button type="link" onClick={() => handleView(record)}>
84 // 查看
85 // </Button>
86 // </Space>
87 // ),
88 // },
89 ];
90
91 const handleView = (record: UserWalletAccount) => {
92 // TODO: 实现查看详情功能
93 console.log('查看账户详情:', record);
94 };
95
96 return (
97 <div>
98 <div style={{ marginBottom: 16, textAlign: 'right' }}>
99 <Button
100 type="primary"
101 icon={<PlusOutlined />}
102 onClick={createUserWalletAccount}
103 >
104 添加账户
105 </Button>
106 </div>
107 <Table
108 columns={columns}
109 dataSource={walletAccountList}
110 rowKey="id"
111 loading={loading}
112 pagination={false}
113 />
114 <AddWalletAccount
115 ref={Ref_AddWalletAccountRef}
116 onSuccess={() => {
117 message.success('添加账户成功');
118 getTaskList(); // 添加成功后刷新列表
119 }}
120 />
121 </div>
122 );
123 }
124
124 lines Plain Text