{{include "header.html"}} {{include "nav.html"}} {{/* 商品详情(product_detail.html)—— Type 是 article,由商品栏目的 c_template 决定。 版式(小米商详): 左图廊 + 右购买信息(标题/评分/价格/SPU 规格选择/服务承诺/数量/加购) → 规格参数(**由栏目字段模型驱动**,不是硬编码 model/spec/warranty) → 产品详情富文本 → 相册 → 标签 → 相关推荐 🚨 SPU 生效需要三个条件同时成立(缺一就整块静默不渲染): ① 栏目 fields 里有 type:"spu" 的字段,且商品 ext 里填了组内其他商品 id; ② 栏目 fields 里有 indexed:true 的属性字段(颜色/版本…)作为规格维度; ③ 组内成员全维度有值、且已发布并回指本商品。 本主题的 init_data.json 为 8 个商品栏目显式写全了各自的字段模型 (不依赖 inherit —— init_data 导入是 CreateInBatches 裸插,不走父级 ext 合并)。 🚨 购买区三态不能混(先判商城关闭,再判售罄): 「立即咨询」放在三态区块**之外**,两种模式下都能看到。 */}} {{if index .ThemesExt "show_breadcrumb"}} {{if .Nav}} {{end}} {{end}} {{if .Content}} {{$ext := .Content.Ext}} {{$tsvc := index .ThemesExt "product_services"}}
{{/* ------------------------------------------------------------- 图廊 */}}
{{if .Content.Img}} {{.Content.Title}} {{else}}
暂无图片
{{end}}
{{$albums := .Content.Albums}} {{if and $albums (ne (index $albums 0) "[]")}} {{end}}
{{/* ------------------------------------------------------------- 购买信息 */}}
{{if .Content.Ext}} {{$badgeTop := index .Content.Ext "badge"}} {{if $badgeTop}}{{$badgeTop}}{{end}} {{end}}

{{.Content.Title}}

{{/* 评分紧贴标题下方(价格上方):对标里 PDP 评分放这个位置平均提升加购 11% */}} {{if .Content.Ext}} {{$rating := index .Content.Ext "rating"}} {{$reviews := index .Content.Ext "reviews"}} {{if $rating}}
{{$rating}} {{if $reviews}}{{$reviews}} 条评价{{end}}
{{end}} {{end}} {{if .Content.Description}}

{{.Content.Description}}

{{end}} {{if .Content.Price}}
¥{{printf "%.2f" .Content.Price}} {{if gt .Content.Sales 0}}已售 {{.Content.Sales}} 件{{end}}
{{with index .ThemesExt "price_note"}}

{{.}}

{{end}}
{{end}} {{/* SPU 复合选择器(京东 / 小米式,2026-10-08 契约)。 spu 字段只做 **id 关联**(索引查询起点);规格维度 = 栏目字段模型里 indexed 的 ext 属性字段,可选值 = 组内商品在这些字段上的取值**并集**。 点击属性组合 → 前端匹配出对应商品 id → **就地**切换标题/相册/价格/库存/ 加购 id,页面不跳转。全量变体数据通过 JSON 数据岛一次性下发 (数据岛与读取它的脚本一起放在页尾,见文件末尾的「页脚本」段)。 服务端先渲染初始按钮态(当前商品的属性值高亮),JS 接管后续交互。 */}} {{with .Content.SpuPicker}}
{{range .Dimensions}} {{$dimKey := .Key}} {{$dimLabel := .Label}}
{{if $dimLabel}}{{$dimLabel}}{{else}}{{$dimKey}}{{end}}
{{range .Values}} {{end}}
{{end}}

已选:—

