添加评论功能
This commit is contained in:
@ -24,7 +24,7 @@
|
||||
.reward(@click="reward") 打赏
|
||||
.comment(id="comment")
|
||||
.comment-title 交流区
|
||||
span(v-if="comments.length") ({{commentAmount}})
|
||||
span(v-if="comments.length") ({{ commentAmount }})
|
||||
.comment-item(v-for="(item, index) in comments", :id="'comment_ID_' + item.comment_ID", :key="index")
|
||||
.comment-avatar
|
||||
img(:src="item.comment_author_avatar_url ? item.comment_author_avatar_url : 'https://picsum.photos/100/100/?blur=' + item.user_id")
|
||||
@ -35,6 +35,8 @@
|
||||
.comment-info {{ item.comment_date }}
|
||||
span.reply(@click="reply(item.comment_ID, null, true)" v-if="replyLastID === null && item.comment_ID === replyID") 取消回复
|
||||
span.reply(@click="reply(item.comment_ID, null)" v-else) 回复
|
||||
span.reply(@click="check(item.comment_ID)" v-if="item.comment_approved === '0' && visitorInfo.manage") 通过审核
|
||||
span.reply(@click="check(item.comment_ID, 2)" v-else-if="visitorInfo.manage") 设为垃圾评论
|
||||
.comment-item(v-for="(i, inx) in item.children", :id="'comment_ID_' + i.comment_ID", :key="inx", style="margin-top: 15px; margin-left: 50px; background-color: #eeeeee; border-radius: 4px;")
|
||||
.comment-avatar
|
||||
img(:src="i.comment_author_avatar_url ? i.comment_author_avatar_url : 'https://picsum.photos/100/100/?blur=' + i.user_id")
|
||||
@ -45,6 +47,8 @@
|
||||
.comment-info {{ i.comment_date }}
|
||||
span.reply(@click="reply(item.comment_ID, i.comment_ID)" v-if="replyLastID !== i.comment_ID") 回复
|
||||
span.reply(@click="reply(item.comment_ID, i.comment_ID, true)" v-else) 取消回复
|
||||
span.reply(@click="check(i.comment_ID)" v-if="i.comment_approved === '0' && visitorInfo.manage") 通过审核
|
||||
span.reply(@click="check(i.comment_ID, 2)" v-else-if="visitorInfo.manage") 设为垃圾评论
|
||||
p(v-if="!comments.length", style="color: #cecece; text-align: center; margin-top: 40px") 暂无内容
|
||||
.comment-default-commit
|
||||
.login(v-if="!visitorToken", @click="login")
|
||||
@ -508,6 +512,27 @@ export default {
|
||||
})
|
||||
}
|
||||
},
|
||||
async check (ID, type) {
|
||||
const { data } = await this.$axios({
|
||||
method: 'post',
|
||||
url: process.env.baseURL + '/comments/check',
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + this.visitorToken
|
||||
},
|
||||
data: {
|
||||
ID,
|
||||
type
|
||||
}
|
||||
})
|
||||
|
||||
if (data.status === 1) {
|
||||
this.getCommentWithVisitorInfo(this.postID)
|
||||
this.$toasted.show(type === 2 ? '已删除' : '已通过', {
|
||||
position: 'top-center',
|
||||
duration: 5000
|
||||
})
|
||||
}
|
||||
},
|
||||
async getCommentWithVisitorInfo (postID) {
|
||||
// 获取评论
|
||||
const tmp = await this.$axios({
|
||||
|
Reference in New Issue
Block a user