From 6d72891941b75f762f67b2e697dc44c55c01e69f Mon Sep 17 00:00:00 2001 From: ch Date: Tue, 28 Jun 2022 18:18:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/goods/comment.js | 30 +++++++++++------------- src/views/goods/comment/detail/index.vue | 3 ++- src/views/goods/comment/list/index.vue | 4 ++-- vite.config.js | 4 ++-- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/store/modules/goods/comment.js b/src/store/modules/goods/comment.js index 88dee1d..1bb2ed1 100644 --- a/src/store/modules/goods/comment.js +++ b/src/store/modules/goods/comment.js @@ -127,7 +127,7 @@ const state = { }, ], commentType: { - //  评论 + // 评论 comment: 1, // 追评 addComment: 2, @@ -156,28 +156,26 @@ const actions = { ...rootGetters['local/page'](pagingCode), ...data, }); - if (!res) { - ElMessage.error('评价列表查询失败'); + if (res) { + commit( + 'setList', + res?.records.map((i) => ({ + ...i, + scoreName: state.opts.score.find((item) => item.value === i.commentScore)?.label, + })) || [] + ); + commit('setTotal', res?.total || 0); } - res; - commit( - 'setList', - res?.records.map((i) => ({ - ...i, - scoreName: state.opts.score.find((item) => item.value == i.commentScore)?.label, - })) || [] - ); - commit('setTotal', res?.total || 0); }, - async updateShow({ state }, params) { + async updateShow({}, params) { const res = await api.updateCommentShow(params); if (!res) { ElMessage.error('状态更新失败!'); - return Promise.reject('更新失败'); + return Promise.reject('状态更新失败!'); } return Promise.resolve(res); }, - async getDetail({ state, commit }, id) { + async getDetail({ commit }, id) { const res = await api.commentDetail({ id }); if (!res) { ElMessage.error('获取详情失败'); @@ -186,7 +184,7 @@ const actions = { commit('setDetail', res); return Promise.resolve(res); }, - async add({ state, commit }, data) { + async add({}, data) { const res = await api.commentAdd(data); if (!res) { ElMessage.error('回复失败'); diff --git a/src/views/goods/comment/detail/index.vue b/src/views/goods/comment/detail/index.vue index 347329a..9748bda 100644 --- a/src/views/goods/comment/detail/index.vue +++ b/src/views/goods/comment/detail/index.vue @@ -31,7 +31,7 @@ @@ -135,6 +135,7 @@ const $textarea = ref(null); const getDetail = async () => { + detailData.value = {}; const res = await store.dispatch('comment/getDetail', route.params.id); if (res) { detailData.value = _.cloneDeep(store.state.comment.detail); diff --git a/src/views/goods/comment/list/index.vue b/src/views/goods/comment/list/index.vue index 60a83a6..713fc19 100644 --- a/src/views/goods/comment/list/index.vue +++ b/src/views/goods/comment/list/index.vue @@ -2,14 +2,14 @@ * @Author: ch * @Date: 2022-06-15 17:29:32 * @LastEditors: ch - * @LastEditTime: 2022-06-20 16:52:35 + * @LastEditTime: 2022-06-28 17:48:42 * @Description: file content -->