124 lines
3.6 KiB
JavaScript
124 lines
3.6 KiB
JavaScript
Page({
|
|
data: {
|
|
// 模拟有评论的情况
|
|
commentsStatistics: {
|
|
commentCount: 5,
|
|
goodCount: 4,
|
|
middleCount: 1,
|
|
badCount: 0,
|
|
goodRate: 80,
|
|
hasImageCount: 2,
|
|
},
|
|
commentsList: [
|
|
{
|
|
id: 1,
|
|
userName: '测试用户1',
|
|
userHeadUrl: 'https://tdesign.gtimg.com/miniprogram/template/retail/avatar/avatar1.png',
|
|
commentScore: 5,
|
|
commentContent: '商品质量很好,物流也很快!',
|
|
commentTime: '2024-01-15',
|
|
specInfo: '颜色:红色 尺寸:M',
|
|
commentResources: [],
|
|
isAnonymity: false,
|
|
sellerReply: '',
|
|
goodsDetailInfo: ''
|
|
},
|
|
{
|
|
id: 2,
|
|
userName: '测试用户2',
|
|
userHeadUrl: 'https://tdesign.gtimg.com/miniprogram/template/retail/avatar/avatar1.png',
|
|
commentScore: 4,
|
|
commentContent: '整体不错,性价比很高。',
|
|
commentTime: '2024-01-14',
|
|
specInfo: '颜色:蓝色 尺寸:L',
|
|
commentResources: [],
|
|
isAnonymity: false,
|
|
sellerReply: '',
|
|
goodsDetailInfo: ''
|
|
}
|
|
],
|
|
testMode: 'with_comments'
|
|
},
|
|
|
|
onLoad() {
|
|
console.log('简单评论测试页面加载');
|
|
console.log('commentsStatistics:', this.data.commentsStatistics);
|
|
console.log('commentsList:', this.data.commentsList);
|
|
console.log('显示条件 (commentCount > 0):', this.data.commentsStatistics.commentCount > 0);
|
|
},
|
|
|
|
// 切换测试模式
|
|
switchTestMode() {
|
|
const currentMode = this.data.testMode;
|
|
|
|
if (currentMode === 'with_comments') {
|
|
// 切换到无评论模式
|
|
this.setData({
|
|
testMode: 'no_comments',
|
|
commentsStatistics: {
|
|
commentCount: 0,
|
|
goodCount: 0,
|
|
middleCount: 0,
|
|
badCount: 0,
|
|
goodRate: 0,
|
|
hasImageCount: 0,
|
|
},
|
|
commentsList: []
|
|
});
|
|
console.log('切换到无评论模式');
|
|
} else {
|
|
// 切换到有评论模式
|
|
this.setData({
|
|
testMode: 'with_comments',
|
|
commentsStatistics: {
|
|
commentCount: 5,
|
|
goodCount: 4,
|
|
middleCount: 1,
|
|
badCount: 0,
|
|
goodRate: 80,
|
|
hasImageCount: 2,
|
|
},
|
|
commentsList: [
|
|
{
|
|
id: 1,
|
|
userName: '测试用户1',
|
|
userHeadUrl: 'https://tdesign.gtimg.com/miniprogram/template/retail/avatar/avatar1.png',
|
|
commentScore: 5,
|
|
commentContent: '商品质量很好,物流也很快!',
|
|
commentTime: '2024-01-15',
|
|
specInfo: '颜色:红色 尺寸:M',
|
|
commentResources: [],
|
|
isAnonymity: false,
|
|
sellerReply: '',
|
|
goodsDetailInfo: ''
|
|
},
|
|
{
|
|
id: 2,
|
|
userName: '测试用户2',
|
|
userHeadUrl: 'https://tdesign.gtimg.com/miniprogram/template/retail/avatar/avatar1.png',
|
|
commentScore: 4,
|
|
commentContent: '整体不错,性价比很高。',
|
|
commentTime: '2024-01-14',
|
|
specInfo: '颜色:蓝色 尺寸:L',
|
|
commentResources: [],
|
|
isAnonymity: false,
|
|
sellerReply: '',
|
|
goodsDetailInfo: ''
|
|
}
|
|
]
|
|
});
|
|
console.log('切换到有评论模式');
|
|
}
|
|
|
|
console.log('新的显示条件 (commentCount > 0):', this.data.commentsStatistics.commentCount > 0);
|
|
},
|
|
|
|
// 导航到评论列表页面
|
|
navToCommentsListPage() {
|
|
console.log('导航到评论列表页面');
|
|
wx.showToast({
|
|
title: '导航到评论列表',
|
|
icon: 'success'
|
|
});
|
|
}
|
|
}); |