Files
zsxt_nbzs_h5/web-react/src/pages/home/index.jsx
2021-06-11 14:48:04 +08:00

71 lines
2.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import React, { Component } from 'react'
import { Row, Col, Divider } from 'antd'
import { isEqual } from 'lodash'
import store from 'store'
import Components from 'components'
import moment from 'moment'
import './index.less'
const { getState, subscribe } = store
const { Container, Image, AntIcon } = Components
const storePath = 'user'
export default class index extends Component {
state = {
[storePath]: getState(storePath)
}
constructor(props) {
super(props)
this.unsubscribe = subscribe(storePath, () => {
this.setState(getState(storePath))
})
}
shouldComponentUpdate(props, state) {
return !isEqual(this.state, state)
}
componentWillUnmount() {
this.unsubscribe()
}
render() {
return (
<>
<div className="home-header">
<Container mode="fluid">
<Row align="middle" justify="space-between" type="flex">
<Col>
<div className="home-header-row">
<div className="home-header-avatar">
<Image id={this.state.user.avatar} size={64} icon={<AntIcon type="UserOutlined" />} type="avatar" />
</div>
<div className="home-header-content">
<h4>
{moment().format('A')}<span>{this.state.user.nickName || this.state.user.name}</span>
</h4>
<div>
<span>上次IP{this.state.user.lastLoginIp}</span>
<Divider type="vertical" />
<span>上次登录时间{this.state.user.lastLoginTime}</span>
</div>
</div>
</div>
</Col>
<Col>
<AntIcon type="MailOutlined" style={{ fontSize: '20px', color: '#f80000' }} className="mr-xs" />
您有<a href="/">0</a>
</Col>
</Row>
</Container>
</div>
</>
)
}
}