better-staridc-MNBT
1<?php
2if (!defined('IN_CRONLITE')) { exit; }
3$page_title = $page_title ?? '我的订单';
4$orders = $orders ?? ['list' => [], 'total' => 0, 'page' => 1, 'per_page' => 15];
5$status_labels = ['pending' => '待支付', 'paid' => '已支付', 'opened' => '已开通', 'failed' => '失败', 'cancelled' => '已取消'];
6$status_cls = ['pending' => 'warning', 'paid' => 'info', 'opened' => 'success', 'failed' => 'danger', 'cancelled' => 'default'];
7$period_labels = hosting_periods();
8$tp = max(1, (int)ceil($orders['total'] / max(1, (int)$orders['per_page'])));
9$cp = (int)$orders['page'];
10ob_start();
11?>
12<div class="sf-section">
13 <div>
14 <h1>我的订单</h1>
15 <p>主机购买订单记录</p>
16 </div>
17</div>
18
19<div class="sf-card">
20 <div class="sf-card-body-flush">
21 <?php if (empty($orders['list'])): ?>
22 <div class="sf-empty">暂无订单,<a href="<?= shop_frontend_url('shop') ?>">去购买主机</a></div>
23 <?php else: ?>
24 <div class="sf-table-wrap">
25 <table class="sf-table">
26 <thead><tr><th>订单号</th><th>套餐</th><th>周期</th><th>金额</th><th>状态</th><th>下单时间</th><th>备注</th></tr></thead>
27 <tbody>
28 <?php foreach ($orders['list'] as $o): ?>
29 <tr>
30 <td class="sf-mono"><?= htmlspecialchars($o['order_no']) ?></td>
31 <td><?= htmlspecialchars($o['plan_name']) ?></td>
32 <td><?= htmlspecialchars($period_labels[$o['period']]['label'] ?? $o['period']) ?></td>
33 <td>¥<?= hosting_format_cents($o['amount_cents']) ?></td>
34 <td><span class="sf-badge sf-badge-<?= $status_cls[$o['status']] ?? 'default' ?>"><?= $status_labels[$o['status']] ?? $o['status'] ?></span></td>
35 <td><?= htmlspecialchars($o['created_at']) ?></td>
36 <td><?= htmlspecialchars($o['remark'] ?: '-') ?></td>
37 </tr>
38 <?php endforeach; ?>
39 </tbody>
40 </table>
41 </div>
42 <?php if ($tp > 1): ?>
43 <div class="sf-pager">
44 <?php if ($cp > 1): ?><a href="<?= shop_frontend_url('shop/orders?page=' . ($cp - 1)) ?>">上一页</a><?php endif; ?>
45 <span>第 <?= $cp ?> / <?= $tp ?> 页</span>
46 <?php if ($cp < $tp): ?><a href="<?= shop_frontend_url('shop/orders?page=' . ($cp + 1)) ?>">下一页</a><?php endif; ?>
47 </div>
48 <?php endif; ?>
49 <?php endif; ?>
50 </div>
51</div>
52<?php
53$content = ob_get_clean();
54include __DIR__ . '/layout.php';