通用评论

AvatarHoverCard.js 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _col = require("antd/es/col");
  6. var _col2 = _interopRequireDefault(_col);
  7. var _row = require("antd/es/row");
  8. var _row2 = _interopRequireDefault(_row);
  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/col/style/css");
  11. require("antd/es/row/style/css");
  12. var _react = require("react");
  13. var _react2 = _interopRequireDefault(_react);
  14. var _reactIntlUniversal = require("react-intl-universal");
  15. var _reactIntlUniversal2 = _interopRequireDefault(_reactIntlUniversal);
  16. require("./AvatarHoverCard.less");
  17. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  18. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  19. 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; }
  20. 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; }
  21. var AvatarHoverCard = function (_Component) {
  22. _inherits(AvatarHoverCard, _Component);
  23. function AvatarHoverCard(props) {
  24. _classCallCheck(this, AvatarHoverCard);
  25. var _this = _possibleConstructorReturn(this, (AvatarHoverCard.__proto__ || Object.getPrototypeOf(AvatarHoverCard)).call(this, props));
  26. _this.state = {
  27. showModal: false
  28. };
  29. return _this;
  30. }
  31. _createClass(AvatarHoverCard, [{
  32. key: "componentDidMount",
  33. value: function componentDidMount() {
  34. var isLogin = this.props.currentUser.user_id > 0;
  35. this.props.getUserInfo({
  36. id: this.props.user_id,
  37. noCheckFollowed: !isLogin
  38. });
  39. }
  40. }, {
  41. key: "render",
  42. value: function render() {
  43. var _this2 = this;
  44. var _props = this.props,
  45. image = _props.image,
  46. user_id = _props.user_id,
  47. currentUser = _props.currentUser,
  48. userAvaHoverData = _props.userAvaHoverData;
  49. var followed = userAvaHoverData[user_id] && userAvaHoverData[user_id].isFollowed;
  50. return _react2.default.createElement(
  51. "div",
  52. { className: "AvatarHoverCard", onClick: function onClick(e) {
  53. return e.stopPropagation();
  54. } },
  55. _react2.default.createElement(
  56. "div",
  57. { onClick: function onClick() {
  58. return _this2.props.userAvaClick(user_id);
  59. } },
  60. _react2.default.createElement(
  61. _row2.default,
  62. { type: "flex", className: "rowUser" },
  63. _react2.default.createElement("div", {
  64. className: "avatar",
  65. style: {
  66. backgroundImage: "url(" + image + ")"
  67. }
  68. }),
  69. _react2.default.createElement(
  70. "div",
  71. { className: "nickname" },
  72. userAvaHoverData[user_id] && userAvaHoverData[user_id].nickname
  73. )
  74. )
  75. ),
  76. _react2.default.createElement("div", { className: "divider" }),
  77. _react2.default.createElement(
  78. _row2.default,
  79. { type: "flex", className: "rowNum" },
  80. _react2.default.createElement(
  81. _col2.default,
  82. { className: "colFans" },
  83. _react2.default.createElement(
  84. "div",
  85. { className: "count" },
  86. userAvaHoverData[user_id] && userAvaHoverData[user_id].fans
  87. ),
  88. _react2.default.createElement(
  89. "div",
  90. { className: "text" },
  91. _reactIntlUniversal2.default.get("bilingually.fan", {
  92. ext: userAvaHoverData[user_id] && userAvaHoverData[user_id].fans > 1 ? "s" : ""
  93. })
  94. )
  95. ),
  96. _react2.default.createElement(_col2.default, { className: "hdivider" }),
  97. _react2.default.createElement(
  98. _col2.default,
  99. { className: "colFollow" },
  100. _react2.default.createElement(
  101. "div",
  102. { className: "count" },
  103. userAvaHoverData[user_id] && userAvaHoverData[user_id].followers
  104. ),
  105. _react2.default.createElement(
  106. "div",
  107. { className: "text" },
  108. _reactIntlUniversal2.default.get("bilingually.follow", {
  109. ext: userAvaHoverData[user_id] && userAvaHoverData[user_id].followers > 1 ? "s" : ""
  110. })
  111. )
  112. )
  113. ),
  114. currentUser.user_id > 0 && currentUser.user_id !== user_id && _react2.default.createElement(
  115. _row2.default,
  116. { type: "flex", className: "rowBtn" },
  117. followed ? _react2.default.createElement(
  118. "div",
  119. {
  120. className: "unFollowBtn",
  121. onClick: function onClick(e) {
  122. e.stopPropagation();
  123. _this2.props.unFocus({
  124. id: user_id
  125. }).then(function () {
  126. _this2.props.getUserInfo({
  127. id: user_id
  128. });
  129. });
  130. }
  131. },
  132. _reactIntlUniversal2.default.get("bilingually.cancel_follow")
  133. ) : _react2.default.createElement(
  134. "div",
  135. {
  136. className: "followBtn",
  137. onClick: function onClick(e) {
  138. e.stopPropagation();
  139. _this2.props.focus({ id: user_id }).then(function () {
  140. _this2.props.getUserInfo({
  141. id: user_id
  142. });
  143. });
  144. }
  145. },
  146. _reactIntlUniversal2.default.get("bilingually.follow", { ext: "" })
  147. ),
  148. _react2.default.createElement(
  149. "div",
  150. {
  151. className: "privateMessageBtn " + (this.props.locale === "en-US" ? "enUs" : ""),
  152. onClick: function onClick() {
  153. return _this2.props.sendMessage({ id: user_id });
  154. }
  155. },
  156. _reactIntlUniversal2.default.get("bilingually.im.send_msg")
  157. )
  158. )
  159. );
  160. }
  161. }]);
  162. return AvatarHoverCard;
  163. }(_react.Component);
  164. exports.default = AvatarHoverCard;
  165. //# sourceMappingURL=AvatarHoverCard.js.map