{{end}} {{/* 服务承诺(可配置;PDP 的转化辅助信息,放在购买按钮上方) */}} {{if $tsvc}}
    {{range $tsvc}}
  • {{index . "title"}}
  • {{end}}
{{end}} {{/* 购买区。🚨 三态齐全、if/else 成对、先判商城关闭后判售罄。 */}}
{{if not .ShopEnabled}}
在线购买暂未开放 留下联系方式咨询 →
{{else}}
{{if .Content.IsSoldOut}}
该规格暂时缺货,可切换其他规格或留下联系方式咨询
{{else}}
{{/* 限量商品 max 用 Stock;不限量不给 max(HTML 上限变成无限制) */}}
查看购物车({{if .Cart}}{{.Cart.TotalQty}}{{end}})

{{if ne .Content.StockLimit 2}}库存 {{.Content.Stock}} 件{{else}}不限量{{end}} {{if gt .Content.Sales 0}} · 已售 {{.Content.Sales}} 件{{end}}

{{end}} {{/* 加购反馈区:只在「有货可加购」时存在 */}}

{{end}} 立即咨询
{{/* 规格参数:**由当前栏目的字段模型驱动**,不是硬编码某几个 key。 这样 8 个商品栏目(手机/电视/笔记本/平板/手表/影音/智能家居/配件)共用 同一个模板,各自展示自己的属性;运营在后台加字段,前台自动多一行。 ⚠️ 跳过不可展示的类型(spu / image / file / image_preview / switch / articles) 与营销字段(badge / rating / reviews)。 ⚠️ data-attr-cell 是 SPU 切换时就地覆写属性值的锚点。 */}} {{$rows := 0}} {{with .CurrentColumn}} {{$fields := index .Ext "fields"}} {{if $fields}} {{range $fields}} {{$k := index . "key"}} {{$t := index . "type"}} {{if not (or (eq $t "spu") (eq $t "image") (eq $t "file") (eq $t "image_preview") (eq $t "switch") (eq $t "articles") (eq $k "badge") (eq $k "rating") (eq $k "reviews"))}} {{$v := index $.Content.Ext $k}} {{if $v}}{{$rows = Add $rows 1}}{{end}} {{end}} {{end}} {{end}} {{end}} {{if gt $rows 0}}

规格参数

{{with .CurrentColumn}} {{$fields := index .Ext "fields"}} {{if $fields}} {{range $fields}} {{$k := index . "key"}} {{$t := index . "type"}} {{if not (or (eq $t "spu") (eq $t "image") (eq $t "file") (eq $t "image_preview") (eq $t "switch") (eq $t "articles") (eq $k "badge") (eq $k "rating") (eq $k "reviews"))}} {{$v := index $.Content.Ext $k}} {{if $v}}
{{index . "label"}}
{{$v}}
{{end}} {{end}} {{end}} {{end}} {{end}}
{{end}} {{/* ------------------------------------------------------------- 详情正文 */}} {{if .Content.Content}}

产品详情

{{.Content.Content|Str2Html}}
{{end}} {{/* --------------------------------------------------------------- 相册 */}} {{$albums := .Content.Albums}} {{if $albums}} {{if ne (index $albums 0) "[]"}}

产品图集

{{range $albums}} {{if and . (ne . "[]")}}
{{$.Content.Title}} 图集
{{end}} {{end}}
{{end}} {{end}} {{if .Content.Tags}}
{{range .Content.Tags}} {{.Name}} {{end}}
{{end}} {{/* ------------------------------------------------------------- 相关产品 */}} {{$related := Related .Content.Id 4}} {{if $related}}

相关推荐

{{range $related}}
{{if .Img}} {{.Title}} {{else}}
暂无图片
{{end}}

{{.Title}}

{{/* RelatedVM 没有 Price 字段(其余主题的相关推荐同样不显示价格)—— 写 .Price 会让整个详情页 500,而不是这一小块静默失败。 */}}
{{end}}
{{end}}
{{end}} {{include "footer.html"}} {{/* ------------------------------------------------------------ 页脚本 */}} {{if and .Content .Content.SpuPicker}} {{/* SPU 数据岛:必须放在 footer include 之后。 校验器要求页模板里任何 {{end}} {{include "js.html"}} {{/* vv-pdp-spu */}}