import React, { PureComponent } from 'react'; import { connect } from 'dva'; import moment from 'moment'; import numeral from 'numeral'; import { List, Card, Row, Col, Icon, Dropdown, Menu, Avatar, Tag, Divider, Tooltip, Spin } from 'antd'; import AvatarList from '../components/AvatarList'; import { formatWan } from '../utils/utils'; import styles from './UserCenter.less'; import stylesArticles from './List/Articles.less'; import stylesApplications from './List/Applications.less'; import stylesProjects from './List/Projects.less'; @connect(({ list, loading, user, project }) => ({ list, listLoading: loading.effects['list/fetch'], currentUser: user.currentUser, currentUserLoading: loading.effects['user/fetchCurrent'], project, projectLoading: loading.effects['project/fetchNotice'], })) export default class UserCenter extends PureComponent { state = { key: 'article', } componentDidMount() { const { dispatch } = this.props; this.props.dispatch({ type: 'user/fetchCurrent', }); dispatch({ type: 'list/fetch', payload: { count: 8, }, }); dispatch({ type: 'project/fetchNotice', }); } onTabChange = (key) => { this.setState({ key }); } renderArticles = (list, loading) => { const IconText = ({ type, text }) => ( {text} ); const ListContent = ({ data: { content, updatedAt, avatar, owner, href } }) => (
{content}
{owner} 发布在 {href} {moment(updatedAt).format('YYYY-MM-DD HH:mm')}
); return ( ( , , , ]} > {item.title} )} description={ Ant Design 设计语言 蚂蚁金服 } /> )} /> ); } renderApplications = (list, loading) => { const itemMenu = ( 1st menu item 2nd menu item 3d menu item ); const CardInfo = ({ activeUser, newUser }) => (

活跃用户

{activeUser}

新增用户

{newUser}

); return ( ( , , , , ]} > } title={item.title} />
)} /> ); } renderProjects = (list, loading) => { return ( ( } > {item.title}} description={item.subDescription} />
{moment(item.updatedAt).fromNow()}
{ item.members.map(member => ( )) }
)} /> ); } render() { const { list: { list }, listLoading, currentUser, currentUserLoading, project: { notice }, projectLoading } = this.props; const operationTabList = [{ key: 'article', tab: '文章(8)', }, { key: 'application', tab: '应用(8)', }, { key: 'project', tab: '项目(8)', }]; const contentMap = { article: this.renderArticles(list, listLoading), application: this.renderApplications(list, listLoading), project: this.renderProjects(list, listLoading), }; return (
{ currentUser && Object.keys(currentUser).length ? (
{currentUser.name}
{currentUser.signature}

{currentUser.title}

{currentUser.group}

{currentUser.geographic.province.label} {currentUser.geographic.city.label}

标签
{ currentUser.tags.map(item => {item.label}) }
团队
{ notice.map(item => ( {item.member} )) }
) : 'loading...' }
{contentMap[this.state.key]}
); } }