better-staridc-MNBT
1<?php
2/**
3 * 用户端 - 我的订单
4 */
5if (!defined('IN_CRONLITE')) {
6 exit;
7}
8$page_title = $page_title ?? '我的订单';
9$orders = $orders ?? ['list' => [], 'total' => 0, 'page' => 1, 'per_page' => 15];
10
11$action_labels = [
12 'buy' => '购买',
13 'upgrade_config' => '配置升级',
14 'upgrade_product' => '产品升级',
15];
16$status_labels = [
17 'pending' => '待处理',
18 'paid' => '已支付',
19 'opened' => '已完成',
20 'failed' => '失败',
21 'cancelled' => '已取消',
22];
23ob_start();
24?>
25<div class="zj-section">
26 <h1>我的订单</h1>
27 <p>购买与升级订单记录</p>
28</div>
29
30<?php if (empty($orders['list'])): ?>
31 <div class="layui-card">
32 <div class="layui-card-body" style="text-align:center;padding:40px;color:#999;">
33 暂无订单,<a href="<?= zjmf_url('reserve/shop') ?>">去选购商品</a>
34 </div>
35 </div>
36<?php else: ?>
37 <div class="layui-card">
38 <div class="layui-card-body" style="padding:0;">
39 <table class="zj-table">
40 <thead>
41 <tr>
42 <th>订单号</th>
43 <th>类型</th>
44 <th>供应商</th>
45 <th>商品</th>
46 <th>周期</th>
47 <th>金额</th>
48 <th>状态</th>
49 <th>下单时间</th>
50 </tr>
51 </thead>
52 <tbody>
53 <?php foreach ($orders['list'] as $o): ?>
54 <tr>
55 <td class="zj-mono"><?= htmlspecialchars($o['order_no']) ?></td>
56 <td><?= htmlspecialchars($action_labels[$o['action']] ?? $o['action']) ?></td>
57 <td><?= htmlspecialchars($o['supplier_name'] ?: '-') ?></td>
58 <td><?= htmlspecialchars($o['product_name']) ?></td>
59 <td><?= htmlspecialchars($o['cycle_name'] ?: '-') ?></td>
60 <td>¥<?= zjmf_format_cents($o['amount_cents']) ?></td>
61 <td>
62 <span class="zj-status zj-status-<?= htmlspecialchars($o['status']) ?>">
63 <?= htmlspecialchars($status_labels[$o['status']] ?? $o['status']) ?>
64 </span>
65 </td>
66 <td class="small"><?= htmlspecialchars($o['created_at']) ?></td>
67 </tr>
68 <?php endforeach; ?>
69 </tbody>
70 </table>
71 </div>
72 </div>
73
74 <?php
75 $total_pages = max(1, (int)ceil($orders['total'] / $orders['per_page']));
76 $current_page = (int)$orders['page'];
77 if ($total_pages > 1):
78 ?>
79 <div class="zj-pager">
80 <?php if ($current_page > 1): ?>
81 <a href="<?= zjmf_url('reserve/orders?page=' . ($current_page - 1)) ?>">上一页</a>
82 <?php endif; ?>
83 <span class="zj-pager-info">第 <?= $current_page ?> / <?= $total_pages ?> 页</span>
84 <?php if ($current_page < $total_pages): ?>
85 <a href="<?= zjmf_url('reserve/orders?page=' . ($current_page + 1)) ?>">下一页</a>
86 <?php endif; ?>
87 </div>
88 <?php endif; ?>
89<?php endif; ?>
90
91<?php
92$content = ob_get_clean();
93include __DIR__ . '/layout.php';