|
|
|
@ -1815,11 +1815,12 @@ Page({ |
|
|
|
const productId = this.data.goodsDetail.productId || this.data.goodsDetail.id; |
|
|
|
|
|
|
|
// 准备评论数据
|
|
|
|
// 只发送服务器需要的参数:productId、phoneNumber和comments
|
|
|
|
// 只发送服务器需要的参数:productId、phoneNumber、comments和review
|
|
|
|
const commentData = { |
|
|
|
productId: String(productId), |
|
|
|
phoneNumber: phoneNumber ? String(phoneNumber) : null, |
|
|
|
comments: content |
|
|
|
comments: content, |
|
|
|
review: 0 // 新提交的评论默认为待审核状态
|
|
|
|
}; |
|
|
|
|
|
|
|
// 调试日志
|
|
|
|
@ -1851,7 +1852,8 @@ Page({ |
|
|
|
liked: false, |
|
|
|
hated: false, |
|
|
|
replies: [], |
|
|
|
phoneNumber: phoneNumber // 添加用户标识信息,用于判断是否可以删除
|
|
|
|
phoneNumber: phoneNumber, // 添加用户标识信息,用于判断是否可以删除
|
|
|
|
review: 0 // 新提交的评论默认为待审核状态
|
|
|
|
}; |
|
|
|
|
|
|
|
// 更新评论列表 - add new comment to the end
|
|
|
|
@ -1952,7 +1954,8 @@ Page({ |
|
|
|
hated: false, |
|
|
|
replies: [], |
|
|
|
phoneNumber: '', |
|
|
|
isDefault: true |
|
|
|
isDefault: true, |
|
|
|
review: 1 // 默认评论默认为审核通过状态
|
|
|
|
})); |
|
|
|
}, |
|
|
|
|
|
|
|
@ -2003,9 +2006,19 @@ 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); |
|
|
|
|
|
|
|
// Always add default comments at the beginning
|
|
|
|
const defaultComments = this.getConsistentRandomComments(productId, 2); |
|
|
|
commentsData = [...defaultComments, ...commentsData]; |
|
|
|
commentsData = [...defaultComments, ...filteredComments]; |
|
|
|
|
|
|
|
// 检查返回的评论是否都属于当前用户
|
|
|
|
const allCommentsBelongToCurrentUser = commentsData.every(comment => |
|
|
|
@ -2026,6 +2039,8 @@ 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) |
|
|
|
})); |
|
|
|
|