fix(payment): 售后弹窗改为按钮载荷同步弹出,修复首次点击无反馈

原实现是「点击 → 先请求 /orders/{n} → 再弹窗」,与项目里所有可用弹窗
(含举报链路 report.js)不同构:举报弹窗把数据放在按钮 data-* 属性里同步
弹出。前置请求会让首次点击在请求返回前毫无反应,体感就是"得二次点击"。

- 按钮 data-aksrt-after-sale-apply / -detail 携带订单与售后状态载荷
  (PHP 模板与 order-center.js 的 actionHtml 同构生成),点击当拍即开
  对应弹窗:申请表单 / 超时效提示 / 售后详细,零前置请求
- 「再次申请售后」同样使用已渲染载荷,不再重新拉取订单
- 提交与图片上传仍走 REST,服务端校验不变;列表刷新后载荷随之更新
- jsdom 多脚本环境实测:三种入口均在点击同一拍弹出且 fetch 计数为 0
This commit is contained in:
2026-10-06 23:29:59 +08:00
parent 4ea02f25ac
commit 93579cbc9f
4 changed files with 77 additions and 51 deletions
@@ -123,12 +123,22 @@ $status_options = [
<?php if (!empty($actions['can_pay'])) : ?><button class="btn-primary" type="button" data-aksrt-order-pay="<?php echo esc_attr($number); ?>" data-aksrt-order-method="<?php echo esc_attr((string) ($order['payment_method']['value'] ?? '')); ?>"><?php esc_html_e('继续支付', 'aksrt'); ?></button><?php endif; ?>
<?php
$after_sale = is_array($order['after_sale'] ?? null) ? $order['after_sale'] : [];
// 售后弹窗载荷随按钮渲染(同举报链路 data-aksrt-report):点击即同步弹窗。
$after_sale_payload = wp_json_encode([
'order_number' => $number,
'product_name' => (string) ($order['product_name'] ?? ''),
'amount' => (string) ($order['amount'] ?? '0'),
'is_points' => !empty($order['is_points']),
'currency_symbol' => (string) ($order['currency_symbol'] ?? ''),
'status_label' => (string) ($order['status_label'] ?? ''),
'after_sale' => $after_sale,
]);
?>
<?php if (!empty($after_sale['enabled'])) : ?>
<?php if (!empty($after_sale['has_application'])) : ?>
<button class="btn-outline" type="button" data-aksrt-after-sale-detail="<?php echo esc_attr($number); ?>"><?php esc_html_e('售后详细', 'aksrt'); ?></button>
<button class="btn-outline" type="button" data-aksrt-after-sale-detail="<?php echo esc_attr($after_sale_payload); ?>"><?php esc_html_e('售后详细', 'aksrt'); ?></button>
<?php else : ?>
<button class="btn-outline" type="button" data-aksrt-after-sale-apply="<?php echo esc_attr($number); ?>"><?php esc_html_e('申请售后', 'aksrt'); ?></button>
<button class="btn-outline" type="button" data-aksrt-after-sale-apply="<?php echo esc_attr($after_sale_payload); ?>"><?php esc_html_e('申请售后', 'aksrt'); ?></button>
<?php endif; ?>
<?php endif; ?>
</footer>