@tbox.cn/app-module-shopping-guide 0.2.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/AGENTS.md +16 -0
  2. package/README.md +96 -0
  3. package/dist/chunk-AYQZO2FV.js +1496 -0
  4. package/dist/chunk-QDTU2FRN.js +1682 -0
  5. package/dist/client/index.d.ts +3 -3
  6. package/dist/client/index.js +1 -1
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.js +2 -8
  9. package/dist/server/index.d.ts +2512 -608
  10. package/dist/server/index.js +1 -7
  11. package/dist/shop-guide-header-art-pea-v2-OME4MKBW.jpg +0 -0
  12. package/dist/shopping-guide-OQ2SSHXL.css +2593 -0
  13. package/package.json +25 -16
  14. package/skills/shopping-guide/SKILL.md +127 -24
  15. package/src/client/assets/shop-guide-header-art-pea-v2.jpg +0 -0
  16. package/src/client/assets/shop-guide-header-art.png +0 -0
  17. package/src/client/assets.d.ts +10 -0
  18. package/src/client/cards/category-list/index.tsx +113 -0
  19. package/src/client/cards/human-guide-list/index.tsx +72 -0
  20. package/src/client/cards/index.ts +14 -0
  21. package/src/client/cards/location-handoff/index.tsx +52 -0
  22. package/src/client/cards/mall-directory/index.tsx +77 -0
  23. package/src/client/cards/nearby-mall-list/index.tsx +40 -0
  24. package/src/client/cards/product-comparison/index.tsx +100 -0
  25. package/src/client/cards/product-detail/index.tsx +97 -0
  26. package/src/client/cards/product-list/index.tsx +223 -0
  27. package/src/client/cards/recommend-merchants/index.tsx +147 -0
  28. package/src/client/cards/shop-detail/index.tsx +133 -0
  29. package/src/client/cards/shop-list/index.tsx +216 -0
  30. package/src/client/cards/view.ts +147 -0
  31. package/src/client/categories.ts +38 -0
  32. package/src/client/components/ImageWithFallback.tsx +34 -0
  33. package/src/client/components/MerchantRow.tsx +78 -0
  34. package/src/client/components/ShopDetailSheet.tsx +383 -0
  35. package/src/client/components/ShopGuideHeader.tsx +24 -0
  36. package/src/client/components/ShopGuideSectionLabel.tsx +10 -0
  37. package/src/client/components/ShopListSheet.tsx +293 -0
  38. package/src/client/index.ts +8 -6
  39. package/src/client/styles/shopping-guide.css +2593 -0
  40. package/src/client/types/css.d.ts +2 -0
  41. package/src/server/cards/category-list/meta.ts +0 -2
  42. package/src/server/cards/human-guide-list/meta.ts +0 -2
  43. package/src/server/cards/index.ts +10 -10
  44. package/src/server/cards/location-handoff/meta.ts +0 -2
  45. package/src/server/cards/mall-directory/meta.ts +0 -2
  46. package/src/server/cards/nearby-mall-list/meta.ts +1 -3
  47. package/src/server/cards/product-comparison/meta.ts +0 -2
  48. package/src/server/cards/product-detail/meta.ts +0 -2
  49. package/src/server/cards/product-list/meta.ts +0 -2
  50. package/src/server/cards/recommend-merchants/meta.ts +37 -0
  51. package/src/server/cards/recommend-merchants/samples.ts +189 -0
  52. package/src/server/cards/{merchant-detail → shop-detail}/meta.ts +6 -6
  53. package/src/server/cards/shop-detail/samples.ts +72 -0
  54. package/src/server/cards/{merchant-list → shop-list}/meta.ts +9 -9
  55. package/src/server/cards/shop-list/samples.ts +154 -0
  56. package/src/server/domain/value-objects.ts +1 -2
  57. package/src/server/handler.ts +63 -0
  58. package/src/server/index.ts +161 -101
  59. package/src/server/ports/index.ts +120 -91
  60. package/src/server/ports/local-adapters.ts +5 -55
  61. package/src/server/projections/index.ts +159 -41
  62. package/src/server/tools/index.ts +590 -315
  63. package/tbox.module.json +137 -0
  64. package/tests/cards-render.test.tsx +830 -0
  65. package/tests/floor-pretool.test.ts +275 -0
  66. package/tests/handler.test.ts +259 -0
  67. package/tests/merchant-list-limit.test.ts +53 -0
  68. package/tests/ports-resolve.test.ts +112 -0
  69. package/tests/samples.test.ts +71 -0
  70. package/tests/shopping-guide.test.ts +402 -234
  71. package/tests/skill.test.ts +86 -0
  72. package/tests/view.test.ts +42 -0
  73. package/tsup.config.ts +9 -1
  74. package/dist/chunk-AGBLC6XI.js +0 -1294
  75. package/dist/chunk-U4WDS5PQ.js +0 -173
  76. package/skills/shopping-guide/references/comparison-format.md +0 -5
  77. package/skills/shopping-guide/references/faq-answers.md +0 -5
  78. package/skills/shopping-guide/references/floor-directory.md +0 -4
  79. package/skills/shopping-guide/references/intent-patterns.md +0 -5
  80. package/skills/shopping-guide/references/location-format.md +0 -5
  81. package/skills/shopping-guide/references/policy-lookup.md +0 -5
  82. package/skills/shopping-guide/references/product-search-tips.md +0 -6
  83. package/skills/shopping-guide/references/recommendation-style.md +0 -5
  84. package/src/client/cards/index.tsx +0 -267
  85. package/src/server/cards/customer-service-faq/meta.ts +0 -18
  86. package/src/server/integrations/joycity/adapter.ts +0 -226
  87. package/src/server/integrations/joycity/auth-strategy.ts +0 -38
  88. package/src/server/integrations/joycity/gateway.ts +0 -128
  89. package/tbox.component.json +0 -48
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@tbox.cn/app-module-shopping-guide",
3
- "version": "0.2.1",
3
+ "version": "0.8.2",
4
4
  "type": "module",
5
- "description": "商圈导购模块:商品/商户搜索、推荐、对比、商场目录、客服FAQ、人工导购、位置导航。",
5
+ "description": "商圈导购模块:商品/商户搜索、推荐、对比、商场目录、人工导购、位置导航。",
6
6
  "exports": {
7
7
  ".": {
8
8
  "types": "./dist/index.d.ts",
@@ -19,33 +19,39 @@
19
19
  "./package.json": "./package.json"
20
20
  },
21
21
  "dependencies": {
22
- "@tbox.cn/app-sdk": "^0.2.0",
23
- "@tbox.cn/app-contracts": "^0.1.0",
24
- "@tbox.cn/app-contracts-mall": "^0.2.0"
22
+ "@tbox.cn/app-sdk": "0.17.0",
23
+ "@tbox.cn/app-contracts": "0.9.0",
24
+ "@tbox.cn/app-contracts-mall": "0.9.0"
25
25
  },
26
26
  "peerDependencies": {
27
- "zod": "^3.24.0",
28
- "react": "^18.3.1"
27
+ "zod": "3.25.76",
28
+ "react": "18.3.1",
29
+ "@phosphor-icons/react": "2.1.10"
29
30
  },
30
31
  "devDependencies": {
31
- "@types/react": "^18.3.12",
32
- "@types/node": "^24.0.0",
33
- "typescript": "^5.7.0",
34
- "tsx": "^4.19.0",
35
- "vitest": "^4.1.4",
36
- "zod": "^3.24.0",
37
- "tsup": "^8.0.0"
32
+ "@types/react": "18.3.31",
33
+ "@types/node": "24.13.3",
34
+ "typescript": "5.9.3",
35
+ "vitest": "4.1.10",
36
+ "zod": "3.25.76",
37
+ "tsup": "8.5.1",
38
+ "happy-dom": "20.11.2",
39
+ "react-dom": "18.3.1",
40
+ "@types/react-dom": "18.3.7",
41
+ "express": "4.22.2",
42
+ "@types/express": "4.17.25"
38
43
  },
39
44
  "files": [
40
45
  "dist",
41
46
  "src",
42
47
  "tests",
43
48
  "skills",
44
- "tbox.component.json",
49
+ "tbox.module.json",
45
50
  "tsconfig.json",
46
51
  "tsup.config.ts",
47
52
  "README.md",
48
- "LICENSE"
53
+ "LICENSE",
54
+ "AGENTS.md"
49
55
  ],
50
56
  "engines": {
51
57
  "node": ">=20.0.0"
@@ -54,6 +60,9 @@
54
60
  "access": "public"
55
61
  },
56
62
  "license": "MIT",
63
+ "sideEffects": [
64
+ "**/*.css"
65
+ ],
57
66
  "scripts": {
58
67
  "typecheck": "tsc --noEmit",
59
68
  "test": "vitest run",
@@ -1,36 +1,139 @@
1
1
  ---
2
2
  name: shopping-guide
3
- description: 商圈导购 SOP——商品/门店搜索、推荐、对比、楼层目录、客服政策的标准回答流程。
3
+ description: 商圈导购 SOP——门店搜索、楼层浏览、类目目录的决策与回答规范。
4
4
  routingTerms:
5
- - 找店
6
- - 买什么
7
- - 推荐
8
- - 对比
9
- - 几楼
5
+ - 门店
6
+ - 店铺
7
+ - 商场
10
8
  - 楼层
11
- - 导航
12
- - 退换货
9
+ - 类目
10
+ - 逛逛
11
+ - 导购
12
+ - 购物
13
+ - 餐饮
14
+ - 美食
15
+ - 生活
16
+ - 娱乐
17
+ - 儿童
18
+ - 亲子
19
+ - 服饰
20
+ - 服装
21
+ - 行程
22
+ - 规划
23
+ - 一日游
24
+ - 路线
13
25
  ---
14
26
 
15
27
  # 商圈导购 SOP
16
28
 
17
- 你是商圈导购助手。回答购物相关问题时遵循本 SOP。
29
+ ## 你是谁
18
30
 
19
- ## 核心规则
31
+ 你是熟悉商场的导购朋友,不是播报机器。像真人一样理解上下文、自然回应;先给用户当前问题的结果,再补最有用的下一步。
20
32
 
21
- 1. **先搜索后回答**:涉及具体商品/门店,必须调用对应工具获取权威数据,禁止编造价格/库存/位置。
22
- 2. **工具绑定卡片**:搜索类工具自动出卡,回答时用文字补充要点即可。
23
- 3. **位置优先**:用户问「在哪里」时优先用搜索结果内嵌的 location.displayText,不必再调 get-location;仅当用户明确要求「导航/怎么走」时调 get-location。
24
- 4. **政策问题走 FAQ**:退换货/积分/停车等服务政策问题,优先调 customer-service-faq;稳定知识走 search-knowledge。
25
- 5. **门店详情按需**:仅当用户点击门店卡片要看详情时调 get-merchant,不在 search-merchants 后自动补调。
26
- 6. **对比**:用户要求对比 2-4 个商品时用 compare-products,并排输出差异。
27
- 7. **人工兜底**:用户明确要求联系人工时调 list-human-guides。
33
+ - **结果先行**:先说结论再给动作("3F 餐厅挺多,火锅有两家,点卡片看详情")
34
+ - **直接给结果**:不说"帮你查到了""已为你找到 X 家",直接说"3F 主要是餐饮和儿童"
35
+ - **查不到也要像人**:先承认没查到,再给个相邻选择(换关键词/换类目),或说明可找客服/导购帮忙
28
36
 
29
- ## 参考
37
+ ❌ `查询成功,3楼共有 18 家门店,包括 MUJI、星巴克、…(列举全部)`
30
38
 
31
- - 门店位置表达:`references/location-format.md`
32
- - 商品搜索技巧:`references/product-search-tips.md`
33
- - 楼层目录回答:`references/floor-directory.md`
34
- - 政策查询:`references/policy-lookup.md`
35
- - 对比回答:`references/comparison-format.md`
36
- - 推荐话术:`references/recommendation-style.md`
39
+ ✅ `3F 以餐饮为主,火锅、咖啡都有,还有 MUJI 和几家童装。`(自然收住)
40
+
41
+ ✅ `3F 主要是餐饮和儿童,火锅有两家。想先从吃的看起吗?`(偏好问句收尾)
42
+
43
+ 收尾风格每轮换,勿复用同一句式。
44
+
45
+ ## 工作方式
46
+
47
+ 每一轮对话都是同一条流程:听懂用户想去哪、想找什么 → 调一个最直接的工具拿到本轮数据 → 先用一两句人话给出结论(在几楼、有没有营业、值不值得去)→ 末尾另起一行输出 `<agent-ui-cards>` 引用本轮返回的卡片 id——标签不写,卡片不渲染,用户只剩一段文字。卡片是你回答的视觉增强,不是附赠品;正文是朋友在说话,卡片是货架上摆好的商品。
48
+
49
+ 正文怎么说话,由这条主线决定:
50
+
51
+ - 每句关于门店、楼层、铺位、营业状态、优惠的结论,都要能在本轮工具返回里指到对应项;指不到的不说,也不拿常识或上一轮印象补
52
+ - 形容词克制:「丰富」「火爆」「超值」这类工具没给的渲染词不添加;返回几家就说几家,不放大
53
+ - 收尾不套模板:一轮用过「完整清单在卡片里」类句子,下一轮换说法或自然收住——结尾可以是下一步建议、一句偏好问询,或什么都不加
54
+ - 有检索结果时,正文只说结论和 3-5 家最相关的点,完整列表交给卡片——把所有返回项逐条念完,等于替用户逛完了卡片,反而没得逛
55
+ - 问什么答什么:问营业状态先说状态,问位置先说位置,不把一次查询扩写成功能介绍
56
+ - 用户只是打招呼或还在犹豫时,友好回应加一句开放式需求("想逛哪一类?"),不主动铺清单
57
+
58
+ ## 能力地图
59
+
60
+ | 用户想要 | 工具 | 出卡 |
61
+ |---|---|---|
62
+ | 指定品牌/店名;在哪、是否营业 | `search-shops`(keywords) | `shop-list` |
63
+ | 按楼层找店,如"3 楼有什么" | `search-shops`(floorCode) | `shop-list` |
64
+ | 按楼栋找店,如"A 座有什么" | `search-shops`(buildingCode) | `shop-list` |
65
+ | 按类目找店,如火锅、咖啡、运动 | `search-shops`(businessCategory) | `shop-list` |
66
+ | 楼层+类目组合,如"3 楼有餐饮吗""2 楼有什么运动品牌" | `search-shops`(floorCode + businessCategory) | `shop-list` |
67
+ | 随便逛/商场有什么 | `search-shops`(无参数) | `shop-list` |
68
+ | 只问有哪些业态分类 | 系统预执行自动出卡(mall-overview 聚合)——正文概括引用 | `shop-list`(概览) |
69
+ | 只问商场有几层/楼层分布 | 系统预执行自动出卡(mall-overview 聚合)——正文概括引用 | `shop-list`(概览) |
70
+ | 求商品推荐/帮挑商品 | `search-shops`(businessCategory 最接近的场景类目,`购物` 兜底) | `shop-list` |
71
+ | 规划行程/一日游安排,如"帮我规划一天的行程" | `search-shops`(无参数全量) | `shop-list` |
72
+ | 用户点击门店卡片查看详情 | `get-shop`(shopId) | `shop-detail` |
73
+
74
+ ## 场景走法
75
+
76
+ ### 楼层 / 楼栋 / 类目浏览
77
+
78
+ 用户问"3 楼有什么""B 座有哪些店""有什么餐厅""想逛童装""商场有什么好逛的"时:从 mall-context 注入块(本轮或会话内历史轮均有效——楼栋/楼层/类目编码会话内不变)里取对应的编码(`floorCode`=`floors[].id`、`buildingCode`=`blocks[].id`、`businessCategory`=`categories[].code`——显示名称推不出 code,直接传 `"3"` 或 `"3楼"` 查不到东西)调 `search-shops`。回答用一句概括开头("餐饮和儿童品牌居多,火锅有两家"),完整店铺列表交给卡片。哪怕上一轮刚查过同一楼层,也重新查一次——旧卡片 id 本轮匹配不上(见「卡片是怎么出来的」)。
79
+
80
+ 用户同时指定楼层和类目(如"3 楼有餐饮吗""2 楼有什么运动品牌""4 楼有吃饭的地方吗")时:同一个 `search-shops` 调用里同时填 `floorCode` + `businessCategory`,一次调用拿到该楼层下指定类目的门店。不要只填 floorCode 返回全量再自己筛——模型人肉筛选结果不会出对应的过滤卡片。类目编码从 mall-context 注入块(本轮或会话内历史轮均有效)的 `categories[].code` 取(如"吃饭/火锅/餐饮"→ `"餐饮"`),楼层编码从 `floors[].id` 取。
81
+
82
+ ### 行程规划
83
+
84
+ 用户要"规划行程""安排一天""推荐逛吃路线"时:先调 `search-shops`(无参数全量)拿本轮门店卡,再排时间线。正文只给时间线骨架(时段 + 楼层 + 一两个锚点品牌,如"11:30 上 2F 儿童区放电"),品牌清单交给卡片——行程里把各楼层品牌铺满正文,等于替用户逛完了卡片;吃喝优惠想提就再调促销工具,但门店总表这张卡不能省。历史轮查过的门店不能直接引用(旧 id 本轮失效),须本轮重查。
85
+
86
+ ### 品牌 / 店名搜索
87
+
88
+ 用户问"MUJI 在几楼""耐克在哪""找一下星巴克"时:调 `search-shops`,`keywords` 传品牌名或店名数组(最多 5 个,只放名称,不塞完整问句)。正文说位置、营业状态、有无优惠。没有结果时,去掉"店、门店、旗舰店"等修饰词保留核心品牌重试一次;仍没有就大方说明,给个相邻选择(比如换类目搜)。
89
+
90
+ 用户表达购物需求但未指定品牌(如"买鞋""买衣服""想吃火锅")时:先从 mall-context 注入块(本轮或会话内历史轮均有效)的 `categories` 里取对应的类目编码,仅传 `businessCategory` 调 `search-shops`(如"买鞋/买衣服"→ `"购物"`,"吃饭/火锅"→ `"餐饮"`)——不要同时加 keywords,类目查询要全量返回该类目下门店。拿到门店列表后出卡,正文概括几家中最相关的。类目也无结果时改用无参数全量浏览。
91
+
92
+ ### 商品推荐
93
+
94
+ 用户求商品推荐("推荐一款面霜""有什么好用的耳机""帮我挑个礼物")时:导购没有商品级推荐能力——不推具体商品、不报价、不谈库存(数据面没有,编造即事故)。先接住诉求再委婉说明("面霜帮不了你挑具体哪款,得看肤质"),随即转门店承接:从 mall-context 注入块(本轮或会话内历史轮均有效)的 `categories` 里取最接近的场景类目(映射不上细粒度品类就取 `购物` 兜底),`businessCategory` 调 `search-shops` 出相关店铺——"护肤的店给你捞几家,去柜台试最准"。让用户到店里看货,比硬编一款商品靠谱。
95
+
96
+ ### 门店详情
97
+
98
+ 用户点门店卡片、说"看看这家的详情""介绍一下 XX"时:`shopId` 来自搜索结果卡,调 `get-shop` 出详情。正文补充图文传达不了的信息(活动、特色),不重复念卡片已有字段。用户没给 shopId 时先走 `search-shops` 拿列表。
99
+
100
+ ### 商场结构 / 类目目录
101
+
102
+ 用户问"商场有几层""有哪些楼层""有哪些业态"这类**纯结构问句**(无可拆的找店参数)时:系统会预执行 `mall-overview` 出一张 shop-list 概览卡(卡头含"共 X 层 · N 类业态 · M 家门店"权威计数,note 含各业态门店数)——正文从注入块的概览数据**引用数字**概括(不要自己数门店列表),并引导用户看卡(类目 Tab 可筛、门店行可点详情)。概览卡门店是首页透出的预览子集(通常只有十余家),**不是全量**——正文不得说"完整门店清单都在卡片里""所有门店都在卡片里"这类话,概览卡筛类目也只筛预览子集。用户要逛全量或找具体类目/楼层的门店时,主动调 `search-shops`(零参数全量,或带 businessCategory/floorCode 精准查)。
103
+
104
+ ## 卡片是怎么出来的
105
+
106
+ 只要正文提到了卡片、清单、列表,回复末尾就必须另起一行输出 `<agent-ui-cards>` 引用本轮工具返回的卡片 id——说了卡片却没出标签,用户什么都看不到,本轮等于白答。`search-shops`、`get-shop` 的返回都带卡片 id,结果非空就引用它们。
107
+
108
+ **出卡优先级**:用户问"有什么推荐的/有推荐的吗/有什么店"时,`search-shops` 返回的 `shop-list` 卡是回答这个问题的核心载体——即使精确品类没搜到、走了全量浏览,只要结果非空就必须引用 shop-list 卡。卡片自带类目 Tab 供用户自行筛选,比纯文字概括有用得多。不要因为有其他域的卡片(优惠券、活动)就省略 shop-list。
109
+
110
+ 同理,上一轮的卡片 id 已经不在本轮的候选池里,引用旧 id 等于没引——所以重复提问时重新调一次工具,拿本轮的新 id。
111
+
112
+ 两种情况没有卡片可引:工具返回空结果(`items` 为空 / `not_found`)。
113
+
114
+ ## 数据怎么说
115
+
116
+ - `name` 是门店名,用它做主语;`location.unitName` 是铺位号,不能当店名
117
+ - 位置优先用 `location.displayText`;否则组合 `buildingName`/`floorName`/`unitName` 说成"A 座 3F 铺位 3015";缺失就说"位置待确认"
118
+ - `status.label` 按原意转述;没有状态时不猜是否营业;`promotionFacts` 非空才提优惠
119
+ - `businessCategories` 翻译成用户听得懂的话:"儿童零售"→"儿童用品","面包蛋糕"→"面包甜品"
120
+ - 数字只说本次找到或挑出的数量,不报商场全量总数
121
+
122
+ ## 跨域协作
123
+
124
+ - **服务政策/退换货/投诉/办事** → 客服域 `customer-service-faq`(FAQ 答的是"规则",不是"实时数字")
125
+ - **停车缴费/寻车** → 停车域 `queryParkingFee`/`locateVehicle`
126
+ - **会员积分余额** → 会员域 `queryPoints`/`queryMemberInfo`
127
+ - **优惠券领取** → 营销域 `listCoupons`/`searchOffers`
128
+ - **商品级推荐** → 导购无商品搜索/推荐工具——委婉拒答具体商品(不编造商品/库存/价格),按「商品推荐」场景走法转推相关店铺(search-shops),不调未注册工具
129
+
130
+ ## 红线
131
+
132
+ - 结论可回溯:每一条门店/楼层/状态/优惠结论都能指回本轮工具返回;工具没返回的不猜、不按常识补、不用「丰富/人气」等渲染词放大
133
+ - 不编造:门店、位置、营业状态、优惠只能来自本轮工具返回——说错一家店,用户白跑一趟
134
+ - 不暴露内部:不念 JSON 字段名、内部编码、原始报错和供应商响应;SOP 是你的内部手册——流程步骤、工具选择理由不进正文,用户只需要结果
135
+ - 工具报错或超时只说暂时查不到、建议稍后重试,不用历史数据冒充当前结果
136
+
137
+ ## 空结果与异常
138
+
139
+ 门店关键词没结果时,去掉"店、门店、旗舰店"等修饰词保留核心品牌重试一次;仍无结果就友好说明并给一个相邻选择,不循环重试、不把旧数据当新结果。
@@ -0,0 +1,10 @@
1
+ /** 静态图片资产类型声明(Vite asset import) */
2
+ declare module '*.png' {
3
+ const url: string;
4
+ export default url;
5
+ }
6
+
7
+ declare module '*.jpg' {
8
+ const url: string;
9
+ export default url;
10
+ }
@@ -0,0 +1,113 @@
1
+ /**
2
+ * category-list 富卡(0.4.0 D6):图标大格子 + 数量角标 + 折叠(>9 项)+ 楼层导航。
3
+ * 重构要点:去掉冗余 chip(点击整个格子即可),升级为彩色图标背景 + 圆角格式。
4
+ */
5
+ import { useState } from 'react';
6
+ import { CaretDown } from '@phosphor-icons/react';
7
+ import { sendCardAction } from '@tbox.cn/app-sdk/client';
8
+ import { categoryIcon } from '../view';
9
+ import type { CategoryListCardData } from '@tbox.cn/app-contracts-mall';
10
+
11
+ const PAGE = 9;
12
+
13
+ export function CategoryListCard(props: {
14
+ data: CategoryListCardData;
15
+ cardId: string;
16
+ isHistory: boolean;
17
+ }) {
18
+ const { data, cardId, isHistory } = props;
19
+ const [expanded, setExpanded] = useState(false);
20
+ const collapsible = data.categories.length > PAGE;
21
+ const visible = collapsible && !expanded ? data.categories.slice(0, PAGE) : data.categories;
22
+
23
+ function handleCategoryClick(c: CategoryListCardData['categories'][number]) {
24
+ if (isHistory) return;
25
+ const sendAction = c.itemActions?.find((a) => a.kind === 'send');
26
+ sendCardAction(cardId, {
27
+ type: 'sendMessage',
28
+ value: sendAction?.value ?? sendAction?.label ?? `查看${c.name}的门店列表`,
29
+ visible: true,
30
+ });
31
+ }
32
+
33
+ return (
34
+ <section className="sg-card sg-category-list">
35
+ <div className="sg-card-title">业态分类</div>
36
+ <ul className="sg-category-grid">
37
+ {visible.map((c) => (
38
+ <li key={c.code}>
39
+ <button
40
+ type="button"
41
+ className="sg-category-cell"
42
+ disabled={isHistory}
43
+ onClick={() => handleCategoryClick(c)}
44
+ aria-label={`查看${c.name}(${c.merchantCount} 家门店)`}
45
+ >
46
+ <span className="sg-category-icon-wrap" aria-hidden="true">
47
+ <span className="sg-category-icon">{categoryIcon(c.code)}</span>
48
+ </span>
49
+ <span className="sg-category-name">{c.name}</span>
50
+ {c.merchantCount > 0 && (
51
+ <span className="sg-category-count">{c.merchantCount} 家</span>
52
+ )}
53
+ </button>
54
+ </li>
55
+ ))}
56
+ </ul>
57
+
58
+ {collapsible && (
59
+ <button
60
+ type="button"
61
+ className="sg-category-toggle"
62
+ aria-expanded={expanded}
63
+ onClick={() => setExpanded((v) => !v)}
64
+ >
65
+ <CaretDown
66
+ size={14}
67
+ className="sg-category-toggle__icon"
68
+ data-rotated={expanded || undefined}
69
+ />
70
+ {expanded ? '收起' : `展开全部 ${data.categories.length} 类`}
71
+ </button>
72
+ )}
73
+
74
+ {data.buildings && data.buildings.length > 0 && (
75
+ <div className="sg-category-floors">
76
+ <div className="sg-category-floors__title">楼层导览</div>
77
+ {data.buildings.map((building) => (
78
+ <div key={building.buildingCode} className="sg-category-floors__building">
79
+ {data.buildings!.length > 1 && (
80
+ <div className="sg-category-floors__building-name">{building.buildingName}</div>
81
+ )}
82
+ <div className="sg-category-floors__floor-list">
83
+ {building.floors.map((floor) => (
84
+ <button
85
+ key={floor.floorCode}
86
+ type="button"
87
+ className="sg-category-floor-chip"
88
+ disabled={isHistory}
89
+ onClick={() => {
90
+ if (isHistory) return;
91
+ sendCardAction(cardId, {
92
+ type: 'sendMessage',
93
+ value: `展示商场${building.buildingName}${floor.floorName}的门店列表`,
94
+ visible: true,
95
+ });
96
+ }}
97
+ >
98
+ <span className="sg-category-floor-chip__name">{floor.floorName}</span>
99
+ {floor.merchantCount > 0 && (
100
+ <span className="sg-category-floor-chip__count">{floor.merchantCount}</span>
101
+ )}
102
+ </button>
103
+ ))}
104
+ </div>
105
+ </div>
106
+ ))}
107
+ </div>
108
+ )}
109
+ </section>
110
+ );
111
+ }
112
+
113
+ export default CategoryListCard;
@@ -0,0 +1,72 @@
1
+ /**
2
+ * human-guide-list 富卡(0.4.0 D6):头像占位 + 渠道标签 + 在线状态 + 联系按钮 + 隐私声明。
3
+ */
4
+ import { sendCardAction } from '@tbox.cn/app-sdk/client';
5
+ import { ImageWithFallback } from '../../components/ImageWithFallback';
6
+ import type { HumanGuideListCardData } from '@tbox.cn/app-contracts-mall';
7
+
8
+ export function HumanGuideListCard(props: {
9
+ data: HumanGuideListCardData;
10
+ cardId: string;
11
+ isHistory: boolean;
12
+ }) {
13
+ const { data, cardId, isHistory } = props;
14
+ return (
15
+ <section className="sg-card sg-human-guide">
16
+ <div className="sg-card-title">{data.merchantName} · 人工导购</div>
17
+ {data.guides.length === 0 ? (
18
+ <div className="sg-empty">暂无导购员信息</div>
19
+ ) : (
20
+ <ul className="sg-guide-list">
21
+ {data.guides.map((g) => {
22
+ const contact = g.itemActions[0];
23
+ const contactDisabled = isHistory || !contact;
24
+ return (
25
+ <li key={g.guideId} className="sg-guide-item">
26
+ <ImageWithFallback src={g.avatarUrl} alt={g.name} className="sg-guide-avatar" size={48} />
27
+ <div className="sg-guide-info">
28
+ <div className="sg-guide-head">
29
+ <span className="sg-merchant-name">{g.name}</span>
30
+ <span className={`sg-status sg-status-${g.available ? 'available' : 'offline'}`}>
31
+ {g.available ? '在线' : '离线'}
32
+ </span>
33
+ </div>
34
+ {g.title && <div className="sg-guide-title">{g.title}</div>}
35
+ {g.contactInfo && g.contactInfo.length > 0 && (
36
+ <div className="sg-guide-channels">
37
+ {g.contactInfo.map((c, i) => (
38
+ <span key={i} className="sg-guide-channel">
39
+ {c.channel}
40
+ </span>
41
+ ))}
42
+ </div>
43
+ )}
44
+ </div>
45
+ <button
46
+ type="button"
47
+ className="sg-guide-contact"
48
+ disabled={contactDisabled}
49
+ title={contact ? contact.label : '暂无可用的联系方式'}
50
+ onClick={() => {
51
+ if (!contact || isHistory) return;
52
+ sendCardAction(
53
+ cardId,
54
+ contact.kind === 'send'
55
+ ? { type: 'sendMessage', value: contact.value ?? contact.label, visible: true }
56
+ : { type: 'openLink', url: contact.url },
57
+ );
58
+ }}
59
+ >
60
+ {contact?.label ?? '联系'}
61
+ </button>
62
+ </li>
63
+ );
64
+ })}
65
+ </ul>
66
+ )}
67
+ <p className="sg-guide-privacy">导购信息由门店提供,联系方式仅用于本次咨询</p>
68
+ </section>
69
+ );
70
+ }
71
+
72
+ export default HumanGuideListCard;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * module-shopping-guide 客户端卡片聚合(0.4.0 D6:一卡一目录)。
3
+ */
4
+ export { default as ProductListCard } from './product-list';
5
+ export { default as ProductDetailCard } from './product-detail';
6
+ export { default as ShopListCard } from './shop-list';
7
+ export { default as ShopDetailCard } from './shop-detail';
8
+ export { default as CategoryListCard } from './category-list';
9
+ export { default as ProductComparisonCard } from './product-comparison';
10
+ export { default as MallDirectoryCard } from './mall-directory';
11
+ export { default as NearbyMallListCard } from './nearby-mall-list';
12
+ export { default as HumanGuideListCard } from './human-guide-list';
13
+ export { default as LocationHandoffCard } from './location-handoff';
14
+ export { default as RecommendMerchantsCard } from './recommend-merchants';
@@ -0,0 +1,52 @@
1
+ /**
2
+ * location-handoff 富卡(0.4.0 D6):地图预览 + 地址 + 三级降级(view.deriveLocationLevel)。
3
+ */
4
+ import { MapPin, NavigationArrow } from '@phosphor-icons/react';
5
+ import { sendCardAction } from '@tbox.cn/app-sdk/client';
6
+ import { ImageWithFallback } from '../../components/ImageWithFallback';
7
+ import { deriveLocationLevel } from '../view';
8
+ import type { LocationHandoffCardData } from '@tbox.cn/app-contracts-mall';
9
+
10
+ export function LocationHandoffCard(props: {
11
+ data: LocationHandoffCardData;
12
+ cardId: string;
13
+ isHistory: boolean;
14
+ }) {
15
+ const { data, cardId } = props;
16
+ const level = deriveLocationLevel({ location: data.location, itemActions: data.itemActions });
17
+ const navAction = data.itemActions.find((a) => a.kind === 'link');
18
+
19
+ return (
20
+ <section className="sg-card sg-location-handoff">
21
+ <div className="sg-card-title">{data.merchantName} · 位置</div>
22
+ {data.mapUrl && (
23
+ <ImageWithFallback src={data.mapUrl} alt={`${data.merchantName} 位置示意`} className="sg-lh-map" size={88} />
24
+ )}
25
+ <div className="sg-lh-address">
26
+ <MapPin size={16} />
27
+ <span>{data.location.displayText}</span>
28
+ </div>
29
+ {(data.location.buildingName || data.location.floorName || data.location.unitName) && (
30
+ <div className="sg-lh-detail">
31
+ {data.location.buildingName && <span>{data.location.buildingName}</span>}
32
+ {data.location.floorName && <span>{data.location.floorName}</span>}
33
+ {data.location.unitName && <span>{data.location.unitName}</span>}
34
+ </div>
35
+ )}
36
+ {level === 'route_available' && navAction && (
37
+ <button
38
+ type="button"
39
+ className="sg-lh-nav"
40
+ onClick={() => {
41
+ sendCardAction(cardId, { type: 'openLink', url: navAction.url });
42
+ }}
43
+ >
44
+ <NavigationArrow size={16} />
45
+ {navAction.label}
46
+ </button>
47
+ )}
48
+ </section>
49
+ );
50
+ }
51
+
52
+ export default LocationHandoffCard;
@@ -0,0 +1,77 @@
1
+ /**
2
+ * mall-directory 富卡(0.4.0 D6):楼栋手风琴(默认第一栋展开)+ 楼层「查看门店」chip。
3
+ */
4
+ import { useState } from 'react';
5
+ import { CaretDown, Storefront } from '@phosphor-icons/react';
6
+ import { sendCardAction } from '@tbox.cn/app-sdk/client';
7
+ import type { MallDirectoryCardData } from '@tbox.cn/app-contracts-mall';
8
+
9
+ export function MallDirectoryCard(props: {
10
+ data: MallDirectoryCardData;
11
+ cardId: string;
12
+ isHistory: boolean;
13
+ }) {
14
+ const { data, cardId, isHistory } = props;
15
+ const [openBuilding, setOpenBuilding] = useState<string | null>(
16
+ data.buildings.length > 0 ? data.buildings[0].buildingCode : null,
17
+ );
18
+
19
+ return (
20
+ <section className="sg-card sg-mall-directory">
21
+ <div className="sg-card-title">{data.mallName} · 楼层目录</div>
22
+ {data.buildings.map((b) => {
23
+ const open = openBuilding === b.buildingCode;
24
+ return (
25
+ <div key={b.buildingCode} className="sg-dir-building">
26
+ <button
27
+ type="button"
28
+ className="sg-dir-building__head"
29
+ aria-expanded={open}
30
+ onClick={() => setOpenBuilding(open ? null : b.buildingCode)}
31
+ >
32
+ <Storefront size={18} />
33
+ <span className="sg-dir-building__name">{b.buildingName}</span>
34
+ <span className="sg-dir-building__count">{b.floors.length} 层</span>
35
+ <CaretDown size={16} className="sg-dir-building__chevron" data-rotated={open || undefined} />
36
+ </button>
37
+ {open && (
38
+ <ul className="sg-dir-floors">
39
+ {b.floors.map((f) => (
40
+ <li key={f.floorCode} className="sg-dir-floor">
41
+ <div className="sg-dir-floor__info">
42
+ <span className="sg-dir-floor__name">{f.floorName}</span>
43
+ <span className="sg-dir-floor__cats">
44
+ {f.businessCategories.join(' / ') || `${f.merchantCount} 家商户`}
45
+ </span>
46
+ </div>
47
+ {f.itemActions && f.itemActions.length > 0 && (
48
+ <button
49
+ type="button"
50
+ className="sg-chip sg-dir-floor__action"
51
+ disabled={isHistory}
52
+ onClick={() => {
53
+ if (isHistory) return;
54
+ const a = f.itemActions![0];
55
+ sendCardAction(
56
+ cardId,
57
+ a.kind === 'send'
58
+ ? { type: 'sendMessage', value: a.value ?? a.label, visible: true }
59
+ : { type: 'openLink', url: a.url },
60
+ );
61
+ }}
62
+ >
63
+ {f.itemActions[0].label}
64
+ </button>
65
+ )}
66
+ </li>
67
+ ))}
68
+ </ul>
69
+ )}
70
+ </div>
71
+ );
72
+ })}
73
+ </section>
74
+ );
75
+ }
76
+
77
+ export default MallDirectoryCard;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * nearby-mall-list 富卡(0.4.0 D6):商场名 + 地址 + 距离(formatDistance)+ 营业状态 + 条目动作。
3
+ */
4
+ import { ItemActionsRow } from '@tbox.cn/app-sdk/client';
5
+ import { formatDistance } from '../view';
6
+ import type { NearbyMallListCardData } from '@tbox.cn/app-contracts-mall';
7
+
8
+ export function NearbyMallListCard(props: {
9
+ data: NearbyMallListCardData;
10
+ cardId: string;
11
+ isHistory: boolean;
12
+ }) {
13
+ const { data, cardId, isHistory } = props;
14
+ if (data.malls.length === 0) {
15
+ return <section className="sg-card"><div className="sg-empty">暂无附近商场</div></section>;
16
+ }
17
+ return (
18
+ <section className="sg-card sg-nearby-malls">
19
+ <div className="sg-card-title">附近商场</div>
20
+ {data.query && <div className="sg-card-summary">查询「{data.query}」</div>}
21
+ <ul className="sg-nearby-list">
22
+ {data.malls.map((m) => (
23
+ <li key={m.mallId} className="sg-nearby-item">
24
+ <div className="sg-nearby-item__head">
25
+ <span className="sg-merchant-name">{m.name}</span>
26
+ <span className={`sg-status sg-status-${m.status.code}`}>{m.status.label}</span>
27
+ </div>
28
+ <div className="sg-nearby-item__meta">
29
+ <span>{m.address}</span>
30
+ <span className="sg-nearby-item__distance">{formatDistance(m.distanceKm)}</span>
31
+ </div>
32
+ <ItemActionsRow actions={m.itemActions} cardId={cardId} isHistory={isHistory} className="sg-item-actions" chipClassName="sg-chip" />
33
+ </li>
34
+ ))}
35
+ </ul>
36
+ </section>
37
+ );
38
+ }
39
+
40
+ export default NearbyMallListCard;