news 2026/4/28 7:39:45

评价展示页面源代码,专注于展示商品的好评内容,并支持带图片和视频的评价展示,同时实现无限滚动加载功能。

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
评价展示页面源代码,专注于展示商品的好评内容,并支持带图片和视频的评价展示,同时实现无限滚动加载功能。

专注于展示XX商品的好评内容,并支持带图片和视频的评价展示,同时实现无限滚动加载功能。

以下是实现方案:

关键功能说明:

  1. 好评筛选:只展示4星及以上的好评内容

  2. 媒体内容展示:支持图片和视频内容的展示,视频会有特殊标识

  3. 无限滚动加载:当用户滚动到页面底部时自动加载更多评价

  4. 初始加载30条:页面加载时首先显示30条评价

  5. 响应式设计:媒体内容采用网格布局,适应不同屏幕尺寸

  6. 加载状态提示:显示加载中和没有更多内容的提示

实际应用中,您需要:

  1. 替换模拟数据生成函数,改为从您的后端API获取真实数据

  2. 根据实际需求调整媒体内容的展示方式

  3. 可能需要添加图片预览和视频播放功能

  4. 考虑添加评价筛选和排序功能

这个实现保持了与XX平台详情页类似的用户体验,同时专注于展示高质量的好评内容。

<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>产品好评展示</title> <style> :root { --primary-color: #e93b3d; --secondary-color: #f5f5f5; } body { margin: 0; padding: 0; font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; background-color: #f9f9f9; } .review-container { max-width: 800px; margin: 0 auto; padding: 20px; } .header { text-align: center; margin-bottom: 20px; } .header h1 { color: var(--primary-color); margin-bottom: 10px; } .disclaimer { background-color: var(--secondary-color); padding: 15px; border-radius: 8px; margin-bottom: 25px; font-size: 14px; color: #666; line-height: 1.6; } .disclaimer a { color: var(--primary-color); text-decoration: none; } .disclaimer a:hover { text-decoration: underline; } .review-item { background-color: white; border-radius: 8px; padding: 20px; margin-bottom: 20px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); } .review-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; } .user-info { display: flex; align-items: center; } .user-avatar { width: 40px; height: 40px; border-radius: 50%; background-color: #f0f0f0; margin-right: 10px; display: flex; align-items: center; justify-content: center; color: var(--primary-color); font-weight: bold; } .user-name { font-weight: bold; color: #333; } .rating { color: #ff9900; font-size: 16px; } .review-time { color: #999; font-size: 12px; } .review-content { margin: 15px 0; line-height: 1.6; color: #333; } .media-container { margin-top: 15px; } .media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 10px; } .media-item { position: relative; border-radius: 4px; overflow: hidden; cursor: pointer; } .media-item img { width: 100%; height: 120px; object-fit: cover; transition: transform 0.3s; } .media-item:hover img { transform: scale(1.03); } .video-icon { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 40px; height: 40px; background-color: rgba(0, 0, 0, 0.6); border-radius: 50%; display: flex; align-items: center; justify-content: center; } .video-icon::after { content: ""; display: block; width: 0; height: 0; border-top: 10px solid transparent; border-bottom: 10px solid transparent; border-left: 15px solid white; margin-left: 3px; } .loading { text-align: center; padding: 20px; color: #999; display: none; } .no-more { text-align: center; padding: 20px; color: #999; display: none; } </style> </head> <body> <div class="review-container"> <div class="header"> <h1>用户好评展示</h1> </div> <div class="disclaimer"> <p>以下评价内容来自云惠商城用户,均为4星及以上好评且包含图片或视频内容。查看原始评价请访问: <a href="https://mry.52yunhui.cn/shangpin.html" target="_blank">云惠商品页面</a> </p> </div> <div id="reviews-list"></div> <div id="loading" class="loading">正在加载更多评价...</div> <div id="no-more" class="no-more"> <a href="https://mry.52yunhui.cn/shangpin.html" target="_blank">查看更多评价和购买请前往XX平台</a> </div> </div> <script> // 模拟数据 - 实际应用中应从后端API获取 const generateMockReviews = (count) => { const mockReviews = []; const nicknames = ["云惠用户", "优质买家", "老顾客", "匿名用户", "VIP会员"]; const contents = [ "产品质量非常好,已经多次购买了!", "包装精美,使用效果超出预期,强烈推荐!", "物流很快,客服态度也很好,产品做工精细!", "比实体店便宜很多,质量却一点不差,非常满意!", "家人很喜欢,下次还会再来购买!" ]; for (let i = 0; i < count; i++) { const hasMedia = Math.random() > 0.3; // 70%概率带媒体内容 const mediaCount = hasMedia ? Math.floor(Math.random() * 5) + 1 : 0; const hasVideo = hasMedia && Math.random() > 0.7; // 30%概率有视频 const media = []; if (hasMedia) { for (let j = 0; j < mediaCount; j++) { const isVideo = hasVideo && j === 0; // 第一个可能是视频 media.push({ type: isVideo ? 'video' : 'image', url: isVideo ? 'https://example.com/video-thumbnail.jpg' : `https://picsum.photos/300/200?random=${i}${j}` }); } } mockReviews.push({ nickname: nicknames[Math.floor(Math.random() * nicknames.length)], score: Math.floor(Math.random() * 2) + 4, // 4-5星 content: contents[Math.floor(Math.random() * contents.length)], creationTime: `2023-${Math.floor(Math.random() * 12) + 1}-${Math.floor(Math.random() * 28) + 1} ${Math.floor(Math.random() * 24)}:${Math.floor(Math.random() * 60)}`, media: media }); } return mockReviews; }; // 初始加载30条评价 let allReviews = generateMockReviews(100); // 模拟总共100条评价 let displayedReviews = 0; const reviewsPerLoad = 30; // 过滤出好评(4星及以上)且带媒体内容的评价 const filteredReviews = allReviews.filter(review => review.score >= 4 && review.media.length > 0 ); function renderReview(review) { const container = document.getElementById('reviews-list'); const reviewElement = document.createElement('div'); reviewElement.className = 'review-item'; // 用户头像使用昵称首字母 const avatarText = review.nickname.charAt(0); // 构建媒体内容HTML let mediaHTML = ''; if (review.media && review.media.length > 0) { mediaHTML = '<div class="media-container"><div class="media-grid">'; review.media.forEach((item, index) => { if (item.type === 'video') { mediaHTML += ` <div class="media-item"> <img src="${item.url}" alt="视频封面"> <div class="video-icon"></div> </div> `; } else { mediaHTML += ` <div class="media-item"> <img src="${item.url}" alt="评价图片"> </div> `; } }); mediaHTML += '</div></div>'; } reviewElement.innerHTML = ` <div class="review-header"> <div class="user-info"> <div class="user-avatar">${avatarText}</div> <div> <div class="user-name">${review.nickname}</div> <div class="rating">${'★'.repeat(review.score)}${'☆'.repeat(5 - review.score)}</div> </div> </div> <div class="review-time">${review.creationTime}</div> </div> <div class="review-content">${review.content}</div> ${mediaHTML} `; container.appendChild(reviewElement); } function loadMoreReviews() { const loadingElement = document.getElementById('loading'); const noMoreElement = document.getElementById('no-more'); loadingElement.style.display = 'block'; // 模拟网络请求延迟 setTimeout(() => { const remainingReviews = filteredReviews.length - displayedReviews; const loadCount = Math.min(reviewsPerLoad, remainingReviews); for (let i = 0; i < loadCount; i++) { if (displayedReviews < filteredReviews.length) { renderReview(filteredReviews[displayedReviews]); displayedReviews++; } } loadingElement.style.display = 'none'; if (displayedReviews >= filteredReviews.length) { noMoreElement.style.display = 'block'; } }, 800); } // 初始加载 document.addEventListener('DOMContentLoaded', () => { loadMoreReviews(); }); // 无限滚动加载 window.addEventListener('scroll', () => { const { scrollTop, scrollHeight, clientHeight } = document.documentElement; const loadingElement = document.getElementById('loading'); const noMoreElement = document.getElementById('no-more'); if (scrollTop + clientHeight >= scrollHeight - 100 && loadingElement.style.display === 'none' && noMoreElement.style.display !== 'block') { loadMoreReviews(); } }); </script> </body> </html>
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/4/23 20:54:22

Maestro性能基准测试终极指南:建立UI响应时间标准

Maestro性能基准测试终极指南&#xff1a;建立UI响应时间标准 【免费下载链接】maestro Painless Mobile UI Automation 项目地址: https://gitcode.com/gh_mirrors/ma/maestro 想要确保你的移动应用UI测试既快速又可靠&#xff1f;Maestro作为一款现代化的移动UI自动化…

作者头像 李华
网站建设 2026/4/24 2:40:27

Windows命令行安装器Scoop终极指南:告别繁琐软件管理

Windows命令行安装器Scoop终极指南&#xff1a;告别繁琐软件管理 【免费下载链接】Scoop A command-line installer for Windows. 项目地址: https://gitcode.com/gh_mirrors/scoop4/Scoop 还在为Windows软件安装的种种烦恼而头疼吗&#xff1f;&#x1f629; 那些没完没…

作者头像 李华
网站建设 2026/4/24 4:26:57

11个专业级Project模板助你项目管理事半功倍

11个专业级Project模板助你项目管理事半功倍 【免费下载链接】Project软件实用模板MPP文件11个场景模板 本仓库提供了一个名为“Project软件实用模板(MPP文件) 11个场景模板.zip”的资源文件下载。该文件包含了11个不同场景下的Project软件模板&#xff0c;适用于各种项目管理需…

作者头像 李华
网站建设 2026/4/23 12:19:35

Flink SQL Deduplication用 ROW_NUMBER 做流式去重

1. Deduplication 是什么&#xff0c;为什么流式场景尤其需要 Deduplication&#xff08;去重&#xff09;是在一组列&#xff08;去重键&#xff09;上移除重复行&#xff0c;只保留第一条或最后一条记录。典型原因是&#xff1a;上游 ETL 不是端到端 exactly-once&#xff0…

作者头像 李华
网站建设 2026/4/19 11:06:06

为什么前些年太多人挤破脑袋进网安?

在过去的十年间&#xff0c;网络安全行业几乎成了炙手可热的“黄金赛道”。不论是高校毕业生、转行的程序员&#xff0c;还是来自各行各业的青年人&#xff0c;都对“网络安全工程师”“白帽黑客”“安全研究员”这样的头衔趋之若鹜。有人说&#xff0c;这是政策推动的结果&…

作者头像 李华