Files
ai_dianshang/miniprogram/pages/debug/hardcoded-comment-test.wxml
2025-11-17 13:32:54 +08:00

175 lines
6.9 KiB
Plaintext

<!--pages/debug/hardcoded-comment-test.wxml-->
<view class="container">
<view class="header">
<text class="title">硬编码评论组件测试</text>
<text class="subtitle">使用硬编码数据测试评论组件显示</text>
</view>
<!-- 测试信息 -->
<view class="section">
<view class="section-title">测试信息</view>
<view class="test-info">
<view class="info-item">
<text class="label">当前模式:</text>
<text class="value">{{testMode === 'with-comments' ? '有评论模式' : '无评论模式'}}</text>
</view>
<view class="info-item">
<text class="label">评论数量:</text>
<text class="value">{{debugInfo.commentCount}}</text>
</view>
<view class="info-item">
<text class="label">显示条件:</text>
<text class="value {{debugInfo.displayCondition ? 'success' : 'error'}}">
commentCount({{debugInfo.commentCount}}) > 0 = {{debugInfo.displayCondition ? 'true (应该显示)' : 'false (不应该显示)'}}
</text>
</view>
<view class="info-item">
<text class="label">更新时间:</text>
<text class="value">{{debugInfo.timestamp}}</text>
</view>
</view>
</view>
<!-- 商品ID测试 -->
<view class="section">
<view class="section-title">商品ID验证测试</view>
<!-- 输入区域 -->
<view class="test-input-area">
<view class="input-row">
<text class="input-label">测试商品ID:</text>
<input class="test-input"
value="{{testProductId}}"
bindinput="onProductIdInput"
placeholder="输入要测试的商品ID" />
</view>
<button class="test-btn" bindtap="testProductIdValidation">测试验证</button>
</view>
<!-- 快速测试按钮 -->
<view class="quick-test-area">
<text class="quick-test-label">快速测试:</text>
<view class="quick-test-buttons">
<button class="quick-btn" bindtap="quickTest" data-value="1">正常ID(1)</button>
<button class="quick-btn" bindtap="quickTest" data-value="0">零值(0)</button>
<button class="quick-btn" bindtap="quickTest" data-value="">空字符串</button>
<button class="quick-btn" bindtap="quickTest" data-value="abc">非数字(abc)</button>
<button class="quick-btn" bindtap="quickTest" data-value="-1">负数(-1)</button>
<button class="quick-btn" bindtap="quickTest" data-value="1.5">小数(1.5)</button>
</view>
</view>
<!-- 测试结果 -->
<view class="test-results" wx:if="{{testResults.length > 0}}">
<view class="results-header">
<text class="results-title">测试结果 ({{testResults.length}}条)</text>
<button class="clear-btn" bindtap="clearTestResults">清空</button>
</view>
<view class="result-item" wx:for="{{testResults}}" wx:key="timestamp">
<view class="result-header">
<text class="result-id">ID: "{{item.productId}}"</text>
<text class="result-time">{{item.timestamp}}</text>
<text class="result-status {{item.success ? 'success' : 'error'}}">
{{item.success ? '✓ 成功' : '✗ 失败'}}
</text>
</view>
<view class="result-content" wx:if="{{item.success}}">
<text class="result-data">返回数据: {{item.data}}</text>
</view>
<view class="result-content" wx:else>
<text class="result-error">错误信息: {{item.error}}</text>
</view>
</view>
</view>
</view>
<!-- 操作按钮 -->
<view class="section">
<view class="section-title">评论组件测试</view>
<button class="switch-btn" bindtap="switchTestMode">
切换到{{testMode === 'with-comments' ? '无评论模式' : '有评论模式'}}
</button>
</view>
<!-- 评论组件显示区域 -->
<view class="section">
<view class="section-title">评论组件显示区域</view>
<!-- 显示条件检查 -->
<view class="condition-check">
<text class="condition-text">
条件检查: commentsStatistics.commentCount = {{commentsStatistics.commentCount}}
</text>
<text class="condition-text">
显示条件: {{commentsStatistics.commentCount > 0 ? 'true (显示)' : 'false (隐藏)'}}
</text>
</view>
<!-- 评论组件 - 完全复制商品详情页的结构 -->
<view class="comments-wrap" wx:if="{{commentsStatistics.commentCount > 0}}">
<view class="comments-head">
<view class="comments-title">
<text class="comments-title-label">商品评价</text>
<text class="comments-title-count">({{commentsStatistics.commentCount}})</text>
</view>
<view class="comments-rate-wrap">
<text class="comments-rate-label">好评率</text>
<text class="comments-rate-num">{{commentsStatistics.goodRate}}%</text>
</view>
</view>
<!-- 评论列表 -->
<view class="comment-item-wrap" wx:for="{{commentsList}}" wx:key="id" wx:if="{{index < 3}}">
<view class="comment-item-head">
<image class="comment-item-avatar" src="{{item.userHeadUrl}}" />
<view class="comment-item-info">
<text class="comment-item-name">{{item.userName}}</text>
<view class="comment-item-rate">
<text class="comment-item-score">{{item.commentScore}}分</text>
</view>
</view>
</view>
<view class="comment-item-content">
<text>{{item.commentContent}}</text>
</view>
<view class="comment-item-spec" wx:if="{{item.specInfo}}">
<text>{{item.specInfo}}</text>
</view>
<view class="comment-item-reply" wx:if="{{item.sellerReply}}">
<text class="reply-label">商家回复:</text>
<text class="reply-content">{{item.sellerReply}}</text>
</view>
<view class="comment-item-time">{{item.commentTime}}</view>
</view>
<!-- 查看更多按钮 -->
<view class="comments-more" bindtap="navToCommentsListPage">
<text>查看全部评价</text>
</view>
</view>
<!-- 无评论时的显示 -->
<view class="no-comments-placeholder" wx:else>
<text class="placeholder-text">评论组件未显示</text>
<text class="placeholder-reason">原因: commentCount = {{commentsStatistics.commentCount}} (不满足 > 0 的条件)</text>
</view>
</view>
<!-- 原始数据显示 -->
<view class="section">
<view class="section-title">原始数据</view>
<view class="data-display">
<view class="data-item">
<text class="data-label">commentsStatistics:</text>
<view class="data-content">{{commentsStatistics}}</view>
</view>
<view class="data-item">
<text class="data-label">commentsList ({{commentsList.length}}条):</text>
<view class="data-content">{{commentsList}}</view>
</view>
</view>
</view>
</view>