From 0da91cd614b4e06711062274bbf873406ede4832 Mon Sep 17 00:00:00 2001
From: ch
Date: Mon, 20 Jun 2022 10:41:47 +0800
Subject: [PATCH] =?UTF-8?q?fat:=E8=AF=84=E4=BB=B7=E8=AF=A6=E6=83=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/goods/comment.js | 10 +-
src/store/modules/goods/comment.js | 109 ++++++++-
src/views/goods/comment/detail/index.vue | 269 ++++++++++++++++++++---
3 files changed, 358 insertions(+), 30 deletions(-)
diff --git a/src/api/goods/comment.js b/src/api/goods/comment.js
index 54364dd..167dd21 100644
--- a/src/api/goods/comment.js
+++ b/src/api/goods/comment.js
@@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-06-15 17:55:43
* @LastEditors: ch
- * @LastEditTime: 2022-06-17 10:43:30
+ * @LastEditTime: 2022-06-17 18:13:27
* @Description: file content
*/
import request from '@/utils/request.js';
@@ -19,6 +19,14 @@ export const commentDetail = ({ id }) =>
url: `/mall/comment/admin/comment/getCommentDetail/${id}`,
method: 'get',
});
+
+//获取评论列表
+export const commentAdd = (data) =>
+ request({
+ url: '/mall/comment/admin/comment',
+ method: 'post',
+ data,
+ });
// 更新评价显示状态
export const updateCommentShow = (data) =>
request({
diff --git a/src/store/modules/goods/comment.js b/src/store/modules/goods/comment.js
index e24e1ae..88dee1d 100644
--- a/src/store/modules/goods/comment.js
+++ b/src/store/modules/goods/comment.js
@@ -2,7 +2,96 @@ import * as api from '@/api/goods/comment.js';
import { ElMessage } from 'element-plus/es';
const state = {
list: [],
- detail: {},
+ detail: {
+ id: 18,
+ originId: 0,
+ parentId: 0,
+ userId: 97,
+ userName: 'ocean',
+ commentContent: '用户超时未做出评价,系统默认好评',
+ isShow: false,
+ createTime: '2022-06-17 15:27:09',
+ commentType: 1,
+ userAvatar: 'https://msb-edu-dev.oss-cn-beijing.aliyuncs.com/default-headimg.png',
+ skuName: '测试SKU',
+ productName: '测试虚拟111',
+ phone: '151****5744',
+ pictureUrl: 'https://msb-edu-dev.oss-cn-beijing.aliyuncs.com/uc/account-avatar/120x120.png',
+ commentScore: 5,
+ followComment: {
+ id: 19,
+ originId: 18,
+ parentId: 18,
+ userId: 97,
+ userName: 'ocean',
+ commentContent: '新增一条追评',
+ isShow: true,
+ createTime: '2022-06-17 17:13:32',
+ commentType: 2,
+ },
+ answerCommentList: [
+ {
+ id: 20,
+ originId: 18,
+ parentId: 18,
+ userId: 8,
+ userName: '随机昵称',
+ commentContent: '新增一条回复',
+ isShow: true,
+ createTime: '2022-06-17 17:14:02',
+ commentType: 3,
+ parentUserName: 'ocean',
+ },
+ {
+ id: 21,
+ originId: 18,
+ parentId: 18,
+ userId: 8,
+ userName: '随机昵称',
+ commentContent: '1232321',
+ isShow: true,
+ createTime: '2022-06-17 18:31:48',
+ commentType: 3,
+ parentUserName: 'ocean',
+ },
+ {
+ id: 22,
+ originId: 18,
+ parentId: 18,
+ userId: 8,
+ userName: '随机昵称',
+ commentContent: '我回复我回复我回复我回复我回复',
+ isShow: true,
+ createTime: '2022-06-17 18:32:39',
+ commentType: 3,
+ parentUserName: 'ocean',
+ },
+ {
+ id: 23,
+ originId: 18,
+ parentId: 22,
+ userId: 8,
+ userName: '随机昵称',
+ commentContent: '222222222222',
+ isShow: true,
+ createTime: '2022-06-17 18:34:30',
+ commentType: 3,
+ parentUserName: '随机昵称',
+ },
+ {
+ id: 24,
+ originId: 18,
+ parentId: 18,
+ userId: 8,
+ userName: '随机昵称',
+ commentContent: '直接评论直接评论',
+ isShow: true,
+ createTime: '2022-06-17 18:36:03',
+ commentType: 3,
+ parentUserName: 'ocean',
+ },
+ ],
+ },
total: 0,
opts: {
isShow: [
@@ -37,6 +126,14 @@ const state = {
label: '5星',
},
],
+ commentType: {
+ // 评论
+ comment: 1,
+ // 追评
+ addComment: 2,
+ // 回复
+ reply: 3,
+ },
},
};
const getters = {};
@@ -84,8 +181,18 @@ const actions = {
const res = await api.commentDetail({ id });
if (!res) {
ElMessage.error('获取详情失败');
+ return Promise.reject('获取详情失败');
}
commit('setDetail', res);
+ return Promise.resolve(res);
+ },
+ async add({ state, commit }, data) {
+ const res = await api.commentAdd(data);
+ if (!res) {
+ ElMessage.error('回复失败');
+ return Promise.reject(false);
+ }
+ return Promise.resolve(res);
},
};
diff --git a/src/views/goods/comment/detail/index.vue b/src/views/goods/comment/detail/index.vue
index ca9f7a0..6b5cfd7 100644
--- a/src/views/goods/comment/detail/index.vue
+++ b/src/views/goods/comment/detail/index.vue
@@ -17,7 +17,7 @@
-
+
@@ -25,52 +25,172 @@
-
{{ detailData.commentContent }}
-{{ detailData.commentContent }}
+{{ detailData.followComment.commentContent }}
+--
-
+
+ 全部回复({{ detailData.answerCommentList?.length || 0 }}条)
+
+
+