better-staridc-MNBT
1<?php
2if (!defined('IN_CRONLITE')) { exit; }
3$page_title = $page_title ?? '我的余额';
4$balance_cents = $balance_cents ?? 0;
5$logs = $logs ?? ['list' => [], 'total' => 0, 'page' => 1, 'per_page' => 15];
6$type_labels = ['recharge' => '充值', 'consume' => '消费', 'refund' => '退款', 'adjust' => '调整'];
7ob_start();
8?>
9<div class="layui-card">
10 <div class="layui-card-body bal-box">
11 <div class="bal-label">当前余额</div>
12 <div class="bal-amount">¥<?= htmlspecialchars(balance_format($balance_cents)) ?></div>
13 <a class="layui-btn layui-btn-lg" href="<?= balance_url('balance/recharge') ?>">充值</a>
14 </div>
15</div>
16
17<div class="layui-card">
18 <div class="layui-card-header" style="font-weight:600;">交易记录</div>
19 <div class="layui-card-body" style="padding:0;">
20 <?php if (empty($logs['list'])): ?>
21 <p style="text-align:center;padding:30px;color:#999;">暂无交易记录</p>
22 <?php else: ?>
23 <table class="ly-table">
24 <thead><tr><th>时间</th><th>类型</th><th>金额</th><th>备注</th><th>订单号</th></tr></thead>
25 <tbody>
26 <?php foreach ($logs['list'] as $log): ?>
27 <tr>
28 <td><?= htmlspecialchars($log['created_at']) ?></td>
29 <td><?= htmlspecialchars($type_labels[$log['type']] ?? $log['type']) ?></td>
30 <td class="<?= (int)$log['amount'] >= 0 ? 'income' : 'expense' ?>"><?= (int)$log['amount'] >= 0 ? '+' : '' ?>¥<?= htmlspecialchars(balance_format(abs((int)$log['amount']))) ?></td>
31 <td><?= htmlspecialchars($log['remark'] ?: '-') ?></td>
32 <td class="ly-mono"><?= $log['order_no'] ? htmlspecialchars($log['order_no']) : '-' ?></td>
33 </tr>
34 <?php endforeach; ?>
35 </tbody>
36 </table>
37 <?php $tp = max(1, (int)ceil($logs['total'] / $logs['per_page'])); $cp = (int)$logs['page'];
38 if ($tp > 1): ?>
39 <div class="ly-pager">
40 <?php if ($cp > 1): ?><a href="<?= balance_url('balance?page=' . ($cp-1)) ?>">上一页</a><?php endif; ?>
41 <span class="ly-pager-info">第 <?= $cp ?> / <?= $tp ?> 页</span>
42 <?php if ($cp < $tp): ?><a href="<?= balance_url('balance?page=' . ($cp+1)) ?>">下一页</a><?php endif; ?>
43 </div>
44 <?php endif; ?>
45 <?php endif; ?>
46 </div>
47</div>
48<?php
49$content = ob_get_clean();
50include __DIR__ . '/layout.php';