From 53ca93a2886a79a5d41b00d7046ecc3081589a58 Mon Sep 17 00:00:00 2001 From: gary <1032230992@qq.com> Date: Tue, 7 Jun 2022 13:58:02 +0800 Subject: [PATCH 01/12] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E8=AF=B4?= =?UTF-8?q?=E6=98=8E=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4c89a72..747cea4 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This project is initialized with [Ant Design Pro](https://pro.ant.design). Follo Install `node_modules`: ```bash -npm install +yarn install ``` or @@ -55,3 +55,14 @@ npm test ## More You can view full document on our [official website](https://pro.ant.design). And welcome any feedback in our [github](https://github.com/ant-design/ant-design-pro). + +### 参考文档 + +1. [ts 入门](https://ts.xcatliu.com/) +1. [react hook 入门](https://www.ruanyifeng.com/blog/2019/09/react-hooks.html) +1. [antd4.0](https://ant-design.gitee.io/components/overview-cn/) +1. [@ant-design/pro-layout](https://procomponents.ant.design/components/layout) +1. [@ant-design/icons](https://ant.design/components/icon-cn/#API) +1. [@ant-design/pro-table](https://procomponents.ant.design/components/table) +1. [@formily/antd-components](https://formilyjs.org/#/zoi8i0/ZrsYs6hytQ) +1. [@formily](https://formilyjs.org) -- 2.40.1 From 2294e72882bb42fb9a774d6039a91202b8f3851e Mon Sep 17 00:00:00 2001 From: zzy <> Date: Mon, 25 Jul 2022 17:29:24 +0800 Subject: [PATCH 02/12] =?UTF-8?q?=E5=85=85=E5=80=BC=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 +- src/components/Table/ConfirmButton/index.less | 13 +++ src/components/Table/ConfirmButton/index.tsx | 24 ++++ src/components/Table/index.tsx | 2 +- src/pages/Login/index.tsx | 2 +- .../List/components/addAddressModal.tsx | 62 +++++++++++ .../List/components/editAddressModal.tsx | 72 ++++++++++++ src/pages/Recharge/Address/List/index.tsx | 102 +++++++++++++++++ .../List/components/addCoinTypeModal.tsx | 68 ++++++++++++ .../List/components/editCoinTypeModal.tsx | 78 +++++++++++++ src/pages/Recharge/CoinType/List/index.tsx | 104 ++++++++++++++++++ src/pages/Recharge/Record/List/index.tsx | 89 +++++++++++++++ src/pages/Recharge/Withdraw/List/index.tsx | 97 ++++++++++++++++ src/routes/index.ts | 32 +++++- src/routes/routePath.ts | 14 +++ src/services/address.ts | 61 ++++++++++ src/services/coinType.ts | 53 +++++++++ src/services/login.ts | 2 +- src/services/record.ts | 20 ++++ src/services/withdraw.ts | 34 ++++++ src/styles/antdGlobal.less | 2 +- src/utils/bigNumber.ts | 6 + src/utils/formatBalance.ts | 6 + 23 files changed, 940 insertions(+), 6 deletions(-) create mode 100644 src/components/Table/ConfirmButton/index.less create mode 100644 src/components/Table/ConfirmButton/index.tsx create mode 100644 src/pages/Recharge/Address/List/components/addAddressModal.tsx create mode 100644 src/pages/Recharge/Address/List/components/editAddressModal.tsx create mode 100644 src/pages/Recharge/Address/List/index.tsx create mode 100644 src/pages/Recharge/CoinType/List/components/addCoinTypeModal.tsx create mode 100644 src/pages/Recharge/CoinType/List/components/editCoinTypeModal.tsx create mode 100644 src/pages/Recharge/CoinType/List/index.tsx create mode 100644 src/pages/Recharge/Record/List/index.tsx create mode 100644 src/pages/Recharge/Withdraw/List/index.tsx create mode 100644 src/services/address.ts create mode 100644 src/services/coinType.ts create mode 100644 src/services/record.ts create mode 100644 src/services/withdraw.ts create mode 100644 src/utils/bigNumber.ts create mode 100644 src/utils/formatBalance.ts diff --git a/package.json b/package.json index 3e4df34..eca941e 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,8 @@ "react-dom": "^17.0.0", "react-helmet-async": "^1.0.4", "umi": "^3.5.0", - "umi-serve": "^1.9.10" + "umi-serve": "^1.9.10", + "bignumber.js": "^9.0.0" }, "devDependencies": { "@ant-design/pro-cli": "^2.0.2", diff --git a/src/components/Table/ConfirmButton/index.less b/src/components/Table/ConfirmButton/index.less new file mode 100644 index 0000000..61897f7 --- /dev/null +++ b/src/components/Table/ConfirmButton/index.less @@ -0,0 +1,13 @@ +.delete-btn { + color: @error-color; + &:hover { + color: @error-color !important; + } +} +.disabled { + color: @disabled-color; + cursor: not-allowed; + &:hover { + color: @disabled-color !important; + } +} diff --git a/src/components/Table/ConfirmButton/index.tsx b/src/components/Table/ConfirmButton/index.tsx new file mode 100644 index 0000000..f1b19ec --- /dev/null +++ b/src/components/Table/ConfirmButton/index.tsx @@ -0,0 +1,24 @@ +import React from 'react'; +import { Popconfirm } from 'antd'; +import styles from './index.less'; +import classNames from 'classnames'; + +interface PropsType { + onConfirm: () => void; + title?: string; + buttonName?: string; + disabled?: boolean; +} +const ConfirmButton: React.FC = ({ + onConfirm, + disabled = false, + title = '', + buttonName = '', +}) => { + return ( + + {buttonName} + + ); +}; +export default ConfirmButton; diff --git a/src/components/Table/index.tsx b/src/components/Table/index.tsx index 1873c46..d4f2fda 100644 --- a/src/components/Table/index.tsx +++ b/src/components/Table/index.tsx @@ -172,7 +172,7 @@ const Table = >(props: PropsType) => { }} > - {item.text || '新建'} + {item.text || '添加'} , ); } else if (item.type === 'batchDelete') { diff --git a/src/pages/Login/index.tsx b/src/pages/Login/index.tsx index a06865a..f876e6e 100644 --- a/src/pages/Login/index.tsx +++ b/src/pages/Login/index.tsx @@ -35,7 +35,7 @@ const Login: React.FC = () => { }} > , diff --git a/src/pages/Recharge/Address/List/components/addAddressModal.tsx b/src/pages/Recharge/Address/List/components/addAddressModal.tsx new file mode 100644 index 0000000..df62cff --- /dev/null +++ b/src/pages/Recharge/Address/List/components/addAddressModal.tsx @@ -0,0 +1,62 @@ +// 创建收款地址弹窗 +import React, { useRef } from 'react'; +import { createForm } from '@formily/core'; +import { createSchemaField } from '@formily/react'; +import Modal, { ModalProps } from '@/components/Modal'; +import { Form, FormItem, Input, Select } from '@formily/antd'; + +interface AddAddressModalPropsType extends ModalProps { + onOk: (val: any) => void; + onCancel: () => void; +} + +const SchemaField = createSchemaField({ + components: { + FormItem, + Input, + Select, + }, +}); + +const form = createForm({}); + +const AddAddressModal = ({ onOk, onCancel, ...rest }: AddAddressModalPropsType) => { + const handleOk = () => { + const formState = form.getFormState(); + onOk(formState.values); + }; + + const handleCancel = () => { + onCancel(); + }; + + return ( + +
+ + + + +
+
+ ); +}; + +export default AddAddressModal; diff --git a/src/pages/Recharge/Address/List/components/editAddressModal.tsx b/src/pages/Recharge/Address/List/components/editAddressModal.tsx new file mode 100644 index 0000000..aca7318 --- /dev/null +++ b/src/pages/Recharge/Address/List/components/editAddressModal.tsx @@ -0,0 +1,72 @@ +// 修改收款地址弹窗 +import React, { useRef, useEffect } from 'react'; +import { createForm } from '@formily/core'; +import { createSchemaField } from '@formily/react'; +import Modal, { ModalProps } from '@/components/Modal'; +import { Form, FormItem, Input, Select } from '@formily/antd'; + +interface EditAddressModalPropsType extends ModalProps { + editModalData: any; + onOk: (val: any) => void; + onCancel: () => void; +} + +const SchemaField = createSchemaField({ + components: { + FormItem, + Input, + Select, + }, +}); + +const form = createForm({}); + +const EditAddressModal = ({ + onOk, + onCancel, + editModalData, + ...rest +}: EditAddressModalPropsType) => { + useEffect(() => { + form.setInitialValues(editModalData); + }); + + const handleOk = () => { + const formState = form.getFormState(); + onOk(formState.values); + }; + + const handleCancel = () => { + onCancel(); + }; + + return ( + +
+ + + + + +
+
+ ); +}; + +export default EditAddressModal; diff --git a/src/pages/Recharge/Address/List/index.tsx b/src/pages/Recharge/Address/List/index.tsx new file mode 100644 index 0000000..2aaedbb --- /dev/null +++ b/src/pages/Recharge/Address/List/index.tsx @@ -0,0 +1,102 @@ +import React, { useState, useRef } from 'react'; +import Table, { ProColumns, ActionType } from '@/components/Table'; +import { getAddressList, deleteAddress, createAddress, modifyAddress } from '@/services/address'; +import { fetchTableData } from '@/utils/table'; +import DeleteButton from '@/components/Table/DeleteButton'; +import AddAddressModal from './components/addAddressModal'; +import EditAddressModal from './components/editAddressModal'; + +const CollectionAddressList = () => { + const [isModalVisible, setIsModalVisible] = useState(false); + const [isEditModalVisible, setIsEditModalVisible] = useState(false); + const [modalData, setModalData] = useState({}); + + const handleEdit = (row: any) => { + setModalData(row); + setIsEditModalVisible(true); + }; + + const handleDelete = async (address: any) => { + await deleteAddress({ address: address }); + }; + const tableRef = useRef(); + const columns: ProColumns[] = [ + { + title: '收款地址', + dataIndex: 'address', + hideInSearch: true, + ellipsis: true, + }, + { + title: '收款游戏币类型', + dataIndex: 'bc_type', + hideInSearch: true, + ellipsis: true, + }, + { + title: '操作', + valueType: 'option', + width: 150, + render: (_, row) => [ + { + handleEdit(row); + }} + > + 编辑 + , + { + handleDelete(row.address); + }} + />, + ], + }, + ]; + return ( +
+ { + setIsModalVisible(true); + }, + }, + ]} + actionRef={tableRef} + request={async (params) => { + const res = await fetchTableData(getAddressList, params); + return res; + }} + /> + { + await createAddress(val); + setIsModalVisible(false); + }} + /> + { + await modifyAddress(val); + setIsEditModalVisible(false); + }} + /> + + ); +}; + +export default CollectionAddressList; diff --git a/src/pages/Recharge/CoinType/List/components/addCoinTypeModal.tsx b/src/pages/Recharge/CoinType/List/components/addCoinTypeModal.tsx new file mode 100644 index 0000000..4430e81 --- /dev/null +++ b/src/pages/Recharge/CoinType/List/components/addCoinTypeModal.tsx @@ -0,0 +1,68 @@ +// 添加代币类型弹窗 +import React, { useRef } from 'react'; +import { createForm } from '@formily/core'; +import { createSchemaField } from '@formily/react'; +import Modal, { ModalProps } from '@/components/Modal'; +import { Form, FormItem, Input, NumberPicker } from '@formily/antd'; + +interface AddCoinTypeModalPropsType extends ModalProps { + onOk: (val: any) => void; + onCancel: () => void; +} + +const SchemaField = createSchemaField({ + components: { + FormItem, + Input, + NumberPicker, + }, +}); + +const form = createForm({}); + +const AddCoinTypeModal = ({ onOk, onCancel, ...rest }: AddCoinTypeModalPropsType) => { + const handleOk = () => { + const formState = form.getFormState(); + onOk(formState.values); + }; + + const handleCancel = () => { + onCancel(); + }; + + return ( + +
+ + + + + + + +
+ ); +}; + +export default AddCoinTypeModal; diff --git a/src/pages/Recharge/CoinType/List/components/editCoinTypeModal.tsx b/src/pages/Recharge/CoinType/List/components/editCoinTypeModal.tsx new file mode 100644 index 0000000..f9b7aa3 --- /dev/null +++ b/src/pages/Recharge/CoinType/List/components/editCoinTypeModal.tsx @@ -0,0 +1,78 @@ +// 修改收款地址弹窗 +import React, { useRef, useEffect } from 'react'; +import { createForm } from '@formily/core'; +import { createSchemaField } from '@formily/react'; +import Modal, { ModalProps } from '@/components/Modal'; +import { Form, FormItem, Input, Select } from '@formily/antd'; + +interface EditCoinTypeModalPropsType extends ModalProps { + editModalData: any; + onOk: (val: any) => void; + onCancel: () => void; +} + +const SchemaField = createSchemaField({ + components: { + FormItem, + Input, + Select, + }, +}); + +const form = createForm({}); + +const EditCoinTypeModal = ({ + onOk, + onCancel, + editModalData, + ...rest +}: EditCoinTypeModalPropsType) => { + useEffect(() => { + form.setInitialValues(editModalData); + }); + + const handleOk = () => { + const formState = form.getFormState(); + onOk(formState.values); + }; + + const handleCancel = () => { + onCancel(); + }; + + return ( + +
+ + + + + + + +
+ ); +}; + +export default EditCoinTypeModal; diff --git a/src/pages/Recharge/CoinType/List/index.tsx b/src/pages/Recharge/CoinType/List/index.tsx new file mode 100644 index 0000000..9dbd9b9 --- /dev/null +++ b/src/pages/Recharge/CoinType/List/index.tsx @@ -0,0 +1,104 @@ +import React, { useState, useRef } from 'react'; +import Table, { ProColumns, ActionType } from '@/components/Table'; +import { addCoinType, getCoinTypeList, modifyCoinType } from '@/services/coinType'; +import { fetchTableData } from '@/utils/table'; +import AddCoinTypeModal from './components/addCoinTypeModal'; +import EditCoinTypeModal from './components/editCoinTypeModal'; + +const CoinTypeList = () => { + const [isModalVisible, setIsModalVisible] = useState(false); + const [isEditModalVisible, setIsEditModalVisible] = useState(false); + const [modalData, setModalData] = useState({}); + + const handleEdit = (row: any) => { + setModalData(row); + setIsEditModalVisible(true); + }; + + const tableRef = useRef(); + const columns: ProColumns[] = [ + { + title: '游戏币名称', + dataIndex: 'bc_name', + hideInSearch: true, + ellipsis: true, + }, + { + title: '游戏币类型', + dataIndex: 'bc_type', + width: '10%', + hideInSearch: true, + }, + { + title: 'usdt比例', + dataIndex: 'usdt_price', + hideInSearch: true, + ellipsis: true, + }, + { + title: 'eth比例', + dataIndex: 'eth_price', + hideInSearch: true, + ellipsis: true, + }, + { + title: '操作', + valueType: 'option', + width: 150, + render: (_, row) => [ + { + handleEdit(row); + }} + > + 编辑 + , + ], + }, + ]; + return ( +
+
{ + setIsModalVisible(true); + }, + }, + ]} + actionRef={tableRef} + request={async (params) => { + const res = await fetchTableData(getCoinTypeList, params); + return res; + }} + /> + { + await addCoinType(val); + setIsModalVisible(false); + }} + /> + { + await modifyCoinType(val); + setIsEditModalVisible(false); + }} + /> + + ); +}; + +export default CoinTypeList; diff --git a/src/pages/Recharge/Record/List/index.tsx b/src/pages/Recharge/Record/List/index.tsx new file mode 100644 index 0000000..7a21d08 --- /dev/null +++ b/src/pages/Recharge/Record/List/index.tsx @@ -0,0 +1,89 @@ +import React, { useRef } from 'react'; +import Table, { ProColumns, ActionType } from '@/components/Table'; +import { getRecordList } from '@/services/record'; +import { fetchTableData } from '@/utils/table'; +import { getBalanceAmount } from '@/utils/formatBalance'; +import BigNumber from 'bignumber.js'; + +const RecordList = () => { + const tableRef = useRef(); + const columns: ProColumns[] = [ + { + title: '时间', + dataIndex: 'time', + hideInTable: true, + valueType: 'dateRange', + ellipsis: true, + }, + { + title: '交易哈希', + dataIndex: 'tx_hash', + hideInSearch: true, + ellipsis: true, + }, + { + title: '金额', + dataIndex: 'price', + width: '10%', + hideInSearch: true, + }, + { + title: '位数', + dataIndex: 'decimals', + width: '10%', + hideInSearch: true, + }, + { + title: '游戏币类型', + dataIndex: 'bc_type', + width: '10%', + hideInSearch: true, + }, + { + title: '发送地址', + dataIndex: 'form_address', + hideInSearch: true, + ellipsis: true, + }, + { + title: '接受地址', + dataIndex: 'to_address', + hideInSearch: true, + ellipsis: true, + }, + { + title: '充值时间', + dataIndex: 'time', + hideInSearch: true, + ellipsis: true, + }, + ]; + return ( +
+
{ + if ((params.time ?? '') !== '') { + params.start_time = params.time[0]; + params.end_time = params.time[1]; + } + const res = await fetchTableData(getRecordList, params); + for (const key in res.data) { + if (Object.prototype.hasOwnProperty.call(res.data, key)) { + const element = res.data[key]; + element.price = getBalanceAmount( + new BigNumber(element.price), + element.decimals, + ).toNumber(); + } + } + return res; + }} + /> + + ); +}; + +export default RecordList; diff --git a/src/pages/Recharge/Withdraw/List/index.tsx b/src/pages/Recharge/Withdraw/List/index.tsx new file mode 100644 index 0000000..e6e6298 --- /dev/null +++ b/src/pages/Recharge/Withdraw/List/index.tsx @@ -0,0 +1,97 @@ +import React, { useRef } from 'react'; +import Table, { ProColumns, ActionType } from '@/components/Table'; +import { getWithdrawList, solveWithdraw } from '@/services/withdraw'; +import { fetchTableData } from '@/utils/table'; +import { getBalanceAmount } from '@/utils/formatBalance'; +import BigNumber from 'bignumber.js'; +import ConfirmButton from '@/components/Table/ConfirmButton'; + +const WithdrawList = () => { + const handleConfirm = async (uuid) => { + await solveWithdraw({ uuid: uuid }); + }; + + const tableRef = useRef(); + const columns: ProColumns[] = [ + { + title: '提现订单号', + dataIndex: 'uuid', + ellipsis: true, + }, + { + title: '金额', + dataIndex: 'price', + width: '10%', + hideInSearch: true, + }, + { + title: '位数', + dataIndex: 'decimals', + width: '10%', + hideInSearch: true, + }, + { + title: '发送地址', + dataIndex: 'form_address', + hideInSearch: true, + ellipsis: true, + }, + { + title: '接受地址', + dataIndex: 'to_address', + hideInSearch: true, + ellipsis: true, + }, + { + title: '游戏币类型', + dataIndex: 'bc_type', + width: '10%', + }, + { + title: '时间', + dataIndex: 'time', + valueType: 'dateRange', + ellipsis: true, + }, + { + title: '操作', + valueType: 'option', + width: 150, + render: (_, row) => [ + { + handleConfirm(row.uuid); + }} + />, + ], + }, + ]; + return ( +
+
{ + console.log('params = ', params); + const res = await fetchTableData(getWithdrawList, params); + for (const key in res.data) { + if (Object.prototype.hasOwnProperty.call(res.data, key)) { + const element = res.data[key]; + element.price = getBalanceAmount( + new BigNumber(element.price), + element.decimals, + ).toNumber(); + } + } + return res; + }} + /> + + ); +}; + +export default WithdrawList; diff --git a/src/routes/index.ts b/src/routes/index.ts index e6d4016..b5847cb 100644 --- a/src/routes/index.ts +++ b/src/routes/index.ts @@ -10,6 +10,37 @@ export default [ layout: false, component: './Login', }, + { + name: '充值系统', + path: RoutePath.RECHARGE, + routes: [ + { + path: RoutePath.RECHARGE, + redirect: RoutePath.RECORD.LIST, + hideInMenu: true, + }, + { + name: '充值订单', + path: RoutePath.RECORD.LIST, + component: './Recharge/Record/List', + }, + { + name: '收款地址', + path: RoutePath.ADDRESS.LIST, + component: './Recharge/Address/List', + }, + { + name: '代币种类', + path: RoutePath.COIN_TYPE.LIST, + component: './Recharge/CoinType/List', + }, + { + name: '提现管理', + path: RoutePath.WITHDRAW.LIST, + component: './Recharge/Withdraw/List', + }, + ], + }, { name: '设置', path: RoutePath.SETTING, @@ -19,7 +50,6 @@ export default [ redirect: RoutePath.WORK.LIST, hideInMenu: true, }, - { name: '作品', path: RoutePath.WORK.LIST, diff --git a/src/routes/routePath.ts b/src/routes/routePath.ts index 566cd52..38a00ed 100644 --- a/src/routes/routePath.ts +++ b/src/routes/routePath.ts @@ -1,6 +1,20 @@ const SETTING = '/setting'; +const RECHARGE = '/recharge'; const RoutePath = { LOGIN: '/login', + RECHARGE: RECHARGE, + RECORD: { + LIST: `${RECHARGE}/record`, + }, + ADDRESS: { + LIST: `${RECHARGE}/address`, + }, + COIN_TYPE: { + LIST: `${RECHARGE}/coin_type`, + }, + WITHDRAW: { + LIST: `${RECHARGE}/withdraw`, + }, SETTING: SETTING, WORK: { LIST: `${SETTING}/work`, diff --git a/src/services/address.ts b/src/services/address.ts new file mode 100644 index 0000000..4acbba8 --- /dev/null +++ b/src/services/address.ts @@ -0,0 +1,61 @@ +import request from '@/utils/request'; + +/** + * 获取开发商收款地址列表 + * @param {object} params + * @returns {array} data + * bc_type 游戏币类型 + * address 地址 + */ +export const getAddressList = (params) => { + return request.request({ + url: '/api/v1/address/get', + method: 'get', + params, + }); +}; + +/** + * 创建开发商收款地址 + * @param {Object} data + * bc_type 游戏币类型 + * address 地址(不传则后台生成) + * @returns + */ +export const createAddress = (data) => { + return request.request({ + url: '/api/v1/address/make', + method: 'post', + data, + }); +}; + +/** + * 删除开发商收款地址 + * @param {Object} data + * address 地址 + * @returns + */ +export const deleteAddress = (data) => { + return request.request({ + url: '/api/v1/address/del', + method: 'post', + data, + }); +}; + +/** + * 修改开发商收款地址 + * @param {Object} data + * address 旧地址 + * bc_type 游戏币类型 + * new_address 新地址 + * @returns + */ +export const modifyAddress = (data) => { + return request.request({ + url: '/api/v1/address/del', + method: 'post', + data, + }); +}; diff --git a/src/services/coinType.ts b/src/services/coinType.ts new file mode 100644 index 0000000..816e7d1 --- /dev/null +++ b/src/services/coinType.ts @@ -0,0 +1,53 @@ +import request from '@/utils/request'; + +/** + * 获取代币种类列表 + * @param {object} params + * type 代币种类 + * @returns {array} data + * bc_name 游戏币名称 + * bc_type 游戏币类型 + * usdt_price 游戏货币与usdt的比例 + * eth_price 游戏货币与eth的比例 + */ +export const getCoinTypeList = (params) => { + return request.request({ + url: '/api/v1/token/get', + method: 'get', + params, + }); +}; + +/** + * 获取代币种类列表 + * @param {object} params + * bc_name 游戏币名称 + * usdt_price 游戏货币与usdt的比例 + * eth_price 游戏货币与eth的比例 + * num 代币数量 + * @returns {object} data + */ +export const addCoinType = (data) => { + return request.request({ + url: '/api/v1/token/make', + method: 'post', + data, + }); +}; + +/** + * 获取代币种类列表 + * @param {object} params + * bc_name 游戏币名称 + * bc_type 游戏币类型 + * usdt_price 游戏货币与usdt的比例 + * eth_price 游戏货币与eth的比例 + * @returns {object} data + */ +export const modifyCoinType = (data) => { + return request.request({ + url: '/api/v1/token/chg', + method: 'post', + data, + }); +}; diff --git a/src/services/login.ts b/src/services/login.ts index a8a49e8..ae0cf3e 100644 --- a/src/services/login.ts +++ b/src/services/login.ts @@ -2,7 +2,7 @@ import request from '@/utils/request'; export const login = (data) => { return request.request({ - url: '/admin/login', + url: '/tbg/api/v1/admin/login', method: 'post', data, }); diff --git a/src/services/record.ts b/src/services/record.ts new file mode 100644 index 0000000..09ba77b --- /dev/null +++ b/src/services/record.ts @@ -0,0 +1,20 @@ +import request from '@/utils/request'; + +/** + * 获取充值列表 + * @param {object} data + * page 页码 + * pageSize 页码大小 + * start_time 开始时间 + * end_time 结束时间 + * @returns {array} data + * bc_type 游戏币类型 + * address 地址 + */ +export const getRecordList = (data) => { + return request.request({ + url: '/tgb/api/v1/recharge/record', + method: 'post', + data, + }); +}; diff --git a/src/services/withdraw.ts b/src/services/withdraw.ts new file mode 100644 index 0000000..3c5f25b --- /dev/null +++ b/src/services/withdraw.ts @@ -0,0 +1,34 @@ +import request from '@/utils/request'; + +/** + * 获取提现列表 + * @param {object} params + * + * @returns {array} data + * uuid 提现订单id + * to_addrss 接收地址 + * form_address 发送地址 + * time 提现时间 + * price 提现金额 + */ +export const getWithdrawList = (params) => { + return request.request({ + url: '/tgb/api/v1/withdrawal/get', + method: 'get', + params, + }); +}; + +/** + * 获取提现列表 + * @param {object} params + * uuid 提现订单id + * @returns {object} data + */ +export const solveWithdraw = (params) => { + return request.request({ + url: '/tgb/api/v1/withdrawal/solve', + method: 'get', + params, + }); +}; diff --git a/src/styles/antdGlobal.less b/src/styles/antdGlobal.less index 41e95a3..a7596d8 100644 --- a/src/styles/antdGlobal.less +++ b/src/styles/antdGlobal.less @@ -176,7 +176,7 @@ .ant-pro-table-list-toolbar-container { flex-direction: column; justify-content: flex-start; - padding: 0 0 20px 0; + padding: 20px 0 20px 0; .ant-pro-table-list-toolbar-left { .ant-space-item { margin-bottom: 16px; diff --git a/src/utils/bigNumber.ts b/src/utils/bigNumber.ts new file mode 100644 index 0000000..2c96fcf --- /dev/null +++ b/src/utils/bigNumber.ts @@ -0,0 +1,6 @@ +import BigNumber from 'bignumber.js'; + +export const BIG_ZERO = new BigNumber(0); +export const BIG_ONE = new BigNumber(1); +export const BIG_NINE = new BigNumber(9); +export const BIG_TEN = new BigNumber(10); diff --git a/src/utils/formatBalance.ts b/src/utils/formatBalance.ts new file mode 100644 index 0000000..8cbe1b5 --- /dev/null +++ b/src/utils/formatBalance.ts @@ -0,0 +1,6 @@ +import BigNumber from 'bignumber.js'; +import { BIG_TEN } from './bigNumber'; + +export const getBalanceAmount = (amount: BigNumber, decimals = 18) => { + return new BigNumber(amount).dividedBy(BIG_TEN.pow(decimals)); +}; -- 2.40.1 From 3d6c3b873c8c1e926801c48a976bb224f3841fc5 Mon Sep 17 00:00:00 2001 From: zzy <> Date: Wed, 27 Jul 2022 17:47:38 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Recharge/Address/List/index.tsx | 7 +- src/pages/Recharge/CoinType/List/index.tsx | 2 +- src/pages/Recharge/Record/List/index.tsx | 2 +- src/pages/Recharge/Withdraw/List/index.tsx | 2 +- src/pages/System/Account/List/index.tsx | 79 +++++++++++++++++++++ src/pages/System/Permissions/List/index.tsx | 66 +++++++++++++++++ src/pages/System/Role/List/index.tsx | 78 ++++++++++++++++++++ src/pages/User/List/index.tsx | 48 +++++++++++++ src/routes/index.ts | 26 +++++++ src/routes/routePath.ts | 11 +++ src/services/{ => Recharge}/address.ts | 0 src/services/{ => Recharge}/coinType.ts | 0 src/services/{ => Recharge}/record.ts | 0 src/services/{ => Recharge}/withdraw.ts | 0 src/services/System/accountManage.ts | 28 ++++++++ src/services/System/role.ts | 30 ++++++++ src/services/User/user.ts | 16 +++++ 17 files changed, 391 insertions(+), 4 deletions(-) create mode 100644 src/pages/System/Account/List/index.tsx create mode 100644 src/pages/System/Permissions/List/index.tsx create mode 100644 src/pages/System/Role/List/index.tsx create mode 100644 src/pages/User/List/index.tsx rename src/services/{ => Recharge}/address.ts (100%) rename src/services/{ => Recharge}/coinType.ts (100%) rename src/services/{ => Recharge}/record.ts (100%) rename src/services/{ => Recharge}/withdraw.ts (100%) create mode 100644 src/services/System/accountManage.ts create mode 100644 src/services/System/role.ts create mode 100644 src/services/User/user.ts diff --git a/src/pages/Recharge/Address/List/index.tsx b/src/pages/Recharge/Address/List/index.tsx index 2aaedbb..604c984 100644 --- a/src/pages/Recharge/Address/List/index.tsx +++ b/src/pages/Recharge/Address/List/index.tsx @@ -1,6 +1,11 @@ import React, { useState, useRef } from 'react'; import Table, { ProColumns, ActionType } from '@/components/Table'; -import { getAddressList, deleteAddress, createAddress, modifyAddress } from '@/services/address'; +import { + getAddressList, + deleteAddress, + createAddress, + modifyAddress, +} from '@/services/Recharge/address'; import { fetchTableData } from '@/utils/table'; import DeleteButton from '@/components/Table/DeleteButton'; import AddAddressModal from './components/addAddressModal'; diff --git a/src/pages/Recharge/CoinType/List/index.tsx b/src/pages/Recharge/CoinType/List/index.tsx index 9dbd9b9..ca85730 100644 --- a/src/pages/Recharge/CoinType/List/index.tsx +++ b/src/pages/Recharge/CoinType/List/index.tsx @@ -1,6 +1,6 @@ import React, { useState, useRef } from 'react'; import Table, { ProColumns, ActionType } from '@/components/Table'; -import { addCoinType, getCoinTypeList, modifyCoinType } from '@/services/coinType'; +import { addCoinType, getCoinTypeList, modifyCoinType } from '@/services/Recharge/coinType'; import { fetchTableData } from '@/utils/table'; import AddCoinTypeModal from './components/addCoinTypeModal'; import EditCoinTypeModal from './components/editCoinTypeModal'; diff --git a/src/pages/Recharge/Record/List/index.tsx b/src/pages/Recharge/Record/List/index.tsx index 7a21d08..c5b6b65 100644 --- a/src/pages/Recharge/Record/List/index.tsx +++ b/src/pages/Recharge/Record/List/index.tsx @@ -1,6 +1,6 @@ import React, { useRef } from 'react'; import Table, { ProColumns, ActionType } from '@/components/Table'; -import { getRecordList } from '@/services/record'; +import { getRecordList } from '@/services/Recharge/record'; import { fetchTableData } from '@/utils/table'; import { getBalanceAmount } from '@/utils/formatBalance'; import BigNumber from 'bignumber.js'; diff --git a/src/pages/Recharge/Withdraw/List/index.tsx b/src/pages/Recharge/Withdraw/List/index.tsx index e6e6298..8ba1df3 100644 --- a/src/pages/Recharge/Withdraw/List/index.tsx +++ b/src/pages/Recharge/Withdraw/List/index.tsx @@ -1,6 +1,6 @@ import React, { useRef } from 'react'; import Table, { ProColumns, ActionType } from '@/components/Table'; -import { getWithdrawList, solveWithdraw } from '@/services/withdraw'; +import { getWithdrawList, solveWithdraw } from '@/services/Recharge/withdraw'; import { fetchTableData } from '@/utils/table'; import { getBalanceAmount } from '@/utils/formatBalance'; import BigNumber from 'bignumber.js'; diff --git a/src/pages/System/Account/List/index.tsx b/src/pages/System/Account/List/index.tsx new file mode 100644 index 0000000..bf36d4c --- /dev/null +++ b/src/pages/System/Account/List/index.tsx @@ -0,0 +1,79 @@ +import React, { useState, useRef } from 'react'; +import Table, { ProColumns, ActionType } from '@/components/Table'; +import { getAccountList, deleteUser } from '@/services/System/accountManage'; +import { fetchTableData } from '@/utils/table'; +import DeleteButton from '@/components/Table/DeleteButton'; +import { Switch } from 'antd'; + +const AccountManageList = () => { + const handleEdit = (row: any) => {}; + + const handleDelete = async (name: any) => { + await deleteUser({ name: name }); + }; + const onChange = (checked: boolean) => {}; + const tableRef = useRef(); + const columns: ProColumns[] = [ + { + title: '账号', + dataIndex: 'name', + hideInSearch: true, + ellipsis: true, + }, + { + title: '角色', + dataIndex: 'role', + hideInSearch: true, + ellipsis: true, + }, + { + title: '用户状态', + dataIndex: 'status', + hideInSearch: true, + ellipsis: true, + }, + { + title: '操作', + valueType: 'option', + width: 180, + render: (_, row) => [ + { + handleEdit(row); + }} + > + 编辑 + , + , + { + handleDelete(row.name); + }} + />, + ], + }, + ]; + return ( +
+
{}, + }, + ]} + actionRef={tableRef} + request={async (params) => { + const res = await fetchTableData(getAccountList, params); + return res; + }} + /> + + ); +}; + +export default AccountManageList; diff --git a/src/pages/System/Permissions/List/index.tsx b/src/pages/System/Permissions/List/index.tsx new file mode 100644 index 0000000..0e90276 --- /dev/null +++ b/src/pages/System/Permissions/List/index.tsx @@ -0,0 +1,66 @@ +import React, { useState, useRef } from 'react'; +import Table, { ProColumns, ActionType } from '@/components/Table'; +import { fetchTableData } from '@/utils/table'; +import DeleteButton from '@/components/Table/DeleteButton'; + +const PermissionsList = () => { + const handleEdit = (row: any) => {}; + + const handleDelete = async (name: any) => {}; + const tableRef = useRef(); + const columns: ProColumns[] = [ + { + title: '收款地址', + dataIndex: 'address', + hideInSearch: true, + ellipsis: true, + }, + { + title: '收款游戏币类型', + dataIndex: 'bc_type', + hideInSearch: true, + ellipsis: true, + }, + { + title: '操作', + valueType: 'option', + width: 150, + render: (_, row) => [ + { + handleEdit(row); + }} + > + 编辑 + , + { + handleDelete(row.name); + }} + />, + ], + }, + ]; + return ( +
+
{}, + }, + ]} + actionRef={tableRef} + request={async (params) => { + return {}; + }} + /> + + ); +}; + +export default PermissionsList; diff --git a/src/pages/System/Role/List/index.tsx b/src/pages/System/Role/List/index.tsx new file mode 100644 index 0000000..a717771 --- /dev/null +++ b/src/pages/System/Role/List/index.tsx @@ -0,0 +1,78 @@ +import React, { useRef } from 'react'; +import Table, { ProColumns, ActionType } from '@/components/Table'; +import { getRoleList, deleteRole } from '@/services/System/role'; +import { fetchTableData } from '@/utils/table'; +import DeleteButton from '@/components/Table/DeleteButton'; + +const RoleList = () => { + const handleEdit = (row: any) => {}; + const handleAuth = (row: any) => {}; + const handleDelete = async (role: any) => { + await deleteRole({ role: role }); + }; + const tableRef = useRef(); + const columns: ProColumns[] = [ + { + title: '角色名称', + dataIndex: 'role_name', + hideInSearch: true, + ellipsis: true, + }, + { + title: '用户类型', + dataIndex: 'role', + hideInSearch: true, + ellipsis: true, + }, + { + title: '操作', + valueType: 'option', + width: 180, + render: (_, row) => [ + { + handleEdit(row); + }} + > + 编辑 + , + { + handleAuth(row); + }} + > + 授权 + , + { + handleDelete(row.role); + }} + />, + ], + }, + ]; + return ( +
+
{}, + }, + ]} + actionRef={tableRef} + request={async (params) => { + const res = await fetchTableData(getRoleList, params); + return res; + }} + /> + + ); +}; + +export default RoleList; diff --git a/src/pages/User/List/index.tsx b/src/pages/User/List/index.tsx new file mode 100644 index 0000000..e10cc1f --- /dev/null +++ b/src/pages/User/List/index.tsx @@ -0,0 +1,48 @@ +import React, { useState, useRef } from 'react'; +import Table, { ProColumns, ActionType } from '@/components/Table'; +import { getUserList } from '@/services/User/user'; +import { fetchTableData } from '@/utils/table'; + +const UserManageList = () => { + const tableRef = useRef(); + const columns: ProColumns[] = [ + { + title: '用户钱包地址', + dataIndex: 'address', + ellipsis: true, + }, + { + title: '登陆时间', + dataIndex: 'last_time', + hideInSearch: true, + ellipsis: true, + }, + { + title: '注册时间', + dataIndex: 'first_time', + hideInSearch: true, + ellipsis: true, + }, + ]; + return ( +
+
{}, + }, + ]} + actionRef={tableRef} + request={async (params) => { + const res = await fetchTableData(getUserList, params); + return res; + }} + /> + + ); +}; + +export default UserManageList; diff --git a/src/routes/index.ts b/src/routes/index.ts index b5847cb..9fc3acb 100644 --- a/src/routes/index.ts +++ b/src/routes/index.ts @@ -41,6 +41,32 @@ export default [ }, ], }, + { + name: '系统设置', + path: RoutePath.SYSTEM, + routes: [ + { + path: RoutePath.SYSTEM, + redirect: RoutePath.ACCOUNT.LIST, + hideInMenu: true, + }, + { + name: '账号管理', + path: RoutePath.ACCOUNT.LIST, + component: './System/Account/List', + }, + { + name: '角色管理', + path: RoutePath.ROLE.LIST, + component: './System/Role/List', + }, + { + name: '权限管理', + path: RoutePath.PERMISSIONS.LIST, + component: './System/Permissions/List', + }, + ], + }, { name: '设置', path: RoutePath.SETTING, diff --git a/src/routes/routePath.ts b/src/routes/routePath.ts index 38a00ed..43be27e 100644 --- a/src/routes/routePath.ts +++ b/src/routes/routePath.ts @@ -1,5 +1,6 @@ const SETTING = '/setting'; const RECHARGE = '/recharge'; +const SYSTEM = '/system'; const RoutePath = { LOGIN: '/login', RECHARGE: RECHARGE, @@ -15,6 +16,16 @@ const RoutePath = { WITHDRAW: { LIST: `${RECHARGE}/withdraw`, }, + SYSTEM: SYSTEM, + ACCOUNT: { + LIST: `${SYSTEM}/account`, + }, + ROLE: { + LIST: `${SYSTEM}/role`, + }, + PERMISSIONS: { + LIST: `${SYSTEM}/permissions`, + }, SETTING: SETTING, WORK: { LIST: `${SETTING}/work`, diff --git a/src/services/address.ts b/src/services/Recharge/address.ts similarity index 100% rename from src/services/address.ts rename to src/services/Recharge/address.ts diff --git a/src/services/coinType.ts b/src/services/Recharge/coinType.ts similarity index 100% rename from src/services/coinType.ts rename to src/services/Recharge/coinType.ts diff --git a/src/services/record.ts b/src/services/Recharge/record.ts similarity index 100% rename from src/services/record.ts rename to src/services/Recharge/record.ts diff --git a/src/services/withdraw.ts b/src/services/Recharge/withdraw.ts similarity index 100% rename from src/services/withdraw.ts rename to src/services/Recharge/withdraw.ts diff --git a/src/services/System/accountManage.ts b/src/services/System/accountManage.ts new file mode 100644 index 0000000..140812a --- /dev/null +++ b/src/services/System/accountManage.ts @@ -0,0 +1,28 @@ +import request from '@/utils/request'; + +/** + * 获取后台用户列表 + * @param {object} params + * @returns {array} data + */ +export const getAccountList = (params) => { + return request.request({ + url: '/tgb/api/v1/user/get', + method: 'get', + params, + }); +}; + +/** + * 删除后台用户 + * @param {object} data + * name 用户名 + * @returns {array} data + */ +export const deleteUser = (data) => { + return request.request({ + url: '/tgb/api/v1/user/get', + method: 'post', + data, + }); +}; diff --git a/src/services/System/role.ts b/src/services/System/role.ts new file mode 100644 index 0000000..b07ea73 --- /dev/null +++ b/src/services/System/role.ts @@ -0,0 +1,30 @@ +import request from '@/utils/request'; + +/** + * 获取后台角色列表 + * @param {object} params + * @returns {array} data + * role_name 角色名称 + * role 角色类型 + */ +export const getRoleList = (params) => { + return request.request({ + url: '/tgb/api/v1/user/role', + method: 'get', + params, + }); +}; + +/** + * 删除后台角色 + * @param {object} params + * role 角色类型 + * @returns {array} data + */ +export const deleteRole = (data) => { + return request.request({ + url: '/tgb/api/v1/user/role/delete', + method: 'post', + data, + }); +}; diff --git a/src/services/User/user.ts b/src/services/User/user.ts new file mode 100644 index 0000000..769f116 --- /dev/null +++ b/src/services/User/user.ts @@ -0,0 +1,16 @@ +import request from '@/utils/request'; + +/** + * 获取后台角色列表 + * @param {object} params + * @returns {array} data + * role_name 角色名称 + * role 角色类型 + */ +export const getUserList = (params) => { + return request.request({ + url: '/tgb/api/v1/account/get', + method: 'get', + params, + }); +}; -- 2.40.1 From 31198544d793badf0d3b545dad59814fba96cf87 Mon Sep 17 00:00:00 2001 From: zzy <> Date: Sat, 30 Jul 2022 16:42:08 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/proxy.ts | 4 +- .../RightContent/AvatarDropdown.tsx | 44 +++++++--- .../Login/components/modifyPasswordModal.tsx | 65 +++++++++++++++ .../List/components/addAddressModal.tsx | 2 +- .../List/components/editAddressModal.tsx | 2 +- .../List/components/editCoinTypeModal.tsx | 2 +- src/pages/Recharge/Record/List/index.tsx | 44 +++++----- src/pages/System/Account/List/index.tsx | 26 +++++- .../Account/components/addAccountModal.tsx | 81 +++++++++++++++++++ src/pages/User/List/index.tsx | 32 ++++---- src/services/Recharge/address.ts | 8 +- src/services/Recharge/coinType.ts | 6 +- src/services/Recharge/record.ts | 2 +- src/services/Recharge/withdraw.ts | 4 +- src/services/System/accountManage.ts | 20 ++++- src/services/System/role.ts | 4 +- src/services/User/user.ts | 2 +- src/services/login.ts | 17 +++- src/utils/request.ts | 6 +- 19 files changed, 296 insertions(+), 75 deletions(-) create mode 100644 src/pages/Login/components/modifyPasswordModal.tsx create mode 100644 src/pages/System/Account/components/addAccountModal.tsx diff --git a/config/proxy.ts b/config/proxy.ts index 4f407c4..3bc1829 100644 --- a/config/proxy.ts +++ b/config/proxy.ts @@ -9,9 +9,9 @@ export default { dev: { // localhost:8000/api/** -> https://preview.pro.ant.design/api/** - '/admin/': { + '/tbg/api/v1': { // 要代理的地址 - target: '', + target: 'http://192.168.1.226:9999', // 配置了这个可以从 http 代理到 https // 依赖 origin 的功能可能需要这个,比如 cookie changeOrigin: true, diff --git a/src/components/RightContent/AvatarDropdown.tsx b/src/components/RightContent/AvatarDropdown.tsx index 150cbce..6a41551 100644 --- a/src/components/RightContent/AvatarDropdown.tsx +++ b/src/components/RightContent/AvatarDropdown.tsx @@ -1,5 +1,5 @@ -import React, { useCallback } from 'react'; -import { LogoutOutlined, SettingOutlined, UserOutlined } from '@ant-design/icons'; +import React, { useState, useCallback } from 'react'; +import { LogoutOutlined, SettingOutlined, UserOutlined, EditOutlined } from '@ant-design/icons'; import { Avatar, Menu, Spin } from 'antd'; import { history } from 'umi'; import { stringify } from 'querystring'; @@ -8,6 +8,7 @@ import styles from './index.less'; import type { MenuInfo } from 'rc-menu/lib/interface'; import RoutePath from '@/routes/routePath'; import { CACHE_TOKEN } from '@/constants/cacheKey'; +import ModifyPasswordModal from '@/pages/Login/components/modifyPasswordModal'; export type GlobalHeaderRightProps = { menu?: boolean; @@ -32,8 +33,18 @@ const loginOut = async () => { }; const AvatarDropdown: React.FC = ({ menu }) => { + const [isModalVisible, setIsModalVisible] = useState(false); + + const modifyPassword = async () => { + setIsModalVisible(true); + }; + const onMenuClick = useCallback((event: MenuInfo) => { const { key } = event; + if (key === 'modify') { + modifyPassword(); + return; + } if (key === 'logout') { loginOut(); return; @@ -77,7 +88,10 @@ const AvatarDropdown: React.FC = ({ menu }) => { )} {menu && } - + + + 修改密码 + 退出登录 @@ -85,12 +99,24 @@ const AvatarDropdown: React.FC = ({ menu }) => { ); return ( - - - - {currentUser.name} - - +
+ + + + {currentUser.name} + + + +
); }; diff --git a/src/pages/Login/components/modifyPasswordModal.tsx b/src/pages/Login/components/modifyPasswordModal.tsx new file mode 100644 index 0000000..a373f38 --- /dev/null +++ b/src/pages/Login/components/modifyPasswordModal.tsx @@ -0,0 +1,65 @@ +// 创建弹窗 +import React, { useRef } from 'react'; +import { createForm } from '@formily/core'; +import { createSchemaField } from '@formily/react'; +import Modal, { ModalProps } from '@/components/Modal'; +import { Form, FormItem, Input, Select } from '@formily/antd'; +import { modifyPassword } from '@/services/login'; + +interface ModifyPasswordModalPropsType extends ModalProps { + onCancel: () => void; + onOk: () => void; +} + +const SchemaField = createSchemaField({ + components: { + FormItem, + Input, + Select, + }, +}); + +const form = createForm({}); + +const ModifyPasswordModal = ({ onOk, onCancel, ...rest }: ModifyPasswordModalPropsType) => { + const handleOk = async () => { + onOk(); + const formState = form.getFormState(); + await modifyPassword(formState.values); + }; + + const handleCancel = () => { + onCancel(); + }; + + return ( + +
+ + + + + +
+ ); +}; + +export default ModifyPasswordModal; diff --git a/src/pages/Recharge/Address/List/components/addAddressModal.tsx b/src/pages/Recharge/Address/List/components/addAddressModal.tsx index df62cff..8853205 100644 --- a/src/pages/Recharge/Address/List/components/addAddressModal.tsx +++ b/src/pages/Recharge/Address/List/components/addAddressModal.tsx @@ -1,4 +1,4 @@ -// 创建收款地址弹窗 +// 创建弹窗 import React, { useRef } from 'react'; import { createForm } from '@formily/core'; import { createSchemaField } from '@formily/react'; diff --git a/src/pages/Recharge/Address/List/components/editAddressModal.tsx b/src/pages/Recharge/Address/List/components/editAddressModal.tsx index aca7318..07a69f9 100644 --- a/src/pages/Recharge/Address/List/components/editAddressModal.tsx +++ b/src/pages/Recharge/Address/List/components/editAddressModal.tsx @@ -1,4 +1,4 @@ -// 修改收款地址弹窗 +// 修改弹窗 import React, { useRef, useEffect } from 'react'; import { createForm } from '@formily/core'; import { createSchemaField } from '@formily/react'; diff --git a/src/pages/Recharge/CoinType/List/components/editCoinTypeModal.tsx b/src/pages/Recharge/CoinType/List/components/editCoinTypeModal.tsx index f9b7aa3..503c418 100644 --- a/src/pages/Recharge/CoinType/List/components/editCoinTypeModal.tsx +++ b/src/pages/Recharge/CoinType/List/components/editCoinTypeModal.tsx @@ -1,4 +1,4 @@ -// 修改收款地址弹窗 +// 修改弹窗 import React, { useRef, useEffect } from 'react'; import { createForm } from '@formily/core'; import { createSchemaField } from '@formily/react'; diff --git a/src/pages/Recharge/Record/List/index.tsx b/src/pages/Recharge/Record/List/index.tsx index c5b6b65..919b1ff 100644 --- a/src/pages/Recharge/Record/List/index.tsx +++ b/src/pages/Recharge/Record/List/index.tsx @@ -59,30 +59,28 @@ const RecordList = () => { }, ]; return ( -
-
{ - if ((params.time ?? '') !== '') { - params.start_time = params.time[0]; - params.end_time = params.time[1]; +
{ + if ((params.time ?? '') !== '') { + params.start_time = params.time[0]; + params.end_time = params.time[1]; + } + const res = await fetchTableData(getRecordList, params); + for (const key in res.data) { + if (Object.prototype.hasOwnProperty.call(res.data, key)) { + const element = res.data[key]; + element.price = getBalanceAmount( + new BigNumber(element.price), + element.decimals, + ).toNumber(); } - const res = await fetchTableData(getRecordList, params); - for (const key in res.data) { - if (Object.prototype.hasOwnProperty.call(res.data, key)) { - const element = res.data[key]; - element.price = getBalanceAmount( - new BigNumber(element.price), - element.decimals, - ).toNumber(); - } - } - return res; - }} - /> - + } + return res; + }} + /> ); }; diff --git a/src/pages/System/Account/List/index.tsx b/src/pages/System/Account/List/index.tsx index bf36d4c..65124d1 100644 --- a/src/pages/System/Account/List/index.tsx +++ b/src/pages/System/Account/List/index.tsx @@ -4,9 +4,18 @@ import { getAccountList, deleteUser } from '@/services/System/accountManage'; import { fetchTableData } from '@/utils/table'; import DeleteButton from '@/components/Table/DeleteButton'; import { Switch } from 'antd'; +import AddAccountModal from '../components/addAccountModal'; const AccountManageList = () => { - const handleEdit = (row: any) => {}; + const [isModalVisible, setIsModalVisible] = useState(false); + const [isEditModal, setIsEditModal] = useState(false); + const [modalData, setModalData] = useState({}); + + const handleEdit = (row: any) => { + setModalData(row); + setIsEditModal(true); + setIsModalVisible(true); + }; const handleDelete = async (name: any) => { await deleteUser({ name: name }); @@ -63,7 +72,9 @@ const AccountManageList = () => { toolBarActions={[ { type: 'add', - onConfirm: () => {}, + onConfirm: () => { + setIsModalVisible(true); + }, }, ]} actionRef={tableRef} @@ -72,6 +83,17 @@ const AccountManageList = () => { return res; }} /> + { + setIsModalVisible(false); + }} + /> ); }; diff --git a/src/pages/System/Account/components/addAccountModal.tsx b/src/pages/System/Account/components/addAccountModal.tsx new file mode 100644 index 0000000..97c3189 --- /dev/null +++ b/src/pages/System/Account/components/addAccountModal.tsx @@ -0,0 +1,81 @@ +// 创建弹窗 +import React, { useRef, useEffect } from 'react'; +import { createForm } from '@formily/core'; +import { createSchemaField } from '@formily/react'; +import Modal, { ModalProps } from '@/components/Modal'; +import { Form, FormItem, Input, Select } from '@formily/antd'; +import { addUser } from '@/services/System/accountManage'; + +interface AddUserModalPropsType extends ModalProps { + isEdit: boolean; + editModalData: any; + onCancel: () => void; + onOk: () => void; +} + +const SchemaField = createSchemaField({ + components: { + FormItem, + Input, + Select, + }, +}); + +const form = createForm({}); + +const AddUserModal = ({ onOk, onCancel, editModalData, ...rest }: AddUserModalPropsType) => { + useEffect(() => { + form.setInitialValues(editModalData); + }); + + const handleOk = async () => { + onOk(); + const formState = form.getFormState(); + await addUser(formState.values); + }; + + const handleCancel = () => { + onCancel(); + }; + + return ( + +
+ + + + + + +
+ ); +}; + +export default AddUserModal; diff --git a/src/pages/User/List/index.tsx b/src/pages/User/List/index.tsx index e10cc1f..dd178fc 100644 --- a/src/pages/User/List/index.tsx +++ b/src/pages/User/List/index.tsx @@ -25,23 +25,21 @@ const UserManageList = () => { }, ]; return ( -
-
{}, - }, - ]} - actionRef={tableRef} - request={async (params) => { - const res = await fetchTableData(getUserList, params); - return res; - }} - /> - +
{}, + }, + ]} + actionRef={tableRef} + request={async (params) => { + const res = await fetchTableData(getUserList, params); + return res; + }} + /> ); }; diff --git a/src/services/Recharge/address.ts b/src/services/Recharge/address.ts index 4acbba8..628296e 100644 --- a/src/services/Recharge/address.ts +++ b/src/services/Recharge/address.ts @@ -9,7 +9,7 @@ import request from '@/utils/request'; */ export const getAddressList = (params) => { return request.request({ - url: '/api/v1/address/get', + url: '/address/get', method: 'get', params, }); @@ -24,7 +24,7 @@ export const getAddressList = (params) => { */ export const createAddress = (data) => { return request.request({ - url: '/api/v1/address/make', + url: '/address/make', method: 'post', data, }); @@ -38,7 +38,7 @@ export const createAddress = (data) => { */ export const deleteAddress = (data) => { return request.request({ - url: '/api/v1/address/del', + url: '/address/del', method: 'post', data, }); @@ -54,7 +54,7 @@ export const deleteAddress = (data) => { */ export const modifyAddress = (data) => { return request.request({ - url: '/api/v1/address/del', + url: '/address/del', method: 'post', data, }); diff --git a/src/services/Recharge/coinType.ts b/src/services/Recharge/coinType.ts index 816e7d1..83c536b 100644 --- a/src/services/Recharge/coinType.ts +++ b/src/services/Recharge/coinType.ts @@ -12,7 +12,7 @@ import request from '@/utils/request'; */ export const getCoinTypeList = (params) => { return request.request({ - url: '/api/v1/token/get', + url: '/token/get', method: 'get', params, }); @@ -29,7 +29,7 @@ export const getCoinTypeList = (params) => { */ export const addCoinType = (data) => { return request.request({ - url: '/api/v1/token/make', + url: '/token/make', method: 'post', data, }); @@ -46,7 +46,7 @@ export const addCoinType = (data) => { */ export const modifyCoinType = (data) => { return request.request({ - url: '/api/v1/token/chg', + url: '/token/chg', method: 'post', data, }); diff --git a/src/services/Recharge/record.ts b/src/services/Recharge/record.ts index 09ba77b..aa99708 100644 --- a/src/services/Recharge/record.ts +++ b/src/services/Recharge/record.ts @@ -13,7 +13,7 @@ import request from '@/utils/request'; */ export const getRecordList = (data) => { return request.request({ - url: '/tgb/api/v1/recharge/record', + url: '/recharge/record', method: 'post', data, }); diff --git a/src/services/Recharge/withdraw.ts b/src/services/Recharge/withdraw.ts index 3c5f25b..a3ad27e 100644 --- a/src/services/Recharge/withdraw.ts +++ b/src/services/Recharge/withdraw.ts @@ -13,7 +13,7 @@ import request from '@/utils/request'; */ export const getWithdrawList = (params) => { return request.request({ - url: '/tgb/api/v1/withdrawal/get', + url: '/withdrawal/get', method: 'get', params, }); @@ -27,7 +27,7 @@ export const getWithdrawList = (params) => { */ export const solveWithdraw = (params) => { return request.request({ - url: '/tgb/api/v1/withdrawal/solve', + url: '/withdrawal/solve', method: 'get', params, }); diff --git a/src/services/System/accountManage.ts b/src/services/System/accountManage.ts index 140812a..fdf8dbe 100644 --- a/src/services/System/accountManage.ts +++ b/src/services/System/accountManage.ts @@ -7,12 +7,28 @@ import request from '@/utils/request'; */ export const getAccountList = (params) => { return request.request({ - url: '/tgb/api/v1/user/get', + url: '/user/get', method: 'get', params, }); }; +/** + * 添加后台用户 + * @param {object} data + * name 账号名称 + * password 密码 + * role 权限角色 + * @returns {array} data + */ +export const addUser = (data) => { + return request.request({ + url: '/user/create', + method: 'post', + data, + }); +}; + /** * 删除后台用户 * @param {object} data @@ -21,7 +37,7 @@ export const getAccountList = (params) => { */ export const deleteUser = (data) => { return request.request({ - url: '/tgb/api/v1/user/get', + url: '/user/get', method: 'post', data, }); diff --git a/src/services/System/role.ts b/src/services/System/role.ts index b07ea73..7813827 100644 --- a/src/services/System/role.ts +++ b/src/services/System/role.ts @@ -9,7 +9,7 @@ import request from '@/utils/request'; */ export const getRoleList = (params) => { return request.request({ - url: '/tgb/api/v1/user/role', + url: '/user/role', method: 'get', params, }); @@ -23,7 +23,7 @@ export const getRoleList = (params) => { */ export const deleteRole = (data) => { return request.request({ - url: '/tgb/api/v1/user/role/delete', + url: '/user/role/delete', method: 'post', data, }); diff --git a/src/services/User/user.ts b/src/services/User/user.ts index 769f116..19f5f20 100644 --- a/src/services/User/user.ts +++ b/src/services/User/user.ts @@ -9,7 +9,7 @@ import request from '@/utils/request'; */ export const getUserList = (params) => { return request.request({ - url: '/tgb/api/v1/account/get', + url: '/account/get', method: 'get', params, }); diff --git a/src/services/login.ts b/src/services/login.ts index ae0cf3e..39eace9 100644 --- a/src/services/login.ts +++ b/src/services/login.ts @@ -2,7 +2,22 @@ import request from '@/utils/request'; export const login = (data) => { return request.request({ - url: '/tbg/api/v1/admin/login', + url: '/admin/login', + method: 'post', + data, + }); +}; + +/** + * 修改用户密码 + * @param data + * password 用户旧密码 + * new_password 用户新密码 + * @returns + */ +export const modifyPassword = (data) => { + return request.request({ + url: '/admin/update', method: 'post', data, }); diff --git a/src/utils/request.ts b/src/utils/request.ts index 6664c28..4a6c46b 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -6,13 +6,13 @@ import { CACHE_TOKEN } from '@/constants/cacheKey'; // create an axios instance const request = axios.create({ - baseURL: '', // + baseURL: '/tbg/api/v1', // timeout: 10000, // request timeout }); // request interceptor request.interceptors.request.use( (memo: any) => { - memo.headers.token = localStorage.getItem(CACHE_TOKEN); + memo.headers.Authorization = localStorage.getItem(CACHE_TOKEN); return memo; }, (error) => { @@ -24,7 +24,7 @@ request.interceptors.response.use( (response) => { const res: any = response.data; if (res.code !== 200) { - if (res.code === 401) { + if (res.code === 401 || res.code === 10001) { notification.error({ message: '错误信息', description: '登录失效', -- 2.40.1 From 2d06115a4eef9217f9b1e0376ff28339648a14e6 Mon Sep 17 00:00:00 2001 From: zzy <> Date: Wed, 3 Aug 2022 15:03:17 +0800 Subject: [PATCH 05/12] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AF=86=E9=92=A5?= =?UTF-8?q?=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/proxy.ts | 2 +- src/pages/System/SecretKey/index.less | 24 +++++++++++++++++++ src/pages/System/SecretKey/index.tsx | 34 +++++++++++++++++++++++++++ src/routes/index.ts | 5 ++++ src/routes/routePath.ts | 1 + src/services/System/secretKey.ts | 26 ++++++++++++++++++++ 6 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 src/pages/System/SecretKey/index.less create mode 100644 src/pages/System/SecretKey/index.tsx create mode 100644 src/services/System/secretKey.ts diff --git a/config/proxy.ts b/config/proxy.ts index 3bc1829..afc029a 100644 --- a/config/proxy.ts +++ b/config/proxy.ts @@ -11,7 +11,7 @@ export default { // localhost:8000/api/** -> https://preview.pro.ant.design/api/** '/tbg/api/v1': { // 要代理的地址 - target: 'http://192.168.1.226:9999', + target: 'http://0.0.0.0:9999', // 配置了这个可以从 http 代理到 https // 依赖 origin 的功能可能需要这个,比如 cookie changeOrigin: true, diff --git a/src/pages/System/SecretKey/index.less b/src/pages/System/SecretKey/index.less new file mode 100644 index 0000000..1565eba --- /dev/null +++ b/src/pages/System/SecretKey/index.less @@ -0,0 +1,24 @@ +@import '~antd/es/style/themes/default.less'; + +.container { + display: flex; + flex-direction: column; + height: 100vh; + padding: 20px; + overflow: auto; + background: white; + :global { + .ant-pro-form-login-header { + margin-bottom: 40px; + } + } +} + +.button { + width: 150px; +} + +.textarea { + width: 600px; + margin-top: 20px; +} diff --git a/src/pages/System/SecretKey/index.tsx b/src/pages/System/SecretKey/index.tsx new file mode 100644 index 0000000..51e6449 --- /dev/null +++ b/src/pages/System/SecretKey/index.tsx @@ -0,0 +1,34 @@ +import React, { useState, useEffect } from 'react'; +import { Button, Input } from 'antd'; +import styles from './index.less'; +import { createSecretKey, getSecretKey } from '@/services/System/secretKey'; + +const { TextArea } = Input; + +const SecretKey: React.FC = () => { + const [secretKey, setSecretKey] = useState(''); + + const create = async () => { + await createSecretKey({}); + }; + + const getUserSecretKey = async () => { + const data = await getSecretKey(); + setSecretKey(data + ''); + }; + + useEffect(() => { + getUserSecretKey(); + }, []); + + return ( +
+ +