설명 없음

index.js 9.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
  4. var _rollupPluginBabelHelpers = require('../_rollupPluginBabelHelpers-3469b70d.js');
  5. var React = require('react');
  6. var React__default = _interopDefault(React);
  7. require('../_commonjsHelpers-72d386ba.js');
  8. var index = require('../index-44e17595.js');
  9. var styleInject_es = require('../style-inject.es-dcee06b6.js');
  10. var utils = require('../utils-9c8fdacf.js');
  11. const img = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAABvklEQVQ4T62UTygEcRTHv29MIsqfk6OL5CYH5aKd9WfjwqxEnBzExYWTCEWJJGove5H8OTA1uwdCrOWAi83ZwUXJiSj5u+Z5s0msmd2SX81h+r33ee/7fW+G8E+H/srhqEcFCjphve1RzcaVK4j3mmoB5YxqQzdOxTji1wE2QZglb2jAEcT7/g4wr0rQugS1OYJ26nOg5nYDr4ZrR7yrl0FBAKBlqjEX3eRLwSXAmidvOJbSI47oF9LVKaCOkNc4/w7kSPOoFBqDwjpp4XA60LUkF8nzbsuERQt4ejtGdsYwiAYTYIV6STOD6UB3EpqXJC0u7zKxz0Mk3Zrj7lOLerJg5T9K+2lWhALiYx8xS9NbDZnUuPXy0wN/hYw3lnbPiNfE7HaSfTAloRqKWkya8WAnMrdmIBqfBqM/BehJAo+gKHMibdMGzUhqKUiZAHGVXJYLwPdpshPnRDRM4fl5+7uKL/0c1WXdOSie5Dh3wZcyoR7SQttO9z+M5MOWEsStFQmsTAoOwVK7qM64d5P6ayKJj9EqHBa5Q4kx2/ujqR1Exnsq493HH2muFN98oNtJ0g7s3Ul5/vwbSab+G+gDqFybE11pYkYAAAAASUVORK5CYII=';
  12. var css = ".ConsumeListView_wrapper__28k7D {\n display: flex;\n justify-content: center;\n}\n.ConsumeListView_wrapper__28k7D .ConsumeListView_consumelist__2RETd {\n padding: 0;\n margin: 0;\n display: flex;\n flex-wrap: wrap;\n padding-top: 10px;\n}\n.ConsumeListView_wrapper__28k7D .ConsumeListView_consumelist__2RETd li {\n list-style: none;\n}\n.ConsumeListView_wrapper__28k7D .ConsumeListView_consumelist__2RETd .ConsumeListView_consumeItem__bsmS9 {\n margin: 0 6px 10px;\n text-align: center;\n position: relative;\n}\n.ConsumeListView_wrapper__28k7D .ConsumeListView_consumelist__2RETd .ConsumeListView_consumeItem__bsmS9 .ConsumeListView_kingdomIcon__3tTNA {\n position: absolute;\n width: 24px;\n height: 22px;\n left: -6px;\n top: -12px;\n}\n.ConsumeListView_wrapper__28k7D .ConsumeListView_consumelist__2RETd .ConsumeListView_consumeItem__bsmS9 .ConsumeListView_avatar__1WsJ3 {\n margin: 0 auto 4px;\n width: 36px;\n height: 36px;\n background-size: cover;\n border-radius: 50%;\n}\n.ConsumeListView_wrapper__28k7D .ConsumeListView_consumelist__2RETd .ConsumeListView_consumeItem__bsmS9 .ConsumeListView_gray__oOyJP {\n color: #9b9b9b;\n font-size: 12px;\n}\n.ConsumeListView_wrapper__28k7D .ConsumeListView_consumelist__2RETd .ConsumeListView_toggle__2bNE3 {\n margin: 0 6px 10px;\n width: 36px;\n height: 36px;\n line-height: 36px;\n background-color: #ececec;\n border-radius: 50%;\n color: #a8adb6;\n cursor: pointer;\n background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAACv0lEQVRIS8WXTW8SURSGzzAYNSYCA7SCUEqBioLtohvjD9CN7ozG36AmXfsRafxYN9b+BqNx50r3GjddqEVRRgSRVr4GWmOsERjfOwEzVYa5lAokEwJzznnOe865d+4IxPFRVXVPrVY73Wq1TgmCMIffYbjZ2q4b+E/GfysWi+WZw+F4it+/zMIKvQwAszcajXnYXEIwl1kwdh8JVPC1bLVaF5FE3cjHEFytVs8hyH04jvMAu9gUkexlp9P5uJv/P2DABCi9hbJehUPPinAkpKL8d6H8BpJQ9fbbAjOooigP8H2BIyi3CaAPJUm6qIdvAwN6G0qvcUfswxDK7wB+vePyB9zu6aNdKK9ROioUn+/0XAOz6W02m6kBBolXe1EUxSibdg0MtQn09Sav9yB2UL0A1QmBbQ6VSmWNd50OAu2sc5fL5WVTfAYD9WTQgP34Y9DOClB7D05X+nHcBdslAf19jnKfNAr2cmWVDuzfR7HoFCFTUyaqR8lUhr7/2KITc/Gu9mjrC6a4iLtjRhHfvv9Ea1/L5JLsNBML94Qz6OukTBWlTt5Dbjp2JGgUtsTAW7i713DxqSql0jkqrJfIKdloNhbpCmfQV8k0VZUNOuwZo2gkQFBmFPanKVibRFxpOUefC0VyOmw0E4+QqCt7s8mgH0ipbdKEb5wiIUB7N0UD9yy13l/O5CmbXyfJfpBm49MkihbSoKuA1jdpcsJD4aDfdA5gUDIdrr+jZLIFyuQK5AD8+NEQvXknU63+jUKTPgoGvDxQ1gJtuPpeTkw1U8+mnPU2MuWngN/DBW0bLe14A8mj3x+zX7TS+ryGi6JrMtoGMrItk6VULpcTqPtQHhIQuuB2uxOjfSwy1SM5CHQmYCRHn/azcjSHvQ586Mdb/aIb+oFeD2eHQOxM87j6eoXBBrGMa2evMPoE/sdL22+mI4T0ou1LqAAAAABJRU5ErkJggg==);\n background-position: center;\n}\n.ConsumeListView_wrapper__28k7D .ConsumeListView_consumelist__2RETd .ConsumeListView_toggle__2bNE3.ConsumeListView_expand__26ifU {\n transform: rotate(180deg);\n}\n";
  13. var styles = {"wrapper":"ConsumeListView_wrapper__28k7D","consumelist":"ConsumeListView_consumelist__2RETd","consumeItem":"ConsumeListView_consumeItem__bsmS9","kingdomIcon":"ConsumeListView_kingdomIcon__3tTNA","avatar":"ConsumeListView_avatar__1WsJ3","gray":"ConsumeListView_gray__oOyJP","toggle":"ConsumeListView_toggle__2bNE3","expand":"ConsumeListView_expand__26ifU"};
  14. styleInject_es.styleInject(css);
  15. var DEFAULT_AVATAR = '//links-comment.oss-cn-beijing.aliyuncs.com/comment/20180820/Kgka4_oU1.jpeg';
  16. var ConsumeListView =
  17. /*#__PURE__*/
  18. function (_Component) {
  19. _rollupPluginBabelHelpers._inherits(ConsumeListView, _Component);
  20. function ConsumeListView() {
  21. _rollupPluginBabelHelpers._classCallCheck(this, ConsumeListView);
  22. return _rollupPluginBabelHelpers._possibleConstructorReturn(this, _rollupPluginBabelHelpers._getPrototypeOf(ConsumeListView).apply(this, arguments));
  23. }
  24. _rollupPluginBabelHelpers._createClass(ConsumeListView, [{
  25. key: "renderConsumeItem",
  26. value: function renderConsumeItem() {
  27. var _this$props = this.props,
  28. dataSource = _this$props.dataSource,
  29. isToggle = _this$props.isToggle,
  30. onConsumeItemClick = _this$props.onConsumeItemClick,
  31. showLength = _this$props.showLength,
  32. listLength = _this$props.listLength,
  33. options = _this$props.options;
  34. var kingdomWidth = options.kingdomWidth,
  35. kingdomHeight = options.kingdomHeight,
  36. kingdomPosition = options.kingdomPosition,
  37. avatarSize = options.avatarSize,
  38. avatarMarginLeftAndRight = options.avatarMarginLeftAndRight;
  39. var renderData = dataSource;
  40. if (!isToggle && listLength > showLength) {
  41. renderData = dataSource.slice(0, showLength - 1);
  42. }
  43. return renderData.map(function (v, i) {
  44. var kingdom = null;
  45. if (i === 0) {
  46. kingdom = React__default.createElement("img", {
  47. className: styles.kingdomIcon,
  48. src: img,
  49. alt: "reward top user",
  50. style: {
  51. width: "".concat(kingdomWidth, "px"),
  52. height: "".concat(kingdomHeight, "px"),
  53. left: "".concat(kingdomPosition[0], "px"),
  54. top: "".concat(kingdomPosition[1], "px")
  55. }
  56. });
  57. }
  58. return React__default.createElement("li", {
  59. key: v.id,
  60. className: styles.consumeItem,
  61. style: {
  62. margin: "0 ".concat(avatarMarginLeftAndRight, "px 10px")
  63. }
  64. }, kingdom, React__default.createElement("div", {
  65. className: styles.avatar,
  66. onClick: function onClick(e) {
  67. return onConsumeItemClick(e, v);
  68. },
  69. style: {
  70. backgroundImage: "url(".concat(utils.addImageProcess(v.user_avatar || DEFAULT_AVATAR, {
  71. small: true
  72. }), ")"),
  73. width: "".concat(avatarSize, "px"),
  74. height: "".concat(avatarSize, "px")
  75. }
  76. }), React__default.createElement("span", {
  77. className: styles.gray
  78. }));
  79. });
  80. }
  81. }, {
  82. key: "renderToggleButton",
  83. value: function renderToggleButton() {
  84. var _this$props2 = this.props,
  85. isToggle = _this$props2.isToggle,
  86. onToggleChange = _this$props2.onToggleChange,
  87. listLength = _this$props2.listLength,
  88. showLength = _this$props2.showLength,
  89. options = _this$props2.options;
  90. var avatarSize = options.avatarSize,
  91. avatarMarginLeftAndRight = options.avatarMarginLeftAndRight;
  92. if (listLength <= showLength) {
  93. return null;
  94. }
  95. return React__default.createElement("li", {
  96. onClick: function onClick() {
  97. return onToggleChange();
  98. },
  99. className: index.classnames(styles.toggle, _rollupPluginBabelHelpers._defineProperty({}, styles.expand, isToggle)),
  100. style: {
  101. width: "".concat(avatarSize, "px"),
  102. height: "".concat(avatarSize, "px"),
  103. lineHeight: "".concat(avatarSize, "px"),
  104. margin: "0 ".concat(avatarMarginLeftAndRight, "px 10px")
  105. }
  106. });
  107. }
  108. }, {
  109. key: "render",
  110. value: function render() {
  111. var _this$props3 = this.props,
  112. showLength = _this$props3.showLength,
  113. options = _this$props3.options;
  114. var avatarSize = options.avatarSize,
  115. avatarMarginLeftAndRight = options.avatarMarginLeftAndRight;
  116. return React__default.createElement("div", {
  117. className: styles.wrapper
  118. }, React__default.createElement("ul", {
  119. className: styles.consumelist,
  120. style: {
  121. width: "calc(".concat(avatarMarginLeftAndRight * 2 + avatarSize, "px * ").concat(showLength, ")")
  122. }
  123. }, this.renderConsumeItem(), this.renderToggleButton()));
  124. }
  125. }]);
  126. return ConsumeListView;
  127. }(React.Component);
  128. _rollupPluginBabelHelpers._defineProperty(ConsumeListView, "defaultProps", {
  129. isToggle: false,
  130. onToggleChange: function onToggleChange() {},
  131. onConsumeItemClick: function onConsumeItemClick() {},
  132. dataSource: [],
  133. listLength: 0,
  134. showLength: 6,
  135. options: {
  136. avatarSize: 36,
  137. avatarMarginLeftAndRight: 6,
  138. kingdomWidth: 24,
  139. kingdomHeight: 22,
  140. kingdomPosition: [-6, -12]
  141. }
  142. });
  143. exports.default = ConsumeListView;
  144. //# sourceMappingURL=index.js.map