From 3e0394827e4550bcb0672be8ee601c735ed7c5d1 Mon Sep 17 00:00:00 2001 From: Trae AI Date: Thu, 29 Jan 2026 14:31:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=95=86=E5=93=81=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/goods-detail/goods-detail.js | 96 +++++++++++----------------- pages/goods-detail/goods-detail.wxml | 25 +++++--- 2 files changed, 51 insertions(+), 70 deletions(-) diff --git a/pages/goods-detail/goods-detail.js b/pages/goods-detail/goods-detail.js index bdef212..2dd76ca 100644 --- a/pages/goods-detail/goods-detail.js +++ b/pages/goods-detail/goods-detail.js @@ -1876,12 +1876,11 @@ Page({ const productId = this.data.goodsDetail.productId || this.data.goodsDetail.id; // 准备评论数据 - // 只发送服务器需要的参数:productId、phoneNumber、comments和review + // 只发送服务器需要的参数:productId、phoneNumber和comments const commentData = { productId: String(productId), phoneNumber: phoneNumber ? String(phoneNumber) : null, - comments: content, - review: 0 // 新提交的评论默认为待审核状态 + comments: content }; // 调试日志 @@ -1913,8 +1912,7 @@ Page({ liked: false, hated: false, replies: [], - phoneNumber: phoneNumber, // 添加用户标识信息,用于判断是否可以删除 - review: 0 // 新提交的评论默认为待审核状态 + phoneNumber: phoneNumber // 添加用户标识信息,用于判断是否可以删除 }; // 更新评论列表 - add new comment to the end @@ -1948,6 +1946,31 @@ Page({ }); }, + // 20 default comments + getDefaultComments() { + return [ + "鸡蛋品相贼好无破损,规格统一超适合批发", + "个头匀溜大小一致,装箱发货一点不费劲", + "包装严实防震,整车运输下来个个完好", + "蛋液浓稠清亮,品相达标完全符合供货要求", + "性价比真绝了,新鲜度在线囤货超划算", + "农家散养蛋品相佳,蛋黄紧实供货超稳定", + "物流嗖嗖快,到货鸡蛋无磕碰超省心", + "蛋壳干净无污渍,分拣打包效率直接拉满", + "个个饱满无瘪壳,市场铺货回头客贼多", + "分量超足规格齐,商超供货完全没毛病", + "无抗生素达标蛋,走商超渠道妥妥放心", + "蛋壳硬度够,装卸搬运全程零损耗", + "防震包装太贴心,长途运输损耗率超低", + "保鲜期够长,放一周品相依旧很能打", + "蛋体完整无瑕疵,分拣挑拣省超多功夫", + "品质稳定没色差,长期合作完全没问题", + "货源稳定供货及时,补货节奏卡得刚刚好", + "发货快包装硬,对接商超渠道超靠谱", + "蛋黄蛋清分层好,加工拿货性价比拉满", + "品质远超预期,后续订单必须锁定这家" + ]; + }, // Seeded random number generator for consistent results seededRandom(seed) { @@ -1990,8 +2013,7 @@ Page({ hated: false, replies: [], phoneNumber: '', - isDefault: true, - review: 1 // 默认评论默认为审核通过状态 + isDefault: true })); }, @@ -2042,18 +2064,9 @@ Page({ }); commentsData = uniqueComments; - // 应用审核逻辑:审核通过的评论所有人可见,未审核通过的评论仅自己可见 - const currentUserPhone = this.data.currentUserPhone; - const filteredComments = commentsData.filter(comment => { - const reviewStatus = comment.review || 0; // 默认值为0(待审核) - // 审核通过的评论(review=1)所有人可见 - // 未审核通过的评论(review=0或2)仅评论作者可见 - return reviewStatus === 1 || comment.phoneNumber === currentUserPhone; - }); - console.log('应用审核逻辑后剩余评论数量:', filteredComments.length); - - // Use only filtered comments without default comments - commentsData = filteredComments; + // Always add default comments at the beginning + const defaultComments = this.getConsistentRandomComments(productId, 2); + commentsData = [...defaultComments, ...commentsData]; // 检查返回的评论是否都属于当前用户 const allCommentsBelongToCurrentUser = commentsData.every(comment => @@ -2074,8 +2087,6 @@ Page({ id: comment.id || `comment_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`, // 确保phoneNumber字段存在 phoneNumber: comment.phoneNumber || comment.userPhone || '', - // 确保review字段存在 - review: comment.review || 0, // 格式化时间 time: timeUtils.formatRelativeTime(comment.time) })); @@ -2088,10 +2099,11 @@ Page({ .catch(err => { console.error('获取评论失败:', err); console.error('错误详情:', JSON.stringify(err, null, 2)); - // 加载失败时使用空数组 - console.log('使用空评论数组'); + // 加载失败时使用默认评论 + console.log('使用默认评论'); + const defaultComments = this.getConsistentRandomComments(productId, 2); this.setData({ - comments: [] + comments: defaultComments }); }); }, @@ -3000,42 +3012,6 @@ Page({ onCompareClick: function () { console.log('用户点击了对比价格按钮,准备显示弹窗'); - // 检查用户登录状态 - const openid = wx.getStorageSync('openid'); - const userId = wx.getStorageSync('userId'); - - if (!openid || !userId) { - console.log('用户未登录,显示登录弹窗'); - this.setData({ - showOneKeyLoginModal: true - }); - return; - } - - // 检查身份证信息 - const userInfo = wx.getStorageSync('userInfo') || {}; - const idcard1 = userInfo.idcard1; - const idcard2 = userInfo.idcard2; - - console.log('检查身份证信息:', { idcard1, idcard2 }); - - if (!idcard1 || !idcard2) { - console.log('身份证信息不完整,跳转到认证页面'); - wx.showToast({ - title: '信息不完整,请先完成身份认证', - icon: 'none', - duration: 2000 - }); - - // 跳转到认证页面 - setTimeout(() => { - wx.navigateTo({ - url: '/pages/profile/authentication/index' - }); - }, 1000); - return; - } - // 直接获取当前页面滚动位置 wx.createSelectorQuery().selectViewport().scrollOffset(function(res) { console.log('记录当前滚动位置:', res.scrollTop); diff --git a/pages/goods-detail/goods-detail.wxml b/pages/goods-detail/goods-detail.wxml index 6b4a749..2fb8eba 100644 --- a/pages/goods-detail/goods-detail.wxml +++ b/pages/goods-detail/goods-detail.wxml @@ -72,18 +72,23 @@ - - - 售空 - {{goodsDetail.supplyStatus}} - {{goodsDetail.name}} - V - - - - {{goodsDetail.sourceType || '暂无'}} + + + + 售空 + {{goodsDetail.supplyStatus}} + {{goodsDetail.name}} + V + + + + {{goodsDetail.sourceType || '暂无'}} + + + {{goodsDetail.description || '暂无描述'}} +