Files
2026-09-15 10:35:56 +08:00

101 lines
5.1 KiB
PHTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/** @var \Esun\Reward\Block\Account\Index $block */
/** @var \Magento\Framework\Escaper $escaper */
$account = $block->getAccount();
$tier = $block->getTier();
$transactions = $block->getTransactions();
$balance = (int)($account['balance'] ?? 0);
$lifetimeSpend = (float)($account['lifetime_spend_base'] ?? 0);
?>
<div class="esun-reward-account">
<section class="esun-account-welcome esun-reward-hero">
<i class="esun-account-avatar iconfont icon-jinbi2" aria-hidden="true"></i>
<div class="esun-reward-hero__content">
<h1><?= $escaper->escapeHtml(__('My Points')) ?></h1>
<strong><?= $escaper->escapeHtml(__('Points: %1', $balance)) ?></strong>
</div>
<div class="esun-reward-tier">
<span><?= $escaper->escapeHtml(__('VIP Tier')) ?></span>
<strong><?= $escaper->escapeHtml($tier['label']) ?></strong>
</div>
</section>
<section class="esun-account-panel esun-reward-overview">
<header><h2><?= $escaper->escapeHtml(__('Points Overview')) ?></h2></header>
<div class="esun-reward-account__summary">
<article class="esun-reward-card">
<i class="iconfont icon-jinbi2" aria-hidden="true"></i>
<span><?= $escaper->escapeHtml(__('Available Points')) ?></span>
<strong><?= $escaper->escapeHtml((string)$balance) ?></strong>
</article>
<article class="esun-reward-card">
<i class="iconfont icon-member6" aria-hidden="true"></i>
<span><?= $escaper->escapeHtml(__('VIP Tier')) ?></span>
<strong><?= $escaper->escapeHtml($tier['label']) ?></strong>
<small><?= $escaper->escapeHtml(__('%1× points', $tier['multiplier'])) ?></small>
</article>
<article class="esun-reward-card">
<i class="iconfont icon-dollar1" aria-hidden="true"></i>
<span><?= $escaper->escapeHtml(__('Lifetime Spend')) ?></span>
<strong>$<?= $escaper->escapeHtml(number_format($lifetimeSpend, 2)) ?></strong>
<?php if ($tier['next_threshold'] !== null): ?>
<small>
<?= $escaper->escapeHtml(
__('$%1 to next tier', number_format(
max(0, $tier['next_threshold'] - $lifetimeSpend),
2
))
) ?>
</small>
<?php endif; ?>
</article>
</div>
</section>
<section class="esun-account-panel esun-reward-history-panel">
<header><h2><?= $escaper->escapeHtml(__('Point History')) ?></h2></header>
<?php if ($transactions): ?>
<div class="table-wrapper">
<table class="data table esun-reward-history">
<thead><tr>
<th scope="col"><?= $escaper->escapeHtml(__('Date')) ?></th>
<th scope="col"><?= $escaper->escapeHtml(__('Activity')) ?></th>
<th scope="col"><?= $escaper->escapeHtml(__('Change')) ?></th>
<th scope="col"><?= $escaper->escapeHtml(__('Balance')) ?></th>
<th scope="col"><?= $escaper->escapeHtml(__('Reason')) ?></th>
</tr></thead>
<tbody>
<?php foreach ($transactions as $row): ?>
<?php $delta = (int)$row['points_delta']; ?>
<tr>
<td data-th="<?= $escaper->escapeHtmlAttr(__('Date')) ?>">
<?= $escaper->escapeHtml($row['created_at']) ?>
</td>
<td data-th="<?= $escaper->escapeHtmlAttr(__('Activity')) ?>">
<?= $escaper->escapeHtml($block->getActivityName((string)$row['type'])) ?>
</td>
<td class="esun-reward-history__change <?= $delta >= 0
? 'is-positive'
: 'is-negative' ?>" data-th="<?= $escaper->escapeHtmlAttr(__('Change')) ?>">
<?= $escaper->escapeHtml(($delta > 0 ? '+' : '') . (string)$delta) ?>
</td>
<td data-th="<?= $escaper->escapeHtmlAttr(__('Balance')) ?>">
<?= $escaper->escapeHtml((string)(int)$row['balance_after']) ?>
</td>
<td data-th="<?= $escaper->escapeHtmlAttr(__('Reason')) ?>">
<?= $escaper->escapeHtml((string)$row['reason']) ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php else: ?>
<div class="esun-reward-empty">
<i class="iconfont icon-jinbi2" aria-hidden="true"></i>
<p><?= $escaper->escapeHtml(__('You have no point activity yet.')) ?></p>
</div>
<?php endif; ?>
</section>
</div>