fix(storefront): 让利原价并入价格单元格(HBox并排红价+划线原价)——独立列致行格数≠表头列数错位(2026-09-18实测);Jinja真渲染验row_cells=2对齐+orig划线在格内
This commit is contained in:
parent
aee498de78
commit
d49790d126
@ -1365,10 +1365,13 @@ class ProductManager:
|
||||
v = (p.get('filter_labels') or {}).get(key[2:], '')
|
||||
vals.append(str(v if v is not None else ''))
|
||||
cells = [{'t': v, 'k': ''} for v in vals]
|
||||
cells.append({'t': '¥%.4g %s' % (p['amount'], p.get('unit_label') or '元'),
|
||||
'k': 'price'})
|
||||
price_cell = {'t': '¥%.4g %s' % (p['amount'], p.get('unit_label') or '元'),
|
||||
'k': 'price', 'orig': None}
|
||||
if discount < 1.0 - 1e-9:
|
||||
cells.append({'t': '¥%.4g' % p['original_price'], 'k': 'orig'})
|
||||
# 原价与折后价同单元格(.ui 渲染为并排两 Text:红价+划线原价),
|
||||
# 不占独立列——否则行单元格数≠表头列数导致错位(2026-09-18 实测)
|
||||
price_cell['orig'] = '¥%.4g' % p['original_price']
|
||||
cells.append(price_cell)
|
||||
rows.append(cells)
|
||||
return {'headers': headers, 'rows': rows}
|
||||
|
||||
|
||||
@ -183,7 +183,14 @@
|
||||
"options": {"css": "tabular-row", "width": "100%"},
|
||||
"subwidgets": [
|
||||
{% for c in row %}
|
||||
{"widgettype": "Text", "options": {"otext": {{json.dumps(c.t, ensure_ascii=False)}}, "text": {{json.dumps(c.t, ensure_ascii=False)}}, "i18n": true, "halign": "left", "css": "filler", "cfontsize": 0.75{% if c.k == 'price' %}, "color": "#e74c3c"{% elif c.k == 'orig' %}, "color": "var(--ink-3)", "textDecoration": "line-through"{% else %}, "color": "var(--ink-2)"{% endif %}}}{{ "," if not loop.last }}
|
||||
{% if c.k == 'price' %}
|
||||
{"widgettype": "HBox", "options": {"css": "filler", "gap": "6px", "alignItems": "center"}, "subwidgets": [
|
||||
{"widgettype": "Text", "options": {"otext": {{json.dumps(c.t, ensure_ascii=False)}}, "text": {{json.dumps(c.t, ensure_ascii=False)}}, "i18n": true, "halign": "left", "cfontsize": 0.75, "color": "#e74c3c"}}{% if c.orig %},
|
||||
{"widgettype": "Text", "options": {"otext": {{json.dumps(c.orig, ensure_ascii=False)}}, "text": {{json.dumps(c.orig, ensure_ascii=False)}}, "i18n": true, "halign": "left", "cfontsize": 0.75, "color": "var(--ink-3)", "textDecoration": "line-through"}}{% endif %}
|
||||
]}{{ "," if not loop.last }}
|
||||
{% else %}
|
||||
{"widgettype": "Text", "options": {"otext": {{json.dumps(c.t, ensure_ascii=False)}}, "text": {{json.dumps(c.t, ensure_ascii=False)}}, "i18n": true, "halign": "left", "css": "filler", "cfontsize": 0.75, "color": "var(--ink-2)"}}{{ "," if not loop.last }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
]
|
||||
}{{ "," if not loop.last }}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user