import { UploadOutlined } from '@ant-design/icons'; import { ProForm, ProFormDependency, ProFormFieldSet, ProFormSelect, ProFormText, ProFormTextArea, } from '@ant-design/pro-components'; import { useRequest } from '@umijs/max'; import { Button, Input, message, Upload } from 'antd'; import React from 'react'; import { queryCity, queryCurrent, queryProvince } from '../service'; import useStyles from './index.style'; const validatorPhone = ( _rule: any, value: string[], callback: (message?: string) => void, ) => { if (!value[0]) { callback('Please input your area code!'); } if (!value[1]) { callback('Please input your phone number!'); } callback(); }; const BaseView: React.FC = () => { const { styles } = useStyles(); // 头像组件 方便以后独立,增加裁剪之类的功能 const AvatarView = ({ avatar }: { avatar: string }) => ( <>
头像
avatar
); const { data: currentUser, loading } = useRequest(() => { return queryCurrent(); }); const getAvatarURL = () => { if (currentUser) { if (currentUser.avatar) { return currentUser.avatar; } const url = 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png'; return url; } return ''; }; const handleFinish = async () => { message.success('更新基本信息成功'); }; return (
{loading ? null : ( <>
dom[1], }} initialValues={{ ...currentUser, phone: currentUser?.phone.split('-'), }} hideRequiredMark > { return queryProvince().then(({ data }) => { return data.map((item) => { return { label: item.name, value: item.id, }; }); }); }} /> {({ province }) => { return ( { if (!province?.key) { return []; } return queryCity(province.key || '').then( ({ data }) => { return data.map((item) => { return { label: item.name, value: item.id, }; }); }, ); }} /> ); }}
)}
); }; export default BaseView;