Sin descripción

index.js 9.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. import {
  2. a as _inherits,
  3. b as _classCallCheck,
  4. c as _possibleConstructorReturn,
  5. d as _getPrototypeOf,
  6. e as _createClass
  7. } from "../inherits-6cb67931.js";
  8. import React, { Component } from "react";
  9. import { s as styleInject } from "../style-inject.es-1f59c1d0.js";
  10. import { _ as _defineProperty } from "../defineProperty-18999f8e.js";
  11. import "../_commonjsHelpers-97e6d7b1.js";
  12. import { c as classnames } from "../index-c9837619.js";
  13. import { a as addImageProcess } from "../utils-6b513b37.js";
  14. var img =
  15. "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAABvklEQVQ4T62UTygEcRTHv29MIsqfk6OL5CYH5aKd9WfjwqxEnBzExYWTCEWJJGove5H8OTA1uwdCrOWAi83ZwUXJiSj5u+Z5s0msmd2SX81h+r33ee/7fW+G8E+H/srhqEcFCjphve1RzcaVK4j3mmoB5YxqQzdOxTji1wE2QZglb2jAEcT7/g4wr0rQugS1OYJ26nOg5nYDr4ZrR7yrl0FBAKBlqjEX3eRLwSXAmidvOJbSI47oF9LVKaCOkNc4/w7kSPOoFBqDwjpp4XA60LUkF8nzbsuERQt4ejtGdsYwiAYTYIV6STOD6UB3EpqXJC0u7zKxz0Mk3Zrj7lOLerJg5T9K+2lWhALiYx8xS9NbDZnUuPXy0wN/hYw3lnbPiNfE7HaSfTAloRqKWkya8WAnMrdmIBqfBqM/BehJAo+gKHMibdMGzUhqKUiZAHGVXJYLwPdpshPnRDRM4fl5+7uKL/0c1WXdOSie5Dh3wZcyoR7SQttO9z+M5MOWEsStFQmsTAoOwVK7qM64d5P6ayKJj9EqHBa5Q4kx2/ujqR1Exnsq493HH2muFN98oNtJ0g7s3Ul5/vwbSab+G+gDqFybE11pYkYAAAAASUVORK5CYII=";
  16. var css =
  17. ".ConsumeListView_wrapper__wlJjh {\n display: flex;\n justify-content: center;\n}\n.ConsumeListView_wrapper__wlJjh .ConsumeListView_consumelist__2dMCR {\n padding: 0;\n margin: 0;\n display: flex;\n flex-wrap: wrap;\n padding-top: 10px;\n}\n.ConsumeListView_wrapper__wlJjh .ConsumeListView_consumelist__2dMCR li {\n list-style: none;\n}\n.ConsumeListView_wrapper__wlJjh .ConsumeListView_consumelist__2dMCR .ConsumeListView_consumeItem__1QGpJ {\n margin: 0 6px 10px;\n text-align: center;\n position: relative;\n}\n.ConsumeListView_wrapper__wlJjh .ConsumeListView_consumelist__2dMCR .ConsumeListView_consumeItem__1QGpJ .ConsumeListView_kingdomIcon__1nBe5 {\n position: absolute;\n width: 24px;\n height: 22px;\n left: -6px;\n top: -12px;\n}\n.ConsumeListView_wrapper__wlJjh .ConsumeListView_consumelist__2dMCR .ConsumeListView_consumeItem__1QGpJ .ConsumeListView_avatar__1H-E5 {\n margin: 0 auto 4px;\n width: 36px;\n height: 36px;\n background-size: cover;\n border-radius: 50%;\n}\n.ConsumeListView_wrapper__wlJjh .ConsumeListView_consumelist__2dMCR .ConsumeListView_consumeItem__1QGpJ .ConsumeListView_gray__3do1I {\n color: #9b9b9b;\n font-size: 12px;\n}\n.ConsumeListView_wrapper__wlJjh .ConsumeListView_consumelist__2dMCR .ConsumeListView_toggle__3eBTC {\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__wlJjh .ConsumeListView_consumelist__2dMCR .ConsumeListView_toggle__3eBTC.ConsumeListView_expand__3l80q {\n transform: rotate(180deg);\n}\n";
  18. var styles = {
  19. wrapper: "ConsumeListView_wrapper__wlJjh",
  20. consumelist: "ConsumeListView_consumelist__2dMCR",
  21. consumeItem: "ConsumeListView_consumeItem__1QGpJ",
  22. kingdomIcon: "ConsumeListView_kingdomIcon__1nBe5",
  23. avatar: "ConsumeListView_avatar__1H-E5",
  24. gray: "ConsumeListView_gray__3do1I",
  25. toggle: "ConsumeListView_toggle__3eBTC",
  26. expand: "ConsumeListView_expand__3l80q"
  27. };
  28. styleInject(css);
  29. var DEFAULT_AVATAR =
  30. "//links-comment.oss-cn-beijing.aliyuncs.com/comment/20180820/Kgka4_oU1.jpeg";
  31. var ConsumeListView =
  32. /*#__PURE__*/
  33. (function(_Component) {
  34. _inherits(ConsumeListView, _Component);
  35. function ConsumeListView() {
  36. _classCallCheck(this, ConsumeListView);
  37. return _possibleConstructorReturn(
  38. this,
  39. _getPrototypeOf(ConsumeListView).apply(this, arguments)
  40. );
  41. }
  42. _createClass(ConsumeListView, [
  43. {
  44. key: "renderConsumeItem",
  45. value: function renderConsumeItem() {
  46. var _this$props = this.props,
  47. dataSource = _this$props.dataSource,
  48. isToggle = _this$props.isToggle,
  49. onConsumeItemClick = _this$props.onConsumeItemClick,
  50. showLength = _this$props.showLength,
  51. listLength = _this$props.listLength,
  52. options = _this$props.options;
  53. var kingdomWidth = options.kingdomWidth,
  54. kingdomHeight = options.kingdomHeight,
  55. kingdomPosition = options.kingdomPosition,
  56. avatarSize = options.avatarSize,
  57. avatarMarginLeftAndRight = options.avatarMarginLeftAndRight;
  58. var renderData = dataSource;
  59. if (!isToggle && listLength > showLength) {
  60. renderData = dataSource.slice(0, showLength - 1);
  61. }
  62. return renderData.map(function(v, i) {
  63. var kingdom = null;
  64. if (i === 0) {
  65. kingdom = React.createElement("img", {
  66. className: styles.kingdomIcon,
  67. src: img,
  68. alt: "reward top user",
  69. style: {
  70. width: "".concat(kingdomWidth, "px"),
  71. height: "".concat(kingdomHeight, "px"),
  72. left: "".concat(kingdomPosition[0], "px"),
  73. top: "".concat(kingdomPosition[1], "px")
  74. }
  75. });
  76. }
  77. return React.createElement(
  78. "li",
  79. {
  80. key: v.id,
  81. className: styles.consumeItem,
  82. style: {
  83. margin: "0 ".concat(avatarMarginLeftAndRight, "px 10px")
  84. }
  85. },
  86. kingdom,
  87. React.createElement("div", {
  88. className: styles.avatar,
  89. onClick: function onClick(e) {
  90. return onConsumeItemClick(e, v);
  91. },
  92. style: {
  93. backgroundImage: "url(".concat(
  94. addImageProcess(v.user_avatar || DEFAULT_AVATAR, {
  95. small: true
  96. }),
  97. ")"
  98. ),
  99. width: "".concat(avatarSize, "px"),
  100. height: "".concat(avatarSize, "px")
  101. }
  102. }),
  103. React.createElement("span", {
  104. className: styles.gray
  105. })
  106. );
  107. });
  108. }
  109. },
  110. {
  111. key: "renderToggleButton",
  112. value: function renderToggleButton() {
  113. var _this$props2 = this.props,
  114. isToggle = _this$props2.isToggle,
  115. onToggleChange = _this$props2.onToggleChange,
  116. listLength = _this$props2.listLength,
  117. showLength = _this$props2.showLength,
  118. options = _this$props2.options;
  119. var avatarSize = options.avatarSize,
  120. avatarMarginLeftAndRight = options.avatarMarginLeftAndRight;
  121. if (listLength <= showLength) {
  122. return null;
  123. }
  124. return React.createElement("li", {
  125. onClick: function onClick() {
  126. return onToggleChange();
  127. },
  128. className: classnames(
  129. styles.toggle,
  130. _defineProperty({}, styles.expand, isToggle)
  131. ),
  132. style: {
  133. width: "".concat(avatarSize, "px"),
  134. height: "".concat(avatarSize, "px"),
  135. lineHeight: "".concat(avatarSize, "px"),
  136. margin: "0 ".concat(avatarMarginLeftAndRight, "px 10px")
  137. }
  138. });
  139. }
  140. },
  141. {
  142. key: "render",
  143. value: function render() {
  144. var _this$props3 = this.props,
  145. showLength = _this$props3.showLength,
  146. options = _this$props3.options;
  147. var avatarSize = options.avatarSize,
  148. avatarMarginLeftAndRight = options.avatarMarginLeftAndRight;
  149. return React.createElement(
  150. "div",
  151. {
  152. className: styles.wrapper
  153. },
  154. React.createElement(
  155. "ul",
  156. {
  157. className: styles.consumelist,
  158. style: {
  159. width: "calc("
  160. .concat(avatarMarginLeftAndRight * 2 + avatarSize, "px * ")
  161. .concat(showLength, ")")
  162. }
  163. },
  164. this.renderConsumeItem(),
  165. this.renderToggleButton()
  166. )
  167. );
  168. }
  169. }
  170. ]);
  171. return ConsumeListView;
  172. })(Component);
  173. ConsumeListView.defaultProps = {
  174. isToggle: false,
  175. onToggleChange: function onToggleChange() {},
  176. onConsumeItemClick: function onConsumeItemClick() {},
  177. dataSource: [],
  178. listLength: 0,
  179. showLength: 6,
  180. options: {
  181. avatarSize: 36,
  182. avatarMarginLeftAndRight: 6,
  183. kingdomWidth: 24,
  184. kingdomHeight: 22,
  185. kingdomPosition: [-6, -12]
  186. }
  187. };
  188. export default ConsumeListView;
  189. //# sourceMappingURL=index.js.map