refactor(revenue): drop standalone QR block and align promotion card with reference
The 推广收益 detail card no longer renders the QR code as its own row. The card becomes a fixed-label info list: 推广链接 [Url][复制链接][推广海报] / 佣金比例 / 累计佣金 / 返佣详解, mirroring the reference theme's 推广中心 card. - profile-revenue.php: QR row removed; poster button moved into the link row and gated server-side on the poster switch; copy label now 复制链接; 推广人数 row dropped; 返佣详解 heading reads the existing pay_rebate_text_details_title; dead $vip_ratios, aksrt-revenue-page class and data-min-amount removed - new affiliate-poster-modal.php: poster previews in a modal before download (reuses .uc-modal + single-render guard), since the QR now only exists inside the poster - credits.js: renderAffiliateQr and its call deleted, along with the dead [data-affiliate-payers] lookup and the inline ch-width hack; initAffiliatePoster builds the poster into the modal stage and reveals 保存海报 - PaymentRuntime: expose affiliate details_title - user-center.js: remove never-defined AKSRTRevenueCenterInit guards (2 sites) - CSS: revenue-earnings.css pruned to live rules plus the new link-row grid and poster stage styles; routes/user-center/revenue.css pruned to its only definitions; dead leaves routes/revenue.css and routes/commerce.css deleted and dequeued from the user-center part list - tests: referral-qr-contract test 2 rewritten for the QR-free card, link row and poster modal; post-visual-contract leaf list updated with regression guards qrcode.min.js stays enqueued — buildPosterCanvas still draws the QR inside the poster. Net -833 lines. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Affiliate poster preview modal.
|
||||
*
|
||||
* The 推广海报 button lives in the revenue detail link row; the QR code is no
|
||||
* longer rendered on its own — it exists only inside the generated poster.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
if (!empty($GLOBALS['aksrt_affiliate_poster_modal_rendered'])) {
|
||||
return;
|
||||
}
|
||||
$GLOBALS['aksrt_affiliate_poster_modal_rendered'] = true;
|
||||
?>
|
||||
<div class="uc-modal" id="aksrt-affiliate-poster-modal" hidden data-aksrt-affiliate-poster-modal>
|
||||
<div class="uc-modal__overlay" data-affiliate-poster-close></div>
|
||||
<div class="uc-modal__dialog" role="dialog" aria-modal="true">
|
||||
<button type="button" class="uc-modal__close" data-affiliate-poster-close aria-label="<?php esc_attr_e('关闭', 'aksrt'); ?>"><i class="fa fas fa-times" aria-hidden="true"></i></button>
|
||||
<h3 class="uc-modal__title"><?php esc_html_e('推广海报', 'aksrt'); ?></h3>
|
||||
<div class="uc-affiliate-poster" data-affiliate-poster-stage>
|
||||
<p class="muted-2-color em09"><?php esc_html_e('正在生成海报…', 'aksrt'); ?></p>
|
||||
</div>
|
||||
<button type="button" class="but jb-blue btn-block mt10" data-affiliate-poster-download hidden><?php esc_html_e('保存海报', 'aksrt'); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -45,7 +45,6 @@ $commission_stats = class_exists('\AKSRT\Payment\CommissionLedger')
|
||||
? \AKSRT\Payment\CommissionLedger::get_instance()->overview($user_id)
|
||||
: ['total' => 0, 'pending' => 0, 'settled' => 0, 'wallet' => 0];
|
||||
$pending_commission = $normalize_balance($commission_stats['pending'] ?? '0')->decimal();
|
||||
$vip_ratios = [];
|
||||
$commission_ratio = class_exists('\AKSRT\Settings\Settings')
|
||||
? (int) \AKSRT\Settings\Settings::affiliate_ratio_for_user($user_id)
|
||||
: 0;
|
||||
@@ -53,6 +52,10 @@ $details_text = trim((string) ($affiliate['promotion_text'] ?? ''));
|
||||
if ($details_text === '') {
|
||||
$details_text = __('好友通过推广链接完成符合条件的订单后,系统会按当前佣金比例记录返佣,结算后进入可提现余额。', 'aksrt');
|
||||
}
|
||||
$details_title = trim((string) ($affiliate['details_title'] ?? ''));
|
||||
if ($details_title === '') {
|
||||
$details_title = __('返佣详解', 'aksrt');
|
||||
}
|
||||
|
||||
$revenue_request = is_array($context['revenue_request'] ?? null) ? $context['revenue_request'] : [];
|
||||
$active_reward_tab = sanitize_key((string) ($revenue_request['reward_tab'] ?? ($_GET['reward_tab'] ?? 'detail')));
|
||||
@@ -106,7 +109,7 @@ $status_labels = [
|
||||
'cancelled' => __('已取消', 'aksrt'),
|
||||
];
|
||||
?>
|
||||
<div class="aksrt-revenue-page uc-revenue-panel" data-aksrt-revenue-page data-min-amount="<?php echo esc_attr((string) $withdraw_min); ?>">
|
||||
<div class="uc-revenue-panel" data-aksrt-revenue-page>
|
||||
<?php if ($affiliate_on) : ?>
|
||||
<section class="uc-commission-summary" aria-label="<?php esc_attr_e('佣金概览', 'aksrt'); ?>">
|
||||
<article class="uc-commission-card uc-commission-card--ratio">
|
||||
@@ -142,25 +145,14 @@ $status_labels = [
|
||||
<div class="uc-revenue-summary-row uc-revenue-summary-row--link">
|
||||
<span><?php esc_html_e('推广链接', 'aksrt'); ?></span>
|
||||
<input type="text" readonly data-affiliate-link aria-label="<?php esc_attr_e('推广链接', 'aksrt'); ?>">
|
||||
<button type="button" class="btn-primary btn-sm" data-affiliate-copy><?php esc_html_e('复制', 'aksrt'); ?></button>
|
||||
<button type="button" class="btn-primary btn-sm" data-affiliate-copy><?php esc_html_e('复制链接', 'aksrt'); ?></button>
|
||||
<?php if (!empty($affiliate['poster']['enabled'])) : ?><button type="button" class="btn-outline btn-sm" data-affiliate-poster hidden><?php esc_html_e('推广海报', 'aksrt'); ?></button><?php endif; ?>
|
||||
<small data-affiliate-feedback role="status" aria-live="polite"></small>
|
||||
</div>
|
||||
<div class="uc-revenue-summary-row uc-revenue-summary-row--qr" data-affiliate-qr-row>
|
||||
<span><?php esc_html_e('推广二维码', 'aksrt'); ?></span>
|
||||
<div class="uc-revenue-qr">
|
||||
<canvas data-affiliate-qr width="148" height="148" aria-label="<?php esc_attr_e('推广链接二维码', 'aksrt'); ?>"></canvas>
|
||||
<div class="uc-revenue-qr__actions">
|
||||
<button type="button" class="btn-sm" data-affiliate-qr-download><?php esc_html_e('下载二维码', 'aksrt'); ?></button>
|
||||
<button type="button" class="btn-sm" data-affiliate-poster hidden><?php esc_html_e('生成推广海报', 'aksrt'); ?></button>
|
||||
</div>
|
||||
<small data-affiliate-qr-feedback role="status" aria-live="polite"></small>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($affiliate_on) : ?><div class="uc-revenue-summary-row"><span><?php esc_html_e('佣金比例', 'aksrt'); ?></span><strong data-affiliate-ratio><?php echo esc_html((string) $commission_ratio); ?>%</strong></div><?php endif; ?>
|
||||
<div class="uc-revenue-summary-row"><span><?php esc_html_e('推广人数', 'aksrt'); ?></span><div class="uc-revenue-count"><strong data-affiliate-promoters>—</strong><em><?php esc_html_e('人', 'aksrt'); ?></em></div></div>
|
||||
<?php if ($affiliate_on) : ?>
|
||||
<div class="uc-revenue-summary-row uc-revenue-summary-row--total"><span><?php esc_html_e('累计佣金', 'aksrt'); ?></span><div><strong>累计<?php echo esc_html($format_amount($commission_stats['total'] ?? 0)); ?>元</strong><strong>待结算<?php echo esc_html($format_amount($commission_stats['pending'] ?? 0)); ?>元</strong></div></div>
|
||||
<div class="uc-revenue-summary-row uc-revenue-summary-row--explain"><span><?php esc_html_e('返佣详解', 'aksrt'); ?></span><div class="uc-reward-richtext"><?php echo wp_kses_post(wpautop($details_text)); ?></div></div>
|
||||
<div class="uc-revenue-summary-row"><span><?php esc_html_e('佣金比例', 'aksrt'); ?></span><strong data-affiliate-ratio><?php echo esc_html((string) $commission_ratio); ?>%</strong></div>
|
||||
<div class="uc-revenue-summary-row uc-revenue-summary-row--total"><span><?php esc_html_e('累计佣金', 'aksrt'); ?></span><div><strong><?php printf(esc_html__('累计 %s 元', 'aksrt'), esc_html($format_amount($commission_stats['total'] ?? 0))); ?></strong><strong><?php printf(esc_html__('待结算 %s 元', 'aksrt'), esc_html($format_amount($commission_stats['pending'] ?? 0))); ?></strong></div></div>
|
||||
<div class="uc-revenue-summary-row uc-revenue-summary-row--explain"><span><?php echo esc_html($details_title); ?></span><div class="uc-reward-richtext"><?php echo wp_kses_post(wpautop($details_text)); ?></div></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -202,3 +194,4 @@ $status_labels = [
|
||||
<?php if ($withdraw_on) {
|
||||
require __DIR__ . '/withdraw-modal.php';
|
||||
} ?>
|
||||
<?php require __DIR__ . '/affiliate-poster-modal.php'; ?>
|
||||
|
||||
Reference in New Issue
Block a user