通用评论 vedio

index.js 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. // import intl from "react-intl-universal";
  24. var CommentList = function (_Component) {
  25. _inherits(CommentList, _Component);
  26. function CommentList(props) {
  27. _classCallCheck(this, CommentList);
  28. var _this = _possibleConstructorReturn(this, (CommentList.__proto__ || Object.getPrototypeOf(CommentList)).call(this, props));
  29. _this.state = {};
  30. return _this;
  31. }
  32. _createClass(CommentList, [{
  33. key: "componentWillMount",
  34. value: function componentWillMount() {
  35. this.props.app.sGetComment({ page: this.props.app.page });
  36. }
  37. }, {
  38. key: "renderPagination",
  39. value: function renderPagination() {
  40. var _props$app = this.props.app,
  41. list = _props$app.list,
  42. total = _props$app.total,
  43. page = _props$app.page,
  44. pageType = _props$app.pageType,
  45. limit = _props$app.limit,
  46. isNoMoreComment = _props$app.isNoMoreComment,
  47. sGetComment = _props$app.sGetComment,
  48. onPageChange = _props$app.onPageChange,
  49. onGetMoreBtnClick = _props$app.onGetMoreBtnClick;
  50. if (pageType === "slice") {
  51. // 截断多余评论,通过点击查看更多跳转
  52. return _react2.default.createElement(
  53. "div",
  54. { className: "comment-list-show-more", onClick: onGetMoreBtnClick },
  55. _react2.default.createElement(
  56. "span",
  57. null,
  58. "\u67E5\u770B\u66F4\u591A"
  59. )
  60. );
  61. } else if (pageType === "more") {
  62. if (!isNoMoreComment && list.length !== total) {
  63. return _react2.default.createElement(
  64. "div",
  65. {
  66. className: "comment-list-show-more",
  67. onClick: function onClick() {
  68. sGetComment({ page: page + 1 });
  69. onPageChange(page + 1);
  70. }
  71. },
  72. _react2.default.createElement(
  73. "span",
  74. null,
  75. "\u66F4\u591A\u8BC4\u8BBA"
  76. )
  77. );
  78. } else {
  79. return null;
  80. }
  81. } else if (pageType === "pagination") {
  82. return _react2.default.createElement(
  83. "div",
  84. { className: "comment-list-pagination" },
  85. _react2.default.createElement(_pagination2.default, {
  86. pageSize: limit,
  87. current: page,
  88. total: total,
  89. onChange: function onChange(p) {
  90. sGetComment({ page: p });
  91. onPageChange(p);
  92. }
  93. })
  94. );
  95. }
  96. }
  97. }, {
  98. key: "render",
  99. value: function render() {
  100. var _props$app2 = this.props.app,
  101. list = _props$app2.list,
  102. total = _props$app2.total,
  103. loading = _props$app2.loading;
  104. var spinning = Boolean(loading.sGetComment || loading.sCommentFavor || loading.sReplyFavor);
  105. return _react2.default.createElement(
  106. "div",
  107. null,
  108. _react2.default.createElement(
  109. _spin2.default,
  110. { spinning: spinning },
  111. list.map(function (item) {
  112. return _react2.default.createElement(_CommentBox2.default, { content: item, key: item.id, commentId: item.id });
  113. }),
  114. this.renderPagination()
  115. )
  116. );
  117. }
  118. }]);
  119. return CommentList;
  120. }(_react.Component);
  121. CommentList.propTypes = {};
  122. exports.default = (0, _Comment2.default)(CommentList);
  123. //# sourceMappingURL=index.js.map