feat(orders): polish detail modal layout and visuals
Restructure the order detail modal into status-tinted hero, product card, info list with copyable order number, multi-item lines, and a newest-first timeline. Refresh spacing, dark mode, and footer buttons.
This commit is contained in:
+121
-35
@@ -514,53 +514,96 @@
|
||||
var status = order.status || "";
|
||||
var statusLabel = order.status_label || status || "—";
|
||||
var statusClass = "is-" + String(status).replace(/[^a-z0-9_-]/gi, "-");
|
||||
var title = order.product_name || (order.product && order.product.title) || "订单";
|
||||
var image = order.image || (order.product && order.product.image) || "";
|
||||
if (!image && order.items && order.items.length && order.items[0].image) {
|
||||
image = order.items[0].image;
|
||||
}
|
||||
var orderNo = order.order_number || "—";
|
||||
|
||||
// Meta fields only — amount lives in hero; type is already on the list card.
|
||||
var rows = [
|
||||
["订单名称", order.product_name || (order.product && order.product.title) || "—"],
|
||||
["订单数量", String(qty)],
|
||||
["应付金额", formatMoneyText(order)],
|
||||
["订单编号", order.order_number || "—"],
|
||||
["创建时间", order.created_at || "—"],
|
||||
["支付时间", order.paid_at || "—"],
|
||||
["支付方式", paymentLabel]
|
||||
{ key: "qty", label: "数量", value: "×" + String(qty) },
|
||||
{ key: "no", label: "订单编号", value: orderNo, copyable: true },
|
||||
{ key: "created", label: "创建时间", value: order.created_at || "—" },
|
||||
{ key: "paid", label: "支付时间", value: order.paid_at || "—" },
|
||||
{ key: "pay", label: "支付方式", value: paymentLabel }
|
||||
];
|
||||
|
||||
if (Number(order.shipping_fee || 0) > 0) {
|
||||
rows.push(["运费", "¥" + Number(order.shipping_fee || 0).toFixed(2)]);
|
||||
rows.push({ key: "ship", label: "运费", value: "¥" + Number(order.shipping_fee || 0).toFixed(2) });
|
||||
}
|
||||
if (Number(order.discount || 0) > 0) {
|
||||
rows.push(["优惠", "¥" + Number(order.discount || 0).toFixed(2)]);
|
||||
rows.push({ key: "disc", label: "优惠", value: "-¥" + Number(order.discount || 0).toFixed(2), accent: "discount" });
|
||||
}
|
||||
if (order.customer_note) {
|
||||
rows.push(["备注", order.customer_note]);
|
||||
rows.push({ key: "note", label: "备注", value: order.customer_note });
|
||||
}
|
||||
|
||||
var html = "";
|
||||
html += '<div class="aksrt-order-detail__hero">';
|
||||
html += ' <div class="aksrt-order-detail__hero-main">';
|
||||
html += '<div class="aksrt-order-detail__hero ' + escapeHtml(statusClass) + '">';
|
||||
html += ' <div class="aksrt-order-detail__hero-top">';
|
||||
html += ' <span class="aksrt-order-detail__status-pill ' + escapeHtml(statusClass) + '">' + escapeHtml(statusLabel) + "</span>";
|
||||
html += ' <strong class="aksrt-order-detail__hero-amount">' + escapeHtml(formatMoneyText(order)) + "</strong>";
|
||||
if (order.product_type_label) {
|
||||
html += ' <span class="aksrt-order-detail__type-chip">' + escapeHtml(order.product_type_label) + "</span>";
|
||||
}
|
||||
html += " </div>";
|
||||
html += ' <div class="aksrt-order-detail__hero-amount-wrap">';
|
||||
html += ' <span class="aksrt-order-detail__hero-label">应付金额</span>';
|
||||
html += ' <strong class="aksrt-order-detail__hero-amount">' + escapeHtml(formatMoneyText(order)) + "</strong>";
|
||||
html += " </div>";
|
||||
html += "</div>";
|
||||
|
||||
html += '<dl class="aksrt-order-detail__list">';
|
||||
rows.forEach(function (row) {
|
||||
html += '<div class="aksrt-order-detail__row">';
|
||||
html += '<dt>' + escapeHtml(row[0]) + '</dt>';
|
||||
html += '<dd>' + escapeHtml(row[1]) + '</dd>';
|
||||
html += '</div>';
|
||||
});
|
||||
html += "</dl>";
|
||||
html += '<div class="aksrt-order-detail__product">';
|
||||
if (image) {
|
||||
html += '<img class="aksrt-order-detail__thumb" src="' + escapeHtml(image) + '" alt="" loading="lazy">';
|
||||
} else {
|
||||
html += '<div class="aksrt-order-detail__thumb aksrt-order-detail__thumb--empty" aria-hidden="true"><i class="fas fa-receipt"></i></div>';
|
||||
}
|
||||
html += ' <div class="aksrt-order-detail__product-info">';
|
||||
html += ' <div class="aksrt-order-detail__product-title">' + escapeHtml(title) + "</div>";
|
||||
html += ' <div class="aksrt-order-detail__product-meta">';
|
||||
html += ' <span>数量 ' + escapeHtml(String(qty)) + "</span>";
|
||||
if (paymentLabel && paymentLabel !== "—") {
|
||||
html += ' <span class="aksrt-order-detail__dot" aria-hidden="true"></span>';
|
||||
html += ' <span>' + escapeHtml(paymentLabel) + "</span>";
|
||||
}
|
||||
html += " </div>";
|
||||
html += " </div>";
|
||||
html += "</div>";
|
||||
|
||||
if (order.items && order.items.length) {
|
||||
html += '<div class="aksrt-order-detail__items"><h4>商品明细</h4><ul>';
|
||||
html += '<section class="aksrt-order-detail__section">';
|
||||
html += ' <h4 class="aksrt-order-detail__section-title">订单信息</h4>';
|
||||
html += ' <dl class="aksrt-order-detail__list">';
|
||||
rows.forEach(function (row) {
|
||||
html += '<div class="aksrt-order-detail__row' + (row.accent ? " is-" + row.accent : "") + '">';
|
||||
html += '<dt>' + escapeHtml(row.label) + '</dt>';
|
||||
html += '<dd>';
|
||||
html += '<span class="aksrt-order-detail__value">' + escapeHtml(row.value) + "</span>";
|
||||
if (row.copyable && orderNo && orderNo !== "—") {
|
||||
html += '<button type="button" class="aksrt-order-detail__copy" data-aksrt-copy-order="' + escapeHtml(orderNo) + '" title="复制订单号" aria-label="复制订单号">';
|
||||
html += '<i class="far fa-copy" aria-hidden="true"></i>';
|
||||
html += "</button>";
|
||||
}
|
||||
html += "</dd>";
|
||||
html += "</div>";
|
||||
});
|
||||
html += "</dl></section>";
|
||||
|
||||
if (order.items && order.items.length > 1) {
|
||||
html += '<section class="aksrt-order-detail__section">';
|
||||
html += ' <h4 class="aksrt-order-detail__section-title">商品明细</h4>';
|
||||
html += ' <ul class="aksrt-order-detail__items">';
|
||||
order.items.forEach(function (item) {
|
||||
var title = item.product_title || item.title || order.product_name || "商品";
|
||||
var itemTitle = item.product_title || item.title || order.product_name || "商品";
|
||||
var itemQty = item.quantity || item.qty || 1;
|
||||
var price = item.pay_price != null ? item.pay_price : (item.unit_price || 0);
|
||||
html += '<li>';
|
||||
html += ' <span class="aksrt-order-detail__item-title">' + escapeHtml(title) + "</span>";
|
||||
var itemImg = item.image || "";
|
||||
html += '<li class="aksrt-order-detail__item">';
|
||||
if (itemImg) {
|
||||
html += '<img class="aksrt-order-detail__item-img" src="' + escapeHtml(itemImg) + '" alt="" loading="lazy">';
|
||||
}
|
||||
html += ' <span class="aksrt-order-detail__item-title">' + escapeHtml(itemTitle) + "</span>";
|
||||
html += ' <em class="aksrt-order-detail__item-qty">×' + escapeHtml(String(itemQty)) + '</em>';
|
||||
if (order.is_points) {
|
||||
html += '<strong class="aksrt-order-detail__item-price">' + escapeHtml(order.currency_symbol || "积分") + " " + Math.round(Number(price || 0)) + "</strong>";
|
||||
@@ -569,26 +612,30 @@
|
||||
}
|
||||
html += "</li>";
|
||||
});
|
||||
html += "</ul></div>";
|
||||
html += "</ul></section>";
|
||||
}
|
||||
|
||||
if (order.timeline && order.timeline.length) {
|
||||
html += '<div class="aksrt-order-detail__timeline"><h4>订单进度</h4><ol>';
|
||||
order.timeline.forEach(function (tl) {
|
||||
html += '<li><span class="aksrt-order-detail__timeline-dot"></span>';
|
||||
// Newest first for a natural "latest activity on top" feel.
|
||||
var timeline = order.timeline.slice().reverse();
|
||||
html += '<section class="aksrt-order-detail__section">';
|
||||
html += ' <h4 class="aksrt-order-detail__section-title">订单进度</h4>';
|
||||
html += ' <ol class="aksrt-order-detail__timeline">';
|
||||
timeline.forEach(function (tl, idx) {
|
||||
html += '<li class="aksrt-order-detail__timeline-item' + (idx === 0 ? " is-latest" : "") + '">';
|
||||
html += '<span class="aksrt-order-detail__timeline-dot"></span>';
|
||||
html += '<div class="aksrt-order-detail__timeline-body">';
|
||||
html += '<time>' + escapeHtml(tl.time || "") + "</time>";
|
||||
html += "<span>" + escapeHtml(tl.label || "") + "</span>";
|
||||
html += '<span class="aksrt-order-detail__timeline-label">' + escapeHtml(tl.label || "") + "</span>";
|
||||
html += '<time class="aksrt-order-detail__timeline-time">' + escapeHtml(tl.time || "") + "</time>";
|
||||
html += "</div></li>";
|
||||
});
|
||||
html += "</ol></div>";
|
||||
html += "</ol></section>";
|
||||
}
|
||||
|
||||
detailBody.innerHTML = html;
|
||||
|
||||
var footer = "";
|
||||
// Status-aware footer actions. The modal's own ✕ button (top-right) is the only
|
||||
// dismiss control, so do not add a duplicate "关闭" button here.
|
||||
// Status-aware footer. Top-right ✕ is the only generic dismiss control.
|
||||
if (actions.can_cancel) {
|
||||
footer += '<button type="button" class="btn-ghost" data-aksrt-order-cancel="' + escapeHtml(order.order_number) + '">关闭订单</button>';
|
||||
}
|
||||
@@ -616,6 +663,37 @@
|
||||
detailFooter.innerHTML = footer;
|
||||
}
|
||||
|
||||
function copyOrderNumber(code, trigger) {
|
||||
if (!code) return;
|
||||
function done() {
|
||||
showToast("已复制订单号");
|
||||
if (trigger) {
|
||||
trigger.classList.add("is-copied");
|
||||
window.setTimeout(function () { trigger.classList.remove("is-copied"); }, 1200);
|
||||
}
|
||||
}
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText(code).then(done).catch(function () {
|
||||
showToast(code);
|
||||
});
|
||||
return;
|
||||
}
|
||||
try {
|
||||
var ta = document.createElement("textarea");
|
||||
ta.value = code;
|
||||
ta.setAttribute("readonly", "");
|
||||
ta.style.position = "fixed";
|
||||
ta.style.opacity = "0";
|
||||
document.body.appendChild(ta);
|
||||
ta.select();
|
||||
document.execCommand("copy");
|
||||
document.body.removeChild(ta);
|
||||
done();
|
||||
} catch (e) {
|
||||
showToast(code);
|
||||
}
|
||||
}
|
||||
|
||||
/* ── After-Sale Modal ── */
|
||||
var afterSaleModal = page.querySelector("[data-aksrt-aftersale-modal]");
|
||||
var afterSaleForm = page.querySelector("[data-aksrt-aftersale-form]");
|
||||
@@ -706,6 +784,14 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// Copy order number inside detail modal
|
||||
var copyBtn = event.target.closest("[data-aksrt-copy-order]");
|
||||
if (copyBtn) {
|
||||
event.preventDefault();
|
||||
copyOrderNumber(copyBtn.getAttribute("data-aksrt-copy-order") || "", copyBtn);
|
||||
return;
|
||||
}
|
||||
|
||||
// Order detail close
|
||||
if (event.target.closest("[data-aksrt-order-detail-close]")) {
|
||||
closeOrderDetailModal();
|
||||
|
||||
Reference in New Issue
Block a user