Skip to content
This repository was archived by the owner on Nov 15, 2018. It is now read-only.

Commit 103e68f

Browse files
committed
feat: (#608) 举报资讯评论
1 parent 7657fba commit 103e68f

File tree

1 file changed

+43
-25
lines changed

1 file changed

+43
-25
lines changed

src/page/news/NewsDetail.vue

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@
8585
:key="`pinned-${comment.id}`"
8686
:comment="comment"
8787
:pinned="true"
88-
@click="replyComment" />
88+
@click="replyComment(comment)" />
8989
<comment-item
9090
v-for="(comment) in comments"
9191
:key="`comment-${comment.id}`"
9292
:comment="comment"
93-
@click="replyComment" />
93+
@click="replyComment(comment)" />
9494
<div class="m-box m-aln-center m-justify-center load-more-box">
9595
<span v-if="noMoreCom" class="load-more-ph">---没有更多---</span>
9696
<span
@@ -441,35 +441,53 @@ export default {
441441
];
442442
this.$bus.$emit("actionSheet", [...defaultActions, ...actions], "取消");
443443
},
444-
replyComment(uid, uname, commentId) {
444+
replyComment(comment) {
445+
const actions = [];
445446
// 是否是自己的评论
446-
if (uid === this.CURRENTUSER.id) {
447+
if (comment.user_id === this.CURRENTUSER.id) {
447448
// 是否是自己文章的评论
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+
});
465466
} 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+
});
470487
}
471488
});
472489
}
490+
this.$bus.$emit("actionSheet", actions);
473491
},
474492
sendComment({ reply_user: replyUser, body }) {
475493
const params = {};

0 commit comments

Comments
 (0)