From 6cd1b9378283237e61a754e738d2bddfa7c28115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=AF=85?= <1335909236@qq.com> Date: Sat, 23 Aug 2025 16:41:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E5=95=86=E5=93=81=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E7=9A=84=E8=AF=84=E4=BB=B7=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/shop.js | 2 + packages/shop/goods/index.vue | 80 ++++++++++++++++++----------------- 2 files changed, 43 insertions(+), 39 deletions(-) diff --git a/api/shop.js b/api/shop.js index 6c0d6624..7d224d89 100644 --- a/api/shop.js +++ b/api/shop.js @@ -15,4 +15,6 @@ export const apiArr = { addAddress: '/api/v2/wechat/commodity/receiving_address/add', // 收货地址添加 addAddressList: '/api/v2/wechat/commodity/receiving_address', // 收货地址列表 queryOrder: '/api/v2/wechat/commodity/order/trade_query', // 查询订单 + getComment: '/api/v2/wechat/commodity/review/list', // 获取评论 + } \ No newline at end of file diff --git a/packages/shop/goods/index.vue b/packages/shop/goods/index.vue index 4863d125..487a803c 100644 --- a/packages/shop/goods/index.vue +++ b/packages/shop/goods/index.vue @@ -95,22 +95,22 @@ -

评价({{ comments.length }})

+

评价({{ comments.length ? comments.length : 0 }})

查看全部 >
- + - {{ comment.time }} + {{ comment.create_time }} - 已购 {{ comment.product }} - {{ comment.content }} - - + 已购 {{ comment.goods_name.goods_name }}{{ comment.goods_name.goods_spec }} + {{ comment.user_review }} + + @@ -193,9 +193,9 @@ - - - + + +
@@ -261,16 +261,16 @@ - + - {{ comment.time }} + {{ comment.create_time }} - 已购 {{ comment.product }} - {{ comment.content }} - - + 已购 {{ comment.goods_name.goods_name }}{{ comment.goods_name.goods_spec }} + {{ comment.user_review }} + + @@ -337,27 +337,7 @@ export default { carOrderList: [], // 新增评论数据 showReviewPopup: false, - comments: [{ - avatar: "https://wechat-img-file.oss-cn-beijing.aliyuncs.com/test.png", - username: "TP", - product: "库尔勒香梨 10kg/箱", - content: "踏入这家位于街角的餐厅,木质门框与暖黄灯光交织出温馨氛围,墙面上手绘的食材插画画透着文艺气息,开放式厨房的设计让食客能看见厨师处理食材的全过程,第一印象便给人以干净与安心。", - images: ["https://wechat-img-file.oss-cn-beijing.aliyuncs.com/test.png"], - time: "2025-03-01 11:24:20", - }, - { - avatar: "https://wechat-img-file.oss-cn-beijing.aliyuncs.com/test.png", - username: "TP", - product: "库尔勒香梨 10kg/箱", - content: "踏入这家位于街角的餐厅,木质门框与暖黄灯光交织出温馨氛围,墙面上手绘的食材插_draw着文艺气息,开放式厨房的设计让食客能看见厨师处理食材的全过程,第一印象便给人以干净与安心。", - images: [ - "https://wechat-img-file.oss-cn-beijing.aliyuncs.com/test.png", - "https://wechat-img-file.oss-cn-beijing.aliyuncs.com/test.png", - "https://wechat-img-file.oss-cn-beijing.aliyuncs.com/test.png", - ], - time: "2025-03-01 11:24:20", - }, - ], + comments: [], show: false, showSize: false, @@ -513,6 +493,7 @@ export default { this.changeImg = item.commodity_pic[0] this.changeName = item.goods_alias this.changePrice = item.sales_price + this.getComment(item.goods_id) }, car() { NavgateTo("../shopCar/index"); @@ -606,6 +587,26 @@ export default { closeSize() { this.showSize = false; }, + // 获取评论 + getComment(id) { + let params = {} + if (id) { + params = { + commodity_id: this.id, + goods_id: id + } + } else { + params = { + commodity_id: this.id, + } + } + request(apiArr.getComment, "POST", params).then((res) => { + this.comments = res.commodity_evaluate_list.map(item => ({ + ...item, + review_image: item.review_image ? item.review_image.split(',') : [] + })); + }); + } }, onLoad(options) { console.log(JSON.parse(decodeURIComponent(options.item))); @@ -621,6 +622,7 @@ export default { this.getShopCarList(); this.getGoodsInfo(); this.getShopCar(); + this.getComment(); }, //离开页面的时候直接更新购物车数量(目前接口是 传入商品id 数量。如果有当前商品就更新数量。如果没有就增加商品。如果删除某个商品 count 为0 就删除)