仰望星辰工作室

better-staridc-MNBT

Z zfhsh first commit 2 个月前
1<?php
2/**
3 * 用户端 - 商品列表(按供应商分组展示)
4 */
5if (!defined('IN_CRONLITE')) {
6 exit;
7}
8$page_title = $page_title ?? '商品选购';
9$products = $products ?? [];
10
11// 按供应商分组
12$groups = [];
13foreach ($products as $product) {
14 $key = (int)$product['supplier_id'];
15 if (!isset($groups[$key])) {
16 $groups[$key] = [
17 'name' => (string)($product['supplier_name'] ?? '其他供应商'),
18 'items' => [],
19 ];
20 }
21 $groups[$key]['items'][] = $product;
22}
23ob_start();
24?>
25<div class="zj-section">
26 <h1>商品选购</h1>
27 <p>选择商品与周期,余额支付后自动开通主机</p>
28</div>
29
30<?php if (empty($groups)): ?>
31 <div class="layui-card">
32 <div class="layui-card-body" style="text-align:center;padding:40px;color:#999;">
33 暂无可购买的商品,请稍后再来。
34 </div>
35 </div>
36<?php else: ?>
37 <?php foreach ($groups as $group): ?>
38 <div class="zj-group">
39 <div class="zj-group-head">
40 <span class="zj-group-name"><?= htmlspecialchars($group['name']) ?></span>
41 <span class="zj-tag">供应商</span>
42 </div>
43 <div class="zj-grid">
44 <?php foreach ($group['items'] as $product): ?>
45 <div class="zj-card">
46 <div class="zj-card-head">
47 <h2><?= htmlspecialchars($product['name']) ?></h2>
48 <?php if (!empty($product['currency'])): ?>
49 <span class="zj-tag"><?= htmlspecialchars($product['currency']) ?></span>
50 <?php endif; ?>
51 </div>
52 <div class="zj-card-desc"><?= zjmf_render_description($product['description']) ?></div>
53 <div class="zj-price">
54 <?php $cycles = zjmf_product_cycles($product); ?>
55 <?php foreach ($cycles as $cycle => $cfg): ?>
56 <div class="zj-price-item">
57 <span class="zj-price-label"><?= htmlspecialchars($cfg['name']) ?></span>
58 <span class="zj-price-value">¥<?= zjmf_format_cents($cfg['price_cents']) ?></span>
59 </div>
60 <?php endforeach; ?>
61 <?php if ($cycles === []): ?>
62 <span style="color:#999;font-size:12px;">暂无可购买周期</span>
63 <?php endif; ?>
64 </div>
65 <div class="zj-buy">
66 <a class="layui-btn"
67 href="<?= zjmf_url('reserve/product/' . (int)$product['id']) ?>">立即购买</a>
68 </div>
69 </div>
70 <?php endforeach; ?>
71 </div>
72 </div>
73 <?php endforeach; ?>
74<?php endif; ?>
75
76<?php
77$content = ob_get_clean();
78include __DIR__ . '/layout.php';