| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441 |
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
- <title>消息</title>
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
- <style>
- * {
- margin: 0;
- padding: 0;
- box-sizing: border-box;
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
- }
-
- body {
- background-color: #f5f5f5;
- color: #333;
- font-size: 14px;
- line-height: 1.5;
- max-width: 100vw;
- overflow-x: hidden;
- }
-
- .container {
- width: 100%;
- max-width: 375px;
- margin: 0 auto;
- background-color: #fff;
- min-height: 100vh;
- position: relative;
- padding-bottom: 60px;
- }
-
- /* 状态栏 */
- .status-bar {
- height: 44px;
- background-color: #fff;
- display: flex;
- align-items: center;
- justify-content: center;
- position: relative;
- border-bottom: 1px solid #eee;
- }
-
- .status-bar .title {
- font-size: 17px;
- font-weight: 600;
- color: #000;
- }
-
- .status-bar .action {
- position: absolute;
- right: 15px;
- color: #3478f6;
- font-size: 15px;
- }
-
- /* 消息列表 */
- .message-list {
- flex: 1;
- overflow-y: auto;
- -webkit-overflow-scrolling: touch;
- padding-bottom: 60px;
- }
-
- .message-item {
- display: flex;
- padding: 12px 15px;
- background-color: #fff;
- border-bottom: 1px solid #f0f0f0;
- position: relative;
- }
-
- .message-item.unread {
- background-color: #f9f9f9;
- }
-
- .message-avatar {
- width: 44px;
- height: 44px;
- border-radius: 6px;
- margin-right: 12px;
- flex-shrink: 0;
- display: flex;
- align-items: center;
- justify-content: center;
- background-color: #f0f0f0;
- color: #999;
- font-size: 20px;
- }
-
- .message-content {
- flex: 1;
- min-width: 0;
- }
-
- .message-header {
- display: flex;
- justify-content: space-between;
- margin-bottom: 4px;
- }
-
- .message-sender {
- font-weight: 600;
- font-size: 16px;
- color: #333;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- max-width: 60%;
- }
-
- .message-time {
- font-size: 12px;
- color: #999;
- }
-
- .message-preview {
- font-size: 14px;
- color: #666;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
-
- .unread-badge {
- position: absolute;
- right: 15px;
- top: 50%;
- transform: translateY(-50%);
- width: 8px;
- height: 8px;
- border-radius: 50%;
- background-color: #f44336;
- }
-
- .official-tag {
- display: inline-block;
- padding: 1px 4px;
- background-color: #3478f6;
- color: #fff;
- border-radius: 2px;
- font-size: 10px;
- margin-left: 4px;
- transform: translateY(-1px);
- }
-
- /* 底部导航栏 - 使用"我的"页面样式 */
- .bottom-nav {
- position: fixed;
- bottom: 0;
- left: 0;
- right: 0;
- background-color: white;
- display: flex;
- justify-content: space-around;
- padding: 8px 0;
- box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
- max-width: 375px;
- margin: 0 auto;
- }
-
- .nav-item {
- display: flex;
- flex-direction: column;
- align-items: center;
- color: #666;
- text-decoration: none;
- font-size: 12px;
- }
-
- .nav-icon {
- font-size: 22px;
- margin-bottom: 3px;
- }
-
- .nav-item.active {
- color: #1971c2;
- }
-
- /* 弹窗 */
- .modal {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background-color: rgba(0, 0, 0, 0.5);
- display: flex;
- align-items: center;
- justify-content: center;
- z-index: 1000;
- display: none;
- }
-
- .modal-content {
- background-color: #fff;
- width: 80%;
- max-width: 300px;
- border-radius: 12px;
- overflow: hidden;
- animation: modalFadeIn 0.3s;
- }
-
- .modal-body {
- padding: 20px;
- text-align: center;
- font-size: 16px;
- line-height: 1.4;
- }
-
- .modal-footer {
- display: flex;
- border-top: 1px solid #eee;
- }
-
- .modal-button {
- flex: 1;
- padding: 12px;
- text-align: center;
- color: #666;
- font-size: 16px;
- }
-
- .modal-button.primary {
- color: #3478f6;
- font-weight: 600;
- border-left: 1px solid #eee;
- }
-
- @keyframes modalFadeIn {
- from {
- opacity: 0;
- transform: translateY(20px);
- }
- to {
- opacity: 1;
- transform: translateY(0);
- }
- }
- </style>
- </head>
- <body>
- <div class="container">
- <!-- 状态栏 -->
- <div class="status-bar">
- <div class="title">消息</div>
- <div class="action" id="markAllRead">全部已读</div>
- </div>
-
- <!-- 消息列表 -->
- <div class="message-list">
- <!-- 订单消息 -->
- <div class="message-item unread" data-id="1">
- <div class="message-avatar">
- <i class="bi bi-receipt"></i>
- </div>
- <div class="message-content">
- <div class="message-header">
- <div class="message-sender">订单消息</div>
- <div class="message-time">3分钟前</div>
- </div>
- <div class="message-preview">你的订单已完结</div>
- </div>
- <div class="unread-badge"></div>
- </div>
-
- <!-- 互动消息 -->
- <div class="message-item unread" data-id="2">
- <div class="message-avatar">
- <i class="bi bi-chat-left-text"></i>
- </div>
- <div class="message-content">
- <div class="message-header">
- <div class="message-sender">互动消息</div>
- <div class="message-time">5小时前</div>
- </div>
- <div class="message-preview">@用户1008600评论了你的内容</div>
- </div>
- <div class="unread-badge"></div>
- </div>
-
- <!-- 系统消息 -->
- <div class="message-item unread" data-id="3">
- <div class="message-avatar">
- <i class="bi bi-gear"></i>
- </div>
- <div class="message-content">
- <div class="message-header">
- <div class="message-sender">系统消息 <span class="official-tag">官方</span></div>
- <div class="message-time">23小时前</div>
- </div>
- <div class="message-preview">你提交的个人信息审核通过</div>
- </div>
- <div class="unread-badge"></div>
- </div>
-
- <!-- 用户消息1 -->
- <div class="message-item unread" data-id="4">
- <div class="message-avatar">
- <i class="bi bi-person"></i>
- </div>
- <div class="message-content">
- <div class="message-header">
- <div class="message-sender">果汁分你一半</div>
- <div class="message-time">2天前</div>
- </div>
- <div class="message-preview">[游记消息]</div>
- </div>
- <div class="unread-badge"></div>
- </div>
-
- <!-- 用户消息2 -->
- <div class="message-item" data-id="5">
- <div class="message-avatar">
- <i class="bi bi-person"></i>
- </div>
- <div class="message-content">
- <div class="message-header">
- <div class="message-sender">飞来飞去</div>
- <div class="message-time">1周前</div>
- </div>
- <div class="message-preview">老炮来北京玩啊~</div>
- </div>
- </div>
- </div>
-
- <!-- 底部导航栏 - 使用"我的"页面样式 -->
- <div class="bottom-nav">
- <a href="#" class="nav-item">
- <i class="bi bi-house-door nav-icon"></i>
- <span>首页</span>
- </a>
- <a href="#" class="nav-item">
- <i class="bi bi-robot nav-icon"></i>
- <span>客服</span>
- </a>
- <a href="#" class="nav-item active">
- <i class="bi bi-chat-dots nav-icon"></i>
- <span>消息</span>
- <span style="position: absolute; top: 2px; right: 20px; background-color: red; width: 8px; height: 8px; border-radius: 50%;"></span>
- </a>
- <a href="#" class="nav-item">
- <i class="bi bi-person nav-icon"></i>
- <span>我的</span>
- </a>
- </div>
- </div>
-
- <!-- 全部已读弹窗 -->
- <div class="modal" id="confirmModal">
- <div class="modal-content">
- <div class="modal-body">
- 标记所有消息为已读?
- </div>
- <div class="modal-footer">
- <div class="modal-button" id="cancelBtn">取消</div>
- <div class="modal-button primary" id="confirmBtn">确定</div>
- </div>
- </div>
- </div>
-
- <script>
- document.addEventListener('DOMContentLoaded', function() {
- // 点击消息项
- const messageItems = document.querySelectorAll('.message-item');
- messageItems.forEach(item => {
- item.addEventListener('click', function() {
- if (this.classList.contains('unread')) {
- this.classList.remove('unread');
- const badge = this.querySelector('.unread-badge');
- if (badge) badge.remove();
-
- // 检查是否还有未读消息
- updateUnreadStatus();
- }
- // 这里可以添加跳转到具体消息详情的逻辑
- });
- });
-
- // 全部已读按钮
- const markAllReadBtn = document.getElementById('markAllRead');
- const confirmModal = document.getElementById('confirmModal');
- const cancelBtn = document.getElementById('cancelBtn');
- const confirmBtn = document.getElementById('confirmBtn');
-
- markAllReadBtn.addEventListener('click', function() {
- confirmModal.style.display = 'flex';
- });
-
- cancelBtn.addEventListener('click', function() {
- confirmModal.style.display = 'none';
- });
-
- confirmBtn.addEventListener('click', function() {
- // 移除所有未读标记
- document.querySelectorAll('.message-item.unread').forEach(item => {
- item.classList.remove('unread');
- const badge = item.querySelector('.unread-badge');
- if (badge) badge.remove();
- });
-
- // 更新未读状态
- updateUnreadStatus();
-
- confirmModal.style.display = 'none';
- });
-
- // 点击模态框外部关闭
- confirmModal.addEventListener('click', function(e) {
- if (e.target === this) {
- this.style.display = 'none';
- }
- });
-
- // 更新未读状态
- function updateUnreadStatus() {
- const unreadCount = document.querySelectorAll('.message-item.unread').length;
- const navBadge = document.querySelector('.nav-item.active span[style]');
-
- if (unreadCount === 0 && navBadge) {
- navBadge.remove();
- } else if (unreadCount > 0 && !navBadge) {
- // 如果还有未读消息但底部导航没有红点,则添加红点
- const navMessage = document.querySelector('.nav-item.active');
- const badge = document.createElement('span');
- badge.style.position = 'absolute';
- badge.style.top = '2px';
- badge.style.right = '20px';
- badge.style.backgroundColor = 'red';
- badge.style.width = '8px';
- badge.style.height = '8px';
- badge.style.borderRadius = '50%';
- navMessage.appendChild(badge);
- }
- }
- });
- </script>
- </body>
- </html>
|