import React from 'react'; import { UploadOutlined } from '@ant-design/icons'; import { Button, Input, Upload, message } from 'antd'; import ProForm, { ProFormDependency, ProFormFieldSet, ProFormSelect, ProFormText, ProFormTextArea, } from '@ant-design/pro-form'; import { useRequest } from 'umi'; import { queryCurrent } from '../service'; import { queryProvince, queryCity } from '../service'; import styles from './BaseView.less'; const validatorPhone = (rule: any, value: string, callback: (message?: string) => void) => { const values = value.split('-'); if (!values[0]) { callback('Please input your area code!'); } if (!values[1]) { callback('Please input your phone number!'); } callback(); }; // 头像组件 方便以后独立,增加裁剪之类的功能 const AvatarView = ({ avatar }: { avatar: string }) => ( <>
头像
avatar
); const BaseView: React.FC = () => { 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 : ( <>
{ 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;