通用评论

AvatarHoverCard.js 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. import React, { Component } from "react";
  2. import { Row, Col } from "antd";
  3. import intl from "react-intl-universal";
  4. import "./AvatarHoverCard.less";
  5. class AvatarHoverCard extends Component {
  6. constructor(props) {
  7. super(props);
  8. this.state = {
  9. showModal: false
  10. };
  11. }
  12. componentDidMount() {
  13. const isLogin =
  14. this.props.currentUser.user_id > 0 || this.props.currentUser.id > 0;
  15. this.props.getUserInfo({
  16. id: this.props.user_id,
  17. noCheckFollowed: !isLogin
  18. });
  19. }
  20. render() {
  21. const { image, user_id, currentUser, userAvaHoverData } = this.props;
  22. const followed =
  23. userAvaHoverData[user_id] && userAvaHoverData[user_id].isFollowed;
  24. return (
  25. <div className="AvatarHoverCard" onClick={e => e.stopPropagation()}>
  26. {/* <Link to={`/bilingual/user/${user_id}`}> */}
  27. <div onClick={() => this.props.userAvaClick(user_id)}>
  28. <Row type="flex" className="rowUser">
  29. <div
  30. className="avatar"
  31. style={{
  32. backgroundImage: `url(${image})`
  33. }}
  34. />
  35. <div className="nickname">
  36. {userAvaHoverData[user_id] && userAvaHoverData[user_id].nickname}
  37. </div>
  38. </Row>
  39. </div>
  40. {/* </Link> */}
  41. <div className="divider" />
  42. <Row type="flex" className="rowNum">
  43. <Col className="colFans">
  44. <div className="count">
  45. {userAvaHoverData[user_id] && userAvaHoverData[user_id].fans}
  46. </div>
  47. <div className="text">
  48. {intl.get("bilingually.fan", {
  49. ext:
  50. userAvaHoverData[user_id] &&
  51. userAvaHoverData[user_id].fans > 1
  52. ? "s"
  53. : ""
  54. })}
  55. </div>
  56. </Col>
  57. <Col className="hdivider" />
  58. <Col className="colFollow">
  59. <div className="count">
  60. {userAvaHoverData[user_id] && userAvaHoverData[user_id].followers}
  61. </div>
  62. <div className="text">
  63. {intl.get("bilingually.follow", {
  64. ext:
  65. userAvaHoverData[user_id] &&
  66. userAvaHoverData[user_id].followers > 1
  67. ? "s"
  68. : ""
  69. })}
  70. </div>
  71. </Col>
  72. </Row>
  73. {currentUser.user_id > 0 && currentUser.user_id !== user_id && (
  74. <Row type="flex" className="rowBtn">
  75. {followed ? (
  76. <div
  77. className="unFollowBtn"
  78. onClick={e => {
  79. e.stopPropagation();
  80. this.props
  81. .unFocus({
  82. id: user_id
  83. })
  84. .then(() => {
  85. this.props.getUserInfo({
  86. id: user_id
  87. });
  88. });
  89. }}
  90. >
  91. {intl.get("bilingually.cancel_follow")}
  92. </div>
  93. ) : (
  94. <div
  95. className="followBtn"
  96. onClick={e => {
  97. e.stopPropagation();
  98. this.props.focus({ id: user_id }).then(() => {
  99. this.props.getUserInfo({
  100. id: user_id
  101. });
  102. });
  103. }}
  104. >
  105. {intl.get("bilingually.follow", { ext: "" })}
  106. </div>
  107. )}
  108. {/* 发私信按钮,暂时隐藏 */}
  109. <div
  110. className={`privateMessageBtn ${
  111. this.props.locale === "en-US" ? "enUs" : ""
  112. }`}
  113. onClick={() => this.props.sendMessage({ id: user_id })}
  114. >
  115. {intl.get("bilingually.im.send_msg")}
  116. </div>
  117. </Row>
  118. )}
  119. </div>
  120. );
  121. }
  122. }
  123. export default AvatarHoverCard;