better-staridc-MNBT
1<?php
2if (!defined('IN_CRONLITE')) { exit; }
3$page_title = $page_title ?? '主机套餐';
4$plans = $plans ?? [];
5ob_start();
6?>
7<div class="sf-section">
8 <div>
9 <h1>主机套餐</h1>
10 <p>选择合适的套餐购买,支付完成后自动开通主机</p>
11 </div>
12</div>
13
14<?php if (empty($plans)): ?>
15 <div class="sf-card"><div class="sf-empty">暂无可购买的套餐,请稍后再来。</div></div>
16<?php else: ?>
17 <div class="sf-plan-grid">
18 <?php foreach ($plans as $plan): ?>
19 <?php $enabled = hosting_plan_enabled_periods($plan); ?>
20 <div class="sf-plan-card">
21 <div class="sf-plan-head">
22 <h2><?= htmlspecialchars($plan['name']) ?></h2>
23 <?php if (!empty($plan['category'])): ?><span class="sf-plan-tag"><?= htmlspecialchars($plan['category']) ?></span><?php endif; ?>
24 </div>
25 <div class="sf-plan-desc"><?= nl2br(htmlspecialchars($plan['description'])) ?></div>
26 <ul class="sf-plan-spec">
27 <li><span>网页空间</span><b><?= (int)$plan['spec_web'] ?> MB</b></li>
28 <li><span>数据库</span><b><?= (int)$plan['spec_sql'] ?> MB</b></li>
29 <li><span>流量</span><b><?= (int)$plan['spec_flow'] > 0 ? ((int)$plan['spec_flow'] . ' GB') : '不限' ?></b></li>
30 <li><span>域名绑定</span><b><?= (int)$plan['spec_domain'] ?> 个</b></li>
31 </ul>
32 <div class="sf-plan-price">
33 <?php foreach ($enabled as $p): ?>
34 <?php
35 $cfg = hosting_periods()[$p];
36 $field = hosting_period_price_field($p);
37 $price = (int)($plan[$field] ?? 0);
38 ?>
39 <div class="sf-price-item"><span class="sf-price-label"><?= htmlspecialchars($cfg['label']) ?></span><span class="sf-price-value">¥<?= hosting_format_cents($price) ?></span></div>
40 <?php endforeach; ?>
41 <?php if ($enabled === []): ?>
42 <span style="color:var(--sf-text-3);font-size:13px;">暂无可购买周期</span>
43 <?php endif; ?>
44 </div>
45 <div class="sf-plan-buy">
46 <?php if ($enabled !== []): ?>
47 <a href="<?= shop_frontend_url('shop/order/' . (int)$plan['id']) ?>" class="sf-btn sf-btn-primary">立即购买</a>
48 <?php endif; ?>
49 </div>
50 </div>
51 <?php endforeach; ?>
52 </div>
53<?php endif; ?>
54<?php
55$content = ob_get_clean();
56include __DIR__ . '/layout.php';