import * as React from 'react' import AvatarImg from '&/components/common/avatarImg/avatarImg.tsx'; import { taker, getApiUrl, getQueryString, getUserInfo } from '&/helper'; export default class UserInfo extends React.PureComponent<{}, {}>{ state = { isFetching: true, avatarColor: '', avatarImg: '', name: '', department: '', position: '' } componentDidMount() { this.getData() } componentWillReceiveProps() { this.getData() } getData = async () => { const selfId = getUserInfo().Id; const toUserID = getQueryString()['to_user_id']; const url = `${getApiUrl('proxy/GetUPaaSCoreGateway/AccountService/GetUserInfo')}?toUserId=${toUserID || selfId}`; let res = await taker(url, 'get') if (!res || !res.OperationObject) return; const { OperationObject } = res; const { UserAvatar, Name = 'ren', Department = '', Position = '' } = OperationObject; this.setState({ isFetching: false, avatarColor: UserAvatar.Color, avatarImg: UserAvatar.Big, name: Name, department: Department, position: Position }) } render() { const { isFetching, avatarColor, avatarImg, name, department, position } = this.state; // const { tagShow } = this.props; if (isFetching) return null return
{name} { department } { position && `ยท${position}` }
{this.props.children}
} }