forked from nsjcy/frontEnd/nsjcy

Mr Ke
2020-05-27 58ae2ba21efcd85df331cf996a94038a77302b51
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
 * 徐祥健<xuxj@hugeinfo.com.cn>
 * 2018年7月16日 14:08
 *
 */
 
 
import React from 'react';
 
import './style.scss';
import { message } from 'antd';
import Fetch from '../../fetch';
export default class Index extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      userInfo: {}
    };
  }
 
  componentDidMount() {
    Fetch.getUserInfo()
      .then(res => {
        if (res.code === 0) {
          this.setState({ userInfo: res.data });
        }
      });
  }
 
  loginOut = () => {
    Fetch.loginOut()
      .then(res => {
        if (res.code === 0) {
          message.success('退出成功', 1, () => {
            location.href = res.data;
          })
        } else {
          message.error('退出失败,请联系管理员', 2)
        }
      });
  }
  userCenter = () => {
    const { userInfo } = this.state;
    this.props.history.push('/updatePWD/' + userInfo.id)
  }
 
  render() {
    const { userInfo } = this.state;
    return (
      <div className="head-view-main">
        <div>
          <label className='head-view-name'>{userInfo.qywxUsername}</label>
          <label className='head-view-center'>
            <span style={{ cursor: 'pointer' }} onClick={this.userCenter}>个人中心</span>&nbsp;|&nbsp;<span style={{ cursor: 'pointer' }} onClick={this.loginOut}>退出登录</span>
          </label>
        </div>
        <div>
          <label className='head-view-role'>{userInfo.upasPostname}</label>
        </div>
      </div>
    );
  }
 
}