12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- import React, { Component } from "react";
- import { Spin, Pagination } from "antd";
- import Comment from "../../Comment";
- import CommentBox from "../CommentBox";
- import "./index.css";
- import { LIMIT } from "../../constant";
-
- class CommentList extends Component {
- constructor(props) {
- super(props);
- this.state = {};
- }
-
- componentWillMount() {
- this.props.app.sGetComment();
- }
-
- renderPagination() {
- const {
- list,
- total,
- page,
- pageType,
- isNoMoreComment,
- sGetComment
- } = this.props.app;
- if (pageType === "more") {
- if (!isNoMoreComment && list.length !== total) {
- return (
- <div
- className="comment-list-show-more"
- onClick={() => sGetComment({ page: page + 1 })}
- >
- <span>查看更多评论</span>
- </div>
- );
- } else {
- return null;
- }
- } else if (pageType === "pagination") {
- return (
- <div className="comment-list-pagination">
- <Pagination
- pageSize={LIMIT}
- current={page}
- total={total}
- onChange={p => {
- sGetComment({ page: p });
- }}
- />
- </div>
- );
- }
- }
-
- render() {
- const { list, total, loading } = this.props.app;
-
- const spinning = Boolean(
- loading.sGetComment || loading.sCommentFavor || loading.sReplyFavor
- );
- return (
- <div>
- <Spin spinning={spinning}>
- <div>共 {total} 条评论</div>
- {list.map(item => (
- <CommentBox content={item} key={item.id} commentId={item.id} />
- ))}
- {this.renderPagination()}
- </Spin>
- </div>
- );
- }
- }
-
- CommentList.propTypes = {};
-
- export default Comment(CommentList);
|