初版:小白超人(从线上实例导出)

This commit is contained in:
deploy
2026-10-29 15:20:39 +08:00
commit b77a309873
100 changed files with 32168 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
<!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">
<link rel="stylesheet" href="css/map.css">
<link rel="stylesheet" href="css/ui-system.css">
<style>
/* 模拟地图底色,仅用于布局预览 */
#baidu_map { background: #dfeef2 !important; }
</style>
</head>
<body>
<div id="map-container">
<div id="baidu_map"></div>
<div class="stats-card">
<button class="stats-analysis-btn" onclick="return false;">
数据分析
</button>
</div>
<div class="legend">
<div class="legend-title">状态图例</div>
<div class="legend-item"><div class="legend-ring available"></div><span class="legend-text">可用 <span id="count-available">0</span></span></div>
<div class="legend-item"><div class="legend-ring used"></div><span class="legend-text">使用中 <span id="count-used">0</span></span></div>
<div class="legend-item"><div class="legend-ring locked"></div><span class="legend-text">欠压 <span id="count-locked">0</span></span></div>
<div class="legend-item"><div class="legend-ring reserved"></div><span class="legend-text">损坏 <span id="count-reserved">0</span></span></div>
<div class="legend-item"><div class="legend-ring low"></div><span class="legend-text">低电量 <span id="count-low">0</span></span></div>
</div>
</div>
<!-- 底部扫码栏 -->
<div class="scan-bar">
<input class="scan-input" id="scan-input" type="number" placeholder="输入5位车牌号" />
<button class="scan-btn" onclick="return false;">查询</button>
</div>
<!-- 找最近的车:独立悬浮按钮(右下角,手机端仅图标) -->
<button class="locate-btn locate-fab" id="locate-btn" onclick="return false;">
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="3"/><path d="M12 2v4m0 12v4M2 12h4m12 0h4"/></svg>
<span class="locate-fab-label">找最近的车</span>
</button>
<!-- 版本号标识 -->
<div class="version-badge" id="version-badge" onclick="return false;">v1.6.0</div>
</body>
</html>
Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

