通用评论 vedio

index.js 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import React, { Component } from "react";
  2. import { Spin, Pagination } from "antd";
  3. import intl from "react-intl-universal";
  4. import Comment from "../../Comment";
  5. import CommentBox from "../CommentBox";
  6. import "./index.css";
  7. import { LIMIT } from "../../constant";
  8. class CommentList extends Component {
  9. constructor(props) {
  10. super(props);
  11. this.state = {};
  12. }
  13. componentWillMount() {
  14. this.props.app.sGetComment({ page: this.props.app.page });
  15. }
  16. renderPagination() {
  17. const {
  18. list,
  19. total,
  20. page,
  21. pageType,
  22. isNoMoreComment,
  23. sGetComment,
  24. onPageChange
  25. } = this.props.app;
  26. if (pageType === "more") {
  27. if (!isNoMoreComment && list.length !== total) {
  28. return (
  29. <div
  30. className="comment-list-show-more"
  31. onClick={() => {
  32. sGetComment({ page: page + 1 });
  33. onPageChange(page + 1);
  34. }}
  35. >
  36. <span>{intl.get("comment.moreComment")}</span>
  37. </div>
  38. );
  39. } else {
  40. return null;
  41. }
  42. } else if (pageType === "pagination") {
  43. return (
  44. <div className="comment-list-pagination">
  45. <Pagination
  46. pageSize={LIMIT}
  47. current={page}
  48. total={total}
  49. onChange={p => {
  50. sGetComment({ page: p });
  51. onPageChange(p);
  52. }}
  53. />
  54. </div>
  55. );
  56. }
  57. }
  58. render() {
  59. const { list, total, loading } = this.props.app;
  60. const spinning = Boolean(
  61. loading.sGetComment || loading.sCommentFavor || loading.sReplyFavor
  62. );
  63. return (
  64. <div>
  65. <Spin spinning={spinning}>
  66. {/* <div>共 {total} 条评论</div> */}
  67. <div>{intl.get("comment.totalComment", { total })}</div>
  68. {list.map(item => (
  69. <CommentBox content={item} key={item.id} commentId={item.id} />
  70. ))}
  71. {this.renderPagination()}
  72. </Spin>
  73. </div>
  74. );
  75. }
  76. }
  77. CommentList.propTypes = {};
  78. export default Comment(CommentList);