forked from nsjcy/frontEnd/nsjcy

bug
liuwh
2020-03-24 51351c2d8c7297cb3f96e572c0e1a110ce8a5073
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
import React from 'react';
import { Toast } from 'antd-mobile';
// import { Icon } from 'antd';
 
import UserInfo from '../view/UserInfo';
import IndexEntry from '../view/IndexEntry';
import PageLoading from '../view/PageLoading';
import Fetch from '../fetch';
import data from '../data/index.entries';
 
export default class Index extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      userInfo: {}
    };
  }
 
  componentDidMount() {
    document.title = '我';
    Fetch.getUserInfo()
      .then(userInfo => {
        this.setState({ userInfo });
      });
  }
 
  onClick = path => {
    this.props.history.push(path);
  }
 
  render() {
    const { avatar, name, info, reach = 2 } = this.state.userInfo;
    return (
      <div className="app-page">
        <UserInfo avatar={avatar} name={name} info={info} />
        {
          data.slice(0, reach).map(({ head, entries }, index) => (
            <IndexEntry
              key={index}
              onClick={this.onClick}
              head={head}
              entries={entries}
            />
          ))
        }{
          !name && <PageLoading />
        }
      </div>
    );
  }
 
}