通用评论

index.js 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 _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; }; }();
  8. require('antd/es/spin/style/css');
  9. var _react = require('react');
  10. var _react2 = _interopRequireDefault(_react);
  11. var _Comment = require('../../Comment');
  12. var _Comment2 = _interopRequireDefault(_Comment);
  13. var _CommentBox = require('../CommentBox');
  14. var _CommentBox2 = _interopRequireDefault(_CommentBox);
  15. require('./index.css');
  16. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  18. 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; }
  19. 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; }
  20. var CommentList = function (_Component) {
  21. _inherits(CommentList, _Component);
  22. function CommentList(props) {
  23. _classCallCheck(this, CommentList);
  24. var _this = _possibleConstructorReturn(this, (CommentList.__proto__ || Object.getPrototypeOf(CommentList)).call(this, props));
  25. _this.state = {};
  26. return _this;
  27. }
  28. _createClass(CommentList, [{
  29. key: 'componentWillMount',
  30. value: function componentWillMount() {
  31. this.props.app.sGetComment();
  32. }
  33. }, {
  34. key: 'render',
  35. value: function render() {
  36. var _props$app = this.props.app,
  37. list = _props$app.list,
  38. total = _props$app.total,
  39. page = _props$app.page,
  40. loading = _props$app.loading,
  41. isNoMoreComment = _props$app.isNoMoreComment,
  42. sGetComment = _props$app.sGetComment;
  43. var spinning = Boolean(loading.sGetComment || loading.sCommentFavor || loading.sReplyFavor);
  44. return _react2.default.createElement(
  45. 'div',
  46. null,
  47. _react2.default.createElement(
  48. _spin2.default,
  49. { spinning: spinning },
  50. _react2.default.createElement(
  51. 'div',
  52. null,
  53. '\u5171 ',
  54. total,
  55. ' \u6761\u8BC4\u8BBA'
  56. ),
  57. list.map(function (item) {
  58. return _react2.default.createElement(_CommentBox2.default, { content: item, key: item.id, commentId: item.id });
  59. }),
  60. !isNoMoreComment && list.length !== total && _react2.default.createElement(
  61. 'div',
  62. {
  63. className: 'showMore',
  64. onClick: function onClick() {
  65. return sGetComment({ page: page + 1 });
  66. }
  67. },
  68. _react2.default.createElement(
  69. 'span',
  70. null,
  71. '\u67E5\u770B\u66F4\u591A\u8BC4\u8BBA'
  72. )
  73. )
  74. )
  75. );
  76. }
  77. }]);
  78. return CommentList;
  79. }(_react.Component);
  80. CommentList.propTypes = {};
  81. exports.default = (0, _Comment2.default)(CommentList);
  82. //# sourceMappingURL=index.js.map