fix: 补全普通和共享订单横幅的时间轮次信息并适配窄屏
This commit is contained in:
@@ -1,4 +1,23 @@
|
||||
#baidu_map canvas { filter: var(--basemap-filter, none); }
|
||||
.order-banner-copy, .share-banner-copy { flex: 1; min-width: 0; }
|
||||
#order-banner .order-banner-left { align-items: flex-start; overflow: visible; }
|
||||
#order-banner #order-banner-text { display: block; }
|
||||
#order-banner .banner-progress, .share-banner .banner-progress {
|
||||
display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 4px;
|
||||
font-size: 12px; line-height: 1.55; opacity: .92; white-space: normal;
|
||||
}
|
||||
#order-banner #order-final-time, #order-banner #order-countdown {
|
||||
white-space: normal; overflow: visible; text-overflow: clip;
|
||||
}
|
||||
#order-banner .order-banner-right { gap: 6px; margin-left: 10px; }
|
||||
#order-banner .order-banner-btn { margin-right: 0 !important; }
|
||||
.share-banner { gap: 10px; }
|
||||
.share-banner-title { display: flex; flex-wrap: wrap; align-items: center; }
|
||||
.share-banner .banner-progress > span { display: block; }
|
||||
@media (max-width: 640px) {
|
||||
#order-banner-detail-btn { display: none; }
|
||||
#order-banner .banner-progress { flex-direction: column; gap: 0; }
|
||||
}
|
||||
.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;
|
||||
|
||||
+1
-1
@@ -2085,7 +2085,7 @@
|
||||
.order-banner-right, .rental-bar > div:last-child { flex: 0 0 auto; white-space: nowrap; }
|
||||
.order-banner-btn, .rental-bar-btn { white-space: nowrap; flex: 0 0 auto; }
|
||||
#order-final-time, #order-countdown, #rental-final-time, #rental-time, #rental-bike-code, .rental-bar-info { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
@media (max-width: 430px) { #order-final-time { display: none !important; } .order-banner { padding: 9px 10px !important; font-size: 13px !important; } .order-banner-btn, .rental-bar-btn { padding: 5px 9px !important; font-size: 12px !important; } }
|
||||
@media (max-width: 430px) { .order-banner { padding: 9px 10px !important; font-size: 13px !important; } .order-banner-btn, .rental-bar-btn { padding: 5px 9px !important; font-size: 12px !important; } }
|
||||
.order-banner.show {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
+54
-12
@@ -1740,6 +1740,9 @@
|
||||
text.textContent = `待支付订单 #${order.code || order.order_id.slice(-6)}`;
|
||||
btn.textContent = "去支付";
|
||||
hideOrderCountdown();
|
||||
const progress = document.getElementById("order-final-time");
|
||||
progress.textContent = "待支付 · 骑行已结束";
|
||||
progress.style.display = "inline";
|
||||
} else if (Number(order.status) === 2) {
|
||||
// 进行中 - 获取倒计时
|
||||
banner.classList.add("riding");
|
||||
@@ -1751,6 +1754,12 @@
|
||||
text.textContent = `进行中 #${order.code || order.order_id.slice(-6)}`;
|
||||
}
|
||||
btn.textContent = "还车";
|
||||
if (String(orderCountdownOrderId) !== String(order.order_id)) {
|
||||
hideOrderCountdown();
|
||||
const progress = document.getElementById("order-final-time");
|
||||
progress.textContent = "骑行中 · 正在同步计时";
|
||||
progress.style.display = "inline";
|
||||
}
|
||||
// 从后端获取剩余时间并启动倒计时
|
||||
fetchOrderCountdown(order.order_id);
|
||||
}
|
||||
@@ -1760,6 +1769,21 @@
|
||||
|
||||
let orderCountdownTimer = null;
|
||||
let orderCountdownSeconds = 0;
|
||||
let orderCountdownDeadline = null;
|
||||
let orderCountdownOrderId = null;
|
||||
|
||||
function rideProgressText(summary) {
|
||||
const current = Math.max(1, Number(summary.current_round) || 1);
|
||||
const total = Math.max(current, Number(summary.total_rounds) || current);
|
||||
const end = String(summary.final_end_time || summary.end_time || "").match(/(?:T|\s)(\d{2}:\d{2})/);
|
||||
const phase = summary.auto_return ? "自动还车已开启" : "手动还车";
|
||||
return `第 ${current}/${total} 轮 · ${phase}` + (end ? ` · 预计 ${end[1]} 结束` : "");
|
||||
}
|
||||
|
||||
function remainingTimeText(seconds) {
|
||||
const remaining = Math.max(0, Math.ceil(Number(seconds) || 0));
|
||||
return `${Math.floor(remaining / 60)}:${String(remaining % 60).padStart(2, "0")}`;
|
||||
}
|
||||
|
||||
function fetchOrderCountdown(orderId) {
|
||||
if (!authToken || !orderId) return;
|
||||
@@ -1769,19 +1793,17 @@
|
||||
})
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
if (!currentOrder || String(currentOrder.order_id) !== String(orderId) || Number(currentOrder.status) !== 2) return;
|
||||
if (data.rtn_code === 0 && data.data && data.data.active) {
|
||||
orderCountdownSeconds = data.data.remaining_seconds;
|
||||
orderCountdownSeconds = Math.max(0, Number(data.data.remaining_seconds) || 0);
|
||||
orderCountdownDeadline = performance.now() + orderCountdownSeconds * 1000;
|
||||
orderCountdownOrderId = orderId;
|
||||
// 多轮适配:展示计划总轮数与最终预计还车时间
|
||||
const finalEl = document.getElementById("order-final-time");
|
||||
const addBtn = document.getElementById("order-banner-add-round-btn");
|
||||
if (finalEl) {
|
||||
if (data.data.final_end_time && data.data.total_rounds > data.data.current_round) {
|
||||
const hhmm = String(data.data.final_end_time).slice(11, 16);
|
||||
finalEl.textContent = `共${data.data.total_rounds}轮 · 预计${hhmm}还车`;
|
||||
finalEl.style.display = "inline";
|
||||
} else {
|
||||
finalEl.style.display = "none";
|
||||
}
|
||||
finalEl.textContent = rideProgressText(data.data);
|
||||
finalEl.style.display = "inline";
|
||||
}
|
||||
if (addBtn) {
|
||||
// 真实订单才可加轮; reminder 计时不显示
|
||||
@@ -1790,6 +1812,11 @@
|
||||
}
|
||||
showOrderCountdown();
|
||||
startOrderCountdown();
|
||||
} else if (data.rtn_code === 0) {
|
||||
hideOrderCountdown();
|
||||
const progress = document.getElementById("order-final-time");
|
||||
progress.textContent = "骑行中 · 计时同步中";
|
||||
progress.style.display = "inline";
|
||||
}
|
||||
})
|
||||
.catch(err => console.error("获取倒计时失败:", err));
|
||||
@@ -1802,6 +1829,10 @@
|
||||
}
|
||||
|
||||
function hideOrderCountdown() {
|
||||
orderCountdownDeadline = null;
|
||||
orderCountdownOrderId = null;
|
||||
document.getElementById("order-banner-add-round-btn").style.display = "none";
|
||||
document.getElementById("order-final-time").style.display = "none";
|
||||
const el = document.getElementById("order-countdown");
|
||||
el.style.display = "none";
|
||||
if (orderCountdownTimer) {
|
||||
@@ -1815,7 +1846,7 @@
|
||||
const remaining = Math.max(0, orderCountdownSeconds);
|
||||
const mins = Math.floor(remaining / 60);
|
||||
const secs = remaining % 60;
|
||||
el.textContent = `${mins}:${secs.toString().padStart(2, "0")}`;
|
||||
el.textContent = remaining > 0 ? `本轮剩余 ${mins}:${secs.toString().padStart(2, "0")}` : "本轮到期 · 同步状态中";
|
||||
|
||||
// 变色提示
|
||||
if (remaining <= 60) {
|
||||
@@ -1830,7 +1861,7 @@
|
||||
function startOrderCountdown() {
|
||||
if (orderCountdownTimer) clearInterval(orderCountdownTimer);
|
||||
orderCountdownTimer = setInterval(() => {
|
||||
orderCountdownSeconds--;
|
||||
orderCountdownSeconds = Math.max(0, Math.ceil((orderCountdownDeadline - performance.now()) / 1000));
|
||||
updateOrderCountdownText();
|
||||
if (orderCountdownSeconds <= 0) {
|
||||
clearInterval(orderCountdownTimer);
|
||||
@@ -5218,9 +5249,9 @@
|
||||
const data = await shareApi("/api/share/active");
|
||||
if (data.rtn_code !== 0) return;
|
||||
shareActiveList = data.data || [];
|
||||
shareActiveList.forEach(it => { it._countdownDeadline = performance.now() + Math.max(0, Number(it.remaining_seconds) || 0) * 1000; });
|
||||
let html = "";
|
||||
shareActiveList.forEach((it, idx) => {
|
||||
const mins = Math.max(1, Math.ceil((it.remaining_seconds || 0) / 60));
|
||||
const isOwner = it.role === "owner";
|
||||
const label = partnerLabel(it.partner_name, it.partner_email, it.remark);
|
||||
const esc = escHtml(label);
|
||||
@@ -5232,7 +5263,9 @@
|
||||
text = '<span>使用 ' + esc + ' 的车中</span><b style="margin:0 4px;">#' + bike + '</b>';
|
||||
}
|
||||
html += '<div class="share-banner show ' + (isOwner ? "" : "rider") + '">'
|
||||
+ '<div style="display:flex;align-items:center;gap:4px;min-width:0;overflow:hidden;white-space:nowrap;">' + text + '<span style="opacity:.8;font-size:12px;margin-left:6px;">剩' + mins + '分</span></div>'
|
||||
+ '<div class="share-banner-copy"><div class="share-banner-title">' + text + '</div>'
|
||||
+ '<div class="banner-progress"><span id="share-countdown-' + idx + '">本轮剩余 ' + remainingTimeText(it.remaining_seconds) + '</span>'
|
||||
+ '<span>' + escHtml(rideProgressText(it)) + '</span></div></div>'
|
||||
+ '<button class="share-banner-btn" onclick="openShareReturnByIdx(' + idx + ')">还车</button>'
|
||||
+ '</div>';
|
||||
});
|
||||
@@ -5253,6 +5286,15 @@
|
||||
: ('你正在使用 <b>' + esc + '</b> 的车 <b>#' + bike + '</b>,确认还车?');
|
||||
document.getElementById("share-return-modal").classList.add("show");
|
||||
}
|
||||
function updateShareCountdowns() {
|
||||
shareActiveList.forEach((it, idx) => {
|
||||
const el = document.getElementById('share-countdown-' + idx);
|
||||
if (!el) return;
|
||||
const seconds = Math.max(0, Math.ceil((it._countdownDeadline - performance.now()) / 1000));
|
||||
el.textContent = seconds > 0 ? '本轮剩余 ' + remainingTimeText(seconds) : '本轮到期 · 同步状态中';
|
||||
});
|
||||
}
|
||||
setInterval(updateShareCountdowns, 1000);
|
||||
// HTML 的 ✕ / 取消 / 遮罩都调用它(此前漏了定义 → 点击直接 ReferenceError,弹窗关不掉)
|
||||
function closeShareReturnModal() {
|
||||
const modal = document.getElementById("share-return-modal");
|
||||
|
||||
Reference in New Issue
Block a user