{{include "header.html"}} {{include "nav.html"}} {{/* 首页(index.html)—— 小米商城式分层: ① 主视觉:左侧深色分类面板(压在轮播左缘)+ 右侧淡入轮播 ② 快捷入口宫格(新品 / 以旧换新 / 服务…) ③ 服务承诺条 ④ 促销横幅 ⑤ 热销推荐 ⑥ 品类楼层(按「全部商品」的子栏目逐层:1 大卡 + 8 小卡) ⑦ 资讯动态 ⑧ 底部 CTA ⚠️ 每个区块都用真实数据或 .ThemesExt 配置,没有数据就不渲染: 空数据还渲染出标题和空网格,是「看起来像坏了」最常见的来源。 ⚠️ 栏目块一律用稳定 slug(product_slug / news_slug)调用 ColumnContents 并判空; CMS 后台怎么改首页栏目定义,都不改变 Type == "home" 与 index.html 这个契约。 */}} {{$ext := .ThemesExt}} {{$pslug := default "products" (index $ext "product_slug")}} {{$nslug := default "news" (index $ext "news_slug")}} {{$prodCol := ""}} {{range .Columns}}{{if eq .Slug $pslug}}{{$prodCol = .}}{{end}}{{end}} {{/* ---------------------------------------------------------- ① 主视觉 */}} {{if index $ext "show_slides"}} {{$slides := HomeSlides}} {{if $slides}}
{{/* 左侧分类面板(lg+):深色半透明压在轮播左缘,小米商城同款布局 */}} {{if $prodCol}} {{if $prodCol.Children}} {{end}} {{end}} {{/* 轮播主体 */}}
{{end}} {{end}} {{/* ------------------------------------------------- ② 快捷入口宫格 */}} {{$quick := index $ext "quick_entries"}} {{if $quick}}
{{range $i, $q := $quick}} {{if eq $i 0}} {{else if eq $i 1}} {{else if eq $i 2}} {{else if eq $i 3}} {{else if eq $i 4}} {{else}} {{end}} {{index $q "title"}} {{end}}
{{end}} {{/* ---------------------------------------------------------- ③ 服务承诺条 */}} {{$promises := index $ext "service_promises"}} {{if $promises}}
{{range $i, $p := $promises}}
{{if eq $i 0}} {{else if eq $i 1}} {{else if eq $i 2}} {{else}} {{end}}
{{index $p "title"}}
{{index $p "desc"}}
{{end}}
{{end}} {{/* -------------------------------------------------------------- ④ 促销横幅 */}} {{$promoTitle := index $ext "promo_title"}} {{if $promoTitle}}
{{$promoTitle}}
{{with index $ext "promo_desc"}}
{{.}}
{{end}}
{{with index $ext "promo_url"}} {{with index $ext "promo_btn_text"}}{{.}}{{else}}立即查看{{end}} {{end}}
{{end}} {{/* -------------------------------------------------------------- ⑤ 热销推荐 */}} {{$products := ColumnContents $pslug 8}} {{if $products}}

{{with index $ext "products_title"}}{{.}}{{else}}热销产品{{end}}

{{with index $ext "products_sub"}}{{.}} {{else}}{{if .ShopCODEnabled}}精选人气好物,支持在线下单与{{.ShopCODTitle}}{{else}}精选人气好物,支持在线下单{{end}}{{end}}

{{if $prodCol}}查看全部 →{{end}}
{{range $products}}
{{if .Img}} {{.Title}} {{else}}
暂无图片
{{end}} {{if .Ext}} {{$badge := index .Ext "badge"}} {{if $badge}} {{$badge}} {{end}} {{end}}

{{.Title}}

{{if .Description}}

{{.Description}}

{{end}}
{{if .Price}}
¥{{printf "%.2f" .Price}}
{{end}} {{if gt .Sales 0}}
已售 {{.Sales}} 件
{{end}}
{{/* 加购按钮:只提交商品 ID,数量固定 1(列表页没有数量选择器)。 🚨 商城关闭时不渲染加购按钮 —— /cart 此时是 404, 「按钮在、点下去 404」比不显示更糟。 */}} {{if $.ShopEnabled}} {{if and (ne .StockLimit 2) (le .Stock 0)}} 已售罄 {{else}} {{end}} {{else}} 查看详情 {{end}}
{{end}}
{{end}} {{/* ------------------------------------------------------------- ⑥ 品类楼层 */}} {{/* 按「全部商品」的子栏目逐层成区:左一张大图卡(跨 2 行)+ 右 8 张小卡 (lg 5 列 × 2 行)。子栏目没有内容时整层不渲染。 ⚠️ 每层最多取 9 条(1 大 + 8 小),多出来的靠「查看全部」进列表页看。 */}} {{if $prodCol}} {{range $prodCol.Children}} {{$items := ColumnContents .Slug 9}} {{if $items}}

{{.Name}}

{{with .Description}}

{{.}}

{{end}}
查看全部 →
{{range $i, $p := $items}} {{if eq $i 0}} {{/* 大图卡:图占满整卡,标题与价格压在底部渐变上 */}}
{{if .Img}} {{.Title}} {{else}}
暂无图片
{{end}}

{{.Title}}

{{if .Price}} ¥{{printf "%.2f" .Price}} {{end}} 了解详情 →
{{else}}
{{if .Img}} {{.Title}} {{else}}
暂无图片
{{end}}

{{.Title}}

{{if .Price}}
¥{{printf "%.2f" .Price}}
{{end}}
{{end}} {{end}}
{{end}} {{end}} {{end}} {{/* ---------------------------------------------------------------- ⑦ 资讯动态 */}} {{$news := ColumnContents $nslug 4}} {{if $news}}

{{with index $ext "news_title"}}{{.}}{{else}}资讯动态{{end}}

了解最新的产品资讯与品牌动态

更多资讯 →
{{range $news}} {{end}}
{{end}} {{/* ------------------------------------------------------------- ⑧ 底部 CTA */}} {{if index $ext "show_cta"}}

{{with index $ext "cta_title"}}{{.}}{{else}}不确定该选哪一款?{{end}}

{{with index $ext "cta_desc"}}{{.}}{{else}}留下你的需求,我们会在 1 个工作日内给出选型建议。{{end}}

{{end}} {{include "footer.html"}} {{/* 页脚本必须在最后一个 footer include 之后、 之前 */}} {{if index $ext "show_slides"}} {{$slides := HomeSlides}} {{if $slides}} {{$slideCount := len $slides}} {{if gt $slideCount 1}} {{end}} {{end}} {{end}} {{include "js.html"}}