yapi/client/containers/Follows/Follows.js

84 lines
1.9 KiB
JavaScript
Raw Normal View History

import React, { Component } from 'react';
2017-08-08 16:21:32 +08:00
import './Follows.scss';
2017-08-15 12:08:59 +08:00
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { Row, Col } from 'antd';
import { getFollowList } from '../../reducer/modules/follow';
import Subnav from '../../components/Subnav/Subnav.js';
2017-08-11 17:47:25 +08:00
import ProjectCard from '../../components/ProjectCard/ProjectCard.js';
2017-08-22 17:26:53 +08:00
import ErrMsg from '../../components/ErrMsg/ErrMsg.js';
2017-08-15 12:08:59 +08:00
@connect(
state => {
return {
2017-08-19 15:18:55 +08:00
data: state.follow.data,
uid: state.user.uid
2017-08-15 12:08:59 +08:00
}
},
{
getFollowList
}
)
2017-08-08 16:21:32 +08:00
class Follows extends Component {
2017-08-15 12:08:59 +08:00
constructor(props) {
super(props);
this.state = {
data: []
}
}
static propTypes = {
2017-08-19 15:18:55 +08:00
getFollowList: PropTypes.func,
uid: PropTypes.number
2017-08-15 12:08:59 +08:00
}
2017-08-19 15:18:55 +08:00
receiveRes = () => {
this.props.getFollowList(this.props.uid).then((res) => {
if (res.payload.data.errcode === 0) {
this.setState({
data: res.payload.data.data.list
})
}
});
}
async componentWillMount() {
this.props.getFollowList(this.props.uid).then((res) => {
2017-08-15 12:08:59 +08:00
if (res.payload.data.errcode === 0) {
this.setState({
data: res.payload.data.data.list
})
}
});
}
render () {
2017-08-15 12:08:59 +08:00
const data = this.state.data;
return (
<div>
2017-08-08 16:21:32 +08:00
<Subnav
default={'我的关注'}
data={[{
name: '项目广场',
path: '/group'
}, {
name: '我的关注',
path: '/follow'
}]}/>
<div className="g-row">
2017-08-22 16:03:39 +08:00
<Row gutter={24} className="follow-box card-panel">
2017-08-22 17:26:53 +08:00
{data.length ? data.map((item, index) => {
2017-08-15 12:08:59 +08:00
return (
2017-08-22 16:03:39 +08:00
<Col span={8} key={index}>
2017-08-22 20:04:15 +08:00
<ProjectCard projectData={item} inFollowPage={true} callbackResult={this.receiveRes} />
2017-08-15 12:08:59 +08:00
</Col>);
2017-08-22 17:26:53 +08:00
}): <ErrMsg type="noFollow"/>}
2017-08-15 12:08:59 +08:00
</Row>
</div>
</div>
)
}
}
2017-08-08 16:21:32 +08:00
export default Follows;