通用评论 vedio

index.js 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. class CommentList extends Component {
  8. constructor(props) {
  9. super(props);
  10. this.state = {};
  11. }
  12. componentWillMount() {
  13. this.props.app.sGetComment({ page: this.props.app.page });
  14. }
  15. renderPagination() {
  16. const {
  17. list,
  18. total,
  19. page,
  20. pageType,
  21. limit,
  22. isNoMoreComment,
  23. sGetComment,
  24. onPageChange,
  25. onGetMoreBtnClick
  26. } = this.props.app;
  27. if (pageType === "slice") {
  28. // 截断多余评论,通过点击查看更多跳转
  29. return (
  30. <div className="comment-list-show-more" onClick={onGetMoreBtnClick}>
  31. <span>查看更多</span>
  32. </div>
  33. );
  34. } else if (pageType === "more") {
  35. if (!isNoMoreComment && list.length !== total) {
  36. return (
  37. <div
  38. className="comment-list-show-more"
  39. onClick={() => {
  40. sGetComment({ page: page + 1 });
  41. onPageChange(page + 1);
  42. }}
  43. >
  44. <span>{intl.get("comment.moreComment")}</span>
  45. </div>
  46. );
  47. } else {
  48. return null;
  49. }
  50. } else if (pageType === "pagination") {
  51. return (
  52. <div className="comment-list-pagination">
  53. <Pagination
  54. pageSize={limit}
  55. current={page}
  56. total={total}
  57. onChange={p => {
  58. sGetComment({ page: p });
  59. onPageChange(p);
  60. }}
  61. />
  62. </div>
  63. );
  64. }
  65. }
  66. render() {
  67. const { list, total, loading } = this.props.app;
  68. const spinning = Boolean(
  69. loading.sGetComment || loading.sCommentFavor || loading.sReplyFavor
  70. );
  71. return (
  72. <div>
  73. <Spin spinning={spinning}>
  74. {/* <div>共 {total} 条评论</div> */}
  75. <div>{intl.get("comment.totalComment", { total })}</div>
  76. {list.map(item => (
  77. <CommentBox content={item} key={item.id} commentId={item.id} />
  78. ))}
  79. {this.renderPagination()}
  80. </Spin>
  81. </div>
  82. );
  83. }
  84. }
  85. CommentList.propTypes = {};
  86. export default Comment(CommentList);