|
85 | 85 | :key="`pinned-${comment.id}`"
|
86 | 86 | :comment="comment"
|
87 | 87 | :pinned="true"
|
88 |
| - @click="replyComment" /> |
| 88 | + @click="replyComment(comment)" /> |
89 | 89 | <comment-item
|
90 | 90 | v-for="(comment) in comments"
|
91 | 91 | :key="`comment-${comment.id}`"
|
92 | 92 | :comment="comment"
|
93 |
| - @click="replyComment" /> |
| 93 | + @click="replyComment(comment)" /> |
94 | 94 | <div class="m-box m-aln-center m-justify-center load-more-box">
|
95 | 95 | <span v-if="noMoreCom" class="load-more-ph">---没有更多---</span>
|
96 | 96 | <span
|
@@ -441,35 +441,53 @@ export default {
|
441 | 441 | ];
|
442 | 442 | this.$bus.$emit("actionSheet", [...defaultActions, ...actions], "取消");
|
443 | 443 | },
|
444 |
| - replyComment(uid, uname, commentId) { |
| 444 | + replyComment(comment) { |
| 445 | + const actions = []; |
445 | 446 | // 是否是自己的评论
|
446 |
| - if (uid === this.CURRENTUSER.id) { |
| 447 | + if (comment.user_id === this.CURRENTUSER.id) { |
447 | 448 | // 是否是自己文章的评论
|
448 |
| - const isOwner = uid === this.userID; |
449 |
| - const actionSheet = [ |
450 |
| - { |
451 |
| - text: isOwner ? "评论置顶" : "申请评论置顶", |
452 |
| - method: () => { |
453 |
| - this.$bus.$emit("applyTop", { |
454 |
| - isOwner, |
455 |
| - type: "newsComment", |
456 |
| - api: api.applyTopNewsComment, |
457 |
| - payload: { newsId: this.newsID, commentId }, |
458 |
| - callback: this.fetchNewsComments |
459 |
| - }); |
460 |
| - } |
461 |
| - }, |
462 |
| - { text: "删除评论", method: () => this.deleteComment(commentId) } |
463 |
| - ]; |
464 |
| - this.$bus.$emit("actionSheet", actionSheet, "取消"); |
| 449 | + const isOwner = comment.user_id === this.userID; |
| 450 | + actions.push({ |
| 451 | + text: isOwner ? "评论置顶" : "申请评论置顶", |
| 452 | + method: () => { |
| 453 | + this.$bus.$emit("applyTop", { |
| 454 | + isOwner, |
| 455 | + type: "newsComment", |
| 456 | + api: api.applyTopNewsComment, |
| 457 | + payload: { newsId: this.newsID, commentId: comment.id }, |
| 458 | + callback: this.fetchNewsComments |
| 459 | + }); |
| 460 | + } |
| 461 | + }); |
| 462 | + actions.push({ |
| 463 | + text: "删除评论", |
| 464 | + method: () => this.deleteComment(comment.id) |
| 465 | + }); |
465 | 466 | } else {
|
466 |
| - this.$bus.$emit("commentInput", { |
467 |
| - placeholder: `回复: ${uname}`, |
468 |
| - onOk: text => { |
469 |
| - this.sendComment({ reply_user: uid, body: text }); |
| 467 | + actions.push({ |
| 468 | + text: "回复", |
| 469 | + method: () => { |
| 470 | + this.$bus.$emit("commentInput", { |
| 471 | + placeholder: `回复: ${comment.user.name}`, |
| 472 | + onOk: text => { |
| 473 | + this.sendComment({ reply_user: comment.user_id, body: text }); |
| 474 | + } |
| 475 | + }); |
| 476 | + } |
| 477 | + }); |
| 478 | + actions.push({ |
| 479 | + text: "举报", |
| 480 | + method: () => { |
| 481 | + this.$bus.$emit("report", { |
| 482 | + type: "comment", |
| 483 | + payload: comment.id, |
| 484 | + username: comment.user.name, |
| 485 | + reference: comment.body |
| 486 | + }); |
470 | 487 | }
|
471 | 488 | });
|
472 | 489 | }
|
| 490 | + this.$bus.$emit("actionSheet", actions); |
473 | 491 | },
|
474 | 492 | sendComment({ reply_user: replyUser, body }) {
|
475 | 493 | const params = {};
|
|
0 commit comments