+89
View File
@@ -0,0 +1,89 @@
/* Native overlay coordinates: the SDK keeps the layer aligned during zooming. */
.bike-bubble-layer {
position: absolute;
top: 0;
left: 0;
width: 0;
height: 0;
z-index: 10;
overflow: visible;
pointer-events: none;
--bubble-surface: rgba(255, 255, 252, .96);
--bubble-ink: #25382f;
--bubble-muted: #65776c;
--bubble-track: #e0e9e2;
--bubble-green: #32a673;
--bubble-border: rgba(255, 255, 255, .95);
}
.bike-bubble-anchor { position: absolute; top: 0; left: 0; }
.bike-bubble, .bike-dot {
position: absolute;
top: 0;
left: 0;
pointer-events: auto;
cursor: pointer;
user-select: none;
-webkit-tap-highlight-color: transparent;
touch-action: none;
font-family: inherit;
transform-origin: center;
will-change: opacity;
transition: box-shadow 160ms ease;
}
.bike-bubble {
width: var(--bubble-size);
height: var(--bubble-size);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 1px;
border-radius: 50%;
border: 1px solid var(--bubble-border);
background: var(--bubble-surface);
color: var(--bubble-ink);
box-shadow: 0 3px 9px rgba(28, 54, 38, .13), 0 9px 24px rgba(28, 54, 38, .09);
transition: box-shadow 160ms ease;
}
.bike-bubble-ring {
position: absolute;
inset: 4px;
border-radius: 50%;
background: conic-gradient(var(--bubble-green) var(--available-angle), var(--bubble-track) 0);
-webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2px));
mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2px));
pointer-events: none;
}
.bike-bubble-count {
font-size: 21px;
font-weight: 750;
line-height: 1.05;
letter-spacing: -.7px;
font-variant-numeric: tabular-nums;
}
.bike-bubble-label { color: var(--bubble-muted); font-size: 10px; font-weight: 600; line-height: 1.4; }
.bike-bubble.is-unavailable { --bubble-green: #92a098; }
.bike-bubble.is-unavailable .bike-bubble-count { color: var(--bubble-muted); }
.bike-dot { width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; }
/* BMap injects .bmap-container button { border-radius: 0 } after page CSS. */
.bike-bubble-layer .bike-bubble,
.bike-bubble-layer .bike-dot { border-radius: 50%; }
.bike-dot img { display: block; width: 100%; height: 100%; pointer-events: none; }
.bike-bubble:focus-visible, .bike-dot:focus-visible { outline: 3px solid var(--bubble-green); outline-offset: 4px; }
.bike-bubble:active { box-shadow: 0 1px 4px rgba(28, 54, 38, .2); }
@media (hover: hover) {
.bike-bubble:hover { box-shadow: 0 4px 12px rgba(28, 54, 38, .2), 0 12px 28px rgba(28, 54, 38, .12); }
}
@media (prefers-color-scheme: dark) {
.bike-bubble-layer {
--bubble-surface: rgba(34, 43, 39, .97);
--bubble-ink: #f2f5f0;
--bubble-muted: #b0c1b4;
--bubble-track: #435149;
--bubble-green: #6bd5a2;
--bubble-border: rgba(207, 230, 215, .24);
}
}
@media (prefers-reduced-motion: reduce) {
.bike-bubble { transition: none; }
}
+86
View File
@@ -0,0 +1,86 @@
#baidu_map canvas { filter: var(--basemap-filter, none); }
.settings-page[hidden], .settings-view[hidden], #settings-page-home[hidden] { display: none !important; }
.settings-page {
position: fixed; inset: 0; z-index: 3500; display: flex; flex-direction: column;
background: var(--ui-canvas); color: var(--text-primary);
}
.settings-page-header {
display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
flex: 0 0 auto; min-height: 72px; padding: 14px max(24px, calc((100% - 740px) / 2));
background: var(--ui-surface); border-bottom: 1px solid var(--border-color);
}
.settings-page-header h1 { font-size: 18px; font-weight: 650; outline: none; }
#settings-page-title:focus { outline: none !important; box-shadow: none !important; }
#settings-page-back { justify-self: start; }
#settings-page-home { justify-self: end; font-size: 12px; color: var(--text-secondary); }
.settings-page-main { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.settings-view { width: min(100%, 740px); margin: 0 auto; padding: 28px 24px 40px; }
.settings-view-content {
position: static !important; transform: none !important; width: 100% !important; max-width: none !important;
max-height: none !important; padding: 0; margin: 0; overflow: visible !important;
background: transparent; border: 0; border-radius: 0; box-shadow: none;
}
.settings-view .devices-list, .settings-view .packages-list, .settings-view #subscribe-list {
max-height: none !important; overflow: visible !important; flex: none;
}
.settings-account { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.settings-view .profile-stats { padding: 18px; margin-bottom: 22px; border-radius: 16px; background: var(--ui-surface); }
.settings-view .stat-value { color: var(--text-primary); font-size: 24px; font-variant-numeric: tabular-nums; }
.settings-view .stat-item + .stat-item { border-left: 1px solid var(--border-color); }
.settings-view .profile-auth-hint { margin: 12px 0 22px; }
.settings-menu { margin-bottom: 28px; }
.settings-menu .settings-link-row + .settings-link-row { border-top: 1px solid var(--border-color); }
.settings-chevron { font-size: 23px; font-weight: 400; color: var(--text-tertiary); }
.settings-logout {
display: block; width: 100%; padding: 16px; border: 1px solid var(--border-color); border-radius: 16px;
background: var(--ui-surface); color: var(--danger); cursor: pointer; font-size: 14px;
}
.settings-view .rental-settings-note { margin-bottom: 22px; }
.settings-view .auth-submit { margin-top: 20px; }
.settings-view .share-content { width: 100%; }
.map-settings-content { width: 430px; max-width: calc(100% - 32px); padding: 0; overflow: auto; }
.map-settings-header {
position: sticky; top: 0; z-index: 1;
display: flex; align-items: center; justify-content: space-between;
padding: 18px 20px; background: var(--bg-card); border-bottom: 1px solid var(--border-color);
}
.map-settings-header h2 { font-size: 18px; font-weight: 650; }
.settings-back {
display: flex; align-items: center; gap: 2px; min-height: 36px;
border: 0; padding: 0; background: none; color: var(--text-primary); font-size: 14px; cursor: pointer;
}
.settings-header-spacer { width: 50px; }
.settings-body { padding: 24px 20px 28px; }
.settings-section-title { color: var(--text-secondary); font-size: 12px; font-weight: 600; margin: 0 4px 10px; }
.settings-group { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 16px; overflow: hidden; }
.settings-page .settings-group { background: var(--ui-surface); }
.map-setting-row, .settings-link-row { display: flex; align-items: center; justify-content: space-between; gap: 22px; padding: 18px 16px; }
.map-setting-row { cursor: pointer; }
.map-setting-copy { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.map-setting-copy strong { color: var(--text-primary); font-size: 15px; font-weight: 600; line-height: 1.4; }
.map-setting-copy > span { color: var(--text-secondary); font-size: 12px; line-height: 1.65; }
.settings-row-note { color: var(--text-secondary); font-size: 11px; line-height: 1.7; padding: 12px 16px; border-top: 1px solid var(--border-color); }
.settings-save-status { min-height: 32px; margin: 10px 4px 22px; color: var(--text-secondary); font-size: 11px; line-height: 1.65; }
.settings-switch { position: relative; flex: 0 0 48px; width: 48px; height: 28px; }
.settings-switch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 1; margin: 0; }
.settings-switch-track { display: block; width: 48px; height: 28px; border-radius: 20px; background: var(--text-tertiary); transition: background 160ms ease; }
.settings-switch-track::after {
content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.18); transition: transform 160ms ease;
}
.settings-switch input:checked + .settings-switch-track { background: #32a673; }
.settings-switch input:checked + .settings-switch-track::after { transform: translateX(20px); }
.settings-switch input:focus-visible + .settings-switch-track { outline: 2px solid var(--text-primary); outline-offset: 4px; }
.settings-link-row { width: 100%; border: 0; background: transparent; color: var(--text-secondary); cursor: pointer; }
.settings-link-row:hover { background: var(--bg-card); }
@media (max-width: 540px) {
.settings-page-header { min-height: 60px; padding: max(12px, env(safe-area-inset-top)) 16px 12px; }
.settings-view { padding: 22px 16px max(28px, env(safe-area-inset-bottom)); }
.settings-page .settings-link-row { padding: 16px; }
#settings-modal .map-settings-content { width: 100%; max-width: 100%; height: 100%; max-height: 100%; border-radius: 0 !important; }
.map-settings-header { padding-top: max(18px, env(safe-area-inset-top)); }
.settings-body { padding-bottom: max(28px, env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
.settings-switch-track, .settings-switch-track::after { transition: none; }
}
+2706
View File
File diff suppressed because it is too large Load Diff
+731
View File
@@ -0,0 +1,731 @@
/*
* 小白超人统一界面系统
* Porcelain (#f6f6f4) / Ink (#171719) / Graphite (#71717a)
* 圆角比例:8 / 12 / 16 / 20 / 24px
*/
:root {
color-scheme: light dark;
--ui-canvas: #f6f6f4;
--ui-surface: #fbfbfa;
--ui-surface-raised: #f0f0ee;
--ui-ink: #171719;
--ui-muted: #68686f;
--ui-faint: #929299;
--ui-line: rgba(23, 23, 25, .09);
--ui-line-strong: rgba(23, 23, 25, .15);
--ui-solid: #1c1c1f;
--ui-on-solid: #f8f8f6;
--ui-acrylic: color-mix(in srgb, var(--ui-surface) 68%, transparent);
--ui-acrylic-soft: color-mix(in srgb, var(--ui-surface) 46%, transparent);
--ui-header-acrylic: rgba(251, 251, 250, .64);
--ui-overlay: rgba(12, 12, 14, .52);
--ui-focus: rgba(23, 23, 25, .24);
--ui-shadow-sm: 0 1px 2px rgba(18, 18, 20, .04), 0 8px 24px rgba(18, 18, 20, .05);
--ui-shadow-md: 0 18px 52px rgba(18, 18, 20, .11);
--ui-shadow-lg: 0 32px 90px rgba(18, 18, 20, .16);
--ui-r-sm: 8px;
--ui-r-md: 12px;
--ui-r-lg: 16px;
--ui-r-xl: 20px;
--ui-r-2xl: 24px;
--ui-ease: cubic-bezier(.16, 1, .3, 1);
--ui-fast: 160ms;
--ui-normal: 280ms;
}
*, *::before, *::after {
box-sizing: border-box;
}
/* 禁用 WebView 点按高亮(蓝色选中态) */
* {
-webkit-tap-highlight-color: transparent;
}
@media (prefers-color-scheme: dark) {
:root {
--ui-canvas: #101011;
--ui-surface: #18181a;
--ui-surface-raised: #222225;
--ui-ink: #f1f1ef;
--ui-muted: #aaaab0;
--ui-faint: #77777f;
--ui-line: rgba(241, 241, 239, .09);
--ui-line-strong: rgba(241, 241, 239, .16);
--ui-solid: #eeeeec;
--ui-on-solid: #151517;
--ui-acrylic: color-mix(in srgb, var(--ui-surface) 68%, transparent);
--ui-acrylic-soft: color-mix(in srgb, var(--ui-surface) 46%, transparent);
--ui-header-acrylic: rgba(238, 238, 236, .07);
--ui-overlay: rgba(3, 3, 4, .68);
--ui-focus: rgba(241, 241, 239, .28);
--ui-shadow-sm: 0 1px 2px rgba(2, 2, 3, .22), 0 10px 28px rgba(2, 2, 3, .18);
--ui-shadow-md: 0 20px 56px rgba(2, 2, 3, .32);
--ui-shadow-lg: 0 36px 100px rgba(2, 2, 3, .46);
}
}
html {
background: var(--ui-canvas);
}
body {
color: var(--ui-ink);
background-color: var(--ui-canvas);
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
animation: ui-page-in 560ms var(--ui-ease) both;
}
body::before {
content: "";
position: fixed;
inset: 0;
z-index: 99999;
pointer-events: none;
opacity: .022;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
body.ui-page-leaving {
animation: ui-page-out 180ms ease-in both;
pointer-events: none;
}
h1, h2, h3, .header-title, .panel-title {
letter-spacing: -.025em;
text-wrap: balance;
}
p, .tip, .hint, .auth-subtitle, .lost-modal-subtitle {
text-wrap: pretty;
}
button, input, select, textarea, a {
-webkit-tap-highlight-color: transparent;
}
button, [role="button"], a {
transition: color var(--ui-fast) ease, background-color var(--ui-fast) ease,
border-color var(--ui-fast) ease, box-shadow var(--ui-fast) ease,
opacity var(--ui-fast) ease, transform var(--ui-fast) var(--ui-ease);
}
button:not(:disabled):active, [role="button"]:active {
transform: scale(.975);
}
button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, a:focus-visible, [tabindex]:focus-visible {
outline: 2px solid var(--ui-ink) !important;
outline-offset: 3px !important;
box-shadow: 0 0 0 5px var(--ui-focus) !important;
}
input, select, textarea {
min-height: 44px;
border-color: var(--ui-line-strong) !important;
border-radius: var(--ui-r-md) !important;
background: var(--ui-surface) !important;
color: var(--ui-ink) !important;
}
input::placeholder, textarea::placeholder {
color: var(--ui-faint);
}
button:disabled, input:disabled, select:disabled {
opacity: .46;
cursor: not-allowed;
}
/* Map + analytics share the same semantic variable names. */
body {
--bg-primary: var(--ui-canvas);
--bg-secondary: var(--ui-surface-raised);
--bg-card: var(--ui-surface);
--text-primary: var(--ui-ink);
--text-secondary: var(--ui-muted);
--text-tertiary: var(--ui-faint);
--border-color: var(--ui-line);
--accent-color: var(--ui-solid);
--accent-contrast: var(--ui-on-solid);
--accent-hover: color-mix(in srgb, var(--ui-solid) 82%, var(--ui-canvas));
--accent-soft: color-mix(in srgb, var(--ui-solid) 9%, transparent);
--overlay: var(--ui-overlay);
--shadow-sm: var(--ui-shadow-sm);
--shadow-md: var(--ui-shadow-md);
--shadow-lg: var(--ui-shadow-lg);
--shadow-up: 0 -18px 52px rgba(18, 18, 20, .09);
--radius-sm: var(--ui-r-sm);
--radius-md: var(--ui-r-md);
--radius-lg: var(--ui-r-lg);
--radius-xl: var(--ui-r-xl);
--transition: var(--ui-normal) var(--ui-ease);
--ease-spring: var(--ui-ease);
}
/* App chrome */
.header {
border-color: var(--ui-line) !important;
background: color-mix(in srgb, var(--ui-canvas) 86%, transparent) !important;
backdrop-filter: blur(18px) saturate(1.25);
-webkit-backdrop-filter: blur(18px) saturate(1.25);
}
.header-title, h1 {
font-weight: 720 !important;
}
.header-sub, .stat-label, .stat-sub, .tip, .hint {
color: var(--ui-muted) !important;
}
.stats-card, .stat-card, .panel, table, .container,
.bike-card, .auth-content, .bell-content, .qr-content, .return-content,
.token-expired-content, .return-confirm-content, .unlock-confirm-content,
.lost-modal-content, .login-gate-card, .modal {
background: var(--ui-surface) !important;
border: 1px solid var(--ui-line) !important;
box-shadow: var(--ui-shadow-sm) !important;
}
.stats-card, .panel, table { border-radius: var(--ui-r-lg) !important; }
.stat-card { border-radius: var(--ui-r-md) !important; }
.bike-card, .auth-content, .bell-content, .qr-content, .return-content,
.token-expired-content, .return-confirm-content, .unlock-confirm-content,
.lost-modal-content, .login-gate-card, .modal {
border-radius: var(--ui-r-xl) !important;
box-shadow: var(--ui-shadow-lg) !important;
}
.stats-analysis-btn, .header-btn, .header-back, .auth-close, .qr-close,
.bike-card-close, .bike-card-find-btn {
border: 1px solid var(--ui-line) !important;
background: var(--ui-surface) !important;
color: var(--ui-ink) !important;
box-shadow: none !important;
}
.stats-analysis-btn:hover, .header-btn:hover, .header-back:hover,
.auth-close:hover, .qr-close:hover, .bike-card-close:hover,
.bike-card-find-btn:hover {
border-color: var(--ui-line-strong) !important;
background: var(--ui-surface-raised) !important;
}
.auth-submit:not(.danger):not(.warning):not(.success),
.return-confirm-btn.confirm, .unlock-confirm-btn.confirm,
.lost-modal-btn.confirm, .btn-primary, .btn-cancel,
.progress-fill:not(.done), #confirm-btn {
border-color: transparent !important;
background: var(--ui-solid) !important;
color: var(--ui-on-solid) !important;
box-shadow: none !important;
}
.auth-submit:not(.danger):not(.warning):not(.success):hover,
.return-confirm-btn.confirm:hover, .unlock-confirm-btn.confirm:hover,
.lost-modal-btn.confirm:hover, .btn-primary:hover, .btn-cancel:hover,
#confirm-btn:hover {
background: color-mix(in srgb, var(--ui-solid) 84%, var(--ui-canvas)) !important;
}
.auth-submit.ghost, .return-confirm-btn.cancel, .unlock-confirm-btn.cancel,
.lost-modal-btn.cancel, .btn-gray, .btn-close, .btn-secondary {
border: 1px solid var(--ui-line) !important;
background: var(--ui-surface-raised) !important;
color: var(--ui-ink) !important;
}
.tab-nav, .tabs, .filter-bar, .info, .log {
border: 1px solid var(--ui-line) !important;
background: var(--ui-surface-raised) !important;
box-shadow: none !important;
}
.tab-nav, .tabs { border-radius: var(--ui-r-md) !important; padding: 4px !important; }
.tab-btn, .tab { border-radius: var(--ui-r-sm) !important; color: var(--ui-muted) !important; }
.tab-btn.active, .tab.active {
background: var(--ui-surface) !important;
color: var(--ui-ink) !important;
box-shadow: 0 1px 4px rgba(18, 18, 20, .08) !important;
}
.panel-title::before { background: var(--ui-ink) !important; }
.stat-value { color: var(--ui-ink) !important; font-variant-numeric: tabular-nums; }
/* Data tables */
table { overflow: clip; }
th {
background: var(--ui-surface-raised) !important;
color: var(--ui-muted) !important;
letter-spacing: .02em;
}
th, td { border-color: var(--ui-line) !important; }
tbody tr { transition: background-color var(--ui-fast) ease; }
tbody tr:hover { background: color-mix(in srgb, var(--ui-ink) 3.5%, transparent) !important; }
td .mono, td:nth-child(n+2) { font-variant-numeric: tabular-nums; }
/* Overlays use visibility rather than display so removing .show animates out. */
.auth-modal, .bell-modal, .qr-modal, .return-modal, .token-expired-modal,
.return-confirm-modal, .unlock-confirm-modal, .lost-modal, .login-gate,
.modal-overlay {
display: flex !important;
opacity: 0;
visibility: hidden;
pointer-events: none;
background: var(--ui-overlay) !important;
transition: opacity 200ms ease, visibility 0s linear 200ms;
}
.auth-modal.show, .bell-modal.show, .qr-modal.show, .return-modal.show,
.token-expired-modal.show, .return-confirm-modal.show,
.unlock-confirm-modal.show, .lost-modal.show, .login-gate.show,
.modal-overlay.show {
opacity: 1;
visibility: visible;
pointer-events: auto;
transition: opacity 220ms ease, visibility 0s;
}
.auth-modal > *, .bell-modal > *, .qr-modal > *, .return-modal > *,
.token-expired-modal > *, .return-confirm-modal > *,
.unlock-confirm-modal > *, .lost-modal > *, .login-gate > *,
.modal-overlay > * {
opacity: 0;
transform: translateY(14px) scale(.985);
transition: opacity 180ms ease, transform 300ms var(--ui-ease);
}
.auth-modal.show > *, .bell-modal.show > *, .qr-modal.show > *,
.return-modal.show > *, .token-expired-modal.show > *,
.return-confirm-modal.show > *, .unlock-confirm-modal.show > *,
.lost-modal.show > *, .login-gate.show > *, .modal-overlay.show > * {
opacity: 1;
transform: translateY(0) scale(1);
}
.card-overlay {
display: block !important;
opacity: 0;
visibility: hidden;
pointer-events: none;
transition: opacity 200ms ease, visibility 0s linear 200ms;
}
.card-overlay.show {
opacity: 1;
visibility: visible;
pointer-events: auto;
transition-delay: 0s;
}
.toast {
border: 1px solid var(--ui-line) !important;
border-radius: var(--ui-r-md) !important;
box-shadow: var(--ui-shadow-md) !important;
}
/* Admin */
body:has(.tabs) {
--bg: var(--ui-canvas);
--card: var(--ui-surface);
--text: var(--ui-ink);
--sec: var(--ui-muted);
--border: var(--ui-line);
--accent: var(--ui-solid);
padding: 28px clamp(16px, 3vw, 40px) !important;
}
body:has(.tabs) > .header,
body:has(.tabs) > .stats,
body:has(.tabs) > .tabs,
body:has(.tabs) > .tab-content {
max-width: 1440px;
margin-left: auto;
margin-right: auto;
}
body:has(.tabs) > .header {
position: relative;
padding: 0 0 20px !important;
background: transparent !important;
backdrop-filter: none;
}
.stats { gap: 10px !important; }
.stat-card .num { letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.filter-bar { border-radius: var(--ui-r-md) !important; padding: 10px !important; }
/* Ring progress page */
body:has(#progress-fill) {
background: var(--ui-canvas) !important;
color: var(--ui-ink) !important;
}
body:has(#progress-fill) .container {
max-width: 460px;
padding: 30px !important;
border-radius: var(--ui-r-2xl) !important;
box-shadow: var(--ui-shadow-lg) !important;
}
body:has(#progress-fill) .header {
background: transparent !important;
backdrop-filter: none;
border: 0 !important;
}
body:has(#progress-fill) .stat {
background: var(--ui-surface-raised) !important;
border: 1px solid var(--ui-line);
border-radius: var(--ui-r-md) !important;
}
body:has(#progress-fill) .stats {
grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}
body:has(#progress-fill) .stat-value:not(.success):not(.failed) { color: var(--ui-ink) !important; }
body:has(#progress-fill) .stat-label,
body:has(#progress-fill) .header p,
body:has(#progress-fill) .log { color: var(--ui-muted) !important; }
body:has(#progress-fill) .progress-bar {
height: 12px !important;
border: 1px solid var(--ui-line);
border-radius: 999px !important;
background: var(--ui-surface-raised) !important;
}
body:has(#progress-fill) .progress-fill {
min-width: 0;
border-radius: 999px !important;
color: var(--ui-on-solid) !important;
transition: width 400ms var(--ui-ease) !important;
}
body:has(#progress-fill) .log { border-radius: var(--ui-r-md) !important; }
/* Email return page */
body:has(#return-form), body:has(> #card) {
background: var(--ui-canvas) !important;
}
body:has(> #card) > .card {
background: var(--ui-surface) !important;
border: 1px solid var(--ui-line) !important;
border-radius: var(--ui-r-2xl) !important;
box-shadow: var(--ui-shadow-lg) !important;
backdrop-filter: none !important;
}
body:has(> #card) .brand { color: var(--ui-muted) !important; letter-spacing: .08em; }
body:has(> #card) .icon {
background: var(--ui-surface-raised) !important;
color: var(--ui-ink) !important;
border: 1px solid var(--ui-line);
border-radius: var(--ui-r-lg) !important;
}
body:has(> #card) h1 { color: var(--ui-ink); }
body:has(> #card) p, body:has(> #card) .label { color: var(--ui-muted) !important; }
body:has(> #card) .info { border-radius: var(--ui-r-lg) !important; }
body:has(> #card) .row { border-color: var(--ui-line) !important; }
/* Standalone authentication page */
.auth-page {
min-height: 100dvh;
display: grid;
place-items: center;
padding: 24px;
background: var(--ui-canvas) !important;
}
.login-box {
width: min(100%, 380px);
padding: 32px;
border: 1px solid var(--ui-line);
border-radius: var(--ui-r-2xl);
background: var(--ui-surface);
box-shadow: var(--ui-shadow-lg);
animation: ui-rise-in 520ms var(--ui-ease) both;
}
.login-mark {
width: 48px;
height: 48px;
display: grid;
place-items: center;
margin-bottom: 24px;
border: 1px solid var(--ui-line);
border-radius: var(--ui-r-lg);
background: var(--ui-surface-raised);
color: var(--ui-ink);
font-size: 17px;
font-weight: 760;
}
.login-box h1 {
margin: 0;
color: var(--ui-ink);
font-size: 24px;
line-height: 1.15;
}
.login-subtitle {
margin: 8px 0 24px;
color: var(--ui-muted);
font-size: 14px;
}
.login-box label {
display: block;
margin: 16px 0 7px;
color: var(--ui-muted);
font-size: 13px;
font-weight: 600;
}
.login-box input {
width: 100%;
padding: 11px 13px;
font-size: 15px;
}
.login-box button {
width: 100%;
min-height: 46px;
margin-top: 24px;
border: 0;
border-radius: var(--ui-r-md);
background: var(--ui-solid);
color: var(--ui-on-solid);
font-size: 15px;
font-weight: 680;
cursor: pointer;
}
.login-box button:hover {
background: color-mix(in srgb, var(--ui-solid) 84%, var(--ui-canvas));
}
.form-error {
margin: 18px 0 2px;
padding: 11px 13px;
border: 1px solid color-mix(in srgb, var(--danger, #d93b35) 28%, transparent);
border-radius: var(--ui-r-md);
background: color-mix(in srgb, var(--danger, #d93b35) 10%, transparent);
color: var(--danger, #d93b35);
font-size: 13px;
line-height: 1.5;
}
.panel-title::before { display: none !important; }
/* Acrylic map chrome: one material recipe across browser and native WebView. */
html:not(.in-native-shell) .header {
background: var(--ui-header-acrylic) !important;
border-color: var(--ui-line-strong) !important;
box-shadow: var(--ui-shadow-sm) !important;
-webkit-backdrop-filter: blur(24px) saturate(1.4) !important;
backdrop-filter: blur(24px) saturate(1.4) !important;
}
.legend,
html.in-native-shell .bike-card {
background: var(--ui-acrylic) !important;
border-color: var(--ui-line-strong) !important;
-webkit-backdrop-filter: blur(20px) saturate(1.35) !important;
backdrop-filter: blur(20px) saturate(1.35) !important;
}
/* 原生壳:native-tools 卡壳保留,材质换成顶部栏同款透明亚克力 */
html.in-native-shell #native-tools {
background: var(--ui-header-acrylic) !important;
border-color: var(--ui-line-strong) !important;
-webkit-backdrop-filter: blur(24px) saturate(1.4) !important;
backdrop-filter: blur(24px) saturate(1.4) !important;
}
/* Keep the legend pinned to the viewport, with breathing room below the web header. */
.legend {
position: absolute !important;
top: 14px !important;
right: 14px !important;
}
/* Analysis card uses the same translucent acrylic recipe in browser and native shell. */
.stats-card {
background: var(--ui-acrylic) !important;
border-color: var(--ui-line-strong) !important;
box-shadow: var(--ui-shadow-md) !important;
-webkit-backdrop-filter: blur(20px) saturate(1.35) !important;
backdrop-filter: blur(20px) saturate(1.35) !important;
}
/* 图例、数据分析卡、版本号、找车按钮、底部扫码栏、车牌输入框与顶部栏同一亚克力材质(浏览器与原生壳统一) */
.legend,
.stats-card,
.version-badge,
.locate-fab,
.scan-bar,
.scan-input {
background: var(--ui-header-acrylic) !important;
border-color: var(--ui-line-strong) !important;
-webkit-backdrop-filter: blur(24px) saturate(1.4) !important;
backdrop-filter: blur(24px) saturate(1.4) !important;
}
/* 车牌输入框 placeholder 用图例文字同款灰(--ui-muted),深浅色自适应 */
.scan-input::placeholder {
color: var(--ui-muted) !important;
}
html.in-native-shell #native-tools #auth-btn.logged-in {
background: var(--ui-acrylic-soft) !important;
background-image: none !important;
color: var(--ui-ink) !important;
border: 1px solid var(--ui-line-strong) !important;
box-shadow: inset 0 1px 0 color-mix(in srgb, var(--ui-ink) 7%, transparent),
var(--ui-shadow-sm) !important;
-webkit-backdrop-filter: blur(18px) saturate(1.3) !important;
backdrop-filter: blur(18px) saturate(1.3) !important;
}
html.in-native-shell .scan-input {
background: var(--ui-acrylic-soft) !important;
border-color: var(--ui-line-strong) !important;
}
/* Keep the map as a full-viewport underlay so translucent chrome always reveals map tiles. */
#map-container {
position: relative;
z-index: 0;
background: transparent !important;
}
#baidu_map {
position: fixed !important;
inset: 0 !important;
width: 100% !important;
height: 100% !important;
z-index: 0;
}
.header,
.order-banner,
.auth-expiry-banner,
#share-banners,
.rental-bar,
.scan-bar {
position: relative;
}
#share-banners {
z-index: 150;
}
@media (max-width: 480px) {
.legend { top: 10px !important; right: 10px !important; }
}
/* Semantic acrylic status banners keep the map visible without losing meaning. */
.rental-bar,
.order-banner,
.auth-expiry-banner,
.share-banner {
color: #fbfbfa !important;
border-bottom: 1px solid rgba(255, 255, 255, .22);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), var(--ui-shadow-sm);
-webkit-backdrop-filter: blur(20px) saturate(1.45) !important;
backdrop-filter: blur(20px) saturate(1.45) !important;
}
.rental-bar,
.order-banner {
background: rgba(198, 80, 0, .56) !important;
}
/* 登录态到期提醒:临近用琥珀色,不足 1 天转红 */
.auth-expiry-banner {
background: rgba(186, 104, 0, .62) !important;
}
.auth-expiry-banner.urgent {
background: rgba(218, 32, 55, .62) !important;
}
.order-banner.warning {
background: rgba(218, 32, 55, .60) !important;
}
.order-banner.riding {
background: rgba(0, 82, 168, .56) !important;
}
.share-banner {
background: rgba(72, 59, 164, .56) !important;
}
.share-banner.rider {
background: rgba(0, 115, 85, .56) !important;
}
.rental-bar-btn,
.order-banner-btn,
.auth-expiry-banner-btn,
.share-banner-btn {
color: #fbfbfa !important;
background: rgba(255, 255, 255, .14) !important;
border-color: rgba(255, 255, 255, .34) !important;
-webkit-backdrop-filter: blur(12px) saturate(1.25);
backdrop-filter: blur(12px) saturate(1.25);
}
.rental-bar-btn:hover,
.order-banner-btn:hover,
.auth-expiry-banner-btn:hover,
.share-banner-btn:hover {
background: rgba(255, 255, 255, .22) !important;
}
/* Layered reveal is limited to primary content groups. */
.stats-grid > *, .stats > *, .panel, body:has(#progress-fill) .container,
body:has(> #card) > .card {
animation: ui-rise-in 520ms var(--ui-ease) both;
}
.stats-grid > *:nth-child(2), .stats > *:nth-child(2) { animation-delay: 45ms; }
.stats-grid > *:nth-child(3), .stats > *:nth-child(3) { animation-delay: 90ms; }
.stats-grid > *:nth-child(4), .stats > *:nth-child(4) { animation-delay: 135ms; }
.stats-grid > *:nth-child(n+5), .stats > *:nth-child(n+5) { animation-delay: 180ms; }
@keyframes ui-page-in {
from { opacity: 0; transform: translateY(5px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes ui-page-out {
from { opacity: 1; transform: translateY(0); }
to { opacity: 0; transform: translateY(-4px); }
}
@keyframes ui-rise-in {
from { opacity: 0; transform: translateY(12px); }
to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 640px) {
body:has(.tabs) { padding: 18px 12px !important; }
body:has(.tabs) h1 { font-size: 22px !important; }
.stats { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
.stats-card, .panel { border-radius: var(--ui-r-md) !important; }
body:has(#progress-fill) .container,
body:has(> #card) > .card { padding: 24px !important; }
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
scroll-behavior: auto !important;
animation-duration: .01ms !important;
animation-iteration-count: 1 !important;
transition-duration: .01ms !important;
transition-delay: 0s !important;
}
body, body.ui-page-leaving { transform: none !important; opacity: 1 !important; }
}
+309
View File
@@ -0,0 +1,309 @@
/* Numeric coordinates, pixel-distance clustering and native, cross-fading overlays. */
(function (root) {
'use strict';
// BMapGL's top three levels (19, 20, 21) always show individual bikes.
const SINGLE_BIKE_ZOOM = 19;
const PREFERENCE_KEY = 'xbniu_map_clustering';
function readClusteringPreference(storage) {
try { return storage.getItem(PREFERENCE_KEY) !== 'false'; }
catch (error) { return true; }
}
function writeClusteringPreference(storage, enabled) {
try { storage.setItem(PREFERENCE_KEY, String(!!enabled)); return true; }
catch (error) { return false; }
}
function coordinate(value, limit) {
if (typeof value !== 'number' && typeof value !== 'string') return null;
if (typeof value === 'string' && !value.trim()) return null;
const n = Number(value);
return Number.isFinite(n) && Math.abs(n) <= limit ? n : null;
}
function normalizeBikes(bikes) {
return (bikes || []).flatMap(bike => {
if (!bike) return [];
const latitude = coordinate(bike.latitude, 90);
const longitude = coordinate(bike.longitude, 180);
if (latitude === null || longitude === null || (latitude === 0 && longitude === 0)) return [];
return [{ ...bike, latitude, longitude, state: Number(bike.state), status: Number(bike.status) }];
});
}
function bikeId(bike) {
return String(parseInt(bike.code, 10) || bike.code || bike.id || `${bike.latitude},${bike.longitude}`);
}
// Look in neighbouring spatial buckets, then measure an actual pixel radius.
// Anchors stay fixed during each pass: a chain of cars cannot swallow the campus.
// Sorting by ID makes results independent of response order and map panning.
function clusterBikes(bikes, project, getPoint, getState, radius = 64, selectedId = null, zoom = 0, enabled = true) {
const buckets = new Map();
const groups = [];
const clusteringEnabled = enabled && zoom < SINGLE_BIKE_ZOOM;
const sorted = normalizeBikes(bikes).sort((a, b) => bikeId(a).localeCompare(bikeId(b), 'en'));
sorted.forEach(bike => {
const point = getPoint(bike);
if (!point || !Number.isFinite(point.lat) || !Number.isFinite(point.lng)) return;
const pixel = project(point);
if (!pixel || !Number.isFinite(pixel.x) || !Number.isFinite(pixel.y)) return;
const id = bikeId(bike);
const gx = Math.floor(pixel.x / radius), gy = Math.floor(pixel.y / radius);
let nearest = null, distance = radius * radius;
if (clusteringEnabled && id !== String(selectedId)) {
for (let x = gx - 1; x <= gx + 1; x++) {
for (let y = gy - 1; y <= gy + 1; y++) {
(buckets.get(`${x}:${y}`) || []).forEach(group => {
const d = (group.x - pixel.x) ** 2 + (group.y - pixel.y) ** 2;
if (d < distance) { nearest = group; distance = d; }
});
}
}
}
if (!nearest) {
nearest = { x: pixel.x, y: pixel.y, members: [], lat: 0, lng: 0 };
groups.push(nearest);
if (clusteringEnabled && id !== String(selectedId)) {
const key = `${gx}:${gy}`;
if (!buckets.has(key)) buckets.set(key, []);
buckets.get(key).push(nearest);
}
}
nearest.members.push(bike);
nearest.lat += point.lat;
nearest.lng += point.lng;
});
return groups.map(group => {
const count = group.members.length;
const ids = group.members.map(bikeId);
return {
key: `${count === 1 ? 'bike' : 'cluster'}:${ids.join(',')}`, ids,
members: group.members, count,
point: { lat: group.lat / count, lng: group.lng / count },
available: group.members.filter(bike => getState(bike) === 'available').length,
size: count === 1 ? 36 : Math.min(72, 48 + Math.log2(count) * 3),
offset: { x: 0, y: 0 }
};
});
}
function createLayer(options) {
const { map, getPoint, getState, getIcon, onBikeClick } = options;
const layer = document.createElement('div');
layer.className = 'bike-bubble-layer';
// Native overlay pixels and the SDK's pane share the same camera transform.
// Screen pixels in a sibling DOM layer can lag behind a reverse zoom.
function BubbleOverlay() {}
BubbleOverlay.prototype = new BMapGL.Overlay();
const overlay = new BubbleOverlay();
overlay.initialize = () => {
map.getPanes().labelPane.appendChild(layer);
return layer;
};
overlay.draw = () => { records.forEach(position); };
const motionQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
let records = new Map(), bikes = [], selectedId = null;
let clusteringEnabled = options.enabled !== false;
let frame = 0, regroupFrame = 0, expandedKey = null, destroyed = false;
const listeners = [];
map.addOverlay(overlay);
function point(value) { return new BMapGL.Point(value.lng, value.lat); }
function schedule() {
if (!frame && !destroyed) frame = requestAnimationFrame(draw);
}
function position(record) {
const p = map.pointToOverlayPixel(point(record.position));
if (!p || !Number.isFinite(p.x) || !Number.isFinite(p.y)) {
record.el.style.visibility = 'hidden';
return;
}
record.el.style.visibility = '';
record.el.style.transform = `translate3d(${p.x + record.offset.x}px,${p.y + record.offset.y}px,0)`;
record.button.style.transform = 'translate(-50%,-50%)';
record.button.style.opacity = record.opacity;
}
// Only opacity changes: every marker stays anchored to its actual coordinate.
function fade(record, retiring) {
record.retiring = retiring;
record.fadeFrom = record.opacity;
record.fadeStart = performance.now();
}
function draw(now) {
frame = 0;
let moving = false;
records.forEach((record, key) => {
const progress = motionQuery.matches ? 1 : Math.min(Math.max((now - record.fadeStart) / 160, 0), 1);
const eased = 1 - (1 - progress) ** 3;
record.opacity = record.fadeFrom + ((record.retiring ? 0 : 1) - record.fadeFrom) * eased;
position(record);
if (record.retiring && progress === 1) { record.el.remove(); records.delete(key); }
moving = moving || progress < 1;
});
if (moving) schedule();
}
function updateContent(record, node) {
record.node = node;
record.position = { ...node.point };
record.offset = node.offset;
record.el.style.zIndex = node.count > 1 ? '2' : '3';
const button = record.button;
button.className = node.count > 1 ? 'bike-bubble' : 'bike-dot';
button.style.setProperty('--bubble-size', `${node.size}px`);
if (node.count > 1) {
button.classList.toggle('is-unavailable', node.available === 0);
button.style.setProperty('--available-angle', `${node.available / node.count * 360}deg`);
if (!record.countEl) {
button.replaceChildren();
const ring = document.createElement('span'); ring.className = 'bike-bubble-ring';
ring.setAttribute('aria-hidden', 'true');
record.countEl = document.createElement('span'); record.countEl.className = 'bike-bubble-count';
record.labelEl = document.createElement('span'); record.labelEl.className = 'bike-bubble-label';
button.append(ring, record.countEl, record.labelEl);
}
record.countEl.textContent = node.count;
record.labelEl.textContent = node.available ? `${node.available} 可用` : '暂无可用';
button.setAttribute('aria-label', `${node.count} 辆电动车,${node.available} 辆可用,点击展开`);
} else {
record.setIcon(getIcon(node.members[0], node.ids[0] === String(selectedId)));
record.setTitle(`#${node.members[0].code}`);
button.setAttribute('aria-label', `查看电动车 #${node.members[0].code}`);
}
}
function createRecord(node) {
const el = document.createElement('div'); el.className = 'bike-bubble-anchor';
const button = document.createElement('button'); button.type = 'button';
el.appendChild(button); layer.appendChild(el);
const record = {
el, button, node, position: { ...node.point }, offset: node.offset,
opacity: 0, fadeFrom: 0, fadeStart: performance.now(), retiring: false,
__animId: node.ids[0],
getPosition() { return point(this.position); },
getTitle() { return this.button.title; },
setTitle(title) { this.button.title = title; },
setIcon(icon) {
const appearance = icon.__xbniuAppearance;
if (!appearance) return;
let img = this.button.querySelector('img');
if (!img) { img = document.createElement('img'); img.alt = ''; this.button.replaceChildren(img); }
if (img.getAttribute('src') !== appearance.url) img.src = appearance.url;
this.button.style.width = this.button.style.height = `${appearance.size}px`;
this.el.style.zIndex = appearance.size > 36 ? '5' : '3';
},
bringToTop() { this.el.style.zIndex = '6'; }
};
// Never turn movement across a bubble into a tap.
let down = null;
button.addEventListener('pointerdown', event => { down = { x: event.clientX, y: event.clientY }; });
button.addEventListener('click', event => {
event.stopPropagation();
if (down && Math.hypot(event.clientX - down.x, event.clientY - down.y) > 8) { down = null; return; }
down = null;
if (record.retiring) return;
if (record.node.count === 1) onBikeClick(record.node.ids[0]);
else expand(record.node);
});
button.addEventListener('dblclick', event => event.stopPropagation());
updateContent(record, node);
position(record);
return record;
}
function render(nodes) {
const nextKeys = new Set(nodes.map(node => node.key));
nodes.forEach(node => {
let record = records.get(node.key);
if (!record) {
record = createRecord(node);
records.set(node.key, record);
} else {
updateContent(record, node);
if (record.retiring) fade(record, false);
}
record.button.disabled = false;
});
records.forEach((record, key) => {
if (nextKeys.has(key)) return;
if (!record.retiring) fade(record, true);
record.button.disabled = true;
});
options.onMarkersChanged(Array.from(records.values()).filter(r => !r.retiring && r.node.count === 1));
schedule();
}
function regroup() {
regroupFrame = 0;
if (destroyed) return;
expandedKey = null;
render(clusterBikes(bikes, p => map.pointToOverlayPixel(point(p)), getPoint, getState, 64, selectedId, map.getZoom(), clusteringEnabled));
}
function requestRegroup() {
schedule();
if (!regroupFrame) regroupFrame = requestAnimationFrame(regroup);
}
function expand(node) {
const zoom = map.getZoom();
const coincident = node.members.every(bike => {
const p = getPoint(bike);
return Math.abs(p.lat - node.point.lat) + Math.abs(p.lng - node.point.lng) < 1e-8;
});
if (zoom < 21 && !coincident) {
map.centerAndZoom(point(node.point), Math.min(21, zoom + 2));
return;
}
// Identical GPS positions still need individually tappable cars.
// A golden-angle spiral keeps even a dense parking spot separated.
expandedKey = node.key;
const others = Array.from(records.values()).filter(r => !r.retiring && r.node.key !== node.key).map(r => r.node);
const singles = node.members.map((bike, index) => {
const angle = index * 2.399963229728653;
const radius = 38 * Math.sqrt(index + 1);
const id = bikeId(bike);
return { key: `bike:${id}`, ids: [id], members: [bike], count: 1,
available: getState(bike) === 'available' ? 1 : 0, size: 36,
point: getPoint(bike), offset: { x: Math.cos(angle) * radius, y: Math.sin(angle) * radius } };
});
render(others.concat(singles));
}
function listen(name, fn) { map.addEventListener(name, fn); listeners.push([name, fn]); }
listen('moving', schedule);
listen('zooming', schedule);
listen('moveend', () => { if (expandedKey) requestRegroup(); else schedule(); });
listen('zoomend', requestRegroup);
listen('resize', requestRegroup);
listen('click', () => { if (expandedKey) requestRegroup(); });
motionQuery.addEventListener('change', schedule);
return {
setData(data) { bikes = normalizeBikes(data); regroup(); },
setClusteringEnabled(enabled) {
clusteringEnabled = !!enabled;
regroup();
},
setSelected(id) {
if (String(selectedId) === String(id)) return;
selectedId = id;
requestRegroup();
},
refresh: requestRegroup,
destroy() {
destroyed = true;
cancelAnimationFrame(frame); cancelAnimationFrame(regroupFrame);
listeners.forEach(([name, fn]) => map.removeEventListener(name, fn));
motionQuery.removeEventListener('change', schedule);
map.removeOverlay(overlay);
layer.remove(); records.clear();
}
};
}
const api = { normalizeBikes, bikeId, clusterBikes, createLayer,
PREFERENCE_KEY, readClusteringPreference, writeClusteringPreference };
if (typeof module !== 'undefined' && module.exports) module.exports = api;
else root.BikeClusters = api;
})(typeof window === 'undefined' ? globalThis : window);
+132
View File
@@ -0,0 +1,132 @@
/*!
* coordtransform 本地内置版 (前端坐标转换)
* ----------------------------------------------------------------
* API 与 npm 包 coordtransform (github.com/wandergis/coordTransform_js)
* 完全一致:均为标准中国坐标偏移算法(MIT 协议)。
* 提供 wgs84 / gcj02 / bd09 三系两两互转,纯前端、同步、零依赖,
* 避免调用百度在线坐标转换接口(BMapGL.Convertor)时的联网/异步依赖。
*
* 引入方式(map.html):
* <script src="/static/js/coordtransform.js"></script>
* 用法(注意:入参顺序均为 (lng, lat),返回 [lng, lat]):
* coordtransform.wgs84tobd09(gpsLng, gpsLat) // => [bd09_lng, bd09_lat]
*/
(function (root, factory) {
if (typeof module === 'object' && module.exports) {
module.exports = factory(); // CommonJS
} else if (typeof define === 'function' && define.amd) {
define(factory); // AMD
} else {
root.coordtransform = factory(); // 浏览器全局(本文件走此分支)
}
}(typeof self !== 'undefined' ? self : this, function () {
'use strict';
var x_PI = 3.14159265358979324 * 3000.0 / 180.0; // 百度加密偏移系数
var PI = 3.1415926535897932384626; // 圆周率
var a = 6378245.0; // 长半轴(克拉索夫斯基椭球)
var ee = 0.00669342162296594323; // 偏心率平方
// 是否在中国境外(境外不适用 GCJ-02 偏移,原样返回)
function out_of_china(lng, lat) {
return (lng < 72.004 || lng > 137.8347) ||
((lat < 0.8293 || lat > 55.8271) || false);
}
// 纬度偏移量
function transformlat(lng, lat) {
var ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat +
0.1 * lng * lat + 0.2 * Math.sqrt(Math.abs(lng));
ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(lat * PI) + 40.0 * Math.sin(lat / 3.0 * PI)) * 2.0 / 3.0;
ret += (160.0 * Math.sin(lat / 12.0 * PI) + 320 * Math.sin(lat * PI / 30.0)) * 2.0 / 3.0;
return ret;
}
// 经度偏移量
function transformlng(lng, lat) {
var ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng +
0.1 * lng * lat + 0.1 * Math.sqrt(Math.abs(lng));
ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(lng * PI) + 40.0 * Math.sin(lng / 3.0 * PI)) * 2.0 / 3.0;
ret += (150.0 * Math.sin(lng / 12.0 * PI) + 300.0 * Math.sin(lng / 30.0 * PI)) * 2.0 / 3.0;
return ret;
}
// WGS84 -> GCJ02
function wgs84togcj02(lng, lat) {
if (out_of_china(lng, lat)) {
return [lng, lat];
}
var dLat = transformlat(lng - 105.0, lat - 35.0);
var dLng = transformlng(lng - 105.0, lat - 35.0);
var radLat = lat / 180.0 * PI;
var magic = Math.sin(radLat);
magic = 1 - ee * magic * magic;
var sqrtMagic = Math.sqrt(magic);
dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * PI);
dLng = (dLng * 180.0) / (a / sqrtMagic * Math.cos(radLat) * PI);
var mgLat = lat + dLat;
var mgLng = lng + dLng;
return [mgLng, mgLat];
}
// GCJ02 -> WGS84(迭代近似)
function gcj02towgs84(lng, lat) {
if (out_of_china(lng, lat)) {
return [lng, lat];
}
var dlat = transformlat(lng - 105.0, lat - 35.0);
var dlng = transformlng(lng - 105.0, lat - 35.0);
var radlat = lat / 180.0 * PI;
var magic = Math.sin(radlat);
magic = 1 - ee * magic * magic;
var sqrtmagic = Math.sqrt(magic);
dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI);
dlng = (dlng * 180.0) / (a / sqrtmagic * Math.cos(radlat) * PI);
var mglat = lat + dlat;
var mglng = lng + dlng;
return [lng * 2 - mglng, lat * 2 - mglat];
}
// GCJ02 -> BD09
function gcj02tobd09(lng, lat) {
var z = Math.sqrt(lng * lng + lat * lat) + 0.00002 * Math.sin(lat * x_PI);
var theta = Math.atan2(lat, lng) + 0.000003 * Math.cos(lng * x_PI);
var bd_lng = z * Math.cos(theta) + 0.0065;
var bd_lat = z * Math.sin(theta) + 0.006;
return [bd_lng, bd_lat];
}
// BD09 -> GCJ02
function bd09togcj02(lng, lat) {
var x = lng - 0.0065;
var y = lat - 0.006;
var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_PI);
var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_PI);
var gg_lng = z * Math.cos(theta);
var gg_lat = z * Math.sin(theta);
return [gg_lng, gg_lat];
}
// WGS84 -> BD09(定位坐标系最常用:GPS 转百度)
function wgs84tobd09(lng, lat) {
var gcj02 = wgs84togcj02(lng, lat);
return gcj02tobd09(gcj02[0], gcj02[1]);
}
// BD09 -> WGS84(百度转 GPS)
function bd09towgs84(lng, lat) {
var gcj02 = bd09togcj02(lng, lat);
return gcj02towgs84(gcj02[0], gcj02[1]);
}
return {
wgs84togcj02: wgs84togcj02,
gcj02towgs84: gcj02towgs84,
gcj02tobd09: gcj02tobd09,
bd09togcj02: bd09togcj02,
wgs84tobd09: wgs84tobd09,
bd09towgs84: bd09towgs84
};
}));
+5305
View File
File diff suppressed because it is too large Load Diff
+1
View File
File diff suppressed because one or more lines are too long
+100
View File
@@ -0,0 +1,100 @@
/* One full-page settings hierarchy; browser Back and the header use the same route. */
(function () {
'use strict';
const routes = {
'settings-modal': { path: '', title: '设置', load: 'openSettingsPage' },
'auth-modal': { path: '/credentials', title: '微信凭证', load: 'openAuthModal' },
'devices-modal': { path: '/devices', title: '登录设备', load: 'openDevicesModal' },
'rental-settings-modal': { path: '/rental', title: '提醒与自动还车', load: 'openRentalSettingsModal' },
'packages-modal': { path: '/cards', title: '我的优惠卡', load: 'openPackagesModal' },
'orders-modal': { path: '/orders', title: '订单历史', load: 'openOrdersModal' },
'order-traj-modal': { path: '/orders/trajectory', title: '骑行轨迹', parent: 'orders-modal', fallback: 'openOrdersModal', close: 'closeOrderTrajModal' },
'subscribe-modal': { path: '/subscriptions', title: '车辆订阅', load: 'openSubscribeModal' },
'share-modal': { path: '/sharing', title: '共享电动车', load: 'openShareModal' },
'share-config-modal': { path: '/sharing/permissions', title: '共享权限', parent: 'share-modal', fallback: 'openShareModal', close: 'closeShareConfig' },
'share-remark-modal': { path: '/sharing/remark', title: '设置备注', parent: 'share-modal', fallback: 'openShareModal', close: 'closeShareRemark' }
};
const shell = document.getElementById('settings-page');
const content = document.getElementById('settings-page-main');
let active = null;
const scrollPositions = new Map();
const routeId = () => Object.keys(routes).find(id => location.hash === '#settings' + routes[id].path);
function hide() {
if (active) scrollPositions.set(active, content.scrollTop);
Object.keys(routes).forEach(id => {
const view = document.getElementById(id);
view.hidden = true;
view.classList.remove('show');
});
shell.hidden = true;
active = null;
}
function show(id) {
hide();
const view = document.getElementById(id);
view.hidden = false;
view.classList.add('show');
view.removeAttribute('aria-hidden');
shell.hidden = false;
active = id;
document.getElementById('settings-page-title').textContent = routes[id].title;
document.getElementById('settings-page-back').setAttribute('aria-label', id === 'settings-modal' ? '返回地图' : '返回上一页');
document.getElementById('settings-page-back-label').textContent = id === 'settings-modal' ? '地图' : '返回';
document.getElementById('settings-page-home').hidden = id === 'settings-modal';
content.scrollTop = scrollPositions.get(id) || 0;
document.getElementById('settings-page-title').focus({ preventScroll: true });
}
function open(id) {
if (!routes[id]) return;
const hash = '#settings' + routes[id].path;
if (location.hash !== hash) {
const depth = routeId() ? (history.state?.settingsDepth || 0) : 0;
history.pushState({ settingsDepth: depth + 1 }, '', hash);
}
show(id);
}
function close() {
const depth = history.state?.settingsDepth || 0;
hide();
if (depth > 0 && routeId()) history.go(-depth);
else history.replaceState(null, '', location.pathname + location.search);
document.getElementById('auth-btn')?.focus({ preventScroll: true });
}
function back() {
if (!active) return;
const route = routes[active];
if ((history.state?.settingsDepth || 0) > 0) history.back();
else if (active !== 'settings-modal') {
const parent = route.parent || 'settings-modal';
history.replaceState(null, '', '#settings' + routes[parent].path);
const load = routes[parent].load;
if (load && typeof window[load] === 'function') window[load]();
else show(parent);
} else close();
}
function requestBack() {
const cleanup = active && routes[active].close;
if (cleanup && typeof window[cleanup] === 'function') window[cleanup]();
else back();
}
function restore() {
const id = routeId();
if (!id) { hide(); return; }
if (!routes[id].load) {
const parent = routes[id].parent || 'settings-modal';
history.replaceState(null, '', '#settings' + routes[parent].path);
}
const load = routes[id].load || routes[id].fallback;
if (load && typeof window[load] === 'function') window[load]();
else show(id);
}
window.addEventListener('popstate', () => {
const id = routeId();
if (id) show(id); else hide();
});
shell.addEventListener('keydown', event => {
if (event.key === 'Escape') { event.preventDefault(); requestBack(); }
});
window.SettingsPages = { open, back, requestBack, close, hide, restore, isOpen: () => !shell.hidden };
})();
+37
View File
@@ -0,0 +1,37 @@
(function () {
'use strict';
const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
window.uiNavigate = function (url) {
if (reduceMotion) {
window.location.href = url;
return;
}
document.body.classList.add('ui-page-leaving');
window.setTimeout(function () { window.location.href = url; }, 170);
};
window.uiCloseWindow = function () {
if (reduceMotion) {
window.close();
return;
}
document.body.classList.add('ui-page-leaving');
window.setTimeout(function () { window.close(); }, 170);
};
document.addEventListener('click', function (event) {
const link = event.target.closest('a[href]');
if (!link || event.defaultPrevented || event.button !== 0 || event.metaKey ||
event.ctrlKey || event.shiftKey || event.altKey || link.target === '_blank' ||
link.hasAttribute('download')) return;
const destination = new URL(link.href, window.location.href);
if (destination.origin !== window.location.origin ||
(destination.pathname === window.location.pathname && destination.hash)) return;
event.preventDefault();
window.uiNavigate(destination.href);
});
})();
Binary file not shown.

After

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 B

+112
View File
@@ -0,0 +1,112 @@
/* =====================================================================
* sw.js — 地图瓦片本地缓存 (Service Worker)
* 作用:拦截并缓存百度地图(及常见地图CDN)的底图瓦片资源,第二次打开
* 同一区域时直接从本地 Cache 读取,减少重复下载。
*
* 注意:
* - 仅缓存地图瓦片图片;对本站 /api/*、页面文档等一律不缓存(车辆数据需实时)。
* - 百度瓦片为跨域 no-cors(opaque) 响应,可缓存可命中,但缓存进出由浏览器管理。
* - 需 https(或 localhost) 环境。若发现某些瓦片域名未命中,按需扩展 CACHE_HOSTS。
* - 瓦片缓存容量由浏览器配额控制;本脚本会主动裁剪旧缓存以免撑爆。
* ===================================================================== */
const MAP_CACHE = 'xbniu-map-tiles-v1';
// 百度/地图瓦片常见来源域名或路径片段。命中即视为“地图瓦片”走缓存策略。
// 覆盖百度 GL WebGL 实际使用的 maponlineX.bdimg.com、*.map.baidu.com、bmapcdn.com 等。
const CACHE_HOST_MARKERS = [
'bdimg.com', // 百度图片/瓦片主域名(maponline0/1/2...bdimg.com 等)
'map.baidu.com', // 百度地图
'bmapcdn.com', // 百度 GL 静态资源
'bcebos.com', // 百度云存储(部分瓦片/资源)
'mapabc.com', // 百度地图历史域名
'baiducontent.com' // 百度内容域
];
function isMapTile(url) {
try {
const u = new URL(url);
if (CACHE_HOST_MARKERS.some(m => u.hostname.indexOf(m) !== -1)) {
return true;
}
return false;
} catch (e) {
return false;
}
}
// POST 或非 GET 一律跳过(不去占用 opaque 缓存)
function onlyGET(req) {
return req.method === 'GET';
}
self.addEventListener('install', (event) => {
// 立即接管,不等旧的这一版
self.skipWaiting();
event.waitUntil(
caches.open(MAP_CACHE).then((c) => c.keys()).catch(() => {})
);
});
self.addEventListener('activate', (event) => {
event.waitUntil(
caches.keys()
.then((keys) => Promise.all(
keys.filter((k) => k !== MAP_CACHE && k.startsWith('xbniu-map-tiles-'))
.map((k) => caches.delete(k))
))
.then(() => self.clients.claim())
);
});
self.addEventListener('message', (event) => {
// 提供清空缓存/状态消息,便于页面内联测试或调试
if (event.data && event.data.type === 'CLEAR_MAP_CACHE') {
caches.delete(MAP_CACHE).then(() => {
if (self.registration.waiting) self.registration.waiting.postMessage({type:'CLEARED'});
});
}
});
self.addEventListener('fetch', (event) => {
const req = event.request;
const url = req.url;
// 非 GET、以及非地图瓦片的其它请求(包括本站 /api/* 与页面)——保持默认直连
if (!onlyGET(req)) return;
const tile = isMapTile(url);
// 诊断:打印所有百度/地图域 GET 请求,便于确认到底哪些被拦截
if (tile) console.log('[SW] 缓存请求: ' + url.slice(0, 120));
if (!tile) return;
// 地图瓦片:缓存优先;未命中则网络获取并写入缓存
event.respondWith(
caches.match(req).then((cached) => {
if (cached) return cached;
return fetch(req).then((resp) => {
// 关键:百度瓦片多为跨域 no-cors 的 opaque 响应,resp.status === 0。
// 只要“似成功”(status 200 或 0 即 opaque) 就缓存;明确的 4xx/5xx 不缓存。
const ok = (resp && (resp.status === 200 || resp.status === 0));
if (ok) {
const copy = resp.clone();
caches.open(MAP_CACHE).then((cache) => cache.put(req, copy));
trimCache(MAP_CACHE, 300);
}
return resp;
}).catch(() => cached);
})
);
});
// 把指定缓存裁剪到不超过 maxItems 条(旧条目优先删除:新增条目排前面)
function trimCache(cacheName, maxItems) {
caches.open(cacheName).then((cache) => {
cache.keys().then((keys) => {
if (keys.length > maxItems) {
// keys() 返回插入顺序大致新→旧不确定;稳妥起见删掉超出部分中的前若干个
const toDelete = keys.length - maxItems;
Promise.all(keys.slice(0, toDelete).map((k) => cache.delete(k))).catch(() => {});
}
});
}).catch(() => {});
}