From fd794616b35d164b57f0334ed7bd7d6cf8c636e0 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 28 Aug 2026 16:34:16 +0800 Subject: [PATCH] =?UTF-8?q?feat(storefront):=20=E5=95=86=E5=9F=8E=E6=94=B9?= =?UTF-8?q?=20TabPanel+=E4=BA=A7=E5=93=81=E5=8D=A1=E7=89=87=E5=B8=83?= =?UTF-8?q?=E5=B1=80;=20=E8=A1=A5=E9=BD=90=E8=B4=AD=E4=B9=B0=E9=93=BE?= =?UTF-8?q?=E8=B7=AF=E6=9D=83=E9=99=90=E6=B3=A8=E5=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 展示层重写: 分类=Tab(服务端渲染), 卡片含介绍+真实定价+立即购买按钮, 点击弹购买确认弹窗(purchase_confirm→purchase_realtime 实时记账链路不变) - 定价文案取资源模块 get_product_display_info(含折扣前的资源真实价) - load_path 补注册 purchase_confirm/purchase_realtime/my_subscriptions (此前缺失, 客户点购买会 401) --- scripts/load_path.py | 3 + wwwroot/storefront/index.ui | 285 ++++++++++++++++++++++-------------- 2 files changed, 178 insertions(+), 110 deletions(-) diff --git a/scripts/load_path.py b/scripts/load_path.py index 94370b3..efa6724 100644 --- a/scripts/load_path.py +++ b/scripts/load_path.py @@ -145,6 +145,9 @@ PATHS_LOGINED = [ # Storefront purchase (requires login) 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) f"/{MOD}/product_resource_list/get_product_resource.dspy", diff --git a/wwwroot/storefront/index.ui b/wwwroot/storefront/index.ui index ffacef7..d62ce2c 100644 --- a/wwwroot/storefront/index.ui +++ b/wwwroot/storefront/index.ui @@ -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", - "options": { + "widgettype": "VBox", + "options": { + "width": "100%", + "height": "100%", + "padding": "0", + "bgcolor": "#f1f5f9" + }, + "subwidgets": [ + { + "widgettype": "TabPanel", + "options": { + "css": "filler", "width": "100%", "height": "100%", - "padding": "0" - }, - "subwidgets": [ - { - "widgettype": "HBox", - "options": { + "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%", - "alignItems": "center", - "padding": "16px 24px", - "marginBottom": "0" - }, - "subwidgets": [ + "height": "100%" + }, + "subwidgets": [ { - "widgettype": "Title2", - "options": { - "text": "产品商城", - "fontWeight": "700" - } - }, - { - "widgettype": "Filler" - }, - { - "widgettype": "Text", - "options": { - "text": "浏览产品,点击了解详情", - "fontSize": "14px" - } - } - ] - }, - { - "widgettype": "HBox", - "options": { - "width": "100%", - "css": "filler", - "gap": "0" - }, - "subwidgets": [ - { - "widgettype": "VBox", - "id": "category_sidebar", - "options": { - "width": "280px", - "minWidth": "48px", - "borderRight": "1px solid #e0e0e0", - "overflowY": "auto" - }, - "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) %} +{% set disp = get_product_display_info(p.get('id')) %} +{% set pricing_text = (disp or {}).get('pricing_text', '定价暂不可用') if (disp or {}).get('success') else '定价暂不可用' %} +{% if not ns.first %},{% endif %} +{% set ns.first = false %} { - "widgettype": "Tree", - "id": "category_tree", - "options": { - "title": "产品分类", - "idField": "id", - "textField": "name", - "parentField": "parent_id", - "dataurl": "{{entire_url('./api/get_categories.dspy')}}" - }, - "binds": [ - { - "wid": "self", - "event": "click", - "actiontype": "urlwidget", - "target": "product_list", - "params_mapping": { - "mapping": { - "id": "category_id" - }, - "need_other": false - }, - "options": { - "method": "POST", - "url": "{{entire_url('./api/get_products.dspy')}}" - } + "widgettype": "VBox", + "options": { + "css": "card", + "cwidth": 24, + "cheight": 15, + "padding": "20px", + "bgcolor": "#fff", + "cursor": "pointer", + "gap": "8px" + }, + "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)}} } - ] - } - ] - }, - { - "widgettype": "VBox", - "options": { - "css": "filler", - "padding": "16px 24px", - "overflowY": "auto" - }, - "subwidgets": [ - { - "widgettype": "Title4", - "options": { - "text": "产品列表", - "fontWeight": "600", - "marginBottom": "12px" + } } - }, - { - "widgettype": "VBox", - "id": "product_list", - "options": { + ], + "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 + } + } + ] + }, + { + "widgettype": "Text", + "options": { + "text": {{json.dumps(pricing_text, ensure_ascii=False)}}, + "fontSize": "14px", + "color": "#e74c3c" + } + }, + { + "widgettype": "HBox", + "options": { "width": "100%", - "css": "filler" - } - }, - { - "widgettype": "VBox", - "id": "product_detail", - "options": { - "width": "100%", - "marginTop": "24px" + "justifyContent": "flex-end" + }, + "subwidgets": [ +{% if 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 %} + ] + } + } + ] }