|
|
@@ -0,0 +1,949 @@
|
|
|
+<!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, viewport-fit=cover">
|
|
|
+ <title>月挑战赛 - 运动版</title>
|
|
|
+ <!-- 本地调试保留 mock_flutter.js,正式接入时移除 -->
|
|
|
+ <!-- <script src="./mock_flutter.js"></script> -->
|
|
|
+ <script src="./bridge.js"></script>
|
|
|
+ <script src="./api.js"></script>
|
|
|
+ <script src="./js/multiavatar.min.js"></script>
|
|
|
+ <link href="./css/all.min.css" rel="stylesheet">
|
|
|
+ <style>
|
|
|
+ :root {
|
|
|
+ --sport-bg: #0f0f0f;
|
|
|
+ --sport-card: #1e1e1e;
|
|
|
+ --sport-accent: #ccff00; /* Neon Green */
|
|
|
+ --sport-secondary: #00ccff; /* Electric Blue */
|
|
|
+ --sport-text: #ffffff;
|
|
|
+ --sport-dim: #888;
|
|
|
+ --footer-bg: #1a1a1a;
|
|
|
+ }
|
|
|
+
|
|
|
+ * {
|
|
|
+ box-sizing: border-box;
|
|
|
+ margin: 0;
|
|
|
+ padding: 0;
|
|
|
+ font-family: 'Segoe UI', 'Roboto', sans-serif;
|
|
|
+ -webkit-tap-highlight-color: transparent;
|
|
|
+ user-select: none;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* detail.html 应该全屏显示,无需圆角 */
|
|
|
+ html {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ overflow: hidden; /* 确保全屏不滚动,由内部 list-container 滚动 */
|
|
|
+ }
|
|
|
+
|
|
|
+ body {
|
|
|
+ background: var(--sport-bg);
|
|
|
+ width: 100%;
|
|
|
+ height: 100%; /* 占满全屏 */
|
|
|
+ margin: 0;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ color: var(--sport-text);
|
|
|
+ }
|
|
|
+
|
|
|
+ /* 顶部 Header */
|
|
|
+ .header-area {
|
|
|
+ height: 200px;
|
|
|
+ background: var(--sport-card);
|
|
|
+ padding: 20px;
|
|
|
+ padding-top: max(30px, env(safe-area-inset-top)); /* 调整顶部填充,避开手机状态栏 */
|
|
|
+ position: relative; flex-shrink: 0;
|
|
|
+ z-index: 1;
|
|
|
+ /* 底部斜切 */
|
|
|
+ clip-path: polygon(0 0, 100% 0, 100% 85%, 0 100%);
|
|
|
+ border-bottom: 2px solid #333;
|
|
|
+ }
|
|
|
+
|
|
|
+ .nav-bar { display: flex; justify-content: space-between; align-items: center; margin-top: 5px; }
|
|
|
+
|
|
|
+ .icon-btn {
|
|
|
+ width: 36px; height: 36px;
|
|
|
+ background: #333;
|
|
|
+ border-radius: 8px; /* 方形倒角 */
|
|
|
+ display: flex; align-items: center; justify-content: center;
|
|
|
+ cursor: pointer; border: 1px solid #444;
|
|
|
+ transform: skewX(-10deg);
|
|
|
+ }
|
|
|
+ .icon-btn i { transform: skewX(10deg); } /* 反向纠正图标 */
|
|
|
+
|
|
|
+ .month-select {
|
|
|
+ font-size: 18px; font-weight: 900; font-style: italic;
|
|
|
+ display: flex; align-items: center; gap: 8px; cursor: pointer;
|
|
|
+ color: var(--sport-text);
|
|
|
+ text-transform: uppercase;
|
|
|
+ }
|
|
|
+ .month-select span { border-bottom: 2px solid var(--sport-accent); padding-bottom: 2px; }
|
|
|
+
|
|
|
+ /* 仪表盘卡片 */
|
|
|
+ .dashboard-card {
|
|
|
+ margin-top: 15px;
|
|
|
+ background: #000;
|
|
|
+ border-radius: 0;
|
|
|
+ padding: 15px 20px;
|
|
|
+ border-left: 4px solid var(--sport-accent);
|
|
|
+ box-shadow: 0 10px 30px rgba(0,0,0,0.5);
|
|
|
+ position: relative;
|
|
|
+ z-index: 5;
|
|
|
+ transform: skewX(-5deg);
|
|
|
+ margin-left: 10px; margin-right: 10px;
|
|
|
+ }
|
|
|
+ /* 内容反向纠正 */
|
|
|
+ .dashboard-card > * { transform: skewX(5deg); }
|
|
|
+
|
|
|
+ .dash-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
|
|
|
+ .dash-title { font-size: 14px; font-weight: bold; display: flex; align-items: center; gap: 8px; color: #aaa; text-transform: uppercase; letter-spacing: 1px; }
|
|
|
+ .dash-icon { color: var(--sport-accent); }
|
|
|
+
|
|
|
+ .dash-badge {
|
|
|
+ background: transparent;
|
|
|
+ color: var(--sport-accent);
|
|
|
+ font-size: 14px; font-weight: 900; font-style: italic;
|
|
|
+ padding: 2px 8px;
|
|
|
+ border: 1px solid var(--sport-accent);
|
|
|
+ }
|
|
|
+
|
|
|
+ .dash-badge.completed { background: var(--sport-accent); color: #000; }
|
|
|
+
|
|
|
+ .trophy-track-container { position: relative; display: flex; justify-content: space-between; align-items: center; padding: 0 5px; margin-top: 10px;}
|
|
|
+
|
|
|
+ /* 进度条改为分段格子 */
|
|
|
+ .track-bg-grid {
|
|
|
+ position: absolute; top: 50%; left: 10px; right: 10px; height: 6px;
|
|
|
+ background: repeating-linear-gradient(90deg, #222, #222 4px, transparent 4px, transparent 8px);
|
|
|
+ transform: translateY(-50%); z-index: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .track-line-active {
|
|
|
+ position: absolute; top: 50%; left: 10px;
|
|
|
+ width: 25%;
|
|
|
+ height: 6px; background: var(--sport-accent);
|
|
|
+ transform: translateY(-50%); z-index: 0;
|
|
|
+ box-shadow: 0 0 10px var(--sport-accent);
|
|
|
+ transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ .trophy-item {
|
|
|
+ position: relative; z-index: 1; width: 24px; height: 24px;
|
|
|
+ background: #222; border: 1px solid #444;
|
|
|
+ transform: rotate(45deg); /* 菱形节点 */
|
|
|
+ display: flex; justify-content: center; align-items: center;
|
|
|
+ color: #666; font-size: 10px;
|
|
|
+ transition: all 0.4s;
|
|
|
+ }
|
|
|
+
|
|
|
+ .trophy-item i { transform: rotate(-45deg); } /* 图标回正 */
|
|
|
+
|
|
|
+ .trophy-item.active {
|
|
|
+ background: #000; border-color: var(--sport-accent); color: var(--sport-accent);
|
|
|
+ box-shadow: 0 0 8px var(--sport-accent);
|
|
|
+ }
|
|
|
+
|
|
|
+ .trophy-item.final { width: 32px; height: 32px; border-color: #666; font-size: 14px; }
|
|
|
+
|
|
|
+ .trophy-item.final.active {
|
|
|
+ background: var(--sport-accent); color: #000; border: none;
|
|
|
+ box-shadow: 0 0 20px var(--sport-accent);
|
|
|
+ }
|
|
|
+
|
|
|
+ /* 领奖台 */
|
|
|
+ .podium-wrap {
|
|
|
+ height: 130px;
|
|
|
+ display: flex; justify-content: center; align-items: flex-end;
|
|
|
+ margin-top: -40px;
|
|
|
+ position: relative;
|
|
|
+ z-index: 10;
|
|
|
+ padding-bottom: 0px;
|
|
|
+ }
|
|
|
+ .p-col { display: flex; flex-direction: column; align-items: center; width: 30%; position: relative;}
|
|
|
+ .p-2 { z-index: 2; margin-right: -8px; }
|
|
|
+ .p-1 { z-index: 3; }
|
|
|
+ .p-3 { z-index: 1; margin-left: -8px; }
|
|
|
+
|
|
|
+ /* 六边形头像遮罩 */
|
|
|
+ .p-img {
|
|
|
+ width: 48px; height: 48px;
|
|
|
+ background: #222; margin-bottom: -15px; position: relative; z-index: 2;
|
|
|
+ clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
|
|
|
+ display: flex; justify-content: center; align-items: center;
|
|
|
+ }
|
|
|
+ .p-img img { width: 100%; height: 100%; object-fit: cover; }
|
|
|
+ /* 边框模拟 */
|
|
|
+ .p-img::before {
|
|
|
+ content: ''; position: absolute; inset: 0;
|
|
|
+ border: 2px solid #444;
|
|
|
+ clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
|
|
|
+ pointer-events: none;
|
|
|
+ }
|
|
|
+
|
|
|
+ .p-1 .p-img { width: 64px; height: 64px; margin-bottom: -20px;}
|
|
|
+ .p-1 .p-img::before { border-color: var(--sport-accent); box-shadow: inset 0 0 10px var(--sport-accent); }
|
|
|
+
|
|
|
+ .crown {
|
|
|
+ position: absolute; top: -28px; color: var(--sport-accent); font-size: 24px;
|
|
|
+ filter: drop-shadow(0 0 5px var(--sport-accent));
|
|
|
+ animation: crownFloat 2s ease-in-out infinite;
|
|
|
+ z-index: 20;
|
|
|
+ }
|
|
|
+ @keyframes crownFloat {
|
|
|
+ 0%, 100% { transform: translateY(0); }
|
|
|
+ 50% { transform: translateY(-5px); }
|
|
|
+ }
|
|
|
+
|
|
|
+ /* 梯形底座 */
|
|
|
+ .p-box {
|
|
|
+ width: 100%; text-align: center; padding-top: 20px;
|
|
|
+ color: white;
|
|
|
+ clip-path: polygon(15% 0, 85% 0, 100% 100%, 0% 100%);
|
|
|
+ }
|
|
|
+ .p-1 .p-box {
|
|
|
+ height: 85px;
|
|
|
+ background: linear-gradient(180deg, rgba(204,255,0,0.2), rgba(204,255,0,0.05));
|
|
|
+ border-top: 2px solid var(--sport-accent);
|
|
|
+ }
|
|
|
+ .p-2 .p-box {
|
|
|
+ height: 65px;
|
|
|
+ background: linear-gradient(180deg, rgba(255,255,255,0.1), rgba(255,255,255,0.02));
|
|
|
+ border-top: 2px solid #888;
|
|
|
+ }
|
|
|
+ .p-3 .p-box {
|
|
|
+ height: 55px;
|
|
|
+ background: linear-gradient(180deg, rgba(255,255,255,0.1), rgba(255,255,255,0.02));
|
|
|
+ border-top: 2px solid #666;
|
|
|
+ }
|
|
|
+ .p-name { font-size: 10px; margin-bottom: 2px; color: #aaa; white-space: nowrap; overflow: hidden; max-width: 70px; margin: 0 auto; text-overflow: ellipsis;}
|
|
|
+ .p-score { font-size: 14px; font-weight: 900; font-style: italic; color: #fff; }
|
|
|
+ .p-1 .p-score { color: var(--sport-accent); }
|
|
|
+
|
|
|
+ /* 列表容器 */
|
|
|
+ .list-container {
|
|
|
+ flex: 1; background: var(--sport-bg);
|
|
|
+ padding: 0 15px 120px 15px;
|
|
|
+ overflow-y: auto;
|
|
|
+ margin-top: 10px;
|
|
|
+ position: relative; z-index: 8;
|
|
|
+ -webkit-overflow-scrolling: touch;
|
|
|
+ }
|
|
|
+
|
|
|
+ .tabs {
|
|
|
+ display: flex; justify-content: center; gap: 20px;
|
|
|
+ position: sticky; top: 0; background: var(--sport-bg); z-index: 9;
|
|
|
+ padding-top: 10px; padding-bottom: 10px;
|
|
|
+ border-bottom: 1px solid #222;
|
|
|
+ }
|
|
|
+
|
|
|
+ .tab {
|
|
|
+ padding: 8px 0;
|
|
|
+ font-size: 14px; color: #666; cursor: pointer;
|
|
|
+ transition: 0.2s; text-transform: uppercase; font-weight: bold;
|
|
|
+ position: relative;
|
|
|
+ }
|
|
|
+ .tab.active { color: var(--sport-text); }
|
|
|
+ .tab.active::after {
|
|
|
+ content: ''; position: absolute; bottom: 0; left: 0; right: 0;
|
|
|
+ height: 3px; background: var(--sport-accent);
|
|
|
+ box-shadow: 0 0 5px var(--sport-accent);
|
|
|
+ }
|
|
|
+
|
|
|
+ .list-item {
|
|
|
+ display: flex; align-items: center; padding: 12px 10px;
|
|
|
+ margin-bottom: 8px;
|
|
|
+ background: #161616;
|
|
|
+ border: 1px solid #222;
|
|
|
+ transform: skewX(-5deg); /* 列表项倾斜 */
|
|
|
+ }
|
|
|
+ /* 内容反向纠正 */
|
|
|
+ .list-item > * { transform: skewX(5deg); }
|
|
|
+
|
|
|
+ .rank { width: 30px; text-align: center; font-weight: 900; font-style: italic; color: #444; font-size: 16px;}
|
|
|
+ /* 前三名排名颜色 */
|
|
|
+ .list-item:nth-child(1) .rank { color: var(--sport-accent); }
|
|
|
+ .list-item:nth-child(2) .rank { color: #fff; }
|
|
|
+ .list-item:nth-child(3) .rank { color: #ccc; }
|
|
|
+
|
|
|
+ .avatar { width: 36px; height: 36px; margin: 0 12px; background: #333; clip-path: circle(50%);}
|
|
|
+ .avatar img { width: 100%; height: 100%; object-fit: cover;}
|
|
|
+ .info { flex: 1; }
|
|
|
+ .name { font-size: 14px; color: #eee; font-weight: bold; }
|
|
|
+ .team { font-size: 10px; color: #666; display: flex; align-items: center; gap: 4px; text-transform: uppercase;}
|
|
|
+ .score { font-size: 16px; font-weight: 900; font-style: italic; color: var(--sport-accent); }
|
|
|
+
|
|
|
+ /* 底部我的排名 */
|
|
|
+ .my-rank-bar {
|
|
|
+ position: fixed; bottom: 0; left: 0; width: 100%;
|
|
|
+ background: #111; border-top: 2px solid var(--sport-accent);
|
|
|
+ display: flex; align-items: center;
|
|
|
+ padding: 0 20px;
|
|
|
+ padding-top: 10px;
|
|
|
+ padding-bottom: calc(10px + env(safe-area-inset-bottom));
|
|
|
+ box-sizing: border-box;
|
|
|
+ z-index: 99;
|
|
|
+ box-shadow: 0 -10px 30px rgba(0,0,0,0.8);
|
|
|
+ }
|
|
|
+ .my-rank-bar .rank { font-size: 18px; color: var(--sport-accent); }
|
|
|
+ .my-rank-bar .avatar { width: 34px; height: 34px; border: 2px solid var(--sport-accent); }
|
|
|
+ .my-rank-bar .name { font-size: 14px; }
|
|
|
+ .my-rank-bar .team { font-size: 10px; }
|
|
|
+ .my-score { font-size: 20px; font-weight: 900; font-style: italic; color: #fff !important; margin-left: auto; text-shadow: 0 0 5px rgba(255,255,255,0.5);}
|
|
|
+
|
|
|
+ /* 演示按钮样式 */
|
|
|
+ .demo-section {
|
|
|
+ margin: 20px 0 0 0; border-top: 1px dashed #333; padding-top: 15px;
|
|
|
+ }
|
|
|
+ .demo-label { font-size: 12px; color: #666; margin-bottom: 10px; }
|
|
|
+ .demo-controls { display: flex; justify-content: center; gap: 10px; }
|
|
|
+ .demo-btn {
|
|
|
+ background: #333; border: 1px solid #555; padding: 6px 12px; font-size: 12px; color: #aaa; cursor: pointer;
|
|
|
+ text-transform: uppercase;
|
|
|
+ }
|
|
|
+ .demo-btn:active { background: var(--sport-accent); color: #000; border-color: var(--sport-accent); }
|
|
|
+
|
|
|
+ /* 下拉菜单 & 模态框 */
|
|
|
+ .dropdown {
|
|
|
+ position: absolute; top: 60px; left: 50%; transform: translateX(-50%); width: 200px;
|
|
|
+ background: #222; border: 1px solid #444;
|
|
|
+ box-shadow: 0 10px 50px rgba(0,0,0,0.8); display: none; flex-direction: column; z-index: 200;
|
|
|
+ }
|
|
|
+ .dropdown.show { display: flex; animation: dropIn 0.2s ease-out; }
|
|
|
+ .dd-item { padding: 12px; color: #aaa; font-size: 14px; text-align: center; border-bottom: 1px solid #333; cursor: pointer; }
|
|
|
+ .dd-active { color: #000; font-weight: bold; background: var(--sport-accent); }
|
|
|
+ @keyframes dropIn { from{opacity:0; transform:translateX(-50%) translateY(-10px);} to{opacity:1; transform:translateX(-50%) translateY(0);} }
|
|
|
+
|
|
|
+ .modal-mask { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); backdrop-filter: blur(5px); z-index: 999; display: flex; justify-content: center; align-items: center; opacity: 0; pointer-events: none; transition: opacity 0.3s; }
|
|
|
+ .modal-mask.show { opacity: 1; pointer-events: auto; }
|
|
|
+ .modal-body {
|
|
|
+ width: 80%; max-width: 320px;
|
|
|
+ background: #1a1a1a; border: 1px solid #444;
|
|
|
+ padding: 25px; text-align: center; transform: scale(0.8); transition: transform 0.3s;
|
|
|
+ box-shadow: 0 20px 50px rgba(0,0,0,0.5);
|
|
|
+ }
|
|
|
+ .modal-mask.show .modal-body { transform: scale(1); }
|
|
|
+ .m-close {
|
|
|
+ background: transparent; color: var(--sport-accent);
|
|
|
+ padding: 10px 25px; border: 1px solid var(--sport-accent);
|
|
|
+ font-weight: bold; cursor: pointer; margin-top: 15px; text-transform: uppercase;
|
|
|
+ }
|
|
|
+ .rule-box { text-align: left; background: #111; border: 1px solid #333; padding: 15px; color: #ccc; font-size: 13px; line-height: 1.6; }
|
|
|
+ .rule-item { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 8px; }
|
|
|
+ .rule-item:last-child { margin-bottom: 0; }
|
|
|
+ .rule-item i { color: var(--sport-accent); margin-top: 2px; }
|
|
|
+
|
|
|
+ .loading-mask {
|
|
|
+ position: fixed; inset: 0; background: rgba(0,0,0,0.7);
|
|
|
+ display: none; align-items: center; justify-content: center;
|
|
|
+ z-index: 300; color: #fff; font-size: 14px; backdrop-filter: blur(2px);
|
|
|
+ }
|
|
|
+ .loading-mask.show { display: flex !important; } /* Fix: display flex to center content */
|
|
|
+ .loading-spinner {
|
|
|
+ border: 4px solid rgba(255,255,255,0.1);
|
|
|
+ border-top-color: var(--sport-accent);
|
|
|
+ border-radius: 50%;
|
|
|
+ width: 36px; height: 36px;
|
|
|
+ animation: spin 1s linear infinite;
|
|
|
+ margin-right: 10px;
|
|
|
+ }
|
|
|
+ @keyframes spin { to { transform: rotate(360deg); } }
|
|
|
+ </style>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+
|
|
|
+ <!-- 头部 -->
|
|
|
+ <div class="header-area">
|
|
|
+ <div class="nav-bar">
|
|
|
+ <div class="icon-btn" onclick="handleBack()"><i class="fa-solid fa-chevron-left" style="color:#ccc"></i></div>
|
|
|
+ <div class="month-select" onclick="toggleDropdown()">
|
|
|
+ <span id="currentMonthText">11月挑战赛</span> <i class="fa-solid fa-caret-down" style="font-size: 12px; margin-left: 5px;"></i>
|
|
|
+ </div>
|
|
|
+ <div class="icon-btn" onclick="openModal()"><i class="fa-solid fa-info" style="color:#ccc"></i></div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- 仪表盘卡片 -->
|
|
|
+ <div class="dashboard-card">
|
|
|
+ <div class="dash-header">
|
|
|
+ <div class="dash-title">
|
|
|
+ 任务状态
|
|
|
+ </div>
|
|
|
+ <div class="dash-badge" id="dashBadge">1 / 4</div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="trophy-track-container">
|
|
|
+ <div class="track-bg-grid"></div>
|
|
|
+ <div class="track-line-active" id="progressLine"></div>
|
|
|
+
|
|
|
+ <!-- 图标1 -->
|
|
|
+ <div class="trophy-item active" id="t1"><i class="fa-solid fa-check"></i></div>
|
|
|
+ <!-- 图标2 -->
|
|
|
+ <div class="trophy-item" id="t2"><i class="fa-solid fa-lock"></i></div>
|
|
|
+ <!-- 图标3 -->
|
|
|
+ <div class="trophy-item" id="t3"><i class="fa-solid fa-lock"></i></div>
|
|
|
+ <!-- 图标4 (Final) -->
|
|
|
+ <div class="trophy-item final" id="t4"><i class="fa-solid fa-trophy"></i></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- 下拉菜单 -->
|
|
|
+ <div class="dropdown" id="dropdown"></div>
|
|
|
+
|
|
|
+ <!-- 领奖台 -->
|
|
|
+ <div class="podium-wrap" id="podiumWrap"></div>
|
|
|
+
|
|
|
+ <!-- 列表区 -->
|
|
|
+ <div class="list-container">
|
|
|
+ <div class="tabs">
|
|
|
+ <div class="tab active" onclick="switchTab('score', this)">积分排名</div>
|
|
|
+ <div class="tab" onclick="switchTab('venue', this)">场地排名</div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div id="rankList"></div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- 底部我的排名 -->
|
|
|
+ <div class="my-rank-bar">
|
|
|
+ <div class="rank" id="myRankNum">--</div>
|
|
|
+ <div class="avatar" id="myAvatar"></div>
|
|
|
+ <div class="info"><div class="name" id="myName">我</div><div class="team" id="myTeam">正在加载...</div></div>
|
|
|
+ <div class="my-score" id="myScoreValue">--</div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- 模态框 -->
|
|
|
+ <div class="modal-mask" id="infoModal">
|
|
|
+ <div class="modal-body">
|
|
|
+ <h3 style="color:var(--sport-text); margin-bottom:15px; text-transform:uppercase; letter-spacing:2px;">规则说明</h3>
|
|
|
+ <div id="ruleContent" class="rule-box">
|
|
|
+ <div class="rule-item"><i class="fa-solid fa-angle-right"></i><div><strong>积分规则:</strong> 在指定公园找到打卡点,耗时越短积分越高。</div></div>
|
|
|
+ <div class="rule-item"><i class="fa-solid fa-angle-right"></i><div><strong>场地排行:</strong> 按解锁的公园场地数量排名。</div></div>
|
|
|
+ <div class="rule-item"><i class="fa-solid fa-angle-right"></i><div><strong>奖杯获取:</strong> 完成4次有效挑战点亮全部奖杯。</div></div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- 演示功能区 -->
|
|
|
+ <div class="demo-section">
|
|
|
+ <div class="demo-label">功能演示</div>
|
|
|
+ <div class="demo-controls">
|
|
|
+ <button class="demo-btn" onclick="demoProgress(1);closeModal()">1/4</button>
|
|
|
+ <button class="demo-btn" onclick="demoProgress(3);closeModal()">3/4</button>
|
|
|
+ <button class="demo-btn" onclick="demoProgress(4);closeModal()">4/4</button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <button class="m-close" onclick="closeModal()">关闭</button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- 加载中遮罩 -->
|
|
|
+ <div class="loading-mask" id="loadingMask">
|
|
|
+ <div class="loading-spinner"></div>
|
|
|
+ <div>数据加载中...</div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <script>
|
|
|
+ const dropdown = document.getElementById('dropdown');
|
|
|
+ const rankListEl = document.getElementById('rankList');
|
|
|
+ const trackLine = document.getElementById('progressLine');
|
|
|
+ const podiumWrap = document.getElementById('podiumWrap');
|
|
|
+ const ruleContent = document.getElementById('ruleContent');
|
|
|
+ const loadingMask = document.getElementById('loadingMask');
|
|
|
+ const state = {
|
|
|
+ activeTab: 'score',
|
|
|
+ scoreList: [],
|
|
|
+ scoreListRendered: null,
|
|
|
+ venueList: [],
|
|
|
+ venueListRendered: null,
|
|
|
+ months: [],
|
|
|
+ currentYM: null,
|
|
|
+ currentMonthData: null,
|
|
|
+ allMonthsData: null
|
|
|
+ };
|
|
|
+
|
|
|
+ // Logger Utility
|
|
|
+ const Logger = {
|
|
|
+ _isDev: false, // Will be set by initPage based on useMock
|
|
|
+
|
|
|
+ init: function(isDev) {
|
|
|
+ this._isDev = isDev;
|
|
|
+ },
|
|
|
+
|
|
|
+ log: function() {
|
|
|
+ if (this._isDev) {
|
|
|
+ console.log.apply(console, arguments);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ warn: function() {
|
|
|
+ if (this._isDev) {
|
|
|
+ console.warn.apply(console, arguments);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ error: function() {
|
|
|
+ // Always log errors, regardless of dev mode
|
|
|
+ console.error.apply(console, arguments);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ function getQuery(name) {
|
|
|
+ const params = new URLSearchParams(window.location.search);
|
|
|
+ return params.get(name);
|
|
|
+ }
|
|
|
+
|
|
|
+ function getYearMonth() {
|
|
|
+ const now = new Date();
|
|
|
+ const year = parseInt(getQuery('year'), 10) || now.getFullYear();
|
|
|
+ const month = parseInt(getQuery('month'), 10) || (now.getMonth() + 1);
|
|
|
+ return { year: year, month: month };
|
|
|
+ }
|
|
|
+
|
|
|
+ function getRecentMonths(count) {
|
|
|
+ const ym = getYearMonth();
|
|
|
+ const list = [];
|
|
|
+ let y = ym.year;
|
|
|
+ let m = ym.month;
|
|
|
+ for (let i = 0; i < (count || 3); i++) {
|
|
|
+ list.push({ year: y, month: m });
|
|
|
+ m -= 1;
|
|
|
+ if (m === 0) { m = 12; y -= 1; }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ function handleBack() {
|
|
|
+ if (window.Bridge && Bridge.toHome) Bridge.toHome();
|
|
|
+ else window.history.back(); // Fallback for web environment
|
|
|
+ }
|
|
|
+
|
|
|
+ function openModal() { document.getElementById('infoModal').classList.add('show'); }
|
|
|
+ function closeModal() { document.getElementById('infoModal').classList.remove('show'); }
|
|
|
+ function toggleDropdown() { dropdown.style.display = (dropdown.style.display === 'flex') ? 'none' : 'flex'; }
|
|
|
+
|
|
|
+ function setLoading(isLoading) {
|
|
|
+ rankListEl.style.opacity = isLoading ? '0.4' : '1';
|
|
|
+ // Use flex for the new layout
|
|
|
+ if (isLoading) loadingMask.classList.add('show');
|
|
|
+ else loadingMask.classList.remove('show');
|
|
|
+ }
|
|
|
+
|
|
|
+ function buildAvatar(name, salt) {
|
|
|
+ // Use local Multiavatar library (Pure JS, no external requests)
|
|
|
+ // It generates high-quality SVG avatars
|
|
|
+ const seedBase = name || 'user';
|
|
|
+ const seed = seedBase + (salt || '');
|
|
|
+
|
|
|
+ // multiavatar(seed) returns an SVG string
|
|
|
+ const svgCode = multiavatar(seed);
|
|
|
+
|
|
|
+ // We need to wrap it in a container or return it as a data URI or direct HTML
|
|
|
+ // Since the existing code expects an <img> tag or innerHTML, putting SVG directly is best for crispness.
|
|
|
+ // However, the existing styling puts it inside a small circle div.
|
|
|
+ // Multiavatar SVG is square, so we rely on parent CSS (overflow: hidden) to clip it to a circle.
|
|
|
+ return svgCode;
|
|
|
+ }
|
|
|
+
|
|
|
+ function setProgress(real, target) {
|
|
|
+ const badge = document.getElementById('dashBadge');
|
|
|
+ const t1 = document.getElementById('t1');
|
|
|
+ const t2 = document.getElementById('t2');
|
|
|
+ const t3 = document.getElementById('t3');
|
|
|
+ const t4 = document.getElementById('t4');
|
|
|
+ const safeReal = Math.max(real || 0, 0);
|
|
|
+ const safeTarget = target && target > 0 ? target : 4;
|
|
|
+ const ratio = Math.min(safeReal / safeTarget, 1);
|
|
|
+ const percent = Math.max(0, Math.min(1, ratio)) * 100;
|
|
|
+ trackLine.style.width = percent + '%';
|
|
|
+ const textReal = safeReal >= safeTarget ? safeTarget : safeReal;
|
|
|
+ badge.innerText = safeReal >= safeTarget ? 'SUCCESS' : `${textReal} / ${safeTarget}`;
|
|
|
+ badge.classList.toggle('completed', safeReal >= safeTarget);
|
|
|
+ function setIconActive(el, active) {
|
|
|
+ if (active) {
|
|
|
+ el.classList.add('active');
|
|
|
+ if (!el.classList.contains('final')) el.innerHTML = '<i class="fa-solid fa-check"></i>';
|
|
|
+ } else {
|
|
|
+ el.classList.remove('active');
|
|
|
+ if (!el.classList.contains('final')) el.innerHTML = '<i class="fa-solid fa-lock"></i>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ setIconActive(t1, safeReal >= 1);
|
|
|
+ setIconActive(t2, safeReal >= 2);
|
|
|
+ setIconActive(t3, safeReal >= 3);
|
|
|
+ setIconActive(t4, safeReal >= safeTarget);
|
|
|
+ }
|
|
|
+
|
|
|
+ function renderBadge(real, target) {
|
|
|
+ setProgress(real, target);
|
|
|
+ }
|
|
|
+
|
|
|
+ function findMonthProgress(year, month, currentMonthData, allMonthsData) {
|
|
|
+ const result = { realNum: 0, targetNum: 4 };
|
|
|
+ const pick = (arr) => {
|
|
|
+ if (!arr || !arr.length) return null;
|
|
|
+ for (let i = 0; i < arr.length; i++) {
|
|
|
+ if (Number(arr[i].month) === Number(month)) return arr[i];
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ };
|
|
|
+ const fromCurrent = currentMonthData && pick(currentMonthData.monthRs || []);
|
|
|
+ if (fromCurrent) return { realNum: fromCurrent.realNum || 0, targetNum: fromCurrent.targetNum || 4 };
|
|
|
+ if (allMonthsData && allMonthsData.length) {
|
|
|
+ for (let i = 0; i < allMonthsData.length; i++) {
|
|
|
+ const item = allMonthsData[i];
|
|
|
+ if (item.year && Number(item.year) !== Number(year)) continue;
|
|
|
+ const found = pick(item.monthRs || []);
|
|
|
+ if (found) return { realNum: found.realNum || 0, targetNum: found.targetNum || 4 };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ function renderMonths(list) {
|
|
|
+ dropdown.innerHTML = '';
|
|
|
+ if (!list || list.length === 0) {
|
|
|
+ dropdown.innerHTML = '<div class="dd-item">暂无月份数据</div>';
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ list.forEach((item, idx) => {
|
|
|
+ const title = `${item.month}月挑战赛`;
|
|
|
+ const div = document.createElement('div');
|
|
|
+ const isCurrent = state.currentYM && state.currentYM.year === item.year && state.currentYM.month === item.month;
|
|
|
+ div.className = 'dd-item' + (isCurrent ? ' dd-active' : '');
|
|
|
+ div.innerText = (idx === 0 && !isCurrent) ? `${title} (本月)` : title;
|
|
|
+ div.onclick = () => {
|
|
|
+ selectMonth(item.year, item.month, title);
|
|
|
+ };
|
|
|
+ dropdown.appendChild(div);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ function renderPodium(list, tabType) {
|
|
|
+ const type = tabType || state.activeTab || 'score';
|
|
|
+ podiumWrap.innerHTML = '';
|
|
|
+
|
|
|
+ // Ensure we have at least 3 elements for the podium, filling with null if less.
|
|
|
+ // This allows the podium structure to always be rendered, even if slots are empty.
|
|
|
+ const podiumData = Array(3).fill(null);
|
|
|
+ if (list && list.length > 0) {
|
|
|
+ list.slice(0, 3).forEach((item, index) => {
|
|
|
+ podiumData[index] = item;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ const p1 = podiumData[0]; // Actual Rank 1
|
|
|
+ const p2 = podiumData[1]; // Actual Rank 2
|
|
|
+ const p3 = podiumData[2]; // Actual Rank 3
|
|
|
+
|
|
|
+ // Define the visual order for rendering (2nd, 1st, 3rd)
|
|
|
+ const podiumItems = [
|
|
|
+ { person: p2, className: 'p-2' }, // Left column - Second place
|
|
|
+ { person: p1, className: 'p-1' }, // Middle column - First place
|
|
|
+ { person: p3, className: 'p-3' } // Right column - Third place
|
|
|
+ ];
|
|
|
+
|
|
|
+ podiumItems.forEach(itemConfig => {
|
|
|
+ const person = itemConfig.person;
|
|
|
+ const col = document.createElement('div');
|
|
|
+ col.className = 'p-col ' + itemConfig.className;
|
|
|
+
|
|
|
+ const name = person ? (person.nickName || person.name || person.userName) : '---';
|
|
|
+ const score = person ? (person.score != null ? person.score : (person.inRankNum != null ? person.inRankNum : '')) : '';
|
|
|
+ // Placeholder avatar for empty slots or Multiavatar for actual people
|
|
|
+ const avatarContent = person ? buildAvatar(name, person.rankNum) : '<div style="width:100%;height:100%;background:#111;display:flex;align-items:center;justify-content:center;color:#333;font-size:12px;font-weight:bold;">?</div>';
|
|
|
+
|
|
|
+ // Only the actual first place gets the crown, and only if that person exists
|
|
|
+ const isActualFirst = (person === p1 && p1 !== null);
|
|
|
+
|
|
|
+ col.innerHTML = `
|
|
|
+ ${isActualFirst ? '<div class="crown"><i class="fa-solid fa-crown"></i></div>' : ''}
|
|
|
+ <div class="p-img">${avatarContent}</div>
|
|
|
+ <div class="p-box">
|
|
|
+ <div class="p-name">${name}</div>
|
|
|
+ <div class="p-score">${score}</div>
|
|
|
+ </div>
|
|
|
+ `;
|
|
|
+ podiumWrap.appendChild(col);
|
|
|
+ });
|
|
|
+
|
|
|
+ // The remaining items for the list below the podium
|
|
|
+ const remaining = list && list.length > 3 ? list.slice(3) : [];
|
|
|
+ if (type === 'venue') {
|
|
|
+ state.venueListRendered = remaining;
|
|
|
+ } else {
|
|
|
+ state.scoreListRendered = remaining;
|
|
|
+ }
|
|
|
+ if (state.activeTab === type) renderRankList(remaining);
|
|
|
+ }
|
|
|
+
|
|
|
+ function renderRankList(list) {
|
|
|
+ rankListEl.innerHTML = '';
|
|
|
+ if (!list || list.length === 0) {
|
|
|
+ rankListEl.innerHTML = '<div style="padding:20px; color:#666; text-align:center; text-transform:uppercase;">暂无数据</div>';
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ list.forEach((item, idx) => {
|
|
|
+ const rankNum = item.rankNum || idx + 1;
|
|
|
+ const name = item.nickName || item.name || item.userName || item.teamName || '选手';
|
|
|
+ const scoreVal = (item.score != null ? item.score : item.inRankNum);
|
|
|
+ const score = scoreVal != null ? scoreVal : '--';
|
|
|
+ const team = item.teamName || item.coiName || '';
|
|
|
+ const teamIcon = team ? '<i class="fa-solid fa-users"></i> ' : '<i class="fa-solid fa-user"></i> ';
|
|
|
+ const row = document.createElement('div');
|
|
|
+ row.className = 'list-item';
|
|
|
+ row.innerHTML = `
|
|
|
+ <div class="rank">${rankNum}</div>
|
|
|
+ <div class="avatar">${buildAvatar(name, rankNum)}</div>
|
|
|
+ <div class="info">
|
|
|
+ <div class="name">${name}</div>
|
|
|
+ <div class="team">${teamIcon}${team || '个人'}</div>
|
|
|
+ </div>
|
|
|
+ <div class="score">${score}</div>
|
|
|
+ `;
|
|
|
+ rankListEl.appendChild(row);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ function renderMyInfo(myRank, myScore, userInfo) {
|
|
|
+ const rankNumEl = document.getElementById('myRankNum');
|
|
|
+ const myScoreEl = document.getElementById('myScoreValue');
|
|
|
+ const myNameEl = document.getElementById('myName');
|
|
|
+ const myTeamEl = document.getElementById('myTeam');
|
|
|
+ const myAvatarEl = document.getElementById('myAvatar');
|
|
|
+ const rankVal = myRank && Number(myRank.rankNum);
|
|
|
+ const hasRank = rankVal > 0;
|
|
|
+ rankNumEl.innerText = hasRank ? rankVal : '--';
|
|
|
+ myScoreEl.innerText = hasRank && myScore && myScore.score != null ? myScore.score : '--';
|
|
|
+ const name = (userInfo && (userInfo.nickName || userInfo.userName)) || '我';
|
|
|
+ myNameEl.innerText = name;
|
|
|
+ myTeamEl.innerText = hasRank ? '继续挑战' : '';
|
|
|
+ myAvatarEl.innerHTML = buildAvatar(name, 'me');
|
|
|
+
|
|
|
+ // Remove click listener if exists (clean slate)
|
|
|
+ document.querySelector('.my-rank-bar').onclick = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ function renderGuestState() {
|
|
|
+ const rankNumEl = document.getElementById('myRankNum');
|
|
|
+ const myScoreEl = document.getElementById('myScoreValue');
|
|
|
+ const myNameEl = document.getElementById('myName');
|
|
|
+ const myTeamEl = document.getElementById('myTeam');
|
|
|
+ const myAvatarEl = document.getElementById('myAvatar');
|
|
|
+ const myRankBar = document.querySelector('.my-rank-bar');
|
|
|
+
|
|
|
+ rankNumEl.innerText = '--';
|
|
|
+ myScoreEl.innerText = '';
|
|
|
+ myNameEl.innerText = '游客';
|
|
|
+ myTeamEl.innerText = '点击登录';
|
|
|
+ myTeamEl.style.color = 'var(--sport-accent)';
|
|
|
+
|
|
|
+ // Random avatar
|
|
|
+ const randomSeed = 'guest_' + Math.floor(Math.random() * 10000);
|
|
|
+ myAvatarEl.innerHTML = buildAvatar('Guest', randomSeed);
|
|
|
+
|
|
|
+ // Add click listener
|
|
|
+ myRankBar.onclick = function() {
|
|
|
+ if (window.Bridge && Bridge.toLogin) {
|
|
|
+ Bridge.toLogin();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ function renderRules(config) {
|
|
|
+ if (!config || !config.configJson) return;
|
|
|
+ try {
|
|
|
+ const parsed = JSON.parse(config.configJson);
|
|
|
+ const rules = parsed.popupRuleList || [];
|
|
|
+ if (rules.length > 0 && rules[0].data && rules[0].data.content) {
|
|
|
+ ruleContent.innerHTML = rules[0].data.content;
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ Logger.warn('[Rule] parse error', err);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function switchTab(type, tabElement) {
|
|
|
+ state.activeTab = type;
|
|
|
+ document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
|
|
|
+ if (tabElement) tabElement.classList.add('active');
|
|
|
+ const baseList = type === 'venue' ? state.venueList : state.scoreList;
|
|
|
+ renderPodium(baseList, type);
|
|
|
+ const rendered = type === 'venue' ? (state.venueListRendered || baseList.slice(3)) : (state.scoreListRendered || baseList.slice(3));
|
|
|
+ renderRankList(rendered);
|
|
|
+ }
|
|
|
+
|
|
|
+ function demoProgress(step) {
|
|
|
+ setProgress(step, 4);
|
|
|
+ }
|
|
|
+
|
|
|
+ async function loadMonthData(year, month) {
|
|
|
+ state.currentYM = { year: year, month: month };
|
|
|
+ document.getElementById('currentMonthText').innerText = `${month}月挑战赛`;
|
|
|
+ renderMonths(state.months);
|
|
|
+ setLoading(true);
|
|
|
+ try {
|
|
|
+ const monthRank = await API.request('MonthRankDetailQuery', { year: year, month: month, dispArrStr: 'grad,mapNum' });
|
|
|
+ const monthGrad = monthRank && monthRank.gradRs ? monthRank.gradRs : [];
|
|
|
+ const monthMap = monthRank && monthRank.mapNumRs ? monthRank.mapNumRs : [];
|
|
|
+ state.scoreList = monthGrad;
|
|
|
+ state.venueList = monthMap;
|
|
|
+ const prog = findMonthProgress(year, month, state.currentMonthData, state.allMonthsData);
|
|
|
+ renderBadge(prog.realNum, prog.targetNum);
|
|
|
+ renderPodium(state.activeTab === 'venue' ? state.venueList : state.scoreList, state.activeTab);
|
|
|
+ switchTab(state.activeTab, document.querySelector('.tab.active'));
|
|
|
+ } catch (err) {
|
|
|
+ Logger.error('[Month] 加载失败', err);
|
|
|
+ rankListEl.innerHTML = '<div style="padding:20px; color:#d63031;">数据加载失败,请重试</div>';
|
|
|
+ } finally {
|
|
|
+ setLoading(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function selectMonth(year, month, title) {
|
|
|
+ dropdown.style.display = 'none';
|
|
|
+ loadMonthData(year, month);
|
|
|
+ }
|
|
|
+
|
|
|
+ async function initPage() {
|
|
|
+ // Platform detection for CSS adjustments
|
|
|
+ if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {
|
|
|
+ document.body.classList.add('platform-ios');
|
|
|
+ }
|
|
|
+
|
|
|
+ const ecId = getQuery('ecId') || '4';
|
|
|
+ const token = getQuery('token');
|
|
|
+ let baseUrl = getQuery('baseUrl') || undefined;
|
|
|
+ const env = (getQuery('env') || '').toLowerCase();
|
|
|
+ const useMock = env === 'mock';
|
|
|
+ Logger.init(useMock); // Initialize logger based on mock status
|
|
|
+ const ym = getYearMonth();
|
|
|
+
|
|
|
+ // 1. Initialize with 6 months
|
|
|
+ state.months = getRecentMonths(6);
|
|
|
+
|
|
|
+ if (!baseUrl && !useMock) baseUrl = 'https://colormaprun.com/api/card/';
|
|
|
+ if (window.Bridge && window.Bridge.onToken) Bridge.onToken(API.setToken);
|
|
|
+ API.init({ token: token || '', useMock: useMock, baseUrl: baseUrl });
|
|
|
+ const allowLogin = !useMock && token;
|
|
|
+
|
|
|
+ renderMonths(state.months);
|
|
|
+ setLoading(true);
|
|
|
+
|
|
|
+ async function safeCall(promiseFactory) {
|
|
|
+ try { return await promiseFactory(); }
|
|
|
+ catch (err) { Logger.warn('[Optional API] ignore error', err); return null; }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Helper to load data for a specific month
|
|
|
+ async function fetchMonthData(year, month) {
|
|
|
+ return await API.request('MonthRankDetailQuery', { year: year, month: month, dispArrStr: 'grad,mapNum' });
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 2. Try loading current month first
|
|
|
+ let targetYM = { year: ym.year, month: ym.month };
|
|
|
+ let monthRank = await fetchMonthData(targetYM.year, targetYM.month);
|
|
|
+
|
|
|
+ // 3. Check if current month has data
|
|
|
+ let monthGrad = monthRank && monthRank.gradRs ? monthRank.gradRs : [];
|
|
|
+ let monthMap = monthRank && monthRank.mapNumRs ? monthRank.mapNumRs : [];
|
|
|
+ let hasData = monthGrad.length > 0 || monthMap.length > 0;
|
|
|
+
|
|
|
+ // 4. If no data, search backwards in the 6-month list
|
|
|
+ if (!hasData) {
|
|
|
+ // Start from index 1 because index 0 (current month) is already checked
|
|
|
+ for (let i = 1; i < state.months.length; i++) {
|
|
|
+ const checkYM = state.months[i];
|
|
|
+ const checkRank = await fetchMonthData(checkYM.year, checkYM.month);
|
|
|
+ const checkGrad = checkRank && checkRank.gradRs ? checkRank.gradRs : [];
|
|
|
+ const checkMap = checkRank && checkRank.mapNumRs ? checkRank.mapNumRs : [];
|
|
|
+
|
|
|
+ if (checkGrad.length > 0 || checkMap.length > 0) {
|
|
|
+ // Found data! Update target and data
|
|
|
+ targetYM = checkYM;
|
|
|
+ monthRank = checkRank;
|
|
|
+ monthGrad = checkGrad;
|
|
|
+ monthMap = checkMap;
|
|
|
+ hasData = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Update state with the found (or original empty) data
|
|
|
+ state.currentYM = targetYM;
|
|
|
+ state.scoreList = monthGrad;
|
|
|
+ state.venueList = monthMap;
|
|
|
+
|
|
|
+ let base, currentMonth, allMonths, myRank, myScore, userInfo, cardConfig;
|
|
|
+ if (useMock || allowLogin) {
|
|
|
+ [base, currentMonth, allMonths, myRank, myScore, userInfo, cardConfig] = await Promise.all([
|
|
|
+ safeCall(() => API.getCardBase(ecId, 'rank')),
|
|
|
+ safeCall(() => API.request('CurrentMonthlyChallengeQuery', { ecId: ecId })),
|
|
|
+ safeCall(() => API.getMonthlyChallenge()),
|
|
|
+ safeCall(() => API.getUserCurrentRank(ecId)),
|
|
|
+ safeCall(() => API.getScore(ecId)),
|
|
|
+ safeCall(() => API.getUserInfo()),
|
|
|
+ safeCall(() => API.getCardConfig(ecId, 'rank'))
|
|
|
+ ]);
|
|
|
+ } else {
|
|
|
+ base = { ecName: `${targetYM.month}月挑战赛` };
|
|
|
+ currentMonth = { monthRs: [{ month: targetYM.month, realNum: 0, targetNum: 4 }] };
|
|
|
+ allMonths = [];
|
|
|
+ myRank = null;
|
|
|
+ myScore = null;
|
|
|
+ userInfo = null;
|
|
|
+ cardConfig = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ const selfRow = monthGrad.find && monthGrad.find(item => item.isSelf === 1);
|
|
|
+ if (!base && monthGrad.length) base = { ecName: `${targetYM.month}月挑战赛` };
|
|
|
+ state.currentMonthData = currentMonth || null;
|
|
|
+ state.allMonthsData = allMonths || null;
|
|
|
+
|
|
|
+ // IMPORTANT: Render with the actually selected month (targetYM)
|
|
|
+ const prog = findMonthProgress(targetYM.year, targetYM.month, state.currentMonthData, state.allMonthsData);
|
|
|
+ document.getElementById('currentMonthText').innerText = `${targetYM.month}月挑战赛`;
|
|
|
+
|
|
|
+ // Re-render dropdown to highlight correct month
|
|
|
+ renderMonths(state.months);
|
|
|
+
|
|
|
+ renderBadge(prog.realNum, prog.targetNum);
|
|
|
+ renderPodium(state.scoreList, 'score');
|
|
|
+ switchTab(state.activeTab, document.querySelector('.tab.active'));
|
|
|
+
|
|
|
+ if (!token && !useMock) {
|
|
|
+ renderGuestState();
|
|
|
+ } else {
|
|
|
+ let hasRenderedMyInfo = false;
|
|
|
+ if (allowLogin && myRank) {
|
|
|
+ const rankVal = Number(myRank.rankNum);
|
|
|
+ if (rankVal > 0) {
|
|
|
+ renderMyInfo({ rankNum: rankVal }, myScore, userInfo);
|
|
|
+ } else {
|
|
|
+ renderMyInfo({ rankNum: null }, null, userInfo);
|
|
|
+ }
|
|
|
+ hasRenderedMyInfo = true;
|
|
|
+ } else if (selfRow) {
|
|
|
+ renderMyInfo({ rankNum: selfRow.rankNum }, { score: selfRow.inRankNum || selfRow.score }, { nickName: selfRow.userName });
|
|
|
+ hasRenderedMyInfo = true;
|
|
|
+ }
|
|
|
+ if (!hasRenderedMyInfo) {
|
|
|
+ renderMyInfo(myRank, myScore, userInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ renderRules(cardConfig);
|
|
|
+ } finally {
|
|
|
+ setLoading(false);
|
|
|
+ loadingMask.classList.remove('show'); // Force remove show class
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ document.addEventListener('click', (e) => {
|
|
|
+ if(!e.target.closest('.month-select') && !e.target.closest('.dropdown')) { dropdown.style.display = 'none'; }
|
|
|
+ });
|
|
|
+
|
|
|
+ document.addEventListener('DOMContentLoaded', initPage);
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+</html>
|