Skip to content

Let's use AI to Earn!

feat:创建钱包账户

yikaJasonMic47d3bd73d4b9
diff --git a/src/api/finance.ts b/src/api/finance.ts
index bd97330e..211f858d 100644
--- a/src/api/finance.ts
+++ b/src/api/finance.ts
@@ -1,7 +1,7 @@
/*
* @Author: nevin
* @Date: 2025-02-22 12:02:55
- * @LastEditTime: 2025-02-28 21:47:31
+ * @LastEditTime: 2025-02-28 21:52:01
* @LastEditors: nevin
* @Description: 财务
*/
@@ -19,7 +19,7 @@ export const financeApi = {
*/
getWalletAccountCode(phone: string) {
return http.post<string>(
- `userWalletAccount/phoneCode/${phone}`,
+ `/finance/userWalletAccount/phoneCode/${phone}`,
{},
{
isToken: true,
@@ -31,7 +31,7 @@ export const financeApi = {
* 创建用户钱包账户
*/
createUserWalletAccount(data: CreateUserWalletAccountParams) {
- return http.post<UserWalletAccount>('/userWalletAccount', data, {
+ return http.post<UserWalletAccount>('/finance/userWalletAccount', data, {
isToken: true,
});
},
@@ -41,7 +41,7 @@ export const financeApi = {
* @returns
*/
getUserWalletAccountList() {
- return http.get<UserWalletAccount[]>(`/userWalletAccount/list`, {
+ return http.get<UserWalletAccount[]>(`/finance/userWalletAccount/list`, {
isToken: true,
});
},
@@ -50,7 +50,7 @@ export const financeApi = {
* 删除用户钱包账户
*/
deleteUserWalletAccount(id: string) {
- return http.delete<boolean>(`/userWalletAccount/delete/${id}`);
+ return http.delete<boolean>(`/finance/userWalletAccount/delete/${id}`);
},
// --------- userWalletAccount END ---------
};
diff --git a/src/views/finance/components/addWalletAccount.tsx b/src/views/finance/components/addWalletAccount.tsx
index e69de29b..5b5ea1a3 100644
--- a/src/views/finance/components/addWalletAccount.tsx
+++ b/src/views/finance/components/addWalletAccount.tsx
@@ -0,0 +1,131 @@
+/*
+ * @Author: nevin
+ * @Date: 2025-02-27 20:44:31
+ * @LastEditTime: 2025-02-28 22:29:24
+ * @LastEditors: nevin
+ * @Description: 添加账户 addWalletAccount
+ */
+import { Button, Form, Input, Modal, Select } from 'antd';
+import { forwardRef, useImperativeHandle, useState } from 'react';
+
+export interface AddWalletAccountRef {
+ init: () => Promise<void>;
+}
+
+import {
+ CreateUserWalletAccountParams,
+ WalletAccountType,
+} from '@/api/types/userWalletAccount';
+import { financeApi } from '@/api/finance';
+
+const Com = forwardRef<AddWalletAccountRef>((props: any, ref) => {
+ const [isModalOpen, setIsModalOpen] = useState(false);
+ const [form] = Form.useForm<CreateUserWalletAccountParams>();
+
+ async function init() {
+ // form表单重置
+ form.resetFields();
+
+ setIsModalOpen(true);
+ }
+
+ useImperativeHandle(ref, () => ({ init: init }));
+
+ /**
+ * 提交
+ */
+ async function submit() {
+ const values = await form.validateFields();
+
+ // 创建
+ const res = await financeApi.createUserWalletAccount(values);
+ console.log('----- rres', res);
+
+ // 创建成功后向父组件发送成功事件
+ props.onSuccess?.(res);
+
+ setIsModalOpen(false);
+ }
+
+ const handleCancel = () => {
+ setIsModalOpen(false);
+ };
+
+ const onFinish = (values: CreateUserWalletAccountParams) => {
+ console.log('Success:', values);
+ };
+
+ const onFinishFailed = (errorInfo: any) => {
+ console.log('Failed:', errorInfo);
+ };
+
+ return (
+ <>
+ <Modal
+ title="新建账户"
+ open={isModalOpen}
+ onCancel={handleCancel}
+ footer={[
+ <Button key="back" onClick={handleCancel}>
+ 取消
+ </Button>,
+ <Button key="submit" type="primary" onClick={submit}>
+ 提交
+ </Button>,
+ ]}
+ >
+ <Form
+ name="basic"
+ form={form}
+ labelCol={{ span: 8 }}
+ wrapperCol={{ span: 16 }}
+ initialValues={{ remember: true }}
+ onFinish={onFinish}
+ onFinishFailed={onFinishFailed}
+ autoComplete="off"
+ >
+ <Form.Item
+ label="真实姓名"
+ name="userName"
+ rules={[{ required: true, message: '请输入真实姓名!' }]}
+ >
+ <Input />
+ </Form.Item>
+
+ <Form.Item
+ label="身份证号"
+ name="cardNum"
+ rules={[{ required: true, message: '请输入身份证号!' }]}
+ >
+ <Input />
+ </Form.Item>
+
+ <Form.Item
+ label="绑定的手机号"
+ name="phone"
+ rules={[{ required: true, message: '请输入绑定的手机号!' }]}
+ >
+ <Input />
+ </Form.Item>
+
+ <Form.Item
+ label="类型"
+ name="type"
+ rules={[{ required: true, message: '请选择类型!' }]}
+ >
+ <Select>
+ <Select.Option value={WalletAccountType.ZFB}>
+ 支付宝
+ </Select.Option>
+ <Select.Option value={WalletAccountType.WX_PAY}>
+ 微信支付
+ </Select.Option>
+ </Select>
+ </Form.Item>
+ </Form>
+ </Modal>
+ </>
+ );
+});
+
+export default Com;
diff --git a/src/views/finance/userWalletAccount.tsx b/src/views/finance/userWalletAccount.tsx
index 28d7984b..4ac0b73e 100644
--- a/src/views/finance/userWalletAccount.tsx
+++ b/src/views/finance/userWalletAccount.tsx
@@ -1,36 +1,45 @@
/*
* @Author: nevin
* @Date: 2025-02-10 22:20:15
- * @LastEditTime: 2025-02-28 21:48:18
+ * @LastEditTime: 2025-02-28 22:09:10
* @LastEditors: nevin
* @Description: 用户的钱包账户 userWalletAccount
*/
import { Button } from 'antd';
import { useState, useEffect, useRef } from 'react';
-import { TaskInfoRef } from '../task/components/popInfo';
-import TaskInfo from '../task/components/popInfo';
+import AddWalletAccount from './components/addWalletAccount';
import { UserWalletAccount } from '@/api/types/userWalletAccount';
import { financeApi } from '@/api/finance';
+import { AddWalletAccountRef } from './components/addWalletAccount';
export default function Page() {
const [walletAccountList, setWalletAccountList] = useState<
UserWalletAccount[]
>([]);
- const Ref_TaskInfo = useRef<TaskInfoRef>(null);
+ const Ref_AddWalletAccountRef = useRef<AddWalletAccountRef>(null);
async function getTaskList() {
const res = await financeApi.getUserWalletAccountList();
setWalletAccountList(res);
}
+ // 新建
+ async function createUserWalletAccount() {
+ Ref_AddWalletAccountRef.current?.init();
+ }
+
useEffect(() => {
getTaskList();
}, []);
return (
<div>
- <TaskInfo ref={Ref_TaskInfo} />
+ <Button type="primary" onClick={createUserWalletAccount}>
+ 新建
+ </Button>
+
+ <AddWalletAccount ref={Ref_AddWalletAccountRef} />
<div>
ƒ{' '}
{walletAccountList.map((v) => {