通用评论 vedio

index.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import React, { Component } from "react";
  2. // import PropTypes from 'prop-type';
  3. import { Icon } from "antd";
  4. import Comment from "../../Comment";
  5. import CommentInput from "../CommentInput";
  6. import "./index.css";
  7. class ReplyItem extends Component {
  8. constructor(props) {
  9. super(props);
  10. this.state = {
  11. showInput: false
  12. };
  13. this.handleToggleInput = this.handleToggleInput.bind(this);
  14. }
  15. handleToggleInput() {
  16. this.setState({ showInput: !this.state.showInput });
  17. }
  18. render() {
  19. const { commentId, replyItem, action, app } = this.props;
  20. const replyId = replyItem.id;
  21. // console.log('replyId', replyId);
  22. const { showInput } = this.state;
  23. return (
  24. <div className="reply-item">
  25. <div className="reply-item-content">
  26. @<strong>{replyItem.user_name}</strong>
  27. {replyItem.reply ? ` 回复 @${replyItem.reply.user_name}` : null}:
  28. &nbsp;
  29. {replyItem.content}
  30. </div>
  31. <div className="reply-item-icon">
  32. <span className="reply-item-span">
  33. <Icon
  34. type="heart"
  35. onClick={() => {
  36. // if (replyId) {
  37. // 如果有 replyId,则说明是评论的回复
  38. app.sReplyFavor(replyItem.id, commentId, replyItem.favored);
  39. // return;
  40. // }
  41. // app.sCommentFavor(replyItem.id, replyItem.favored);
  42. }}
  43. className={
  44. replyItem.favored
  45. ? "comment-favor comment-favored"
  46. : "comment-favor"
  47. }
  48. />
  49. &nbsp; {replyItem.favor_count}
  50. </span>
  51. <span className="reply-item-span">
  52. <Icon type="message" onClick={this.handleToggleInput} /> &nbsp;{" "}
  53. {replyItem.reply_count || 0}
  54. </span>
  55. </div>
  56. {showInput && (
  57. <CommentInput
  58. content={app.children}
  59. action={action}
  60. replyId={replyId}
  61. commentId={commentId}
  62. callback={this.handleToggleInput}
  63. />
  64. )}
  65. </div>
  66. );
  67. }
  68. }
  69. export default Comment(ReplyItem);