- + - - - - {{ item.title }} - {{ item.desc }} + + + + + {{ item.unreadCount > 99 ? '99+' : item.unreadCount }} + + + + + + {{ item.name }} + {{ item.lastMessageTime }} + + + {{ item.lastMessage }} - - - 暂无咨询服务 + + + 暂无咨询消息 + 学生咨询后会显示在这里 @@ -38,14 +48,6 @@ - - @@ -61,41 +63,103 @@ export default { }, data() { return { - showModal: false, - modalContent: '', - consultationList: [ + // 聊天会话列表(模拟数据) + chatList: [ { id: 1, - title: "智能问答", - desc: "AI智能机器人为您解答", - icon: "/static/common/icon/robot.png", - type: "ai" + userId: 'user_001', + name: '山东考生1', + avatar: '/static/avatar/default-avatar.png', + lastMessage: '你好,在吗', + lastMessageTime: '09:50', + unreadCount: 2, }, { id: 2, - title: "招生咨询", - desc: "招生相关问题咨询", - icon: "/static/common/icon/admissions.png", - type: "admissions" + userId: 'user_002', + name: '河北考生2', + avatar: '/static/avatar/default-avatar.png', + lastMessage: '我是保研的是否了解到了后续计划,谁信谁的呢们爱国士...', + lastMessageTime: '09:50', + unreadCount: 0, }, { id: 3, - title: "教务咨询", - desc: "教务相关问题咨询", - icon: "/static/common/icon/academic.png", - type: "academic" + userId: 'user_003', + name: '山东考生34523', + avatar: '/static/avatar/default-avatar.png', + lastMessage: '请问,学校宿舍几人间?', + lastMessageTime: '09:50', + unreadCount: 1, + }, + { + id: 4, + userId: 'user_004', + name: '招办王老师', + avatar: '/static/avatar/default-avatar.png', + lastMessage: '你好,在吗', + lastMessageTime: '09:50', + unreadCount: 0, + }, + { + id: 5, + userId: 'user_005', + name: '山东考生34523', + avatar: '/static/avatar/default-avatar.png', + lastMessage: '请问,学校宿舍几人间?', + lastMessageTime: '09:50', + unreadCount: 3, + }, + { + id: 6, + userId: 'user_006', + name: '招办王老师', + avatar: '/static/avatar/default-avatar.png', + lastMessage: '你好,在吗', + lastMessageTime: '09:50', + unreadCount: 0, }, ], }; }, + + onLoad() { + // 加载聊天列表 + this.loadChatList(); + }, + + onShow() { + // 页面显示时刷新列表 + this.refreshChatList(); + }, + methods: { handleTabChange(path, index) { console.log("切换到标签页:", path, index); }, - handleConsultation(item) { - // 这里可以跳转到具体的咨询页面 - this.modalContent = `即将进入${item.title}`; - this.showModal = true; + + // 打开聊天页面 + openChat(item) { + console.log('打开聊天:', item); + uni.navigateTo({ + url: `/pages/chat/chat-detail?userId=${item.userId}&name=${item.name}` + }); + }, + + // 加载聊天列表 + loadChatList() { + // TODO: 接入真实API + // this.$u.api.getChatList().then(res => { + // this.chatList = res.data; + // }); + + console.log('[在线咨询] 加载聊天列表'); + }, + + // 刷新聊天列表 + refreshChatList() { + console.log('[在线咨询] 刷新聊天列表'); + // TODO: 刷新数据 }, }, }; @@ -167,58 +231,116 @@ export default { z-index: 100; } -.consultation-item { - background-color: #fff; - padding: 20px; - margin-bottom: 10px; - border-radius: 12px; - box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05); +/* ===== 聊天列表项 ===== */ +.chat-item { + display: flex; + padding: 15px; + background: #fff; + border-bottom: 1rpx solid #f0f0f0; + transition: background-color 0.2s; +} + +.chat-item:active { + background-color: #f5f5f5; +} + +.chat-avatar-wrapper { + position: relative; + margin-right: 12px; +} + +.chat-avatar { + width: 50px; + height: 50px; + border-radius: 8px; + background-color: #e8e8e8; +} + +.unread-badge { + position: absolute; + top: -5px; + right: -5px; + min-width: 18px; + height: 18px; + padding: 0 5px; + background: #ff4d4f; + border-radius: 9px; + color: #fff; + font-size: 11px; + line-height: 18px; + text-align: center; + border: 2px solid #fff; +} + +.chat-content { + flex: 1; + min-width: 0; + display: flex; + flex-direction: column; + justify-content: space-between; +} + +.chat-header { display: flex; justify-content: space-between; align-items: center; - cursor: pointer; - transition: all 0.3s; -} - -.consultation-item:active { - background-color: #f8f8f8; -} - -.item-left { - display: flex; - align-items: center; - flex: 1; -} - -.item-icon { - width: 48px; - height: 48px; - margin-right: 15px; - border-radius: 8px; -} - -.item-info { - display: flex; - flex-direction: column; -} - -.item-title { - font-size: 16px; - font-weight: 500; - color: #333; margin-bottom: 5px; } -.item-desc { +.chat-name { + font-size: 16px; + font-weight: 500; + color: #333; + max-width: 200px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.chat-time { + font-size: 12px; + color: #999; + flex-shrink: 0; +} + +.chat-preview { + display: flex; + align-items: center; +} + +.preview-text { + font-size: 13px; + color: #999; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + flex: 1; +} + +/* ===== 空状态 ===== */ +.empty-container { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + padding: 100px 20px; +} + +.empty-image { + width: 120px; + height: 120px; + margin-bottom: 20px; +} + +.empty-text { + font-size: 16px; + color: #666; + margin-bottom: 8px; +} + +.empty-hint { font-size: 13px; color: #999; } - -.empty-tip { - text-align: center; - padding: 50px 20px; - color: #999; - font-size: 14px; -} diff --git a/pages/test/websocket-test.vue b/pages/test/websocket-test.vue new file mode 100644 index 0000000..02e6fa9 --- /dev/null +++ b/pages/test/websocket-test.vue @@ -0,0 +1,533 @@ + + + + + +