| 
				
			 | 
			
			
				@@ -33,6 +33,7 @@ class App extends Component { 
			 | 
		
	
		
			
			| 
				33
			 | 
			
				33
			 | 
			
			
				     this.sCreateComment = this.sCreateComment.bind(this); 
			 | 
		
	
		
			
			| 
				34
			 | 
			
				34
			 | 
			
			
				     this.sCreateReply = this.sCreateReply.bind(this); 
			 | 
		
	
		
			
			| 
				35
			 | 
			
				35
			 | 
			
			
				     this.sCommentFavor = this.sCommentFavor.bind(this); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				36
			 | 
			
			
				+    this.sReplyFavor = this.sReplyFavor.bind(this); 
			 | 
		
	
		
			
			| 
				36
			 | 
			
				37
			 | 
			
			
				     this.sOssSts = this.sOssSts.bind(this); 
			 | 
		
	
		
			
			| 
				37
			 | 
			
				38
			 | 
			
			
				   } 
			 | 
		
	
		
			
			| 
				38
			 | 
			
				39
			 | 
			
			
				  
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -102,28 +103,34 @@ class App extends Component { 
			 | 
		
	
		
			
			| 
				102
			 | 
			
				103
			 | 
			
			
				     axios 
			 | 
		
	
		
			
			| 
				103
			 | 
			
				104
			 | 
			
			
				       .get(`${API}/replies?comment_id=${commentId}&page=${page}&limit=${LIMIT}`) 
			 | 
		
	
		
			
			| 
				104
			 | 
			
				105
			 | 
			
			
				       .then(response => { 
			 | 
		
	
		
			
			| 
				105
			 | 
			
				
			 | 
			
			
				-        const { list: replies } = response.data; 
			 | 
		
	
		
			
			| 
				106
			 | 
			
				
			 | 
			
			
				-        if (!replies) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				106
			 | 
			
			
				+        // const { list: replies, total, page } = response.data; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				107
			 | 
			
			
				+        if (!response.data.list) { 
			 | 
		
	
		
			
			| 
				107
			 | 
			
				108
			 | 
			
			
				           message.info("没有更多数据了!"); 
			 | 
		
	
		
			
			| 
				108
			 | 
			
				109
			 | 
			
			
				         } 
			 | 
		
	
		
			
			| 
				109
			 | 
			
				110
			 | 
			
			
				         const list = this.state.list.map(item => { 
			 | 
		
	
		
			
			| 
				110
			 | 
			
				111
			 | 
			
			
				           if (item.id === commentId) { 
			 | 
		
	
		
			
			| 
				111
			 | 
			
				112
			 | 
			
			
				             if (!item.replies) item.replies = []; 
			 | 
		
	
		
			
			| 
				112
			 | 
			
				
			 | 
			
			
				-            if (replies) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				113
			 | 
			
			
				+            if (response.data.list) { 
			 | 
		
	
		
			
			| 
				113
			 | 
			
				114
			 | 
			
			
				               if (page === 1) { 
			 | 
		
	
		
			
			| 
				114
			 | 
			
				115
			 | 
			
			
				                 // 如果当前页数为第一页,则清空当前所有的 replies 
			 | 
		
	
		
			
			| 
				115
			 | 
			
				116
			 | 
			
			
				                 // 并将获取到的 replies 存放在 state 
			 | 
		
	
		
			
			| 
				116
			 | 
			
				
			 | 
			
			
				-                item.replies = replies; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				117
			 | 
			
			
				+                item.replies = response.data.list; 
			 | 
		
	
		
			
			| 
				117
			 | 
			
				118
			 | 
			
			
				               } else { 
			 | 
		
	
		
			
			| 
				118
			 | 
			
				
			 | 
			
			
				-                item.replies = item.replies.concat(replies); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				119
			 | 
			
			
				+                item.replies = item.replies 
			 | 
		
	
		
			
			| 
				
			 | 
			
				120
			 | 
			
			
				+                  .filter(o => !o.isTemporary) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				121
			 | 
			
			
				+                  .concat(response.data.list); 
			 | 
		
	
		
			
			| 
				119
			 | 
			
				122
			 | 
			
			
				                 // 如果当前页数非第一页,则合并 replies 
			 | 
		
	
		
			
			| 
				120
			 | 
			
				123
			 | 
			
			
				               } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				124
			 | 
			
			
				+              item.reply_count = response.data.total; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				125
			 | 
			
			
				+              item.reply_page = response.data.page; 
			 | 
		
	
		
			
			| 
				121
			 | 
			
				126
			 | 
			
			
				             } else { 
			 | 
		
	
		
			
			| 
				122
			 | 
			
				127
			 | 
			
			
				               item.isNoMoreReply = true; 
			 | 
		
	
		
			
			| 
				123
			 | 
			
				128
			 | 
			
			
				             } 
			 | 
		
	
		
			
			| 
				124
			 | 
			
				129
			 | 
			
			
				           } 
			 | 
		
	
		
			
			| 
				125
			 | 
			
				130
			 | 
			
			
				           return item; 
			 | 
		
	
		
			
			| 
				126
			 | 
			
				131
			 | 
			
			
				         }); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				132
			 | 
			
			
				+        console.log("list: ", list); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				133
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				127
			 | 
			
				134
			 | 
			
			
				         this.setState({ list }); 
			 | 
		
	
		
			
			| 
				128
			 | 
			
				135
			 | 
			
			
				       }) 
			 | 
		
	
		
			
			| 
				129
			 | 
			
				136
			 | 
			
			
				       .catch(error => { 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -185,6 +192,8 @@ class App extends Component { 
			 | 
		
	
		
			
			| 
				185
			 | 
			
				192
			 | 
			
			
				    * @param {object} data { comment_id, content, [reply_id] } 
			 | 
		
	
		
			
			| 
				186
			 | 
			
				193
			 | 
			
			
				    */ 
			 | 
		
	
		
			
			| 
				187
			 | 
			
				194
			 | 
			
			
				   sCreateReply(data, cb) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				195
			 | 
			
			
				+    console.log("list: ", this.state.list); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				196
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				188
			 | 
			
				197
			 | 
			
			
				     if (!data.content) return message.error("回复内容不能为空 "); 
			 | 
		
	
		
			
			| 
				189
			 | 
			
				198
			 | 
			
			
				     this.handleChangeLoading("sCreateReply", true); 
			 | 
		
	
		
			
			| 
				190
			 | 
			
				199
			 | 
			
			
				     const { API } = this.props; 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -194,19 +203,23 @@ class App extends Component { 
			 | 
		
	
		
			
			| 
				194
			 | 
			
				203
			 | 
			
			
				       withCredentials: true 
			 | 
		
	
		
			
			| 
				195
			 | 
			
				204
			 | 
			
			
				     }) 
			 | 
		
	
		
			
			| 
				196
			 | 
			
				205
			 | 
			
			
				       .then(response => { 
			 | 
		
	
		
			
			| 
				197
			 | 
			
				
			 | 
			
			
				-        // // 将该条数据插入到 list 中 
			 | 
		
	
		
			
			| 
				198
			 | 
			
				
			 | 
			
			
				-        // const list = this.state.list.map(item => { 
			 | 
		
	
		
			
			| 
				199
			 | 
			
				
			 | 
			
			
				-        //   if (item.id === data.comment_id) { 
			 | 
		
	
		
			
			| 
				200
			 | 
			
				
			 | 
			
			
				-        //     if (!item.replies) item.replies = []; 
			 | 
		
	
		
			
			| 
				201
			 | 
			
				
			 | 
			
			
				-        //     item.reply_count += 1 
			 | 
		
	
		
			
			| 
				202
			 | 
			
				
			 | 
			
			
				-        //     item.replies.unshift(response.data); 
			 | 
		
	
		
			
			| 
				203
			 | 
			
				
			 | 
			
			
				-        //   } 
			 | 
		
	
		
			
			| 
				204
			 | 
			
				
			 | 
			
			
				-        //   return item; 
			 | 
		
	
		
			
			| 
				205
			 | 
			
				
			 | 
			
			
				-        // }); 
			 | 
		
	
		
			
			| 
				206
			 | 
			
				
			 | 
			
			
				-        // this.setState({ list }); 
			 | 
		
	
		
			
			| 
				207
			 | 
			
				
			 | 
			
			
				-        this.sGetReply({ commentId: data.comment_id }); 
			 | 
		
	
		
			
			| 
				208
			 | 
			
				206
			 | 
			
			
				         message.success("回复成功!"); 
			 | 
		
	
		
			
			| 
				209
			 | 
			
				207
			 | 
			
			
				         if (isFunction(cb)) cb(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				208
			 | 
			
			
				+        // 将数据写入到 list 中 
			 | 
		
	
		
			
			| 
				
			 | 
			
				209
			 | 
			
			
				+        // 临时插入 
			 | 
		
	
		
			
			| 
				
			 | 
			
				210
			 | 
			
			
				+        // 等到获取数据之后,删除临时数据 
			 | 
		
	
		
			
			| 
				
			 | 
			
				211
			 | 
			
			
				+        const list = this.state.list.map(item => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				212
			 | 
			
			
				+          if (item.id === data.comment_id) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				213
			 | 
			
			
				+            if (!item.replies) item.replies = []; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				214
			 | 
			
			
				+            item.replies.push({ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				215
			 | 
			
			
				+              ...response.data, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				216
			 | 
			
			
				+              isTemporary: true // 临时的数据 
			 | 
		
	
		
			
			| 
				
			 | 
			
				217
			 | 
			
			
				+            }); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				218
			 | 
			
			
				+            item.reply_count += 1; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				219
			 | 
			
			
				+          } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				220
			 | 
			
			
				+          return item; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				221
			 | 
			
			
				+        }); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				222
			 | 
			
			
				+        this.setState({ list }); 
			 | 
		
	
		
			
			| 
				210
			 | 
			
				223
			 | 
			
			
				       }) 
			 | 
		
	
		
			
			| 
				211
			 | 
			
				224
			 | 
			
			
				       .catch(error => { 
			 | 
		
	
		
			
			| 
				212
			 | 
			
				225
			 | 
			
			
				         if (error.response && error.response.data && error.response.data.msg) { 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -221,7 +234,7 @@ class App extends Component { 
			 | 
		
	
		
			
			| 
				221
			 | 
			
				234
			 | 
			
			
				   } 
			 | 
		
	
		
			
			| 
				222
			 | 
			
				235
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				223
			 | 
			
				236
			 | 
			
			
				   /** 
			 | 
		
	
		
			
			| 
				224
			 | 
			
				
			 | 
			
			
				-   * 点赞/取消点赞 
			 | 
		
	
		
			
			| 
				
			 | 
			
				237
			 | 
			
			
				+   * 评论 点赞/取消点赞 
			 | 
		
	
		
			
			| 
				225
			 | 
			
				238
			 | 
			
			
				    * @param {string} commentId { commentId } 
			 | 
		
	
		
			
			| 
				226
			 | 
			
				239
			 | 
			
			
				    * @param {boolean} favored   是否已经点过赞 
			 | 
		
	
		
			
			| 
				227
			 | 
			
				240
			 | 
			
			
				    */ 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -256,6 +269,47 @@ class App extends Component { 
			 | 
		
	
		
			
			| 
				256
			 | 
			
				269
			 | 
			
			
				       }); 
			 | 
		
	
		
			
			| 
				257
			 | 
			
				270
			 | 
			
			
				   } 
			 | 
		
	
		
			
			| 
				258
			 | 
			
				271
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				272
			 | 
			
			
				+  /** 
			 | 
		
	
		
			
			| 
				
			 | 
			
				273
			 | 
			
			
				+   * 回复 点赞/取消点赞 
			 | 
		
	
		
			
			| 
				
			 | 
			
				274
			 | 
			
			
				+   * @param {string} replyId  replyId 
			 | 
		
	
		
			
			| 
				
			 | 
			
				275
			 | 
			
			
				+   * @param {string} commentId  commentId 
			 | 
		
	
		
			
			| 
				
			 | 
			
				276
			 | 
			
			
				+   * @param {boolean} favored   是否已经点过赞 
			 | 
		
	
		
			
			| 
				
			 | 
			
				277
			 | 
			
			
				+   */ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				278
			 | 
			
			
				+  sReplyFavor(replyId, commentId, favored) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				279
			 | 
			
			
				+    this.handleChangeLoading("sReplyFavor", true); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				280
			 | 
			
			
				+    console.log("replyId, commentId ", replyId, commentId); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				281
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				282
			 | 
			
			
				+    const { API } = this.props; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				283
			 | 
			
			
				+    axios(`${API}/replies/${replyId}/favor`, { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				284
			 | 
			
			
				+      method: favored ? "delete" : "put", 
			 | 
		
	
		
			
			| 
				
			 | 
			
				285
			 | 
			
			
				+      withCredentials: true 
			 | 
		
	
		
			
			| 
				
			 | 
			
				286
			 | 
			
			
				+    }) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				287
			 | 
			
			
				+      .then(response => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				288
			 | 
			
			
				+        console.log("response: ", response); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				289
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				290
			 | 
			
			
				+        message.success(favored ? "取消点赞成功!" : "点赞成功!"); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				291
			 | 
			
			
				+        // // 更新 list 中的该项数据的 favored 
			 | 
		
	
		
			
			| 
				
			 | 
			
				292
			 | 
			
			
				+        // const list = this.state.list.map(item => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				293
			 | 
			
			
				+        //   if (item.id === replyId) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				294
			 | 
			
			
				+        //     item.favored = !favored; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				295
			 | 
			
			
				+        //     item.favor_count += favored ? -1 : 1; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				296
			 | 
			
			
				+        //   } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				297
			 | 
			
			
				+        //   return item; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				298
			 | 
			
			
				+        // }); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				299
			 | 
			
			
				+        // this.setState({ list }); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				300
			 | 
			
			
				+      }) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				301
			 | 
			
			
				+      .catch(error => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				302
			 | 
			
			
				+        if (error.response && error.response.data && error.response.data.msg) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				303
			 | 
			
			
				+          message.error(lang[error.response.data.msg] || ERROR_DEFAULT); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				304
			 | 
			
			
				+          return; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				305
			 | 
			
			
				+        } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				306
			 | 
			
			
				+        message.error(lang[error.message] || ERROR_DEFAULT); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				307
			 | 
			
			
				+      }) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				308
			 | 
			
			
				+      .finally(() => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				309
			 | 
			
			
				+        this.handleChangeLoading("sReplyFavor", false); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				310
			 | 
			
			
				+      }); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				311
			 | 
			
			
				+  } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				312
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				259
			 | 
			
				313
			 | 
			
			
				   /** 
			 | 
		
	
		
			
			| 
				260
			 | 
			
				314
			 | 
			
			
				    * 获取 OSS 上传的参数 
			 | 
		
	
		
			
			| 
				261
			 | 
			
				315
			 | 
			
			
				    */ 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -287,6 +341,7 @@ class App extends Component { 
			 | 
		
	
		
			
			| 
				287
			 | 
			
				341
			 | 
			
			
				       sCreateComment: this.sCreateComment, 
			 | 
		
	
		
			
			| 
				288
			 | 
			
				342
			 | 
			
			
				       sGetComment: this.sGetComment, 
			 | 
		
	
		
			
			| 
				289
			 | 
			
				343
			 | 
			
			
				       sCommentFavor: this.sCommentFavor, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				344
			 | 
			
			
				+      sReplyFavor: this.sReplyFavor, 
			 | 
		
	
		
			
			| 
				290
			 | 
			
				345
			 | 
			
			
				       sCreateReply: this.sCreateReply, 
			 | 
		
	
		
			
			| 
				291
			 | 
			
				346
			 | 
			
			
				       sGetReply: this.sGetReply, 
			 | 
		
	
		
			
			| 
				292
			 | 
			
				347
			 | 
			
			
				       sOssSts: this.sOssSts 
			 |