|
@@ -1,7 +1,7 @@
|
1
|
1
|
import React, { Component } from "react";
|
2
|
2
|
import PropTypes from "prop-types";
|
3
|
|
-import { Icon } from "antd";
|
4
|
|
-import intl from "react-intl-universal";
|
|
3
|
+import { Icon, AutoComplete } from "antd";
|
|
4
|
+// import intl from "react-intl-universal";
|
5
|
5
|
import Comment from "../../Comment";
|
6
|
6
|
import ContentItem from "./../ContentItem";
|
7
|
7
|
import ReplyItem from "./../ReplyItem";
|
|
@@ -12,14 +12,12 @@ class CommentBox extends Component {
|
12
|
12
|
super(props);
|
13
|
13
|
this.state = {
|
14
|
14
|
showReply: true,
|
15
|
|
- page: 1,
|
16
|
|
- isShowOver3: false
|
|
15
|
+ page: 1
|
17
|
16
|
};
|
18
|
17
|
|
19
|
18
|
this.handleToggleReply = this.handleToggleReply.bind(this);
|
20
|
19
|
this.handleGetMoreReply = this.handleGetMoreReply.bind(this);
|
21
|
20
|
this.renderReplies = this.renderReplies.bind(this);
|
22
|
|
- this.handleClickCollapse = this.handleClickCollapse.bind(this);
|
23
|
21
|
}
|
24
|
22
|
|
25
|
23
|
/**
|
|
@@ -29,14 +27,6 @@ class CommentBox extends Component {
|
29
|
27
|
this.setState({ showReply: !this.state.showReply });
|
30
|
28
|
}
|
31
|
29
|
|
32
|
|
- /**
|
33
|
|
- * 点击收起按钮的时候只展示最多三条留言
|
34
|
|
- */
|
35
|
|
- handleClickCollapse() {
|
36
|
|
- this.setState({ isShowOver3: !this.state.isShowOver3 });
|
37
|
|
- console.log("this.isMore", this.state.isShowOver3);
|
38
|
|
- }
|
39
|
|
-
|
40
|
30
|
/**
|
41
|
31
|
* 获取更多评论
|
42
|
32
|
* @param {string} commentId comment id
|
|
@@ -116,14 +106,9 @@ class CommentBox extends Component {
|
116
|
106
|
* @param {boolean} isNoMoreReply 是否没有更多回复
|
117
|
107
|
*/
|
118
|
108
|
renderReplies(replies, replyCount, isNoMoreReply) {
|
119
|
|
- console.log("this.isMore3", this.state.isShowOver3);
|
120
|
109
|
const { commentId } = this.props;
|
121
|
110
|
const { showReply } = this.state;
|
122
|
|
- console.log("replies", replies);
|
123
|
|
- console.log("replyCount", replyCount);
|
124
|
|
- console.log("isNoMoreReply", isNoMoreReply);
|
125
|
111
|
if (showReply && replies && replies.length) {
|
126
|
|
- console.log("showReply", showReply);
|
127
|
112
|
const len = replies.length;
|
128
|
113
|
return (
|
129
|
114
|
<div
|
|
@@ -131,52 +116,46 @@ class CommentBox extends Component {
|
131
|
116
|
marginLeft: 50,
|
132
|
117
|
borderTop: "1px solid #e3e3e3",
|
133
|
118
|
paddingTop: 15,
|
134
|
|
- marginTop: -5
|
|
119
|
+ marginTop: 10,
|
|
120
|
+ overflow: "auto"
|
135
|
121
|
}}
|
136
|
122
|
>
|
137
|
123
|
{replies.map((item, index) => {
|
138
|
124
|
if (index === len - 1) {
|
139
|
125
|
return [
|
140
|
|
- <ReplyItem replyItem={item} key={item.id} />,
|
|
126
|
+ <ReplyItem
|
|
127
|
+ replyItem={item}
|
|
128
|
+ key={item.id}
|
|
129
|
+ commentId={commentId}
|
|
130
|
+ action="replyToReply"
|
|
131
|
+ />,
|
141
|
132
|
<div key="show_more_button">
|
142
|
133
|
{!isNoMoreReply && replyCount !== len && (
|
143
|
134
|
<span
|
144
|
|
- // className="comment-show-more"
|
|
135
|
+ className="comment-show-more"
|
145
|
136
|
onClick={() => this.handleGetMoreReply(commentId)}
|
146
|
137
|
>
|
147
|
138
|
展开更多评论
|
148
|
139
|
<Icon type="down" />
|
149
|
140
|
</span>
|
150
|
141
|
)}
|
151
|
|
- {replyCount === len && (
|
152
|
|
- <span
|
153
|
|
- // className="comment-show-more"
|
154
|
|
- onClick={() => this.handleClickCollapse()}
|
155
|
|
- >
|
156
|
|
- 收起
|
157
|
|
- <Icon type="up" />
|
158
|
|
- </span>
|
159
|
|
- )}
|
160
|
|
-
|
161
|
|
- {/* <a
|
|
142
|
+ <a
|
162
|
143
|
style={{ float: "right" }}
|
163
|
144
|
onClick={this.handleToggleReply}
|
164
|
145
|
>
|
165
|
|
- <Icon type="up" /> {intl.get("reply.collapse")}
|
166
|
|
- </a> */}
|
|
146
|
+ <Icon type="up" /> 收起
|
|
147
|
+ </a>
|
167
|
148
|
</div>
|
168
|
149
|
];
|
169
|
150
|
}
|
170
|
|
- if (this.state.isShowOver3) {
|
171
|
|
- console.log("11111");
|
172
|
|
- return <ReplyItem replyItem={item} key={item.id} />;
|
173
|
|
- }
|
174
|
|
- if (!this.state.isShowOver3 && index < 3) {
|
175
|
|
- console.log("222222");
|
176
|
|
- return <ReplyItem replyItem={item} key={item.id} />;
|
177
|
|
- }
|
178
|
|
- console.log("3333");
|
179
|
|
- return null;
|
|
151
|
+ return (
|
|
152
|
+ <ReplyItem
|
|
153
|
+ replyItem={item}
|
|
154
|
+ key={item.id}
|
|
155
|
+ commentId={commentId}
|
|
156
|
+ action="replyToReply"
|
|
157
|
+ />
|
|
158
|
+ );
|
180
|
159
|
})}
|
181
|
160
|
</div>
|
182
|
161
|
);
|