This commit is contained in:
2026-08-08 17:19:44 +08:00
parent 9276ed7358
commit dc0d2622f3
76 changed files with 1384 additions and 376 deletions
+54 -7
View File
@@ -1,7 +1,13 @@
<?php
$layoutArr = [];
if (!empty($p['layout'])) { $d = json_decode($p['layout'], true); if (is_array($d)) $layoutArr = $d; }
$hasCanvas = !empty($layoutArr);
// 模式渲染:可视化编辑(builder)且有 layout → 画布;否则固定版式(封面/图集/描述)。
$useBuilder = !empty($layoutArr) && ($p['mode'] ?? '') !== 'fixed';
// 固定版面素材
$cover = $p['cover'] ?? '';
$galleryArr = [];
if (!empty($p['gallery'])) { $dg = json_decode($p['gallery'], true); if (is_array($dg)) $galleryArr = $dg; }
?>
<section class="page-hero">
<div class="container">
@@ -16,18 +22,26 @@ $hasCanvas = !empty($layoutArr);
</nav>
</div>
<?php if ($hasCanvas): ?>
<?php if ($useBuilder): ?>
<?php echo \Core\View::buffer('parts/canvas', ['layout' => $layoutArr, 'item' => $p, 'module' => 'product']); ?>
<?php else: ?>
<section class="section detail-sec" style="padding-top:20px">
<div class="container">
<div class="detail-wrap">
<div>
<div class="detail-thumb" style="background:<?php echo gradient($p['id']); ?>">❄</div>
<?php if ($cover): ?>
<div class="detail-thumb"><img class="detail-cover" src="<?php echo e(site_url($cover)); ?>" alt="<?php echo e($p['name']); ?>"></div>
<?php else: ?>
<div class="detail-thumb" style="background:<?php echo gradient($p['id']); ?>">❄</div>
<?php endif; ?>
<div class="gallery">
<div class="detail-thumb" style="aspect-ratio:1/1;font-size:28px;background:<?php echo gradient($p['id'] + 1); ?>">❄</div>
<div class="detail-thumb" style="aspect-ratio:1/1;font-size:28px;background:<?php echo gradient($p['id'] + 2); ?>">❄</div>
<div class="detail-thumb" style="aspect-ratio:1/1;font-size:28px;background:<?php echo gradient($p['id'] + 3); ?>">❄</div>
<?php if (!empty($galleryArr)): ?>
<?php foreach ($galleryArr as $gi): ?><div class="detail-thumb gal"><img src="<?php echo e(site_url($gi)); ?>" alt=""></div><?php endforeach; ?>
<?php else: ?>
<div class="detail-thumb" style="aspect-ratio:1/1;font-size:28px;background:<?php echo gradient($p['id'] + 1); ?>">❄</div>
<div class="detail-thumb" style="aspect-ratio:1/1;font-size:28px;background:<?php echo gradient($p['id'] + 2); ?>">❄</div>
<div class="detail-thumb" style="aspect-ratio:1/1;font-size:28px;background:<?php echo gradient($p['id'] + 3); ?>">❄</div>
<?php endif; ?>
</div>
</div>
<div class="detail-info">
@@ -39,7 +53,7 @@ $hasCanvas = !empty($layoutArr);
<?php foreach ($specs as $s): ?><tr><td><?php echo e($s['k']); ?></td><td><?php echo e($s['v']); ?></td></tr><?php endforeach; ?>
</table>
<?php endif; ?>
<p class="detail-desc"><?php echo e($p['description']); ?></p>
<?php if (!empty($p['description'])): ?><div class="detail-desc detail-rich"><?php echo $p['description']; ?></div><?php endif; ?>
<div style="display:flex;gap:12px;margin-top:24px;flex-wrap:wrap">
<a class="btn btn-primary magnetic" href="<?php echo site_url('order/checkout/' . $p['slug']); ?>">立即购买</a>
<a class="btn btn-ghost" href="<?php echo site_url('contact'); ?>">咨询报价</a>
@@ -51,6 +65,25 @@ $hasCanvas = !empty($layoutArr);
</section>
<?php endif; ?>
<?php if (!empty($faqs)): ?>
<section class="section" style="padding-top:10px">
<div class="container">
<div class="section-head reveal">
<p class="eyebrow">常见问题</p>
<h2 class="section-title">关于本品,您可能想了解</h2>
</div>
<div class="faq-list">
<?php foreach ($faqs as $f): ?>
<details class="faq-item reveal">
<summary><?php echo e($f['q']); ?><span class="faq-ico">+</span></summary>
<div class="faq-a"><?php echo e($f['a']); ?></div>
</details>
<?php endforeach; ?>
</div>
</div>
</section>
<?php endif; ?>
<?php if (!empty($related)): ?>
<section class="section" style="padding-top:30px">
<div class="container">
@@ -58,7 +91,11 @@ $hasCanvas = !empty($layoutArr);
<div class="product-grid">
<?php foreach ($related as $r): ?>
<a class="product-card" href="<?php echo site_url('products/' . $r['slug']); ?>">
<?php if (!empty($r['cover'])): ?>
<div class="product-thumb"><img src="<?php echo e(site_url($r['cover'])); ?>" alt="<?php echo e($r['name']); ?>"></div>
<?php else: ?>
<div class="product-thumb" style="background:<?php echo gradient($r['id']); ?>">❄</div>
<?php endif; ?>
<div class="product-body">
<div class="product-name"><?php echo e($r['name']); ?></div>
<div class="product-sum"><?php echo e($r['summary']); ?></div>
@@ -83,3 +120,13 @@ $hasCanvas = !empty($layoutArr);
</div>
</div>
</div>
<style>
.detail-cover{width:100%;height:100%;object-fit:cover;display:block;border-radius:var(--radius)}
.detail-thumb.gal img{width:100%;height:100%;object-fit:cover;display:block;border-radius:var(--radius)}
.detail-rich img{max-width:100%;height:auto;display:block;border-radius:8px;margin:10px 0}
.detail-rich h2{font-size:24px;margin:.6em 0 .4em}
.detail-rich h3{font-size:20px;margin:.6em 0 .4em}
.detail-rich blockquote{margin:.6em 0;padding:8px 14px;border-left:4px solid var(--c-primary);color:var(--c-muted);background:rgba(14,165,233,.06)}
.detail-rich a{color:var(--c-primary)}
</style>