yumoqing 100dbe28cd feat(storefront): 多价目定价改表格展示——表头=定价要素+价格,行=要素组合对应价
病根:qwen-image-3.0-pro 按分辨率×类型四档价,一行文本拼出「按次 ¥0.02 元/张 |
按次 ¥0.02 元/张 | 按次 ¥0.25 元/张 | 按次 ¥0.5 元/张」,客户看不出各价适用条件。

- core.py 新增 _build_price_table:len(prices)>1 时返回 price_table
  {headers,rows,html};要素列=计费方式(label有区分度时)+定价维度(filter_labels,
  英文维度名中文润饰)+计价因子(factor各行不同时,token三因子);全表同因子(flat)
  省略因子列;让利时价格附划线原价;html 全量 escape 防注入
- get_customer_price_display 返回值增 price_table 键;有表格时 original_text 置空
  (原价已进表格单元格)
- storefront/index.ui 价格区:有 price_table 渲染 Html 表格,否则原文本路径不变
  (单价目无歧义)
- 实测:图像四档/token三因子/视频SR分档/产线包月包年四场景表头行值正确,XSS转义通过
2026-09-09 11:59:14 +08:00

310 lines
15 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{% set cats_r = get_category_tree(org_id='0') %}
{% set cats = (cats_r or {}).get('tree', []) if (cats_r or {}).get('success') else [] %}
{% set userid = get_user() %}
{% set userorgid = get_userorgid() %}
{
"widgettype": "VBox",
"options": {
"width": "100%",
"height": "100%",
"padding": "0",
"bgcolor": "#f1f5f9"
},
"subwidgets": [
{
"widgettype": "TabPanel",
"options": {
"css": "filler",
"width": "100%",
"height": "100%",
"tab_pos": "top",
"items": [
{% for cat in cats %}
{% set pr = get_products_by_category(cat.id, org_id='0') %}
{% set prods = (pr or {}).get('products', []) %}
{
"name": "cat_{{cat.id}}",
"label": {{json.dumps(cat.name or '', ensure_ascii=False)}},
"content": {
"widgettype": "VScrollPanel",
"options": {
"width": "100%",
"height": "100%"
},
"subwidgets": [
{
"widgettype": "VBox",
"options": {
"width": "100%",
"padding": "20px 24px",
"gap": "16px"
},
"subwidgets": [
{
"widgettype": "HBox",
"options": {
"width": "100%",
"flexWrap": "wrap",
"gap": "16px"
},
"subwidgets": [
{% set ns = namespace(first=true) %}
{% for p in prods %}
{% if p.get('is_active', true) %}
{# 显示价 = 资源真实定价 × 客户折扣率(2026-09-06):未登录按 '*' 通用折扣报价 #}
{% set cust = get_customer_price_display(p.get('id'), user_org_id=userorgid or '') %}
{% set pricing_text = (cust or {}).get('pricing_text', '定价暂不可用') if (cust or {}).get('success') else ((cust or {}).get('message') or '定价暂不可用') %}
{% set original_text = (cust or {}).get('original_text', '') %}
{# 多价目产品(如模型按分辨率×类型分档)用表格展示定价要素+价格(2026-09-09 用户要求),
一行文本拼「A ¥x | A ¥y」客户看不出适用条件;单价目仍走文本 #}
{% set price_table = (cust or {}).get('price_table') or none %}
{% set is_pipeline = (p.get('product_type') == 'pipeline') %}
{# 模型按量产品:不支持也无需「购买」(purchase_realtime 只支持 account/storage/pipeline),
卡片不弹购买框、不出立即购买按钮,改为「按量付费」字样(2026-09-08 用户要求) #}
{% set is_model = (p.get('product_type') in ('pipeline_llm_model', 'llm_model')) %}
{% set extra = {} %}
{% if is_pipeline %}
{# 产线订阅状态:已订阅→「进入产线」直达;未订阅→「立即购买」弹购买确认 #}
{% set sub = check_subscription_valid(p.get('id'), userorgid or '') if userorgid else {'valid': False} %}
{% set _urls = {'PIPE-OPP': '/pipeline-opportunity/agent', 'PIPE-BID': '/pipeline-bidding/agent', 'PIPE-DEV': '/pipeline_core/agent', 'opportunity_general': '/pipeline-opportunity/agent', 'bidding_general': '/pipeline-bidding/agent', 'sdlc_general': '/pipeline_core/agent'} %}
{% set extra = {'tab_name': 'pipeline_card_' + str(p.get('product_code','')), 'tab_label': p.get('product_name') or '', 'url': _urls.get(p.get('product_code') or '', ''), 'planned': not _urls.get(p.get('product_code') or '', ''), 'message': (p.get('product_name') or '') + '规划中,尚未开发', 'subscribed': (sub or {}).get('valid', False), 'sub_end': (sub or {}).get('end_date', '')} %}
{% endif %}
{% if not ns.first %},{% endif %}
{% set ns.first = false %}
{
"widgettype": "VBox",
"options": {
"css": "card",
"cwidth": 24,
"cheight": 15,
"padding": "20px",
"bgcolor": "#fff",
"cursor": {{json.dumps('default' if is_model else 'pointer')}},
"gap": "8px"
},
{% if is_pipeline %}
"binds": [
{% if extra.planned %}
{
"wid": "self",
"event": "click",
"actiontype": "script",
"target": "self",
"script": {{json.dumps("bricks.show_message({title:" + json.dumps(extra.tab_label, ensure_ascii=False) + ",message:" + json.dumps(extra.message, ensure_ascii=False) + "});", ensure_ascii=False)}}
}
{% else %}
{
"wid": "self",
"event": "click",
"actiontype": "script",
"target": "self",
"script": {{json.dumps("var _tp=bricks.getWidgetById('main_content',bricks.app);if(_tp&&_tp.open_tab){_tp.open_tab({name:" + json.dumps(extra.tab_name, ensure_ascii=False) + ",label:" + json.dumps(extra.tab_label, ensure_ascii=False) + ",url:" + json.dumps(extra.url, ensure_ascii=False) + ",removable:true});}", ensure_ascii=False)}}
}
{% endif %}
],
{% elif not is_model %}
"binds": [
{
"wid": "self",
"event": "click",
"actiontype": "urlwidget",
"target": "PopupWindow",
"popup_options": {
"title": {{json.dumps('购买 - ' + (p.get('product_name') or ''), ensure_ascii=False)}},
"cwidth": 40,
"cheight": 26
},
"options": {
"method": "POST",
"url": "{{entire_url('/product_management/storefront/api/purchase_confirm.dspy')}}",
"params": {
"product_id": {{json.dumps(p.get('id') or '', ensure_ascii=False)}}
}
}
}
],
{% endif %}
"subwidgets": [
{
"widgettype": "Title4",
"options": {
"text": {{json.dumps(p.get('product_name') or '', ensure_ascii=False)}},
"color": "#1e293b"
}
},
{
"widgettype": "VScrollPanel",
"options": {
"flex": "1",
"width": "100%"
},
"subwidgets": [
{
"widgettype": "Text",
"options": {
"text": {{json.dumps(p.get('brief_intro') or '暂无介绍', ensure_ascii=False)}},
"fontSize": "13px",
"color": "#64748b",
"wrap": true
}
}
]
},
{% if is_pipeline and extra.planned %}
{
"widgettype": "Text",
"options": {
"text": "规划中",
"fontSize": "14px",
"color": "#94a3b8",
"fontWeight": "600"
}
},
{% else %}
{% if price_table %}
{# 多价目:表格展示(要素列+价格列),产线包月/包年、模型分辨率×类型分档都走这里 #}
{
"widgettype": "Html",
"options": {
"html": {{json.dumps(price_table.html, ensure_ascii=False)}}
}
},
{% else %}
{
"widgettype": "Text",
"options": {
"text": {{json.dumps(pricing_text, ensure_ascii=False)}},
"fontSize": "14px",
"color": "#e74c3c"
}
},
{% if original_text %}
{
"widgettype": "Text",
"options": {
"text": {{json.dumps(original_text, ensure_ascii=False)}},
"fontSize": "11px",
"color": "#94a3b8",
"textDecoration": "line-through"
}
},
{% endif %}
{% endif %}
{% if is_pipeline %}
{
"widgettype": "Text",
"options": {
"text": {{json.dumps(('订阅制 · 已订阅至 ' + extra.sub_end) if extra.subscribed else '订阅制 · 模型/存储消耗另计', ensure_ascii=False)}},
"fontSize": "11px",
"color": {{json.dumps('#27ae60' if extra.subscribed else '#94a3b8')}}
}
},
{% endif %}
{% endif %}
{
"widgettype": "HBox",
"options": {
"width": "100%",
"justifyContent": "flex-end"
},
"subwidgets": [
{% if is_pipeline and extra.planned %}
{
"widgettype": "Text",
"options": {
"text": "敬请期待",
"fontSize": "13px",
"color": "#94a3b8"
}
}
{% elif is_pipeline and extra.subscribed %}
{
"widgettype": "Button",
"options": {
"label": "进入产线",
"bgcolor": "#2563eb",
"color": "#fff",
"padding": "8px 24px",
"borderRadius": "6px"
},
"binds": [
{
"wid": "self",
"event": "click",
"actiontype": "script",
"target": "self",
"script": {{json.dumps("var _tp=bricks.getWidgetById('main_content',bricks.app);if(_tp&&_tp.open_tab){_tp.open_tab({name:" + json.dumps(extra.tab_name, ensure_ascii=False) + ",label:" + json.dumps(extra.tab_label, ensure_ascii=False) + ",url:" + json.dumps(extra.url, ensure_ascii=False) + ",removable:true});}", ensure_ascii=False)}}
}
]
}
{% elif is_model %}
{
"widgettype": "Text",
"options": {
"text": "按量付费",
"fontSize": "13px",
"color": "#e74c3c",
"fontWeight": "600"
}
}
{% elif userid %}
{
"widgettype": "Button",
"options": {
"label": "立即购买",
"bgcolor": "#e74c3c",
"color": "#fff",
"padding": "8px 24px",
"borderRadius": "6px"
},
"binds": [
{
"wid": "self",
"event": "click",
"actiontype": "urlwidget",
"target": "PopupWindow",
"popup_options": {
"title": {{json.dumps('购买 - ' + (p.get('product_name') or ''), ensure_ascii=False)}},
"cwidth": 40,
"cheight": 26
},
"options": {
"method": "POST",
"url": "{{entire_url('/product_management/storefront/api/purchase_confirm.dspy')}}",
"params": {
"product_id": {{json.dumps(p.get('id') or '', ensure_ascii=False)}}
}
}
}
]
}
{% else %}
{
"widgettype": "Text",
"options": {
"text": "登录后购买",
"fontSize": "13px",
"color": "#94a3b8"
}
}
{% endif %}
]
}
]
}
{% endif %}
{% endfor %}
]
}
]
}
]
}
}{% if not loop.last %},{% endif %}
{% endfor %}
]
}
}
]
}