添加评论功能

This commit is contained in:
yi-ge 2020-07-16 23:38:24 +08:00
parent 4d05c1a1a5
commit 321dd05d97

View File

@ -467,21 +467,35 @@ export default {
return
}
const { data } = await this.$axios.post('/comments/commit', {
postID,
lastID,
parentID,
content: type === 'editor-reply' ? window.editorReplyObj.getValue() : window.editorObj.getValue()
const editorObj = type === 'editor-reply' ? window.editorReplyObj : window.editorObj
const { data } = await this.$axios({
method: 'post',
url: process.env.baseURL + '/comments/commit',
headers: {
Authorization: 'Bearer ' + window.localStorage.visitorToken
},
data: {
postID,
lastID,
parentID,
content: editorObj.getValue()
}
})
if (data.status === 1) {
//
const tmp = await this.$axios.get(`/public/comments/post?ID=${postID}`)
const comments = tmp.result.list || []
const commentAmount = tmp.result.amount || 0
const tmp = await this.$axios.get(process.env.baseURL + `/public/comments/post?ID=${postID}`)
const comments = tmp.data.result.list || []
const commentAmount = tmp.data.result.amount || 0
this.comments = comments
this.commentAmount = commentAmount
this.setCommentMap()
editorObj.setValue('', true)
this.$nextTick(() => {
editorObj.focus()
editorObj.insertValue('', true)
})
}
},
commentLogout () {