diff --git a/.env.prod b/.env.prod index 4df8ab0..811cd1a 100644 --- a/.env.prod +++ b/.env.prod @@ -1,4 +1,4 @@ VITE_BASE_URL=https://you-gateway.mashibing.com VITE_SOCKET_URL=wss://you-gateway.mashibing.com/ws VITE_REQUEST_TIMEOUT=20000 -VITE_BROWSER_URL = https://k8s-shop-pc.mashibing.cn +VITE_BROWSER_URL = https://you.mashibing.com diff --git a/src/api/goods/comment.js b/src/api/goods/comment.js new file mode 100644 index 0000000..167dd21 --- /dev/null +++ b/src/api/goods/comment.js @@ -0,0 +1,36 @@ +/* + * @Author: ch + * @Date: 2022-06-15 17:55:43 + * @LastEditors: ch + * @LastEditTime: 2022-06-17 18:13:27 + * @Description: file content + */ +import request from '@/utils/request.js'; +//获取评论列表 +export const commentList = (params) => + request({ + url: '/mall/comment/admin/comment', + method: 'get', + params, + }); +// 获取评价详情 +export const commentDetail = ({ id }) => + request({ + 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({ + url: '/mall/comment/admin/comment', + method: 'put', + data, + }); diff --git a/src/store/modules/goods/comment.js b/src/store/modules/goods/comment.js new file mode 100644 index 0000000..88dee1d --- /dev/null +++ b/src/store/modules/goods/comment.js @@ -0,0 +1,204 @@ +import * as api from '@/api/goods/comment.js'; +import { ElMessage } from 'element-plus/es'; +const state = { + list: [], + 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: [ + { + value: true, + label: '显示', + }, + { + value: false, + label: '隐藏', + }, + ], + score: [ + { + value: 1, + label: '1星', + }, + { + value: 2, + label: '2星', + }, + { + value: 3, + label: '3星', + }, + { + value: 4, + label: '4星', + }, + { + value: 5, + label: '5星', + }, + ], + commentType: { + //  评论 + comment: 1, + // 追评 + addComment: 2, + // 回复 + reply: 3, + }, + }, +}; +const getters = {}; +const mutations = { + setList: (state, data) => (state.list = data), + setTotal: (state, data) => (state.total = data), + setDetail: (state, data) => (state.detail = data), +}; +const actions = { + async search({ state, commit, rootGetters }, params) { + let data = { ...params }; + let pagingCode = params.pagingCode; + if (data.dateRange?.length) { + data.commentTimeBegin = data.dateRange[0]; + data.commentTimeEnd = data.dateRange[1]; + } + delete data.dateRange; + delete data.pagingCode; + const res = await api.commentList({ + ...rootGetters['local/page'](pagingCode), + ...data, + }); + if (!res) { + ElMessage.error('评价列表查询失败'); + } + 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) { + const res = await api.updateCommentShow(params); + if (!res) { + ElMessage.error('状态更新失败!'); + return Promise.reject('更新失败'); + } + return Promise.resolve(res); + }, + async getDetail({ state, commit }, id) { + 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); + }, +}; + +export default { + state, + getters, + mutations, + actions, +}; diff --git a/src/views/goods/comment/detail/index.vue b/src/views/goods/comment/detail/index.vue new file mode 100644 index 0000000..6b5cfd7 --- /dev/null +++ b/src/views/goods/comment/detail/index.vue @@ -0,0 +1,350 @@ + + + diff --git a/src/views/goods/comment/list/index.vue b/src/views/goods/comment/list/index.vue new file mode 100644 index 0000000..ff40212 --- /dev/null +++ b/src/views/goods/comment/list/index.vue @@ -0,0 +1,258 @@ + + + +