From 321dd05d97f57a03358a27817efbeb4f312232dc Mon Sep 17 00:00:00 2001 From: yige Date: Thu, 16 Jul 2020 23:38:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=84=E8=AE=BA=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/post/_id.vue | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/pages/post/_id.vue b/pages/post/_id.vue index 6d1ab1d..3e03fc9 100644 --- a/pages/post/_id.vue +++ b/pages/post/_id.vue @@ -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 () {