通用评论 vedio

index.js 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _spin = require("antd/es/spin");
  6. var _spin2 = _interopRequireDefault(_spin);
  7. var _pagination = require("antd/es/pagination");
  8. var _pagination2 = _interopRequireDefault(_pagination);
  9. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  10. require("antd/es/spin/style/css");
  11. require("antd/es/pagination/style/css");
  12. var _react = require("react");
  13. var _react2 = _interopRequireDefault(_react);
  14. var _Comment = require("../../Comment");
  15. var _Comment2 = _interopRequireDefault(_Comment);
  16. var _CommentBox = require("../CommentBox");
  17. var _CommentBox2 = _interopRequireDefault(_CommentBox);
  18. require("./index.css");
  19. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  20. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  21. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  22. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  23. var CommentList = function (_Component) {
  24. _inherits(CommentList, _Component);
  25. function CommentList(props) {
  26. _classCallCheck(this, CommentList);
  27. var _this = _possibleConstructorReturn(this, (CommentList.__proto__ || Object.getPrototypeOf(CommentList)).call(this, props));
  28. _this.state = {};
  29. return _this;
  30. }
  31. _createClass(CommentList, [{
  32. key: "componentWillMount",
  33. value: function componentWillMount() {
  34. this.props.app.sGetComment({ page: this.props.app.page });
  35. }
  36. }, {
  37. key: "renderPagination",
  38. value: function renderPagination() {
  39. var _props$app = this.props.app,
  40. list = _props$app.list,
  41. total = _props$app.total,
  42. page = _props$app.page,
  43. pageType = _props$app.pageType,
  44. limit = _props$app.limit,
  45. isNoMoreComment = _props$app.isNoMoreComment,
  46. sGetComment = _props$app.sGetComment,
  47. onPageChange = _props$app.onPageChange,
  48. onGetMoreBtnClick = _props$app.onGetMoreBtnClick;
  49. if (pageType === "slice") {
  50. // 截断多余评论,通过点击查看更多跳转
  51. return _react2.default.createElement(
  52. "div",
  53. { className: "comment-list-show-more", onClick: onGetMoreBtnClick },
  54. _react2.default.createElement(
  55. "span",
  56. null,
  57. "\u67E5\u770B\u66F4\u591A"
  58. )
  59. );
  60. } else if (pageType === "more") {
  61. if (!isNoMoreComment && list.length !== total) {
  62. return _react2.default.createElement(
  63. "div",
  64. {
  65. className: "comment-list-show-more",
  66. onClick: function onClick() {
  67. sGetComment({ page: page + 1 });
  68. onPageChange(page + 1);
  69. }
  70. },
  71. _react2.default.createElement(
  72. "span",
  73. null,
  74. "\u67E5\u770B\u66F4\u591A\u8BC4\u8BBA"
  75. )
  76. );
  77. } else {
  78. return null;
  79. }
  80. } else if (pageType === "pagination") {
  81. return _react2.default.createElement(
  82. "div",
  83. { className: "comment-list-pagination" },
  84. _react2.default.createElement(_pagination2.default, {
  85. pageSize: limit,
  86. current: page,
  87. total: total,
  88. onChange: function onChange(p) {
  89. sGetComment({ page: p });
  90. onPageChange(p);
  91. }
  92. })
  93. );
  94. }
  95. }
  96. }, {
  97. key: "render",
  98. value: function render() {
  99. var _props$app2 = this.props.app,
  100. list = _props$app2.list,
  101. total = _props$app2.total,
  102. loading = _props$app2.loading;
  103. var spinning = Boolean(loading.sGetComment || loading.sCommentFavor || loading.sReplyFavor);
  104. return _react2.default.createElement(
  105. "div",
  106. null,
  107. _react2.default.createElement(
  108. _spin2.default,
  109. { spinning: spinning },
  110. _react2.default.createElement(
  111. "div",
  112. null,
  113. "\u5171 ",
  114. total,
  115. " \u6761\u8BC4\u8BBA"
  116. ),
  117. list.map(function (item) {
  118. return _react2.default.createElement(_CommentBox2.default, { content: item, key: item.id, commentId: item.id });
  119. }),
  120. this.renderPagination()
  121. )
  122. );
  123. }
  124. }]);
  125. return CommentList;
  126. }(_react.Component);
  127. CommentList.propTypes = {};
  128. exports.default = (0, _Comment2.default)(CommentList);
  129. //# sourceMappingURL=index.js.map