user-zzy-dev #2
|
|
@ -0,0 +1,5 @@
|
||||||
|
export enum CoinType {
|
||||||
|
ETH = 'eth',
|
||||||
|
TRON = 'tron',
|
||||||
|
}
|
||||||
|
export default CoinType;
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
import { createForm } from '@formily/core';
|
||||||
|
import { createSchemaField } from '@formily/react';
|
||||||
|
import Modal, { ModalProps } from '@/components/Modal';
|
||||||
|
import { message } from 'antd';
|
||||||
|
|
||||||
|
import { Form, FormItem, Input, Submit } from '@formily/antd';
|
||||||
|
import { AddAddress } from '@/services/eth';
|
||||||
|
import { initWeb3, walletSign } from '../../../../utils/web3';
|
||||||
|
import { values } from 'lodash';
|
||||||
|
|
||||||
|
interface AddAddressModalPropsType extends ModalProps {
|
||||||
|
onOk: (val: any) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const SchemaField = createSchemaField({
|
||||||
|
components: {
|
||||||
|
FormItem,
|
||||||
|
Input,
|
||||||
|
Submit,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const form = createForm({});
|
||||||
|
|
||||||
|
const AddAddressModal = (onOk, { ...rest }: AddAddressModalPropsType) => {
|
||||||
|
const handleOk = () => {
|
||||||
|
const val = form.getState();
|
||||||
|
console.log('val = ', val);
|
||||||
|
onOk && onOk(val);
|
||||||
|
// try {
|
||||||
|
// await initWeb3();
|
||||||
|
// const signInfo = await walletSign();
|
||||||
|
// val.key = signInfo.raw;
|
||||||
|
// val.sign = signInfo.sign;
|
||||||
|
// val.coinType = 'eth';
|
||||||
|
// val.num = parseInt(val.num);
|
||||||
|
// const params = { ...val };
|
||||||
|
// await AddAddress(params);
|
||||||
|
// message.success('操作成功');
|
||||||
|
// } catch (e) {}
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<Modal title="添加地址" onOk={handleOk} width={800} {...rest}>
|
||||||
|
<Form form={form} labelCol={4} wrapperCol={18}>
|
||||||
|
<SchemaField>
|
||||||
|
<SchemaField.String
|
||||||
|
name="alias"
|
||||||
|
title="备注"
|
||||||
|
required
|
||||||
|
x-decorator="FormItem"
|
||||||
|
x-component="Input"
|
||||||
|
/>
|
||||||
|
<SchemaField.Number
|
||||||
|
name="num"
|
||||||
|
title="数量"
|
||||||
|
required
|
||||||
|
x-decorator="FormItem"
|
||||||
|
x-component="Input"
|
||||||
|
/>
|
||||||
|
</SchemaField>
|
||||||
|
</Form>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AddAddressModal;
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
import { createForm } from '@formily/core';
|
||||||
|
import { createSchemaField } from '@formily/react';
|
||||||
|
import { message, Spin } from 'antd';
|
||||||
|
import DetailPageContainer from '@/components/DetailPageContainer';
|
||||||
|
import { AddAddress } from '@/services/eth';
|
||||||
|
import { initWeb3, walletSign } from '../../../../utils/web3';
|
||||||
|
import { Form, FormItem, Input, FormButtonGroup, Submit } from '@formily/antd';
|
||||||
|
|
||||||
|
const SchemaField = createSchemaField({
|
||||||
|
components: {
|
||||||
|
FormItem,
|
||||||
|
Input,
|
||||||
|
Submit,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const form = createForm({});
|
||||||
|
const WorkEdit = () => {
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
const handleSubmit = async (val) => {
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
await initWeb3();
|
||||||
|
const signInfo = await walletSign();
|
||||||
|
val.key = signInfo.raw;
|
||||||
|
val.sign = signInfo.sign;
|
||||||
|
val.coinType = 'eth';
|
||||||
|
val.num = parseInt(val.num);
|
||||||
|
const params = { ...val };
|
||||||
|
await AddAddress(params);
|
||||||
|
message.success('操作成功');
|
||||||
|
setLoading(false);
|
||||||
|
history.back();
|
||||||
|
} catch (e) {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<DetailPageContainer>
|
||||||
|
<Spin spinning={loading}>
|
||||||
|
<Form form={form} labelCol={4} wrapperCol={18} onAutoSubmit={handleSubmit}>
|
||||||
|
<SchemaField>
|
||||||
|
<SchemaField.String
|
||||||
|
name="alias"
|
||||||
|
title="备注"
|
||||||
|
required
|
||||||
|
x-decorator="FormItem"
|
||||||
|
x-component="Input"
|
||||||
|
/>
|
||||||
|
<SchemaField.Number
|
||||||
|
name="num"
|
||||||
|
title="数量"
|
||||||
|
required
|
||||||
|
x-decorator="FormItem"
|
||||||
|
x-component="Input"
|
||||||
|
/>
|
||||||
|
</SchemaField>
|
||||||
|
<FormButtonGroup.FormItem>
|
||||||
|
<Submit block size="large">
|
||||||
|
提交
|
||||||
|
</Submit>
|
||||||
|
</FormButtonGroup.FormItem>
|
||||||
|
</Form>
|
||||||
|
</Spin>
|
||||||
|
</DetailPageContainer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default WorkEdit;
|
||||||
|
|
@ -0,0 +1,76 @@
|
||||||
|
import React, { useRef, useState } from 'react';
|
||||||
|
import Table, { ProColumns, ActionType } from '@/components/Table';
|
||||||
|
import { history } from 'umi';
|
||||||
|
import RoutePath from '@/routes/routePath';
|
||||||
|
import { queryAddressList } from '@/services/eth';
|
||||||
|
import { fetchTableData } from '@/utils/table';
|
||||||
|
import CoinType from '@/constants/enum/coinType';
|
||||||
|
// import WorkSelectModal from '@/widget/Work/WorkSelectModal';
|
||||||
|
// import AddAddressModal from '../Edit/AddAddressModal';
|
||||||
|
|
||||||
|
const AddressList = () => {
|
||||||
|
// const [isModalVisible, setIsModalVisible] = useState(false);
|
||||||
|
const tableRef = useRef<ActionType>();
|
||||||
|
const columns: ProColumns<any>[] = [
|
||||||
|
{
|
||||||
|
title: '备注',
|
||||||
|
dataIndex: 'remarks',
|
||||||
|
width: '20%',
|
||||||
|
// hideInSearch: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '地址',
|
||||||
|
dataIndex: 'address',
|
||||||
|
hideInSearch: true,
|
||||||
|
ellipsis: true,
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// title: '余额',
|
||||||
|
// dataIndex: 'series',
|
||||||
|
// hideInSearch: true,
|
||||||
|
// },
|
||||||
|
{
|
||||||
|
title: 'key',
|
||||||
|
dataIndex: 'key',
|
||||||
|
hideInSearch: true,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Table
|
||||||
|
columns={columns}
|
||||||
|
// indexColumn
|
||||||
|
rowKey="id"
|
||||||
|
actionRef={tableRef}
|
||||||
|
toolBarActions={[
|
||||||
|
{
|
||||||
|
type: 'add',
|
||||||
|
onConfirm: () => {
|
||||||
|
history.push(RoutePath.ETH_ADDRESS.EDIT);
|
||||||
|
// setIsModalVisible(true);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
request={async (params) => {
|
||||||
|
params.coinType = CoinType.ETH;
|
||||||
|
return fetchTableData(queryAddressList, params);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{/* <WorkSelectModal
|
||||||
|
visible={isModalVisible}
|
||||||
|
value={[]}
|
||||||
|
onOk={function (val: any): void {
|
||||||
|
setIsModalVisible(false);
|
||||||
|
}}
|
||||||
|
/> */}
|
||||||
|
{/* <AddAddressModal
|
||||||
|
visible={isModalVisible}
|
||||||
|
onOk={function (val: any): void {
|
||||||
|
setIsModalVisible(false);
|
||||||
|
}}
|
||||||
|
/> */}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AddressList;
|
||||||
|
|
@ -0,0 +1,81 @@
|
||||||
|
import React, { useRef } from 'react';
|
||||||
|
import Table, { ProColumns, ActionType } from '@/components/Table';
|
||||||
|
import { queryRecordList } from '@/services/eth';
|
||||||
|
import { fetchTableData } from '@/utils/table';
|
||||||
|
import CoinType from '@/constants/enum/coinType';
|
||||||
|
import { web3 } from '@/utils/web3';
|
||||||
|
|
||||||
|
const AddressList = () => {
|
||||||
|
const tableRef = useRef<ActionType>();
|
||||||
|
const columns: ProColumns<any>[] = [
|
||||||
|
{
|
||||||
|
title: '交易哈希',
|
||||||
|
dataIndex: 'txHash',
|
||||||
|
// width: '20%',
|
||||||
|
// hideInSearch: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '金额',
|
||||||
|
dataIndex: 'amount',
|
||||||
|
// hideInSearch: true,
|
||||||
|
// ellipsis: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '位数',
|
||||||
|
dataIndex: 'decimals',
|
||||||
|
// hideInSearch: true,
|
||||||
|
// ellipsis: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '区块',
|
||||||
|
dataIndex: 'blockNumber',
|
||||||
|
// hideInSearch: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '发送地址',
|
||||||
|
dataIndex: 'from',
|
||||||
|
// hideInSearch: true,
|
||||||
|
// ellipsis: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '接受地址',
|
||||||
|
dataIndex: 'to',
|
||||||
|
// hideInSearch: true,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Table
|
||||||
|
columns={columns}
|
||||||
|
// indexColumn
|
||||||
|
rowKey="id"
|
||||||
|
actionRef={tableRef}
|
||||||
|
// toolBarActions={[
|
||||||
|
// {
|
||||||
|
// type: 'add',
|
||||||
|
// onConfirm: () => {
|
||||||
|
// history.push(RoutePath.ETH_ADDRESS.EDIT);
|
||||||
|
// setIsModalVisible(true);
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// ]}
|
||||||
|
request={async (params) => {
|
||||||
|
params.coinType = CoinType.ETH;
|
||||||
|
const res = await fetchTableData(queryRecordList, params);
|
||||||
|
for (const key in res.data) {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(res.data, key)) {
|
||||||
|
const element = res.data[key];
|
||||||
|
element.amount = web3.utils
|
||||||
|
.toBN(element.amount)
|
||||||
|
.div(web3.utils.toBN(Math.pow(10, Number(element.decimals))))
|
||||||
|
.toNumber();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AddressList;
|
||||||
|
|
@ -16,7 +16,7 @@ const Login: React.FC = () => {
|
||||||
await initWeb3();
|
await initWeb3();
|
||||||
const signInfo = await walletSign();
|
const signInfo = await walletSign();
|
||||||
const res: any = await login({ data: signInfo.raw, sign: signInfo.sign });
|
const res: any = await login({ data: signInfo.raw, sign: signInfo.sign });
|
||||||
localStorage.setItem(CACHE_TOKEN, res.token);
|
localStorage.setItem(CACHE_TOKEN, res);
|
||||||
// const res: any = await login({ ...values });
|
// const res: any = await login({ ...values });
|
||||||
// localStorage.setItem(CACHE_TOKEN, res.token);
|
// localStorage.setItem(CACHE_TOKEN, res.token);
|
||||||
/** 此方法会跳转到 redirect 参数所在的位置 */
|
/** 此方法会跳转到 redirect 参数所在的位置 */
|
||||||
|
|
@ -25,7 +25,6 @@ const Login: React.FC = () => {
|
||||||
const { redirect } = query as { redirect: string };
|
const { redirect } = query as { redirect: string };
|
||||||
history.push(redirect || '/');
|
history.push(redirect || '/');
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
<div className={styles.content}>
|
<div className={styles.content}>
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import RoutePath from '@/routes/routePath';
|
||||||
import { queryWorkList, deleteWork } from '@/services/work';
|
import { queryWorkList, deleteWork } from '@/services/work';
|
||||||
import { fetchTableData } from '@/utils/table';
|
import { fetchTableData } from '@/utils/table';
|
||||||
import TimeText from '@/components/Typography/TimeText';
|
import TimeText from '@/components/Typography/TimeText';
|
||||||
|
import WorkSelectModal from '@/widget/Work/WorkSelectModal';
|
||||||
|
|
||||||
const WorkList = () => {
|
const WorkList = () => {
|
||||||
const tableRef = useRef<ActionType>();
|
const tableRef = useRef<ActionType>();
|
||||||
|
|
@ -74,23 +75,28 @@ const WorkList = () => {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
return (
|
return (
|
||||||
<Table
|
<div>
|
||||||
columns={columns}
|
<Table
|
||||||
// indexColumn
|
columns={columns}
|
||||||
rowKey="id"
|
// indexColumn
|
||||||
actionRef={tableRef}
|
rowKey="id"
|
||||||
toolBarActions={[
|
actionRef={tableRef}
|
||||||
{
|
toolBarActions={[
|
||||||
type: 'add',
|
{
|
||||||
onConfirm: () => {
|
type: 'add',
|
||||||
history.push(RoutePath.WORK.EDIT);
|
onConfirm: () => {
|
||||||
|
history.push(RoutePath.WORK.EDIT);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
]}
|
||||||
]}
|
request={async (params) => {
|
||||||
request={async (params) => {
|
return fetchTableData(queryWorkList, params);
|
||||||
return fetchTableData(queryWorkList, params);
|
}}
|
||||||
}}
|
/>
|
||||||
/>
|
<WorkSelectModal value={[1, 2, 3]} onOk={function (val: any): void {
|
||||||
|
throw new Error('Function not implemented.');
|
||||||
|
} } />
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,39 +16,33 @@ export default [
|
||||||
routes: [
|
routes: [
|
||||||
{
|
{
|
||||||
path: RoutePath.ETH,
|
path: RoutePath.ETH,
|
||||||
redirect: RoutePath.ADDRESS.LIST,
|
redirect: RoutePath.ETH_ADDRESS.LIST,
|
||||||
hideInMenu: true,
|
hideInMenu: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'ETH地址管理',
|
name: 'ETH地址管理',
|
||||||
path: RoutePath.ADDRESS.LIST,
|
path: RoutePath.ETH_ADDRESS.LIST,
|
||||||
component: './Work/List',
|
component: './Eth/Address/List',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'ETH地址详情',
|
name: 'ETH地址详情',
|
||||||
path: RoutePath.ADDRESS.EDIT,
|
path: RoutePath.ETH_ADDRESS.EDIT,
|
||||||
hideInMenu: true,
|
hideInMenu: true,
|
||||||
component: './Work/Edit',
|
component: './Eth/Address/Edit',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'ETH充值记录',
|
name: 'ETH充值记录',
|
||||||
path: RoutePath.RECORD.LIST,
|
path: RoutePath.ETH_RECORD.LIST,
|
||||||
component: './Work/List',
|
component: './Eth/Record/List',
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'ETH充值详情',
|
|
||||||
path: RoutePath.RECORD.EDIT,
|
|
||||||
hideInMenu: true,
|
|
||||||
component: './Work/Edit',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'ETH币种管理',
|
name: 'ETH币种管理',
|
||||||
path: RoutePath.CURRENCY.LIST,
|
path: RoutePath.ETH_CURRENCY.LIST,
|
||||||
component: './Work/List',
|
component: './Work/List',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'ETH币种详情',
|
name: 'ETH币种详情',
|
||||||
path: RoutePath.CURRENCY.EDIT,
|
path: RoutePath.ETH_CURRENCY.EDIT,
|
||||||
hideInMenu: true,
|
hideInMenu: true,
|
||||||
component: './Work/Edit',
|
component: './Work/Edit',
|
||||||
},
|
},
|
||||||
|
|
@ -79,7 +73,7 @@ export default [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
redirect: RoutePath.WORK.LIST,
|
redirect: RoutePath.ETH_ADDRESS.LIST,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,14 @@ const ETH = '/eth';
|
||||||
const RoutePath = {
|
const RoutePath = {
|
||||||
LOGIN: '/login',
|
LOGIN: '/login',
|
||||||
ETH: ETH,
|
ETH: ETH,
|
||||||
ADDRESS: {
|
ETH_ADDRESS: {
|
||||||
LIST: `${ETH}/address`,
|
LIST: `${ETH}/address`,
|
||||||
EDIT: `${ETH}/address/edit`,
|
EDIT: `${ETH}/address/edit`,
|
||||||
},
|
},
|
||||||
RECORD: {
|
ETH_RECORD: {
|
||||||
LIST: `${ETH}/record`,
|
LIST: `${ETH}/record`,
|
||||||
EDIT: `${ETH}/record/edit`,
|
|
||||||
},
|
},
|
||||||
CURRENCY: {
|
ETH_CURRENCY: {
|
||||||
LIST: `${ETH}/currency`,
|
LIST: `${ETH}/currency`,
|
||||||
EDIT: `${ETH}/currency/edit`,
|
EDIT: `${ETH}/currency/edit`,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
import request from '@/utils/request';
|
||||||
|
|
||||||
|
export const queryAddressList = (data) => {
|
||||||
|
return request.request({
|
||||||
|
url: '/admin/api/v1/address/get',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const AddAddress = (data) => {
|
||||||
|
return request.request({
|
||||||
|
url: '/admin/api/v1/address/mask',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const queryRecordList = (data) => {
|
||||||
|
return request.request({
|
||||||
|
url: '/admin/api/v1/records/get',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
@ -9,8 +9,7 @@ export const fetchTableData = async (
|
||||||
delete params.current;
|
delete params.current;
|
||||||
delete params.pageSize;
|
delete params.pageSize;
|
||||||
const res = (await fetch(params)) || {};
|
const res = (await fetch(params)) || {};
|
||||||
const data = res.data;
|
const data = res;
|
||||||
|
|
||||||
data?.forEach((n: any) => {
|
data?.forEach((n: any) => {
|
||||||
for (const key in formatObj) {
|
for (const key in formatObj) {
|
||||||
n[key] = n[formatObj[key]];
|
n[key] = n[formatObj[key]];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue