68 lines
1.8 KiB
TypeScript
68 lines
1.8 KiB
TypeScript
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;
|