feat(前端): TypeScript 重写版(esbuild IIFE 产物,暂不接管线上)
- 新增 src-ts/(22 个 .ts / 7792 行):按 core / map / card / order / nav / share / subscribe / ui / compat 分层,types 里有 BMapGL 与 API 响应声明 - compat/globals.ts 是唯一挂 window 的地方(292 个),覆盖模板 139 处内联事件 - esbuild 产出 static/dist/app.js(226.6 KiB,IIFE,es2019)+ README(构建/切换/回滚) - 构建可复现:node esbuild.config.mjs、node --check、npx tsc --noEmit 均通过 - .gitignore 增加 node_modules/ 与 static/dist/*.map(sourcemap 可重生成,不入库) - 暂不改 templates/map.html 与 MAP_ASSETS:等独立核对通过再切换,回滚=换回四个 script
This commit is contained in:
@@ -0,0 +1,543 @@
|
||||
/* 由 static/js/{navigation,share,subscribe,map}.js 逐块搬运而来;正文与原实现一致。 */
|
||||
|
||||
import { S } from "../core/state";
|
||||
import { escHtml } from "../core/format";
|
||||
import { startRental } from "../order/actions";
|
||||
import { checkPendingShareRequests, refreshShareBanners } from "../share/share";
|
||||
// static/js/map.js:4085-4085
|
||||
let currentQrPosition: any = null; // 当前二维码对应的位置
|
||||
|
||||
// static/js/map.js:4087-4146
|
||||
export function showQrModal(code) {
|
||||
const modal = document.getElementById("qr-modal");
|
||||
const qrBox = document.getElementById("qrcode-box");
|
||||
const quickBtn = document.getElementById("quick-unlock-btn");
|
||||
|
||||
// 清空旧的二维码
|
||||
qrBox.innerHTML = "";
|
||||
|
||||
// 获取当前位置
|
||||
currentQrPosition = null;
|
||||
if (navigator.geolocation) {
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
pos => {
|
||||
currentQrPosition = {
|
||||
lat: pos.coords.latitude,
|
||||
lng: pos.coords.longitude
|
||||
};
|
||||
},
|
||||
err => console.error("获取位置失败:", err),
|
||||
{ timeout: 5000 }
|
||||
);
|
||||
}
|
||||
|
||||
// 生成新二维码
|
||||
const url = "http://bike.sdlongren.com/bicycle?code=" + code;
|
||||
|
||||
// 判断暗色模式
|
||||
const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||
const dark = isDark ? '#ffffff' : '#000000';
|
||||
const light = isDark ? '#1a1a1a' : '#ffffff';
|
||||
|
||||
// 生成 img 格式二维码(参考 xbcr.html)
|
||||
createQrImage(url, dark, light, function(dataUrl) {
|
||||
qrBox.innerHTML = ""; // 清空旧内容
|
||||
if (!dataUrl) {
|
||||
// 二维码库不可用:明确告知并保留一键开锁入口,避免“点了没反应”
|
||||
qrBox.innerHTML = '<div style="padding:30px 10px;color:var(--text-secondary);font-size:13px;">二维码生成组件加载失败,<br/>可直接使用下方一键开锁。</div>';
|
||||
modal.classList.add("show");
|
||||
quickBtn.style.display = (S.authToken && S.currentUser) ? "block" : "none";
|
||||
showToast("二维码组件加载失败,可一键开锁");
|
||||
return;
|
||||
}
|
||||
const img = document.createElement('img');
|
||||
img.src = dataUrl;
|
||||
img.alt = '用车二维码';
|
||||
img.style.cssText = 'width:160px;height:160px;border-radius:4px;box-shadow:rgba(0,0,0,0.4) 2px 2px 8px;display:block;';
|
||||
qrBox.appendChild(img);
|
||||
qrBox.dataset.bikeCode = code; // 存车牌,长按时用
|
||||
modal.classList.add("show");
|
||||
|
||||
// 如果用户已登录,显示一键开锁按钮
|
||||
if (S.authToken && S.currentUser) {
|
||||
quickBtn.style.display = "block";
|
||||
} else {
|
||||
quickBtn.style.display = "none";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 生成高质量二维码图片(img格式,适配微信长按识别)
|
||||
|
||||
// static/js/map.js:4147-4190
|
||||
export function createQrImage(text, dark, light, callback) {
|
||||
const size = 160;
|
||||
const padding = 20;
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = canvas.height = size + padding * 2;
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
// 白色背景
|
||||
ctx.fillStyle = light;
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// 生成二维码到临时容器
|
||||
const tmp = document.createElement('div');
|
||||
tmp.style.display = 'none';
|
||||
document.body.appendChild(tmp);
|
||||
|
||||
// qrcodejs 加载失败时(如外链 CDN 不可达)给出明确提示,而不是无声无息
|
||||
if (typeof QRCode === "undefined") {
|
||||
document.body.removeChild(tmp);
|
||||
callback(null);
|
||||
return;
|
||||
}
|
||||
|
||||
new QRCode(tmp, {
|
||||
text: text,
|
||||
width: size,
|
||||
height: size,
|
||||
colorDark: dark,
|
||||
colorLight: light,
|
||||
correctLevel: QRCode.CorrectLevel.L
|
||||
});
|
||||
|
||||
// 从临时容器提取 canvas 并画到带padding的画布上
|
||||
setTimeout(function() {
|
||||
var qrCanvas = tmp.querySelector('canvas');
|
||||
if (qrCanvas) {
|
||||
ctx.drawImage(qrCanvas, padding, padding);
|
||||
}
|
||||
document.body.removeChild(tmp);
|
||||
callback(qrCanvas ? canvas.toDataURL('image/png', 1) : null);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
// 关闭二维码弹窗
|
||||
|
||||
// static/js/map.js:4191-4200
|
||||
export function closeQrModal() {
|
||||
document.getElementById("qr-modal").classList.remove("show");
|
||||
document.getElementById("quick-unlock-btn").style.display = "none";
|
||||
// 清除长按定时器
|
||||
longPressTimer = null;
|
||||
longPressTarget = null;
|
||||
currentQrPosition = null;
|
||||
}
|
||||
|
||||
// 长按检测变量
|
||||
|
||||
// static/js/map.js:4201-4201
|
||||
let longPressTimer: any = null;
|
||||
|
||||
// static/js/map.js:4202-4202
|
||||
let longPressTarget: any = null;
|
||||
|
||||
// static/js/map.js:4203-4205
|
||||
let qrModalBikeCode: any = null; // 当前二维码对应的车牌
|
||||
|
||||
// 二维码弹窗的二维码区域长按检测
|
||||
|
||||
// static/js/map.js:4206-4247
|
||||
export function setupQrLongPress() {
|
||||
const qrBox = document.getElementById("qrcode-box");
|
||||
|
||||
// 统一用 pointer 事件(兼容触摸和鼠标)
|
||||
qrBox.addEventListener("pointerdown", function(e) {
|
||||
if (!S.currentUser) return;
|
||||
e.preventDefault(); // 阻止右键菜单等默认行为
|
||||
qrModalBikeCode = qrBox.dataset.bikeCode || "";
|
||||
longPressTimer = setTimeout(() => {
|
||||
longPressTimer = null;
|
||||
if (qrModalBikeCode && S.currentUser) {
|
||||
// 视觉反馈
|
||||
qrBox.style.backgroundColor = "rgba(52,199,89,0.2)";
|
||||
setTimeout(() => { qrBox.style.backgroundColor = "white"; }, 500);
|
||||
startRental(qrModalBikeCode);
|
||||
}
|
||||
}, 300);
|
||||
});
|
||||
|
||||
qrBox.addEventListener("pointerup", function(e) {
|
||||
if (longPressTimer) {
|
||||
clearTimeout(longPressTimer);
|
||||
longPressTimer = null;
|
||||
}
|
||||
});
|
||||
|
||||
qrBox.addEventListener("pointerleave", function(e) {
|
||||
if (longPressTimer) {
|
||||
clearTimeout(longPressTimer);
|
||||
longPressTimer = null;
|
||||
}
|
||||
});
|
||||
|
||||
qrBox.addEventListener("pointercancel", function(e) {
|
||||
if (longPressTimer) {
|
||||
clearTimeout(longPressTimer);
|
||||
longPressTimer = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 页面加载时初始化长按检测
|
||||
|
||||
// static/js/map.js:4259-4259
|
||||
let _appConfirmResolve: any = null;
|
||||
|
||||
// static/js/map.js:4260-4295
|
||||
export function appConfirm(message, opts) {
|
||||
const o = opts || {};
|
||||
const modal = document.getElementById("app-confirm-modal");
|
||||
const titleEl = document.getElementById("app-confirm-title");
|
||||
const textEl = document.getElementById("app-confirm-text");
|
||||
const okBtn = document.getElementById("app-confirm-ok");
|
||||
const cancelBtn = document.getElementById("app-confirm-cancel");
|
||||
if (!modal || !textEl) { // 极老页面兜底
|
||||
return Promise.resolve(window.confirm ? window.confirm(message) : true);
|
||||
}
|
||||
titleEl.textContent = o.title || "确认操作";
|
||||
// 支持换行(保留 \n 的排版)
|
||||
textEl.innerHTML = String(message || "")
|
||||
.split("\n")
|
||||
.map(line => escHtml(line))
|
||||
.join("<br/>");
|
||||
okBtn.textContent = o.okText || "确认";
|
||||
cancelBtn.textContent = o.cancelText || "取消";
|
||||
okBtn.classList.toggle("danger", !!o.danger);
|
||||
|
||||
return new Promise<any>(resolve => {
|
||||
_appConfirmResolve = resolve;
|
||||
const finish = (val) => {
|
||||
modal.classList.remove("show");
|
||||
okBtn.onclick = null;
|
||||
cancelBtn.onclick = null;
|
||||
modal.onclick = null;
|
||||
_appConfirmResolve = null;
|
||||
resolve(val);
|
||||
};
|
||||
okBtn.onclick = (e) => { e.stopPropagation(); finish(true); };
|
||||
cancelBtn.onclick = (e) => { e.stopPropagation(); finish(false); };
|
||||
modal.onclick = (e) => { if (e.target === modal) finish(false); };
|
||||
modal.classList.add("show");
|
||||
});
|
||||
}
|
||||
|
||||
// static/js/map.js:4296-4303
|
||||
export function appConfirmClose() {
|
||||
if (_appConfirmResolve) {
|
||||
const r = _appConfirmResolve;
|
||||
_appConfirmResolve = null;
|
||||
document.getElementById("app-confirm-modal").classList.remove("show");
|
||||
r(false);
|
||||
}
|
||||
}
|
||||
|
||||
// static/js/map.js:4357-4366
|
||||
export function showToast(msg) {
|
||||
const t = document.getElementById("toast");
|
||||
t.textContent = msg;
|
||||
t.classList.add("show");
|
||||
setTimeout(() => t.classList.remove("show"), 2500);
|
||||
}
|
||||
|
||||
// ========== 抓包工具下载 ==========
|
||||
// 安装包是 Windows exe,任何手机/平板都跑不了;微信、QQ、支付宝等内置
|
||||
// WebView 还会直接拦截 exe 下载。这两类情况都改为提示复制链接到电脑浏览器。
|
||||
|
||||
// static/js/map.js:4367-4370
|
||||
const CAPTURE_TOOL_PATH = "/download/capture-tool.exe";
|
||||
|
||||
// 鸿蒙 UA 有两种:老版 HarmonyOS + Android 兼容层,新版纯 OpenHarmony/ArkWeb;
|
||||
// 微信鸿蒙版仍带 MicroMessenger,但部分版本 UA 精简后只剩 HarmonyOS。
|
||||
|
||||
// static/js/map.js:4371-4374
|
||||
export function detectHarmony() {
|
||||
const ua = navigator.userAgent || "";
|
||||
return /OpenHarmony|HarmonyOS|ArkWeb|HMSCore/i.test(ua);
|
||||
}
|
||||
|
||||
// static/js/map.js:4375-4392
|
||||
export function detectMobile() {
|
||||
const ua = navigator.userAgent || "";
|
||||
const touchPoints = navigator.maxTouchPoints || 0;
|
||||
// iPadOS 13+ 默认「请求桌面网站」,UA 伪装成 macOS;
|
||||
// 靠触点数区分真正的 Mac(0)与 iPad(>1)
|
||||
if (/Macintosh/.test(ua) && touchPoints > 1) return "iPad";
|
||||
// 鸿蒙平板也常带 Tablet,先于手机判断
|
||||
if (/OpenHarmony|HarmonyOS|ArkWeb/.test(ua)) {
|
||||
return /Tablet/i.test(ua) ? "鸿蒙平板" : "鸿蒙手机";
|
||||
}
|
||||
if (/iPhone|iPod/.test(ua)) return "iPhone";
|
||||
if (/iPad/.test(ua)) return "iPad";
|
||||
if (/Android/.test(ua)) return /Tablet/i.test(ua) ? "安卓平板" : "安卓手机";
|
||||
// 兜底:UA 明确标了 Mobile 但没给出具体平台
|
||||
if (/Mobile/i.test(ua)) return "手机";
|
||||
return null;
|
||||
}
|
||||
// 返回需要拦截的"环境名",null 表示可以直接下载
|
||||
|
||||
// static/js/map.js:4393-4404
|
||||
export function detectInAppBrowser() {
|
||||
const ua = navigator.userAgent || "";
|
||||
// 原生壳优先判断:它是最外层容器,UA 里可能同时带 Android
|
||||
if (/xbniu-native/i.test(ua)) return "APP";
|
||||
if (/MicroMessenger/i.test(ua)) return detectHarmony() ? "鸿蒙微信" : "微信";
|
||||
if (/\bQQ\/|QQBrowser/i.test(ua)) return "QQ";
|
||||
if (/AlipayClient/i.test(ua)) return "支付宝";
|
||||
if (/DingTalk/i.test(ua)) return "钉钉";
|
||||
if (/Weibo/i.test(ua)) return "微博";
|
||||
if (/aweme|ByteDance/i.test(ua)) return "抖音";
|
||||
return null;
|
||||
}
|
||||
|
||||
// static/js/map.js:4405-4408
|
||||
export function captureToolUrl() {
|
||||
return new URL(CAPTURE_TOOL_PATH, window.location.href).href;
|
||||
}
|
||||
// 返回 true 时放行 <a download> 的原生下载
|
||||
|
||||
// static/js/map.js:4409-4416
|
||||
export function onDownloadCaptureTool(event) {
|
||||
const app = detectInAppBrowser();
|
||||
const mobile = app ? null : detectMobile(); // 内嵌环境优先,文案更具体
|
||||
if (!app && !mobile) return true;
|
||||
if (event) event.preventDefault();
|
||||
showDownloadTipModal(app, mobile);
|
||||
return false;
|
||||
}
|
||||
|
||||
// static/js/map.js:4417-4433
|
||||
export function showDownloadTipModal(appName, mobileName) {
|
||||
const title = document.getElementById("download-tip-title");
|
||||
const desc = document.getElementById("download-tip-desc");
|
||||
const hint = document.getElementById("download-tip-hint");
|
||||
title.textContent = "请在电脑上下载安装";
|
||||
if (appName) {
|
||||
desc.textContent = `${appName}内无法直接下载安装包。请复制下面的链接,在电脑浏览器中打开下载。`;
|
||||
hint.textContent = "安装包为 Windows 程序,手机端下载后无法运行。";
|
||||
} else {
|
||||
// 普通移动端浏览器:能下载但装了也用不了,引导去电脑
|
||||
desc.textContent = `当前是${mobileName || "移动设备"},安装包为 Windows 程序,在此设备上无法运行。请复制下面的链接,在电脑浏览器中打开下载。`;
|
||||
hint.textContent = "";
|
||||
}
|
||||
hint.style.display = hint.textContent ? "block" : "none";
|
||||
document.getElementById("download-tip-link").value = captureToolUrl();
|
||||
document.getElementById("download-tip-modal").classList.add("show");
|
||||
}
|
||||
|
||||
// static/js/map.js:4434-4441
|
||||
export function closeDownloadTipModal() {
|
||||
document.getElementById("download-tip-modal").classList.remove("show");
|
||||
}
|
||||
|
||||
// ========== 数据导出(CSV 直链,1 小时有效) ==========
|
||||
// 流程:POST /api/export/create(登录态)→ 拿到免登录直链。
|
||||
// UA 复用 detectInAppBrowser:微信/QQ/支付宝/钉钉/微博/抖音/原生壳内无法直接下载,
|
||||
// 弹「复制链接到外部浏览器」提示;普通浏览器直接触发下载。
|
||||
|
||||
// static/js/map.js:4442-4444
|
||||
export function closeExportTipModal() {
|
||||
document.getElementById("export-tip-modal").classList.remove("show");
|
||||
}
|
||||
|
||||
// static/js/map.js:4445-4466
|
||||
export async function copyExportLink() {
|
||||
const url = document.getElementById("export-tip-link").value;
|
||||
const input = document.getElementById("export-tip-link");
|
||||
try {
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
await navigator.clipboard.writeText(url);
|
||||
showToast("链接已复制,请在浏览器中打开");
|
||||
return;
|
||||
}
|
||||
throw new Error("clipboard unavailable");
|
||||
} catch (e) {
|
||||
try {
|
||||
input.removeAttribute("readonly");
|
||||
input.select();
|
||||
document.execCommand("copy");
|
||||
input.setAttribute("readonly", "");
|
||||
showToast("链接已复制,请在浏览器中打开");
|
||||
} catch (e2) {
|
||||
showToast("复制失败,请长按链接手动复制");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// static/js/map.js:4467-4503
|
||||
export async function exportHistoryCsv() {
|
||||
if (!S.authToken) { showToast("请先登录"); return; }
|
||||
showToast("正在生成导出链接...");
|
||||
try {
|
||||
const resp = await fetch("/api/export/create", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json",
|
||||
"Authorization": `Bearer ${S.authToken}` },
|
||||
body: JSON.stringify({ type: "history_csv" })
|
||||
});
|
||||
const data = await resp.json();
|
||||
if (data.rtn_code !== 0) {
|
||||
showToast(data.message || "生成导出链接失败");
|
||||
return;
|
||||
}
|
||||
const url = new URL(data.data.url, window.location.href).href;
|
||||
const app = detectInAppBrowser();
|
||||
if (app) {
|
||||
// 微信/原生壳等内嵌环境:给直链,复制到外部浏览器下载(直链免登录,1小时有效)
|
||||
document.getElementById("export-tip-desc").textContent =
|
||||
`${app}内无法直接下载文件。请复制下面的链接到系统浏览器打开(免登录,${data.data.ttl_hours} 小时内有效)。`;
|
||||
document.getElementById("export-tip-link").value = url;
|
||||
document.getElementById("export-tip-modal").classList.add("show");
|
||||
return;
|
||||
}
|
||||
// 普通浏览器:直接下载,同时保留直链以便换浏览器使用
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = "";
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
a.remove();
|
||||
showToast(`已开始下载(直链 ${data.data.ttl_hours} 小时内有效)`);
|
||||
} catch (err) {
|
||||
showToast("导出失败,请重试");
|
||||
}
|
||||
}
|
||||
|
||||
// static/js/map.js:4504-4531
|
||||
export async function copyDownloadLink() {
|
||||
const url = captureToolUrl();
|
||||
const input = document.getElementById("download-tip-link");
|
||||
// 微信等 WebView 常禁用 navigator.clipboard(非安全上下文或权限拒绝),
|
||||
// 回退到选中 + execCommand 的老办法
|
||||
try {
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
await navigator.clipboard.writeText(url);
|
||||
showToast("链接已复制");
|
||||
return;
|
||||
}
|
||||
throw new Error("clipboard unavailable");
|
||||
} catch (e) {
|
||||
try {
|
||||
input.removeAttribute("readonly");
|
||||
input.select();
|
||||
input.setSelectionRange(0, url.length);
|
||||
const ok = document.execCommand("copy");
|
||||
input.setAttribute("readonly", "readonly");
|
||||
showToast(ok ? "链接已复制" : "复制失败,请长按链接手动复制");
|
||||
} catch (e2) {
|
||||
showToast("复制失败,请长按链接手动复制");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 底层异常转用户提示:网关/错误页返回 HTML 时 resp.json() 会抛
|
||||
// "Unexpected token '<' ... is not valid JSON",直接展示既难懂又含 token 字样易引起误解
|
||||
|
||||
// static/js/map.js:4542-4542
|
||||
let _credInvalidLastShownAt: any = 0;
|
||||
|
||||
// static/js/map.js:4543-4543
|
||||
const CRED_INVALID_MODAL_COOLDOWN = 10 * 60 * 1000; // 10 分钟内不重复弹出
|
||||
|
||||
// static/js/map.js:4544-4550
|
||||
export function notifyCredentialInvalid(message) {
|
||||
const modal = document.getElementById("token-expired-modal");
|
||||
if (!modal || modal.classList.contains("show")) return;
|
||||
if (Date.now() - _credInvalidLastShownAt < CRED_INVALID_MODAL_COOLDOWN) return;
|
||||
_credInvalidLastShownAt = Date.now();
|
||||
showTokenExpiredModal(null, message);
|
||||
}
|
||||
|
||||
// static/js/map.js:4551-4557
|
||||
export function showTokenExpiredModal(customTitle, customDesc) {
|
||||
document.getElementById("token-expired-title").textContent = customTitle || "token已失效,请重新登录";
|
||||
document.getElementById("token-expired-desc").textContent = customDesc || "您的微信凭据已过期,请重新抓包获取最新的 Token ID(及 AccessToken)";
|
||||
document.getElementById("token-expired-modal").classList.add("show");
|
||||
// 预填当前用户已有的token信息
|
||||
loadExpiredTokenFields();
|
||||
}
|
||||
|
||||
// static/js/map.js:4558-4561
|
||||
export function closeTokenExpiredModal() {
|
||||
document.getElementById("token-expired-modal").classList.remove("show");
|
||||
document.getElementById("expired-tip").textContent = "";
|
||||
}
|
||||
|
||||
// static/js/map.js:4562-4574
|
||||
export async function loadExpiredTokenFields() {
|
||||
if (!S.authToken) return;
|
||||
try {
|
||||
const resp = await fetch("/api/auth/profile", {
|
||||
headers: { "Authorization": `Bearer ${S.authToken}` }
|
||||
});
|
||||
const data = await resp.json();
|
||||
if (data.rtn_code === 0 && data.data) {
|
||||
document.getElementById("expired-token-id").value = data.data.token_id || "";
|
||||
document.getElementById("expired-signature").value = data.data.token || "";
|
||||
}
|
||||
} catch (e) { /* ignore */ }
|
||||
}
|
||||
|
||||
// static/js/map.js:4575-4629
|
||||
export async function saveExpiredToken() {
|
||||
if (!S.authToken) {
|
||||
document.getElementById("expired-tip").textContent = "请先登录";
|
||||
return;
|
||||
}
|
||||
const token_id = document.getElementById("expired-token-id").value.trim();
|
||||
const access_token = document.getElementById("expired-signature").value.trim();
|
||||
const tip = document.getElementById("expired-tip");
|
||||
|
||||
if (!token_id) {
|
||||
tip.textContent = "Token ID 必填;AccessToken 选填";
|
||||
return;
|
||||
}
|
||||
|
||||
tip.textContent = "验证中...";
|
||||
try {
|
||||
const verifyResp = await fetch("/api/auth/verify_token", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json",
|
||||
"Authorization": `Bearer ${S.authToken}` },
|
||||
body: JSON.stringify({ access_token, token_id })
|
||||
});
|
||||
const verifyData = await verifyResp.json();
|
||||
if (!verifyData.valid) {
|
||||
tip.textContent = verifyData.message || "凭据验证失败,请检查 Token ID 是否正确";
|
||||
return;
|
||||
}
|
||||
} catch (err) {
|
||||
tip.textContent = "验证失败";
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const resp = await fetch("/api/auth/save_token", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": `Bearer ${S.authToken}`
|
||||
},
|
||||
body: JSON.stringify({ access_token, token_id })
|
||||
});
|
||||
const data = await resp.json();
|
||||
if (data.rtn_code === 0) {
|
||||
tip.textContent = "";
|
||||
closeTokenExpiredModal();
|
||||
showToast("凭证已更新 ✓");
|
||||
} else {
|
||||
tip.textContent = data.message || "保存失败";
|
||||
}
|
||||
} catch (err) {
|
||||
tip.textContent = "保存失败";
|
||||
}
|
||||
}
|
||||
|
||||
// ========== 定位最近车辆(手动找车)==========
|
||||
|
||||
// static/js/map.js:4988-4991
|
||||
export function shareAfterLogin() {
|
||||
refreshShareBanners();
|
||||
setTimeout(() => checkPendingShareRequests(), 800);
|
||||
}
|
||||
Reference in New Issue
Block a user