增加个人中心页面
This commit is contained in:
65
src/pages/PersonalInfo/index.tsx
Normal file
65
src/pages/PersonalInfo/index.tsx
Normal file
@ -0,0 +1,65 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Descriptions, Spin, message } from 'antd';
|
||||
import { useIntl } from 'umi';
|
||||
import { getUserInfo } from './services';
|
||||
|
||||
// 性别转中文
|
||||
const getGenderLabel = (sex: string | number | undefined) => {
|
||||
if (sex === '1' || sex === 1) return '男';
|
||||
if (sex === '0' || sex === 0) return '女';
|
||||
return '';
|
||||
};
|
||||
|
||||
const PersonalInfo: React.FC = () => {
|
||||
const intl = useIntl();
|
||||
const [userInfo, setUserInfo] = useState<any>({});
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
|
||||
useEffect(() => {
|
||||
setLoading(true);
|
||||
getUserInfo()
|
||||
.then(res => {
|
||||
if (res.code === 200 && res.data) {
|
||||
setUserInfo(res.data);
|
||||
} else {
|
||||
message.error('获取用户信息失败');
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
message.error('获取用户信息失败');
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
});
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
||||
<div className="common-container">
|
||||
<Spin spinning={loading}>
|
||||
<Descriptions bordered column={2} labelStyle={{ width: '120px' }}>
|
||||
<Descriptions.Item label={intl.formatMessage({ id: 'page.workbench.personal.name' })}>
|
||||
{userInfo.contactsName || '-'}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={intl.formatMessage({ id: 'page.workbench.personal.gender' })}>
|
||||
{getGenderLabel(userInfo.sex)}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={intl.formatMessage({ id: 'page.workbench.personal.phone' })}>
|
||||
{userInfo.mobile || userInfo.contactsPhone || '-'}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={intl.formatMessage({ id: 'page.workbench.personal.email' })}>
|
||||
{userInfo.contactsEmail || '-'}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={intl.formatMessage({ id: 'page.workbench.personal.department' })}>
|
||||
{userInfo.orgName || '-'}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={intl.formatMessage({ id: 'page.workbench.personal.position' })}>
|
||||
{userInfo.position || '-'}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
</Spin>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default PersonalInfo;
|
11
src/pages/PersonalInfo/services.ts
Normal file
11
src/pages/PersonalInfo/services.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import request from '@/utils/request';
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*/
|
||||
export async function getUserInfo() {
|
||||
return request('/coscoSupplierUser/user/info', {
|
||||
method: 'GET'
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user