feat(orders): 规范化前台订单详情弹窗
弹窗外壳由 modal-runtime 挂载在 body 下,并不位于 .aksrt-orders-page 之内, 而原有 .aksrt-order-detail__* 规则引用的 --orders-ink / --orders-line 等别名 只定义在页面容器上。变量在该作用域无法解析,整条声明被判为无效值丢弃,于是 边框、分隔线与次要文字色全部没有生效——弹窗此前「没做完」的根因就在这里。 - renderDetail() 重构为状态横幅 + 商品信息 + 交易信息 + 操作栏四段 - 状态配色改由单个 --hero-accent 变量驱动,按状态切换琥珀 / 绿 / 品牌色 / 中性灰;--hero-text 再与墨色混合,避免强调色直接用作正文导致对比度不足 - 交易信息补上支付方式;流水号增加复制按钮(clipboard API + textarea 回退, 带 is-copied 反馈) - 待支付订单在详情内显示实时倒计时;updateCountdowns() 经新增的 countdownScopes() 一并扫描弹窗内容,原先只扫页面根节点 - 补充此前完全缺失的 refresh-state 与 skeleton 样式 - 金额口径按状态区分应付款 / 实付款 / 订单金额;卡密核销回退出的原始渠道 key 归一显示为「卡密核销」 - 弹窗外壳挂 aksrt-order-detail-modal 类以限定样式作用域,宽度调至 480px 关键点是所需 token 在弹窗外壳上重新声明,而不是继续依赖页面级别名——后者会 因 portal 作用域再次失效。移动端沿用 bottom sheet,操作按钮等分宽度。 验证:node --test tests/**/*.test.cjs 362/364 通过(2 项失败为改动前既存, 见上一笔提交说明);phpunit 44 项 / 103 断言全部通过;Chromium 实拍 1080px 浅色与暗色两套主题逐项核对;样式类定义 21 个与引用 21 个完全对应,无遗留 死样式;order-center.js 经 node --check 语法校验通过。
This commit is contained in:
@@ -92,8 +92,71 @@
|
||||
.aksrt-orders-page__empty i { display: block; margin-bottom: 12px; color: var(--color-primary, #3b82f6); font-size: 30px; }
|
||||
.aksrt-orders-page__empty h3 { margin: 0 0 7px; font-size: 15px; }.aksrt-orders-page__empty p { margin: 0 0 16px; color: var(--orders-muted); font-size: 13px; }
|
||||
|
||||
.aksrt-order-detail__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; padding: 12px 16px; border-top: 1px solid var(--orders-line); background: var(--surface-2, #f7f8fb); }
|
||||
.aksrt-order-detail__hero { display: flex; align-items: center; justify-content: space-between; padding: 15px; border-radius: 11px; background: color-mix(in srgb, var(--color-primary, #3b82f6) 9%, var(--surface-2, #f7f8fb)); }.aksrt-order-detail__hero.is-pending { background: color-mix(in srgb, var(--color-warning, #c87819) 11%, var(--surface-2, #f7f8fb)); }.aksrt-order-detail__hero.is-paid { background: color-mix(in srgb, var(--color-success, #168560) 10%, var(--surface-2, #f7f8fb)); }.aksrt-order-detail__status-pill { font-size: 12px; font-weight: 700; }.aksrt-order-detail__hero-amount { font-size: 23px; font-variant-numeric: tabular-nums; }.aksrt-order-detail__product { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 11px; align-items: center; }.aksrt-order-detail__thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; }.aksrt-order-detail__thumb--empty { display: grid; place-items: center; background: var(--surface-2, #f4f6f9); color: var(--color-primary, #3b82f6); }.aksrt-order-detail__product-title { display: block; line-height: 1.4; }.aksrt-order-detail__product-meta { display: block; margin-top: 5px; color: var(--orders-muted); font-size: 12px; }.aksrt-order-detail__list { margin: 0; border: 1px solid var(--orders-line); border-radius: 10px; overflow: hidden; }.aksrt-order-detail__list > div { display: grid; grid-template-columns: 86px minmax(0, 1fr); padding: 10px 12px; border-bottom: 1px solid var(--orders-line); font-size: 12px; }.aksrt-order-detail__list > div:last-child { border-bottom: 0; }.aksrt-order-detail__list dt { color: var(--orders-muted); }.aksrt-order-detail__list dd { margin: 0; overflow-wrap: anywhere; text-align: right; font-variant-numeric: tabular-nums; }
|
||||
/* ---- Order detail modal (front-end order center) ---- */
|
||||
/* The dialog is portalled to <body>, so it cannot inherit the page-scoped
|
||||
`--orders-*` aliases; it re-declares the few tokens it needs on the shell. */
|
||||
.aksrt-order-detail-modal {
|
||||
--detail-ink: var(--color-ink, #333333);
|
||||
--detail-muted: var(--color-ink-3, #777777);
|
||||
--detail-line: var(--color-line-stronger, rgba(50, 50, 50, .12));
|
||||
--detail-surface: var(--surface-1, #fff);
|
||||
--detail-surface-2: var(--surface-2, #eee);
|
||||
--detail-surface-3: var(--surface-4, #f8f8f8);
|
||||
--detail-primary: var(--color-primary, #f04494);
|
||||
--detail-warning: var(--color-warning, #f59e0b);
|
||||
--detail-success: var(--color-success, #10b981);
|
||||
}
|
||||
|
||||
.aksrt-order-detail-modal:not(.aksrt-modal-runtime--bottom) .aksrt-modal-runtime__dialog { width: min(480px, calc(100vw - 32px)); }
|
||||
.aksrt-order-detail-modal .aksrt-modal-runtime__header { padding: 15px 18px 14px; border-bottom: 1px solid var(--detail-line); }
|
||||
.aksrt-order-detail-modal .aksrt-modal-runtime__title { font-size: 16px; font-weight: 700; }
|
||||
.aksrt-order-detail-modal .aksrt-modal-runtime__content { display: flex; flex-direction: column; gap: 18px; padding: 16px 18px 0; }
|
||||
|
||||
.aksrt-order-detail__skeleton { display: grid; gap: 12px; padding: 4px 0; }
|
||||
|
||||
/* Status banner — a single local variable drives the whole colour scheme. */
|
||||
.aksrt-order-detail__hero { --hero-accent: var(--detail-primary); --hero-text: color-mix(in srgb, var(--hero-accent) 72%, var(--detail-ink)); display: flex; align-items: center; gap: 13px; padding: 15px; border: 1px solid color-mix(in srgb, var(--hero-accent) 20%, transparent); border-radius: 14px; background: color-mix(in srgb, var(--hero-accent) 12%, var(--detail-surface)); }
|
||||
.aksrt-order-detail__hero.is-pending { --hero-accent: var(--detail-warning); }
|
||||
.aksrt-order-detail__hero.is-paid { --hero-accent: var(--detail-success); }
|
||||
.aksrt-order-detail__hero.is-refunded, .aksrt-order-detail__hero.is-closed { --hero-accent: var(--detail-muted); }
|
||||
.aksrt-order-detail__hero-icon { display: grid; flex: 0 0 auto; width: 42px; height: 42px; place-items: center; border-radius: 12px; background: color-mix(in srgb, var(--hero-accent) 16%, transparent); color: var(--hero-text); font-size: 19px; }
|
||||
.aksrt-order-detail__hero-copy { display: grid; flex: 1 1 auto; gap: 4px; min-width: 0; }
|
||||
.aksrt-order-detail__status { color: var(--hero-text); font-size: 15px; font-weight: 750; line-height: 1.2; }
|
||||
.aksrt-order-detail__desc { margin: 0; color: var(--detail-muted); font-size: 12px; line-height: 1.45; }
|
||||
.aksrt-order-detail__countdown { color: var(--hero-text); font-size: 12px; font-variant-numeric: tabular-nums; }
|
||||
.aksrt-order-detail__hero-amount { display: grid; flex: 0 0 auto; gap: 3px; justify-items: end; text-align: right; }
|
||||
.aksrt-order-detail__hero-amount strong { color: var(--detail-ink); font-size: 21px; font-weight: 750; line-height: 1.1; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
|
||||
.aksrt-order-detail__hero-amount span { color: var(--detail-muted); font-size: 11px; }
|
||||
|
||||
.aksrt-order-detail__group { display: grid; gap: 10px; }
|
||||
.aksrt-order-detail__group-title { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--detail-ink); font-size: 13px; font-weight: 700; line-height: 1.3; }
|
||||
.aksrt-order-detail__group-title::before { content: ""; width: 3px; height: 13px; border-radius: 2px; background: var(--detail-primary); }
|
||||
|
||||
.aksrt-order-detail__product { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--detail-line); border-radius: 12px; background: var(--detail-surface); }
|
||||
.aksrt-order-detail__thumb { width: 54px; height: 54px; border-radius: 10px; object-fit: cover; }
|
||||
.aksrt-order-detail__thumb--empty { display: grid; place-items: center; background: var(--detail-surface-2); color: var(--detail-primary); font-size: 19px; }
|
||||
.aksrt-order-detail__product-copy { display: grid; gap: 6px; min-width: 0; }
|
||||
.aksrt-order-detail__product-title { display: -webkit-box; overflow: hidden; color: var(--detail-ink); font-size: 14px; line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
|
||||
.aksrt-order-detail__product-meta { display: inline-flex; justify-self: start; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--detail-primary) 9%, var(--detail-surface-2)); color: var(--detail-primary); font-size: 11px; font-weight: 650; line-height: 1.5; }
|
||||
|
||||
.aksrt-order-detail__list { display: grid; margin: 0; overflow: hidden; border: 1px solid var(--detail-line); border-radius: 12px; background: var(--detail-surface); }
|
||||
.aksrt-order-detail__list > div { display: grid; grid-template-columns: 84px minmax(0, 1fr); align-items: center; gap: 12px; padding: 11px 13px; border-bottom: 1px solid var(--detail-line); }
|
||||
.aksrt-order-detail__list > div:last-child { border-bottom: 0; }
|
||||
.aksrt-order-detail__list dt { color: var(--detail-muted); font-size: 12.5px; }
|
||||
.aksrt-order-detail__list dd { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; margin: 0; color: var(--detail-ink); font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; }
|
||||
.aksrt-order-detail__value-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.aksrt-order-detail__value-text.is-mono { font-family: var(--font-mono, monospace); font-size: 12.5px; letter-spacing: .01em; }
|
||||
.aksrt-order-detail__copy { display: inline-grid; flex: 0 0 auto; width: 24px; height: 24px; padding: 0; place-items: center; border: 1px solid var(--detail-line); border-radius: 7px; background: var(--detail-surface-3); color: var(--detail-muted); font-size: 11px; line-height: 1; cursor: pointer; transition: color .15s ease, border-color .15s ease; }
|
||||
.aksrt-order-detail__copy:hover { border-color: color-mix(in srgb, var(--detail-primary) 45%, var(--detail-line)); color: var(--detail-primary); }
|
||||
.aksrt-order-detail__copy.is-copied { border-color: color-mix(in srgb, var(--detail-success) 45%, var(--detail-line)); color: var(--detail-success); }
|
||||
|
||||
.aksrt-order-detail__refresh-state { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px; padding: 12px 13px; border: 1px solid color-mix(in srgb, var(--detail-warning) 26%, transparent); border-radius: 12px; background: color-mix(in srgb, var(--detail-warning) 10%, var(--detail-surface-2)); color: var(--detail-ink); font-size: 12.5px; }
|
||||
.aksrt-order-detail__refresh-state > i { color: var(--detail-warning); font-size: 15px; }
|
||||
.aksrt-order-detail__refresh-state p { margin: 0; }
|
||||
.aksrt-order-detail__refresh-state button { grid-column: 2; justify-self: start; }
|
||||
|
||||
.aksrt-order-detail-modal .aksrt-order-detail__actions { position: sticky; bottom: 0; z-index: 2; flex-direction: row; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin: 0 -18px; padding: 13px 18px; border-top: 1px solid var(--detail-line); background: var(--detail-surface); }
|
||||
.aksrt-order-detail-modal .aksrt-order-detail__actions > button { flex: 0 0 auto; min-height: 38px; padding: 0 16px; white-space: nowrap; }
|
||||
|
||||
/* Orders extensions */
|
||||
.aksrt-orders-page__extra-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
|
||||
@@ -112,5 +175,5 @@
|
||||
.aksrt-coupon-card__meta { margin-bottom: 4px; color: var(--muted-2-color, #888); font-size: 12px; }
|
||||
.aksrt-orders-page__field { margin-bottom: 12px; }
|
||||
.aksrt-orders-page__input, .aksrt-orders-page__select, .aksrt-orders-page__textarea { box-sizing: border-box; width: 100%; padding: 8px 10px; border: 1px solid var(--main-border-color, #ddd); border-radius: 6px; }
|
||||
@media (max-width: 767px) { .uc-orders-panel__head { grid-template-columns: 1fr; gap: 17px; }.aksrt-orders-page__stats { max-width: none; }.aksrt-orders-page__search { flex-wrap: wrap; }.aksrt-orders-page__search input { min-width: 150px; }.aksrt-orders-page__search .btn-primary { margin-left: auto; }.aksrt-orders-page__filter-toggle { margin-left: auto; }.aksrt-orders-page__card-rail time { width: 100%; margin-left: 0; order: 3; }.aksrt-orders-page__card-main { grid-template-columns: 48px minmax(0, 1fr); }.aksrt-orders-page__card-img, .aksrt-orders-page__card-art { width: 48px; height: 48px; }.aksrt-orders-page__card-value { grid-column: 2; text-align: left; }.aksrt-orders-page__card-actions > :not(.aksrt-orders-page__countdown) { flex: 1 1 auto; }.aksrt-orders-page__countdown { width: 100%; }.aksrt-order-detail__actions > * { flex: 1; } }
|
||||
html.dark .aksrt-orders-page__stat, html.dark .aksrt-orders-page__card { background: var(--surface-1, #1a1d24); } html.dark .aksrt-orders-page__card-rail, html.dark .aksrt-orders-page__filter-panel, html.dark .aksrt-order-detail__actions { background: var(--surface-2, #12151b); }
|
||||
@media (max-width: 767px) { .uc-orders-panel__head { grid-template-columns: 1fr; gap: 17px; }.aksrt-orders-page__stats { max-width: none; }.aksrt-orders-page__search { flex-wrap: wrap; }.aksrt-orders-page__search input { min-width: 150px; }.aksrt-orders-page__search .btn-primary { margin-left: auto; }.aksrt-orders-page__filter-toggle { margin-left: auto; }.aksrt-orders-page__card-rail time { width: 100%; margin-left: 0; order: 3; }.aksrt-orders-page__card-main { grid-template-columns: 48px minmax(0, 1fr); }.aksrt-orders-page__card-img, .aksrt-orders-page__card-art { width: 48px; height: 48px; }.aksrt-orders-page__card-value { grid-column: 2; text-align: left; }.aksrt-orders-page__card-actions > :not(.aksrt-orders-page__countdown) { flex: 1 1 auto; }.aksrt-orders-page__countdown { width: 100%; }.aksrt-order-detail-modal .aksrt-order-detail__actions > button { flex: 1 1 0; min-width: 0; padding: 0 10px; } }
|
||||
html.dark .aksrt-orders-page__stat, html.dark .aksrt-orders-page__card { background: var(--surface-1, #1a1d24); } html.dark .aksrt-orders-page__card-rail, html.dark .aksrt-orders-page__filter-panel { background: var(--surface-2, #12151b); }
|
||||
|
||||
+140
-16
@@ -70,35 +70,104 @@
|
||||
'</div>';
|
||||
}
|
||||
|
||||
function statusMeta(status) {
|
||||
var map = {
|
||||
pending: { icon: "fa-clock", desc: "订单已生成,请在有效期内完成支付" },
|
||||
paid: { icon: "fa-check-circle", desc: "支付已完成,相关权益已发放至账户" },
|
||||
refunding: { icon: "fa-hourglass-half", desc: "退款申请已受理,正在处理中" },
|
||||
refunded: { icon: "fa-undo-alt", desc: "退款已完成,款项将原路退回" },
|
||||
closed: { icon: "fa-times-circle", desc: "订单已关闭,如有需要可重新下单" },
|
||||
};
|
||||
return map[status] || map.closed;
|
||||
}
|
||||
|
||||
function amountCaption(status) {
|
||||
if (status === "pending") return "应付款";
|
||||
if (status === "closed") return "订单金额";
|
||||
return "实付款";
|
||||
}
|
||||
|
||||
function paymentMethodText(order) {
|
||||
var method = order && order.payment_method ? order.payment_method : {};
|
||||
// 卡密核销不是真实收银渠道,直接回退的原始 key 对用户没有意义。
|
||||
if (method.value === "card_pass") return "卡密核销";
|
||||
return String(method.label || "");
|
||||
}
|
||||
|
||||
function detailRow(label, value, copyable) {
|
||||
var text = value == null ? "" : String(value);
|
||||
var cell = '<span class="aksrt-order-detail__value-text' + (copyable ? " is-mono" : "") + '">' +
|
||||
escapeHtml(text || "—") + "</span>";
|
||||
if (copyable && text !== "") {
|
||||
cell += '<button class="aksrt-order-detail__copy" type="button" data-aksrt-order-copy="' +
|
||||
escapeHtml(text) + '" aria-label="复制' + escapeHtml(label) + '" title="复制' + escapeHtml(label) + '">' +
|
||||
'<i class="fa fas fa-copy" aria-hidden="true"></i></button>';
|
||||
}
|
||||
return "<div><dt>" + escapeHtml(label) + "</dt><dd>" + cell + "</dd></div>";
|
||||
}
|
||||
|
||||
function renderDetail(state, order, session) {
|
||||
var allowedActions = order.allowed_actions || {};
|
||||
var reconciliation = order.reconciliation || {};
|
||||
var paymentMethod = order.payment_method || {};
|
||||
var image = order.image || "";
|
||||
var title = order.product_name || "订单";
|
||||
var status = order.status_group || "closed";
|
||||
var html = '<div class="aksrt-order-detail__hero is-' + escapeHtml(status) + '">';
|
||||
html += '<span class="aksrt-order-detail__status-pill is-' + escapeHtml(status) + '">' + escapeHtml(order.status_label || "") + "</span>";
|
||||
html += '<strong class="aksrt-order-detail__hero-amount">' + formatMoney(order) + "</strong></div>";
|
||||
var meta = statusMeta(status);
|
||||
var timeLeft = Number(order.time_left || 0);
|
||||
var html = "";
|
||||
|
||||
// 状态横幅:整块配色只由 --hero-accent 驱动,换状态只改一处变量。
|
||||
html += '<section class="aksrt-order-detail__hero is-' + escapeHtml(status) + '">';
|
||||
html += '<span class="aksrt-order-detail__hero-icon" aria-hidden="true"><i class="fa fas ' + meta.icon + '"></i></span>';
|
||||
html += '<div class="aksrt-order-detail__hero-copy">';
|
||||
html += '<strong class="aksrt-order-detail__status">' + escapeHtml(order.status_label || "") + "</strong>";
|
||||
html += '<p class="aksrt-order-detail__desc">' + escapeHtml(meta.desc) + "</p>";
|
||||
if (status === "pending" && timeLeft > 0) {
|
||||
html += '<span class="aksrt-order-detail__countdown" data-aksrt-order-countdown="' + timeLeft + '">剩余支付时间 ' + timeLeft + " 秒</span>";
|
||||
}
|
||||
html += "</div>";
|
||||
html += '<div class="aksrt-order-detail__hero-amount"><strong>' + formatMoney(order) + "</strong>";
|
||||
html += "<span>" + escapeHtml(amountCaption(status)) + "</span></div></section>";
|
||||
|
||||
html += '<section class="aksrt-order-detail__group">';
|
||||
html += '<h4 class="aksrt-order-detail__group-title">商品信息</h4>';
|
||||
html += '<div class="aksrt-order-detail__product">';
|
||||
html += image
|
||||
? '<img src="' + escapeHtml(image) + '" class="aksrt-order-detail__thumb" alt="">'
|
||||
: '<span class="aksrt-order-detail__thumb aksrt-order-detail__thumb--empty"><i class="fa fas fa-book"></i></span>';
|
||||
html += '<div><strong class="aksrt-order-detail__product-title">' + escapeHtml(title) + "</strong>";
|
||||
html += '<span class="aksrt-order-detail__product-meta">' + escapeHtml(order.product_type_label || "") + "</span></div></div>";
|
||||
: '<span class="aksrt-order-detail__thumb aksrt-order-detail__thumb--empty" aria-hidden="true"><i class="fa fas fa-book"></i></span>';
|
||||
html += '<div class="aksrt-order-detail__product-copy">';
|
||||
html += '<strong class="aksrt-order-detail__product-title">' + escapeHtml(title) + "</strong>";
|
||||
html += '<span class="aksrt-order-detail__product-meta">' + escapeHtml(order.product_type_label || "") + "</span>";
|
||||
html += "</div></div></section>";
|
||||
|
||||
html += '<section class="aksrt-order-detail__group">';
|
||||
html += '<h4 class="aksrt-order-detail__group-title">交易信息</h4>';
|
||||
html += '<dl class="aksrt-order-detail__list">';
|
||||
[["流水号", order.order_number], ["创建时间", order.created_at], ["支付时间", order.paid_at || "—"]].forEach(function (row) {
|
||||
html += "<div><dt>" + escapeHtml(row[0]) + "</dt><dd>" + escapeHtml(row[1] || "—") + "</dd></div>";
|
||||
[
|
||||
["流水号", order.order_number],
|
||||
["支付方式", paymentMethodText(order)],
|
||||
["创建时间", order.created_at],
|
||||
["支付时间", order.paid_at],
|
||||
].forEach(function (row) {
|
||||
html += detailRow(row[0], row[1], row[0] === "流水号");
|
||||
});
|
||||
html += "</dl>";
|
||||
html += "</dl></section>";
|
||||
|
||||
if (reconciliation.state === "refresh_available") {
|
||||
html += '<div class="aksrt-order-detail__refresh-state" role="status">支付状态可能仍在同步,请刷新后查看。';
|
||||
html += '<button class="btn-outline" type="button" data-aksrt-order-refresh="' + escapeHtml(order.order_number) + '">刷新支付状态</button></div>';
|
||||
html += '<div class="aksrt-order-detail__refresh-state" role="status">';
|
||||
html += '<i class="fa fas fa-info-circle" aria-hidden="true"></i>';
|
||||
html += "<p>支付状态可能仍在同步,请刷新后查看。</p>";
|
||||
html += '<button class="btn-outline" type="button" data-aksrt-order-refresh="' + escapeHtml(order.order_number) + '">刷新支付状态</button>';
|
||||
html += "</div>";
|
||||
}
|
||||
|
||||
html += '<footer class="aksrt-modal__footer aksrt-order-detail__actions">';
|
||||
html += '<button class="btn-outline" type="button" data-aksrt-modal-close>关闭</button>';
|
||||
if (allowedActions.can_cancel) html += '<button class="btn-ghost" type="button" data-aksrt-order-cancel="' + escapeHtml(order.order_number) + '">关闭订单</button>';
|
||||
if (allowedActions.can_pay) html += '<button class="btn-primary" type="button" data-aksrt-order-pay="' + escapeHtml(order.order_number) + '" data-aksrt-order-method="' + escapeHtml((order.payment_method || {}).value || "") + '">继续支付</button>';
|
||||
if (allowedActions.can_pay) html += '<button class="btn-primary" type="button" data-aksrt-order-pay="' + escapeHtml(order.order_number) + '" data-aksrt-order-method="' + escapeHtml(paymentMethod.value || "") + '">继续支付</button>';
|
||||
html += "</footer>";
|
||||
|
||||
session.content.innerHTML = html;
|
||||
}
|
||||
|
||||
@@ -111,6 +180,7 @@
|
||||
headers: actionKey ? { "Idempotency-Key": state.operationKeys[actionKey] } : {},
|
||||
kind: "orders",
|
||||
title: "订单详情",
|
||||
className: "aksrt-order-detail-modal",
|
||||
responseType: "json",
|
||||
cache: !refresh,
|
||||
cacheKey: "orders:detail:" + orderNumber,
|
||||
@@ -223,11 +293,21 @@
|
||||
if (list) list.after(root);
|
||||
}
|
||||
|
||||
function countdownScopes(state) {
|
||||
// 详情弹窗挂在 body 上,不在 state.root 内,需要单独纳入倒计时扫描。
|
||||
var scopes = [state.root];
|
||||
if (state.detailSession && state.detailSession.content) scopes.push(state.detailSession.content);
|
||||
return scopes;
|
||||
}
|
||||
|
||||
function updateCountdowns(state) {
|
||||
state.root.querySelectorAll("[data-aksrt-order-countdown]").forEach(function (node) {
|
||||
var value = Math.max(0, Number(node.getAttribute("data-aksrt-order-countdown") || 0) - 1);
|
||||
node.setAttribute("data-aksrt-order-countdown", String(value));
|
||||
node.textContent = value ? "剩余支付时间 " + value + " 秒" : "订单即将关闭";
|
||||
countdownScopes(state).forEach(function (scope) {
|
||||
if (!scope || !scope.querySelectorAll) return;
|
||||
scope.querySelectorAll("[data-aksrt-order-countdown]").forEach(function (node) {
|
||||
var value = Math.max(0, Number(node.getAttribute("data-aksrt-order-countdown") || 0) - 1);
|
||||
node.setAttribute("data-aksrt-order-countdown", String(value));
|
||||
node.textContent = value ? "剩余支付时间 " + value + " 秒" : "订单即将关闭";
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -343,6 +423,44 @@
|
||||
});
|
||||
}
|
||||
|
||||
function copyOrderValue(button) {
|
||||
var value = button.getAttribute("data-aksrt-order-copy") || "";
|
||||
if (!value) return;
|
||||
var icon = button.querySelector("i");
|
||||
var settle = function (ok) {
|
||||
notyf(ok ? "流水号已复制" : "复制失败,请手动选择复制", ok ? "success" : "danger");
|
||||
if (!ok) return;
|
||||
button.classList.add("is-copied");
|
||||
if (icon) icon.className = "fa fas fa-check";
|
||||
window.setTimeout(function () {
|
||||
button.classList.remove("is-copied");
|
||||
if (icon) icon.className = "fa fas fa-copy";
|
||||
}, 1600);
|
||||
};
|
||||
var fallback = function () {
|
||||
try {
|
||||
var field = document.createElement("textarea");
|
||||
field.value = value;
|
||||
field.setAttribute("readonly", "readonly");
|
||||
field.style.position = "fixed";
|
||||
field.style.top = "-1000px";
|
||||
field.style.opacity = "0";
|
||||
document.body.appendChild(field);
|
||||
field.select();
|
||||
document.execCommand("copy");
|
||||
document.body.removeChild(field);
|
||||
settle(true);
|
||||
} catch (error) {
|
||||
settle(false);
|
||||
}
|
||||
};
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText(value).then(function () { settle(true); }, fallback);
|
||||
return;
|
||||
}
|
||||
fallback();
|
||||
}
|
||||
|
||||
function closest(target, selector) {
|
||||
return target && target.closest ? target.closest(selector) : null;
|
||||
}
|
||||
@@ -416,6 +534,12 @@
|
||||
};
|
||||
state.onDocumentClick = function (event) {
|
||||
if (!state.detailSession || window.AksrtModalRuntime.getActive() !== state.detailSession.shell) return;
|
||||
var copy = closest(event.target, "[data-aksrt-order-copy]");
|
||||
if (copy) {
|
||||
event.preventDefault();
|
||||
copyOrderValue(copy);
|
||||
return;
|
||||
}
|
||||
var refresh = closest(event.target, "[data-aksrt-order-refresh]");
|
||||
if (refresh) {
|
||||
event.preventDefault();
|
||||
|
||||
Reference in New Issue
Block a user