fix(pay): 待支付浮窗无刷新同步

- modal-cache 失效时广播 aksrt:cache:invalidated
- 新增 GET /orders/wait-pay-float 返回浮窗片段
- wait-pay-float.js 监听 orders 标签失效并替换/移除浮窗、重启倒计时
- VIP/充值/下载待支付分支触发 orders 失效

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
kate522andClaude Fable 5 committed 2026-10-29 11:11:13 +08:00
1 parent d9d1122e9c
commit c3328e7279
8 files changed
+83 -1

No files matched your search

+15
View File
@@ -40,6 +40,12 @@ class OrderCenterRest {
'permission_callback' => [$this, 'require_logged_in'],
'args' => $query_args,
]);
// 待支付浮窗片段:须在 /orders/{order_number} 之前注册,避免被单号路由吞掉。
register_rest_route($namespace, '/orders/wait-pay-float', [
'methods' => \WP_REST_Server::READABLE,
'callback' => [$this, 'get_wait_pay_float'],
'permission_callback' => [$this, 'require_logged_in'],
]);
$route_args = [
'order_number' => [
'required' => true,
@@ -97,6 +103,15 @@ class OrderCenterRest {
return $this->success(['data' => $view]);
}
public function get_wait_pay_float(): \WP_REST_Response {
$enabled = class_exists('\AKSRT\Settings\Settings')
&& !empty(\AKSRT\Settings\Settings::get_order_settings()['wait_float']);
$html = $enabled && function_exists('aksrt_get_wait_pay_float_html') ? aksrt_get_wait_pay_float_html() : '';
$response = $this->success(['data' => ['html' => $html]]);
$response->header('Cache-Control', 'no-store, private');
return $response;
}
public function pay(\WP_REST_Request $request): \WP_REST_Response {
$operation_key = \AKSRT\Ledger\OperationKey::from_request($request, 'order-pay', get_current_user_id());
if (is_wp_error($operation_key)) {