feat(storefront): 商城改 TabPanel+产品卡片布局; 补齐购买链路权限注册

- 展示层重写: 分类=Tab(服务端渲染), 卡片含介绍+真实定价+立即购买按钮,
  点击弹购买确认弹窗(purchase_confirm→purchase_realtime 实时记账链路不变)
- 定价文案取资源模块 get_product_display_info(含折扣前的资源真实价)
- load_path 补注册 purchase_confirm/purchase_realtime/my_subscriptions
  (此前缺失, 客户点购买会 401)
This commit is contained in:
yumoqing 2026-08-28 16:34:16 +08:00
parent 167d06cd93
commit fd794616b3
2 changed files with 178 additions and 110 deletions

View File

@ -145,6 +145,9 @@ PATHS_LOGINED = [
# Storefront purchase (requires login) # Storefront purchase (requires login)
f"/{MOD}/storefront/api/purchase.dspy", f"/{MOD}/storefront/api/purchase.dspy",
f"/{MOD}/storefront/api/purchase_confirm.dspy",
f"/{MOD}/storefront/api/purchase_realtime.dspy",
f"/{MOD}/storefront/api/my_subscriptions.dspy",
# CRUD auto-generated .dspy (new tables) # CRUD auto-generated .dspy (new tables)
f"/{MOD}/product_resource_list/get_product_resource.dspy", f"/{MOD}/product_resource_list/get_product_resource.dspy",

View File

@ -1,123 +1,188 @@
{% 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() %}
{ {
"widgettype": "VBox", "widgettype": "VBox",
"options": { "options": {
"width": "100%",
"height": "100%",
"padding": "0",
"bgcolor": "#f1f5f9"
},
"subwidgets": [
{
"widgettype": "TabPanel",
"options": {
"css": "filler",
"width": "100%", "width": "100%",
"height": "100%", "height": "100%",
"padding": "0" "tab_pos": "top",
}, "items": [
"subwidgets": [ {% for cat in cats %}
{ {% set pr = get_products_by_category(cat.id, org_id='0') %}
"widgettype": "HBox", {% set prods = (pr or {}).get('products', []) %}
"options": { {
"name": "cat_{{cat.id}}",
"label": {{json.dumps(cat.name or '', ensure_ascii=False)}},
"content": {
"widgettype": "VScrollPanel",
"options": {
"width": "100%", "width": "100%",
"alignItems": "center", "height": "100%"
"padding": "16px 24px", },
"marginBottom": "0" "subwidgets": [
},
"subwidgets": [
{ {
"widgettype": "Title2", "widgettype": "VBox",
"options": { "options": {
"text": "产品商城", "width": "100%",
"fontWeight": "700" "padding": "20px 24px",
} "gap": "16px"
}, },
{ "subwidgets": [
"widgettype": "Filler" {
}, "widgettype": "HBox",
{ "options": {
"widgettype": "Text", "width": "100%",
"options": { "flexWrap": "wrap",
"text": "浏览产品,点击了解详情", "gap": "16px"
"fontSize": "14px" },
} "subwidgets": [
} {% set ns = namespace(first=true) %}
] {% for p in prods %}
}, {% if p.get('is_active', true) %}
{ {% set disp = get_product_display_info(p.get('id')) %}
"widgettype": "HBox", {% set pricing_text = (disp or {}).get('pricing_text', '定价暂不可用') if (disp or {}).get('success') else '定价暂不可用' %}
"options": { {% if not ns.first %},{% endif %}
"width": "100%", {% set ns.first = false %}
"css": "filler",
"gap": "0"
},
"subwidgets": [
{
"widgettype": "VBox",
"id": "category_sidebar",
"options": {
"width": "280px",
"minWidth": "48px",
"borderRight": "1px solid #e0e0e0",
"overflowY": "auto"
},
"subwidgets": [
{ {
"widgettype": "Tree", "widgettype": "VBox",
"id": "category_tree", "options": {
"options": { "css": "card",
"title": "产品分类", "cwidth": 24,
"idField": "id", "cheight": 15,
"textField": "name", "padding": "20px",
"parentField": "parent_id", "bgcolor": "#fff",
"dataurl": "{{entire_url('./api/get_categories.dspy')}}" "cursor": "pointer",
}, "gap": "8px"
"binds": [ },
{ "binds": [
"wid": "self", {
"event": "click", "wid": "self",
"actiontype": "urlwidget", "event": "click",
"target": "product_list", "actiontype": "urlwidget",
"params_mapping": { "target": "PopupWindow",
"mapping": { "popup_options": {
"id": "category_id" "title": {{json.dumps('购买 - ' + (p.get('product_name') or ''), ensure_ascii=False)}},
}, "cwidth": 40,
"need_other": false "cheight": 26
}, },
"options": { "options": {
"method": "POST", "method": "POST",
"url": "{{entire_url('./api/get_products.dspy')}}" "url": "{{entire_url('/product_management/storefront/api/purchase_confirm.dspy')}}",
} "params": {
"product_id": {{json.dumps(p.get('id') or '', ensure_ascii=False)}}
} }
] }
}
]
},
{
"widgettype": "VBox",
"options": {
"css": "filler",
"padding": "16px 24px",
"overflowY": "auto"
},
"subwidgets": [
{
"widgettype": "Title4",
"options": {
"text": "产品列表",
"fontWeight": "600",
"marginBottom": "12px"
} }
}, ],
{ "subwidgets": [
"widgettype": "VBox", {
"id": "product_list", "widgettype": "Title4",
"options": { "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
}
}
]
},
{
"widgettype": "Text",
"options": {
"text": {{json.dumps(pricing_text, ensure_ascii=False)}},
"fontSize": "14px",
"color": "#e74c3c"
}
},
{
"widgettype": "HBox",
"options": {
"width": "100%", "width": "100%",
"css": "filler" "justifyContent": "flex-end"
} },
}, "subwidgets": [
{ {% if userid %}
"widgettype": "VBox", {
"id": "product_detail", "widgettype": "Button",
"options": { "options": {
"width": "100%", "label": "立即购买",
"marginTop": "24px" "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 %}
]
}
}
]
} }