room-join.html 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>加入房间 - LineFunQueue</title>
  7. <!-- Tailwind CSS -->
  8. <script src="https://cdn.tailwindcss.com"></script>
  9. <!-- FontAwesome -->
  10. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
  11. <!-- 自定义样式 -->
  12. <link rel="stylesheet" href="../css/custom.css">
  13. <style>
  14. .app-content {
  15. padding-bottom: 60px; /* 为底部导航栏留出空间 */
  16. }
  17. </style>
  18. </head>
  19. <body>
  20. <div class="iphone-frame">
  21. <!-- 引入状态栏 -->
  22. <iframe src="../components/status-bar.html" frameborder="0" scrolling="no" style="width:100%; height:44px; overflow:hidden;"></iframe>
  23. <!-- 导航栏 -->
  24. <div class="app-navbar">
  25. <div class="left-button" onclick="history.back()">
  26. <i class="fas fa-chevron-left mr-1"></i> 返回
  27. </div>
  28. <div class="title">加入房间</div>
  29. </div>
  30. <!-- 内容区域 -->
  31. <div class="app-content bg-white">
  32. <!-- 扫码提示 -->
  33. <div class="text-center py-8">
  34. <div class="w-24 h-24 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-4">
  35. <i class="fas fa-qrcode text-4xl text-primary"></i>
  36. </div>
  37. <h2 class="text-xl font-bold">扫描二维码加入房间</h2>
  38. <p class="text-sm text-gray-500 mt-2 px-8">请扫描主持人分享的二维码,或输入房间码手动加入</p>
  39. </div>
  40. <!-- 分隔线 -->
  41. <div class="relative flex py-5 items-center px-8">
  42. <div class="flex-grow border-t border-gray-200"></div>
  43. <span class="flex-shrink mx-4 text-gray-400 text-sm">或者</span>
  44. <div class="flex-grow border-t border-gray-200"></div>
  45. </div>
  46. <!-- 手动输入 -->
  47. <div class="px-8 pb-8">
  48. <h3 class="text-center font-medium mb-4">手动输入房间码</h3>
  49. <!-- 房间码输入框 -->
  50. <div class="flex justify-center mb-6">
  51. <div class="flex space-x-2">
  52. <input type="text" maxlength="1" class="w-12 h-12 border-2 border-primary rounded-md text-center text-xl font-bold room-code" value="A">
  53. <input type="text" maxlength="1" class="w-12 h-12 border-2 border-primary rounded-md text-center text-xl font-bold room-code" value="B">
  54. <input type="text" maxlength="1" class="w-12 h-12 border-2 border-primary rounded-md text-center text-xl font-bold room-code" value="C">
  55. <input type="text" maxlength="1" class="w-12 h-12 border-2 border-gray-300 rounded-md text-center text-xl font-bold focus:border-primary room-code" value="1">
  56. <input type="text" maxlength="1" class="w-12 h-12 border-2 border-gray-300 rounded-md text-center text-xl font-bold focus:border-primary room-code" value="2">
  57. <input type="text" maxlength="1" class="w-12 h-12 border-2 border-gray-300 rounded-md text-center text-xl font-bold focus:border-primary room-code" value="3">
  58. </div>
  59. </div>
  60. <!-- 加入按钮 -->
  61. <button id="joinBtn" class="app-button primary w-full flex justify-center">
  62. 加入房间
  63. </button>
  64. </div>
  65. <!-- 最近房间记录 -->
  66. <div class="p-4 bg-gray-50">
  67. <h3 class="text-sm font-medium text-gray-700 mb-3">最近加入的房间</h3>
  68. <div class="space-y-3">
  69. <!-- 房间记录1 -->
  70. <div class="bg-white p-3 rounded-lg shadow-sm flex justify-between items-center">
  71. <div>
  72. <div class="font-medium">欢乐海龟汤</div>
  73. <div class="flex items-center text-xs text-gray-500">
  74. <span class="mr-2">房间码: ABC123</span>
  75. <span>2分钟前</span>
  76. </div>
  77. </div>
  78. <button class="text-primary recent-room" data-room-code="ABC123" data-room-name="欢乐海龟汤">加入</button>
  79. </div>
  80. <!-- 房间记录2 -->
  81. <div class="bg-white p-3 rounded-lg shadow-sm flex justify-between items-center">
  82. <div>
  83. <div class="font-medium">周末猜谜</div>
  84. <div class="flex items-center text-xs text-gray-500">
  85. <span class="mr-2">房间码: XYZ456</span>
  86. <span>昨天</span>
  87. </div>
  88. </div>
  89. <button class="text-primary recent-room" data-room-code="XYZ456" data-room-name="周末猜谜">加入</button>
  90. </div>
  91. </div>
  92. </div>
  93. <!-- 扫码按钮 -->
  94. <div class="fixed bottom-24 right-6">
  95. <button class="w-14 h-14 rounded-full bg-primary text-white flex items-center justify-center shadow-lg">
  96. <i class="fas fa-camera text-xl"></i>
  97. </button>
  98. </div>
  99. </div>
  100. <!-- 引入底部导航栏 -->
  101. <iframe src="../components/nav-bar.html" frameborder="0" scrolling="no" style="width:100%; height:50px; overflow:hidden; position:fixed; bottom:0;"></iframe>
  102. </div>
  103. <script>
  104. document.addEventListener("DOMContentLoaded", function() {
  105. // 自动聚焦到下一个输入框
  106. const inputs = document.querySelectorAll('.room-code');
  107. inputs.forEach((input, index) => {
  108. input.addEventListener('keyup', function() {
  109. if (this.value.length === 1 && index < inputs.length - 1) {
  110. inputs[index + 1].focus();
  111. }
  112. });
  113. input.addEventListener('keydown', function(e) {
  114. if (e.key === 'Backspace' && this.value.length === 0 && index > 0) {
  115. inputs[index - 1].focus();
  116. }
  117. });
  118. });
  119. // 加入房间按钮
  120. const joinBtn = document.getElementById('joinBtn');
  121. joinBtn.addEventListener('click', function() {
  122. joinRoom();
  123. });
  124. // 快速加入最近的房间
  125. const recentRoomBtns = document.querySelectorAll('.recent-room');
  126. recentRoomBtns.forEach(btn => {
  127. btn.addEventListener('click', function() {
  128. const roomCode = this.getAttribute('data-room-code');
  129. const roomName = this.getAttribute('data-room-name');
  130. joinRoomWithCode(roomCode, roomName);
  131. });
  132. });
  133. // 加入房间函数
  134. function joinRoom() {
  135. let roomCode = '';
  136. inputs.forEach(input => {
  137. roomCode += input.value;
  138. });
  139. joinRoomWithCode(roomCode, '');
  140. }
  141. // 使用指定房间码加入
  142. function joinRoomWithCode(roomCode, roomName) {
  143. // 保存加入的房间信息到本地存储(模拟)
  144. const roomData = {
  145. id: roomCode,
  146. name: roomName || `房间 ${roomCode}`,
  147. gameType: '海龟汤',
  148. maxPlayers: 6,
  149. currentPlayers: 3,
  150. isHost: false,
  151. status: 'waiting'
  152. };
  153. localStorage.setItem('currentRoom', JSON.stringify(roomData));
  154. // 跳转到等待房间
  155. window.location.href = 'room-waiting.html';
  156. }
  157. });
  158. </script>
  159. </body>
  160. </html>