通用评论 vedio

index.js 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. <span>更多评论</span>
  46. </div>
  47. );
  48. } else {
  49. return null;
  50. }
  51. } else if (pageType === "pagination") {
  52. return (
  53. <div className="comment-list-pagination">
  54. <Pagination
  55. pageSize={limit}
  56. current={page}
  57. total={total}
  58. onChange={p => {
  59. sGetComment({ page: p });
  60. onPageChange(p);
  61. }}
  62. />
  63. </div>
  64. );
  65. }
  66. }
  67. render() {
  68. const { list, total, loading } = this.props.app;
  69. const spinning = Boolean(
  70. loading.sGetComment || loading.sCommentFavor || loading.sReplyFavor
  71. );
  72. return (
  73. <div>
  74. <Spin spinning={spinning}>
  75. {/* <div>共 {total} 条评论</div> */}
  76. {/* <div>{intl.get("comment.totalComment", { total })}</div> */}
  77. {list.map(item => (
  78. <CommentBox content={item} key={item.id} commentId={item.id} />
  79. ))}
  80. {this.renderPagination()}
  81. </Spin>
  82. </div>
  83. );
  84. }
  85. }
  86. CommentList.propTypes = {};
  87. export default Comment(CommentList);