| | |
| | | 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 useStyles from './index.style'; |
| | |
| | | |
| | | import defaultAvat from '/public/img/defaultAva.png' |
| | | |
| | | const validatorPhone = (rule, value, callback) => { |
| | | if (!value[0]) { |
| | | callback('Please input your area code!'); |
| | | } |
| | | if (!value[1]) { |
| | | callback('Please input your phone number!'); |
| | | } |
| | | callback(); |
| | | }; |
| | | |
| | | const BaseView = () => { |
| | | const { styles } = useStyles(); |
| | | const [loading, setLoading] = React.useState(false); |
| | | const [currentUser, setCurrentUser] = React.useState({}); |
| | | |
| | | const AvatarView = ({ avatar }) => ( |
| | | <> |
| | |
| | | </> |
| | | ); |
| | | |
| | | const queryCurrent = async () => { |
| | | await Http.doGet('api/auth/user'); |
| | | const queryCurrent = () => { |
| | | setLoading(true); |
| | | Http.doGetPromise('api/auth/user', {}, (res) => { |
| | | setLoading(false); |
| | | setCurrentUser(res.data); |
| | | }).catch((err) => { |
| | | console.error(err); |
| | | setLoading(false); |
| | | }) |
| | | } |
| | | |
| | | React.useEffect(() => { |
| | | queryCurrent(); |
| | | }, []); |
| | | |
| | | |
| | | const { data: currentUser, loading } = useRequest(() => { |
| | | return queryCurrent(); |
| | | }); |
| | | console.log(1); |
| | | |
| | | const getAvatarURL = () => { |
| | | if (currentUser) { |
| | |
| | | }} |
| | | initialValues={{ |
| | | ...currentUser, |
| | | phone: currentUser?.phone.split('-'), |
| | | // phone: currentUser?.phone.split('-'), |
| | | }} |
| | | hideRequiredMark |
| | | > |
| | |
| | | }, |
| | | ]} |
| | | /> |
| | | <ProFormFieldSet |
| | | name="phone" |
| | | label="联系电话" |
| | | rules={[ |
| | | { |
| | | required: true, |
| | | message: '请输入您的联系电话!', |
| | | }, |
| | | { |
| | | validator: validatorPhone, |
| | | }, |
| | | ]} |
| | | > |
| | | <Input className={styles.area_code} /> |
| | | <Input className={styles.phone_number} /> |
| | | </ProFormFieldSet> |
| | | </ProForm> |
| | | </div> |
| | | <div className={styles.right}> |