room-waiting-player.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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. .share-btn {
  18. position: relative;
  19. }
  20. .share-options {
  21. display: none;
  22. position: absolute;
  23. top: 100%;
  24. right: 0;
  25. width: 200px;
  26. background: white;
  27. border-radius: 8px;
  28. box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  29. padding: 8px 0;
  30. z-index: 100;
  31. }
  32. .share-option {
  33. padding: 8px 16px;
  34. display: flex;
  35. align-items: center;
  36. }
  37. .share-option i {
  38. width: 24px;
  39. margin-right: 8px;
  40. text-align: center;
  41. }
  42. .share-option:hover {
  43. background-color: #f3f4f6;
  44. }
  45. .user-status.ready {
  46. color: var(--color-primary);
  47. }
  48. .user-status.not-ready {
  49. color: #9ca3af;
  50. }
  51. .host-badge {
  52. background-color: #FFA000;
  53. color: white;
  54. }
  55. .player-badge {
  56. background-color: #0EA5E9;
  57. color: white;
  58. }
  59. </style>
  60. </head>
  61. <body>
  62. <div class="iphone-frame">
  63. <!-- 引入状态栏 -->
  64. <iframe src="../components/status-bar.html" frameborder="0" scrolling="no" style="width:100%; height:44px; overflow:hidden;"></iframe>
  65. <!-- 导航栏 -->
  66. <div class="app-navbar">
  67. <div class="left-button" onclick="history.back()">
  68. <i class="fas fa-chevron-left mr-1"></i> 返回
  69. </div>
  70. <div class="title" id="roomName">欢乐海龟汤</div>
  71. <div class="right-button">
  72. <i class="fas fa-ellipsis-v"></i>
  73. </div>
  74. </div>
  75. <!-- 内容区域 -->
  76. <div class="app-content bg-white">
  77. <!-- 房间状态 -->
  78. <div class="bg-sky-100 p-3 text-center">
  79. <div class="text-sky-700 font-medium">等待开始...</div>
  80. <div class="text-xs text-sky-600 mt-1"><span id="playerCount">3</span>/10人已加入,等待主持人开始游戏</div>
  81. </div>
  82. <!-- 房间信息和分享 -->
  83. <div class="p-3 border-b border-gray-200">
  84. <div class="flex justify-between items-center">
  85. <div class="flex items-center">
  86. <div class="font-bold text-lg mr-2" id="roomCode">ABC123</div>
  87. <button id="copyBtn" class="text-xs text-gray-500 border border-gray-300 rounded px-1.5 py-0.5 flex items-center">
  88. <i class="far fa-copy mr-1"></i> 复制
  89. </button>
  90. </div>
  91. <div class="share-btn relative">
  92. <button id="shareBtn" class="bg-sky-100 text-sky-700 py-1 px-3 rounded-full text-sm flex items-center">
  93. <i class="fas fa-share-alt mr-1"></i> 邀请好友
  94. </button>
  95. <div class="share-options" id="shareOptions">
  96. <div class="share-option">
  97. <i class="fab fa-weixin text-green-500"></i>
  98. <span>微信好友</span>
  99. </div>
  100. <div class="share-option">
  101. <i class="fab fa-qq text-blue-500"></i>
  102. <span>QQ好友</span>
  103. </div>
  104. <div class="share-option">
  105. <i class="fas fa-comment text-yellow-500"></i>
  106. <span>短信</span>
  107. </div>
  108. <div class="share-option">
  109. <i class="fas fa-link text-gray-500"></i>
  110. <span>复制链接</span>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. </div>
  116. <!-- 游戏信息 -->
  117. <div class="p-3 flex items-center border-b border-gray-200">
  118. <div class="w-12 h-12 rounded-lg overflow-hidden mr-3">
  119. <img src="https://images.unsplash.com/photo-1582845512747-e42001c95638?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=48&h=48&q=80" class="w-full h-full object-cover" alt="海龟汤">
  120. </div>
  121. <div>
  122. <h3 class="font-medium">海龟汤</h3>
  123. <div class="text-xs text-gray-500">
  124. <span>预计游戏时长: 30分钟</span>
  125. </div>
  126. </div>
  127. </div>
  128. <!-- 玩家列表 -->
  129. <div class="p-3">
  130. <h3 class="font-medium mb-2">玩家 (<span id="currentPlayers">3</span>/<span id="maxPlayers">10</span>)</h3>
  131. <div class="space-y-2">
  132. <!-- 主持人 -->
  133. <div class="flex items-center p-2 bg-amber-50 rounded-lg">
  134. <div class="w-10 h-10 rounded-full overflow-hidden mr-3">
  135. <img src="https://images.unsplash.com/photo-1494790108377-be9c29b29330?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=40&h=40&q=80" class="w-full h-full object-cover" alt="用户头像">
  136. </div>
  137. <div class="flex-1">
  138. <div class="font-medium flex items-center">
  139. 小明
  140. <span class="ml-2 text-xs host-badge px-1.5 py-0.5 rounded-full">主持人</span>
  141. </div>
  142. <div class="text-xs text-amber-600 user-status ready">准备中...</div>
  143. </div>
  144. </div>
  145. <!-- 玩家1 -->
  146. <div class="flex items-center p-2 bg-gray-50 rounded-lg">
  147. <div class="w-10 h-10 rounded-full overflow-hidden mr-3">
  148. <img src="https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=40&h=40&q=80" class="w-full h-full object-cover" alt="用户头像">
  149. </div>
  150. <div class="flex-1">
  151. <div class="font-medium">小红</div>
  152. <div class="text-xs user-status ready">
  153. <i class="fas fa-check-circle mr-1"></i> 已准备
  154. </div>
  155. </div>
  156. </div>
  157. <!-- 玩家2 (我) -->
  158. <div id="player-view" class="flex items-center p-2 bg-sky-50 rounded-lg border border-sky-200">
  159. <div class="w-10 h-10 rounded-full overflow-hidden mr-3 border-2 border-sky-500">
  160. <img src="https://images.unsplash.com/photo-1527980965255-d3b416303d12?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=40&h=40&q=80" class="w-full h-full object-cover" alt="用户头像">
  161. </div>
  162. <div class="flex-1">
  163. <div class="font-medium flex items-center">
  164. <span class="ml-2 text-xs player-badge px-1.5 py-0.5 rounded-full">我</span>
  165. </div>
  166. <div class="text-xs user-status not-ready" id="myStatus">
  167. <i class="fas fa-clock mr-1"></i> 等待准备
  168. </div>
  169. </div>
  170. </div>
  171. </div>
  172. </div>
  173. <!-- 游戏说明 -->
  174. <div class="p-3 bg-gray-50 mb-3">
  175. <h3 class="font-medium mb-2 text-sm">游戏说明</h3>
  176. <p class="text-xs text-gray-700">
  177. 海龟汤是一种解谜类游戏,游戏开始时,主持人会给出一个离奇古怪的情境(汤面),玩家需要通过提问获取更多线索,最终解开谜题找出真相(汤底)。
  178. </p>
  179. </div>
  180. <!-- 玩家视图的按钮 -->
  181. <div id="player-controls" class="p-3 sticky bottom-0 bg-white border-t border-gray-200">
  182. <button id="readyBtn" class="app-button primary w-full flex justify-center items-center">
  183. <i class="fas fa-check-circle mr-1"></i> 我已准备
  184. </button>
  185. </div>
  186. </div>
  187. <!-- 引入底部导航栏 -->
  188. <iframe src="../components/nav-bar.html" frameborder="0" scrolling="no" style="width:100%; height:50px; overflow:hidden; position:fixed; bottom:0;"></iframe>
  189. </div>
  190. <script>
  191. document.addEventListener("DOMContentLoaded", function() {
  192. // 检查是否为玩家
  193. const currentRoom = JSON.parse(localStorage.getItem('currentRoom') || '{}');
  194. if (currentRoom.isHost) {
  195. // 如果是主持人,跳转到主持人等待页面
  196. window.location.href = 'room-waiting.html';
  197. return;
  198. }
  199. // 填充房间信息
  200. document.getElementById('roomName').textContent = currentRoom.name || '欢乐海龟汤';
  201. document.getElementById('roomCode').textContent = currentRoom.id || 'ABC123';
  202. document.getElementById('playerCount').textContent = currentRoom.currentPlayers || 3;
  203. document.getElementById('currentPlayers').textContent = currentRoom.currentPlayers || 3;
  204. document.getElementById('maxPlayers').textContent = currentRoom.maxPlayers || 10;
  205. // 分享按钮功能
  206. const shareBtn = document.getElementById('shareBtn');
  207. const shareOptions = document.getElementById('shareOptions');
  208. shareBtn.addEventListener('click', function() {
  209. if (shareOptions.style.display === 'block') {
  210. shareOptions.style.display = 'none';
  211. } else {
  212. shareOptions.style.display = 'block';
  213. }
  214. });
  215. // 点击其他地方关闭分享选项
  216. document.addEventListener('click', function(e) {
  217. if (!shareBtn.contains(e.target) && !shareOptions.contains(e.target)) {
  218. shareOptions.style.display = 'none';
  219. }
  220. });
  221. // 复制房间码功能
  222. const copyBtn = document.getElementById('copyBtn');
  223. copyBtn.addEventListener('click', function() {
  224. const roomCode = document.getElementById('roomCode').textContent;
  225. navigator.clipboard.writeText(roomCode).then(function() {
  226. copyBtn.innerHTML = '<i class="fas fa-check mr-1"></i> 已复制';
  227. setTimeout(function() {
  228. copyBtn.innerHTML = '<i class="far fa-copy mr-1"></i> 复制';
  229. }, 2000);
  230. });
  231. });
  232. // 准备按钮功能
  233. const readyBtn = document.getElementById('readyBtn');
  234. const myStatus = document.getElementById('myStatus');
  235. let isReady = false;
  236. readyBtn.addEventListener('click', function() {
  237. isReady = !isReady;
  238. if (isReady) {
  239. // 已准备状态
  240. myStatus.classList.remove('not-ready');
  241. myStatus.classList.add('ready');
  242. myStatus.innerHTML = '<i class="fas fa-check-circle mr-1"></i> 已准备';
  243. readyBtn.innerHTML = '<i class="fas fa-times-circle mr-1"></i> 取消准备';
  244. readyBtn.classList.remove('primary');
  245. readyBtn.classList.add('secondary');
  246. } else {
  247. // 未准备状态
  248. myStatus.classList.remove('ready');
  249. myStatus.classList.add('not-ready');
  250. myStatus.innerHTML = '<i class="fas fa-clock mr-1"></i> 等待准备';
  251. readyBtn.innerHTML = '<i class="fas fa-check-circle mr-1"></i> 我已准备';
  252. readyBtn.classList.remove('secondary');
  253. readyBtn.classList.add('primary');
  254. }
  255. // 保存准备状态(模拟)
  256. currentRoom.isReady = isReady;
  257. localStorage.setItem('currentRoom', JSON.stringify(currentRoom));
  258. });
  259. });
  260. </script>
  261. </body>
  262. </html>