@tbox.cn/app-module-shopping-guide 0.9.12 → 1.0.0-alpha.10
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.
- package/AGENTS.md +3 -3
- package/dist/chunk-MBJPTP72.js +1692 -0
- package/dist/client/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/server/index.d.ts +696 -696
- package/package.json +12 -9
- package/src/client/cards/category-list/index.tsx +17 -17
- package/src/client/cards/human-guide-list/index.tsx +17 -14
- package/src/client/cards/location-handoff/index.tsx +10 -10
- package/src/client/cards/mall-directory/index.tsx +14 -14
- package/src/client/cards/nearby-mall-list/index.tsx +29 -11
- package/src/client/cards/product-comparison/index.tsx +29 -18
- package/src/client/cards/product-detail/index.tsx +41 -25
- package/src/client/cards/product-list/index.tsx +74 -54
- package/src/client/cards/recommend-merchants/index.tsx +19 -9
- package/src/client/cards/shop-detail/index.tsx +13 -9
- package/src/client/cards/shop-list/index.tsx +19 -9
- package/src/client/components/ImageWithFallback.tsx +1 -1
- package/src/client/components/MerchantRow.tsx +23 -13
- package/src/client/components/ShopDetailSheet.tsx +94 -131
- package/src/client/components/ShopGuideHeader.tsx +6 -6
- package/src/client/components/ShopGuideSectionLabel.tsx +1 -1
- package/src/client/components/ShopListSheet.tsx +58 -96
- package/src/client/index.ts +0 -2
- package/tbox.module.json +0 -1
- package/tests/cards-render.test.tsx +40 -7
- package/tsup.config.ts +0 -5
- package/dist/chunk-PAYDOSCV.js +0 -1676
- package/dist/shopping-guide-62BDCPW5.css +0 -2600
- package/src/client/styles/shopping-guide.css +0 -2600
- package/src/client/types/css.d.ts +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tbox.cn/app-module-shopping-guide",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-alpha.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "门店导览模块:商品/商户搜索、推荐、对比、商场目录、人工导购、位置导航。",
|
|
6
6
|
"exports": {
|
|
@@ -19,15 +19,16 @@
|
|
|
19
19
|
"./package.json": "./package.json"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@tbox.cn/app-contracts": "0.
|
|
23
|
-
"@tbox.cn/app-
|
|
24
|
-
"@tbox.cn/app-
|
|
25
|
-
"@tbox.cn/app-agent-sdk-server": "0.
|
|
22
|
+
"@tbox.cn/app-contracts": "1.0.0-alpha.10",
|
|
23
|
+
"@tbox.cn/app-agent-sdk-client": "1.0.0-alpha.10",
|
|
24
|
+
"@tbox.cn/app-contracts-mall": "1.0.0-alpha.10",
|
|
25
|
+
"@tbox.cn/app-agent-sdk-server": "1.0.0-alpha.10"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"zod": "3.25.76",
|
|
29
29
|
"react": "18.3.1",
|
|
30
|
-
"@phosphor-icons/react": "2.1.10"
|
|
30
|
+
"@phosphor-icons/react": "2.1.10",
|
|
31
|
+
"@tbox.cn/app-agent-ui-kit": "^1.0.0-alpha.10"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@types/react": "18.3.31",
|
|
@@ -62,9 +63,11 @@
|
|
|
62
63
|
"access": "public"
|
|
63
64
|
},
|
|
64
65
|
"license": "MIT",
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
|
|
66
|
+
"peerDependenciesMeta": {
|
|
67
|
+
"@tbox.cn/app-agent-ui-kit": {
|
|
68
|
+
"optional": true
|
|
69
|
+
}
|
|
70
|
+
},
|
|
68
71
|
"scripts": {
|
|
69
72
|
"typecheck": "tsc --noEmit",
|
|
70
73
|
"test": "vitest run",
|
|
@@ -31,24 +31,24 @@ export function CategoryListCard(props: {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
return (
|
|
34
|
-
<section className="sg-card sg-category-list">
|
|
35
|
-
<div className="sg-card-title">业态分类</div>
|
|
36
|
-
<ul className="sg-category-grid">
|
|
34
|
+
<section className="sg-card sg-category-list p-5 text-foreground">
|
|
35
|
+
<div className="sg-card-title mb-2 flex items-center gap-2 text-lg leading-6 font-bold text-foreground before:h-4 before:w-1 before:shrink-0 before:rounded-[2px] before:bg-[var(--tbox-domain-sg-accent,#096bfa)]">业态分类</div>
|
|
36
|
+
<ul className="sg-category-grid m-0 grid list-none grid-cols-3 gap-2 p-0">
|
|
37
37
|
{visible.map((c) => (
|
|
38
38
|
<li key={c.code}>
|
|
39
39
|
<button
|
|
40
40
|
type="button"
|
|
41
|
-
className="sg-category-cell"
|
|
41
|
+
className="sg-category-cell flex w-full cursor-pointer flex-col items-center gap-[5px] rounded-[12px] border-0 bg-[var(--tbox-domain-sg-surface,#f7faff)] px-1 pt-3.5 pb-2.5 text-center transition-[transform,background-color] duration-[120ms] active:scale-95 active:bg-[var(--tbox-domain-sg-border,#cfe0f7)] disabled:cursor-not-allowed disabled:opacity-50 disabled:active:scale-100 disabled:active:bg-[var(--tbox-domain-sg-surface,#f7faff)] [font-family:inherit] tracking-normal"
|
|
42
42
|
disabled={isHistory}
|
|
43
43
|
onClick={() => handleCategoryClick(c)}
|
|
44
44
|
aria-label={`查看${c.name}(${c.merchantCount} 家门店)`}
|
|
45
45
|
>
|
|
46
|
-
<span className="sg-category-icon-wrap" aria-hidden="true">
|
|
47
|
-
<span className="sg-category-icon">{categoryIcon(c.code)}</span>
|
|
46
|
+
<span className="sg-category-icon-wrap flex size-12 items-center justify-center rounded-full bg-[rgba(9,107,250,0.08)]" aria-hidden="true">
|
|
47
|
+
<span className="sg-category-icon text-2xl leading-none select-none">{categoryIcon(c.code)}</span>
|
|
48
48
|
</span>
|
|
49
|
-
<span className="sg-category-name">{c.name}</span>
|
|
49
|
+
<span className="sg-category-name text-sm leading-4.5 font-semibold break-all text-foreground">{c.name}</span>
|
|
50
50
|
{c.merchantCount > 0 && (
|
|
51
|
-
<span className="sg-category-count">{c.merchantCount} 家</span>
|
|
51
|
+
<span className="sg-category-count text-xs leading-3.5 text-secondary-foreground">{c.merchantCount} 家</span>
|
|
52
52
|
)}
|
|
53
53
|
</button>
|
|
54
54
|
</li>
|
|
@@ -58,13 +58,13 @@ export function CategoryListCard(props: {
|
|
|
58
58
|
{collapsible && (
|
|
59
59
|
<button
|
|
60
60
|
type="button"
|
|
61
|
-
className="sg-category-toggle"
|
|
61
|
+
className="sg-category-toggle mt-2.5 flex w-full cursor-pointer items-center justify-center gap-1 rounded-[8px] border-[0.5px] border-border bg-transparent py-2 text-xs text-secondary-foreground [font-family:inherit] tracking-normal"
|
|
62
62
|
aria-expanded={expanded}
|
|
63
63
|
onClick={() => setExpanded((v) => !v)}
|
|
64
64
|
>
|
|
65
65
|
<CaretDown
|
|
66
66
|
size={14}
|
|
67
|
-
className="sg-category-toggle__icon"
|
|
67
|
+
className="sg-category-toggle__icon transition-transform duration-150 data-[rotated]:rotate-180"
|
|
68
68
|
data-rotated={expanded || undefined}
|
|
69
69
|
/>
|
|
70
70
|
{expanded ? '收起' : `展开全部 ${data.categories.length} 类`}
|
|
@@ -72,19 +72,19 @@ export function CategoryListCard(props: {
|
|
|
72
72
|
)}
|
|
73
73
|
|
|
74
74
|
{data.buildings && data.buildings.length > 0 && (
|
|
75
|
-
<div className="sg-category-floors">
|
|
76
|
-
<div className="sg-category-floors__title">楼层导览</div>
|
|
75
|
+
<div className="sg-category-floors mt-3 border-t-[0.5px] border-border pt-2.5">
|
|
76
|
+
<div className="sg-category-floors__title mb-2 text-xs font-medium text-secondary-foreground">楼层导览</div>
|
|
77
77
|
{data.buildings.map((building) => (
|
|
78
|
-
<div key={building.buildingCode} className="sg-category-floors__building">
|
|
78
|
+
<div key={building.buildingCode} className="sg-category-floors__building mb-2">
|
|
79
79
|
{data.buildings!.length > 1 && (
|
|
80
|
-
<div className="sg-category-floors__building-name">{building.buildingName}</div>
|
|
80
|
+
<div className="sg-category-floors__building-name mb-[5px] text-xs text-muted-foreground">{building.buildingName}</div>
|
|
81
81
|
)}
|
|
82
|
-
<div className="sg-category-floors__floor-list">
|
|
82
|
+
<div className="sg-category-floors__floor-list flex flex-wrap gap-1.5">
|
|
83
83
|
{building.floors.map((floor) => (
|
|
84
84
|
<button
|
|
85
85
|
key={floor.floorCode}
|
|
86
86
|
type="button"
|
|
87
|
-
className="sg-category-floor-chip"
|
|
87
|
+
className="sg-category-floor-chip inline-flex cursor-pointer items-center gap-[3px] rounded-[20px] border-[0.5px] border-border bg-card px-2.5 py-[5px] text-xs text-foreground transition-[background-color,border-color] duration-100 active:border-[var(--tbox-domain-sg-accent,#096bfa)] active:bg-[#e8f0fe] disabled:cursor-not-allowed disabled:opacity-50 [font-family:inherit] tracking-normal"
|
|
88
88
|
disabled={isHistory}
|
|
89
89
|
onClick={() => {
|
|
90
90
|
if (isHistory) return;
|
|
@@ -97,7 +97,7 @@ export function CategoryListCard(props: {
|
|
|
97
97
|
>
|
|
98
98
|
<span className="sg-category-floor-chip__name">{floor.floorName}</span>
|
|
99
99
|
{floor.merchantCount > 0 && (
|
|
100
|
-
<span className="sg-category-floor-chip__count">{floor.merchantCount}</span>
|
|
100
|
+
<span className="sg-category-floor-chip__count text-xs text-muted-foreground">{floor.merchantCount}</span>
|
|
101
101
|
)}
|
|
102
102
|
</button>
|
|
103
103
|
))}
|
|
@@ -12,30 +12,33 @@ export function HumanGuideListCard(props: {
|
|
|
12
12
|
}) {
|
|
13
13
|
const { data, cardId, isHistory } = props;
|
|
14
14
|
return (
|
|
15
|
-
<section className="sg-card sg-human-guide">
|
|
16
|
-
<div className="sg-card-title">{data.merchantName} · 人工导购</div>
|
|
15
|
+
<section className="sg-card sg-human-guide p-5 text-foreground">
|
|
16
|
+
<div className="sg-card-title mb-2 flex items-center gap-2 text-lg leading-6 font-bold text-foreground before:h-4 before:w-1 before:shrink-0 before:rounded-[2px] before:bg-[var(--tbox-domain-sg-accent,#096bfa)]">{data.merchantName} · 人工导购</div>
|
|
17
17
|
{data.guides.length === 0 ? (
|
|
18
|
-
<div className="sg-empty">暂无导购员信息</div>
|
|
18
|
+
<div className="sg-empty py-6 text-center text-sm text-muted-foreground">暂无导购员信息</div>
|
|
19
19
|
) : (
|
|
20
|
-
<ul className="sg-guide-list">
|
|
20
|
+
<ul className="sg-guide-list m-0 list-none p-0">
|
|
21
21
|
{data.guides.map((g) => {
|
|
22
22
|
const contact = g.itemActions[0];
|
|
23
23
|
const contactDisabled = isHistory || !contact;
|
|
24
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">
|
|
25
|
+
<li key={g.guideId} className="sg-guide-item flex items-center gap-3 border-b-[0.5px] border-border py-3 last:border-b-0">
|
|
26
|
+
<ImageWithFallback src={g.avatarUrl} alt={g.name} className="sg-guide-avatar size-12 shrink-0 max-w-full rounded-full object-cover" size={48} />
|
|
27
|
+
<div className="sg-guide-info min-w-0 flex-1">
|
|
28
28
|
<div className="sg-guide-head">
|
|
29
|
-
<span className="sg-merchant-name">{g.name}</span>
|
|
30
|
-
<span className={
|
|
29
|
+
<span className="sg-merchant-name min-w-0 flex-1 truncate text-base font-semibold text-foreground">{g.name}</span>
|
|
30
|
+
<span className={g.available
|
|
31
|
+
? 'sg-status sg-status-available inline-block rounded-full bg-success-soft px-2 py-0.5 text-xs leading-4 whitespace-nowrap text-success'
|
|
32
|
+
: 'sg-status sg-status-offline inline-block rounded-full bg-[#fff4df] px-2 py-0.5 text-xs leading-4 whitespace-nowrap text-[#986415]'}
|
|
33
|
+
>
|
|
31
34
|
{g.available ? '在线' : '离线'}
|
|
32
35
|
</span>
|
|
33
36
|
</div>
|
|
34
|
-
{g.title && <div className="sg-guide-title">{g.title}</div>}
|
|
37
|
+
{g.title && <div className="sg-guide-title mt-[2px] text-xs text-secondary-foreground">{g.title}</div>}
|
|
35
38
|
{g.contactInfo && g.contactInfo.length > 0 && (
|
|
36
|
-
<div className="sg-guide-channels">
|
|
39
|
+
<div className="sg-guide-channels mt-1 flex flex-wrap gap-1.5">
|
|
37
40
|
{g.contactInfo.map((c, i) => (
|
|
38
|
-
<span key={i} className="sg-guide-channel">
|
|
41
|
+
<span key={i} className="sg-guide-channel rounded-[8px] bg-muted px-1.5 py-[0.5px] text-xs text-secondary-foreground">
|
|
39
42
|
{c.channel}
|
|
40
43
|
</span>
|
|
41
44
|
))}
|
|
@@ -44,7 +47,7 @@ export function HumanGuideListCard(props: {
|
|
|
44
47
|
</div>
|
|
45
48
|
<button
|
|
46
49
|
type="button"
|
|
47
|
-
className="sg-guide-contact"
|
|
50
|
+
className="sg-guide-contact min-h-8 shrink-0 cursor-pointer rounded-[9px] border border-border bg-[var(--tbox-domain-sg-surface,#f7faff)] px-3 text-xs text-[var(--tbox-domain-sg-accent,#096bfa)] disabled:cursor-not-allowed disabled:opacity-50 [font-family:inherit] tracking-normal"
|
|
48
51
|
disabled={contactDisabled}
|
|
49
52
|
title={contact ? contact.label : '暂无可用的联系方式'}
|
|
50
53
|
onClick={() => {
|
|
@@ -64,7 +67,7 @@ export function HumanGuideListCard(props: {
|
|
|
64
67
|
})}
|
|
65
68
|
</ul>
|
|
66
69
|
)}
|
|
67
|
-
<p className="sg-guide-privacy">导购信息由门店提供,联系方式仅用于本次咨询</p>
|
|
70
|
+
<p className="sg-guide-privacy mt-2.5 text-xs leading-4 text-muted-foreground">导购信息由门店提供,联系方式仅用于本次咨询</p>
|
|
68
71
|
</section>
|
|
69
72
|
);
|
|
70
73
|
}
|
|
@@ -17,26 +17,26 @@ export function LocationHandoffCard(props: {
|
|
|
17
17
|
const navAction = data.itemActions.find((a) => a.kind === 'link');
|
|
18
18
|
|
|
19
19
|
return (
|
|
20
|
-
<section className="sg-card sg-location-handoff">
|
|
21
|
-
<div className="sg-card-title">{data.merchantName} · 位置</div>
|
|
20
|
+
<section className="sg-card sg-location-handoff p-5 text-foreground">
|
|
21
|
+
<div className="sg-card-title mb-2 flex items-center gap-2 text-lg leading-6 font-bold text-foreground before:h-4 before:w-1 before:shrink-0 before:rounded-[2px] before:bg-[var(--tbox-domain-sg-accent,#096bfa)]">{data.merchantName} · 位置</div>
|
|
22
22
|
{data.mapUrl && (
|
|
23
|
-
<ImageWithFallback src={data.mapUrl} alt={`${data.merchantName} 位置示意`} className="sg-lh-map" size={88} />
|
|
23
|
+
<ImageWithFallback src={data.mapUrl} alt={`${data.merchantName} 位置示意`} className="sg-lh-map h-40 w-full max-w-full rounded-[12px] object-cover" size={88} />
|
|
24
24
|
)}
|
|
25
|
-
<div className="sg-lh-address">
|
|
26
|
-
<MapPin size={16} />
|
|
25
|
+
<div className="sg-lh-address mt-2.5 flex items-center gap-1.5 text-sm font-medium text-foreground">
|
|
26
|
+
<MapPin size={16} className="shrink-0 text-[var(--tbox-domain-sg-accent,#096bfa)]" />
|
|
27
27
|
<span>{data.location.displayText}</span>
|
|
28
28
|
</div>
|
|
29
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>}
|
|
30
|
+
<div className="sg-lh-detail mt-2 flex flex-wrap gap-1.5">
|
|
31
|
+
{data.location.buildingName && <span className="rounded-[8px] bg-muted px-2 py-0.5 text-xs text-secondary-foreground">{data.location.buildingName}</span>}
|
|
32
|
+
{data.location.floorName && <span className="rounded-[8px] bg-muted px-2 py-0.5 text-xs text-secondary-foreground">{data.location.floorName}</span>}
|
|
33
|
+
{data.location.unitName && <span className="rounded-[8px] bg-muted px-2 py-0.5 text-xs text-secondary-foreground">{data.location.unitName}</span>}
|
|
34
34
|
</div>
|
|
35
35
|
)}
|
|
36
36
|
{level === 'route_available' && navAction && (
|
|
37
37
|
<button
|
|
38
38
|
type="button"
|
|
39
|
-
className="sg-lh-nav"
|
|
39
|
+
className="sg-lh-nav mt-3 flex h-10 w-full cursor-pointer items-center justify-center gap-1.5 rounded-[9px] border-0 bg-[linear-gradient(108deg,#2493ff_0%,#0b63ff_100%)] text-sm font-medium text-white shadow-[0_4px_11px_rgba(18,118,255,0.35)] [font-family:inherit] tracking-normal"
|
|
40
40
|
onClick={() => {
|
|
41
41
|
sendCardAction(cardId, { type: 'openLink', url: navAction.url });
|
|
42
42
|
}}
|
|
@@ -17,37 +17,37 @@ export function MallDirectoryCard(props: {
|
|
|
17
17
|
);
|
|
18
18
|
|
|
19
19
|
return (
|
|
20
|
-
<section className="sg-card sg-mall-directory">
|
|
21
|
-
<div className="sg-card-title">{data.mallName} · 楼层目录</div>
|
|
20
|
+
<section className="sg-card sg-mall-directory p-5 text-foreground">
|
|
21
|
+
<div className="sg-card-title mb-2 flex items-center gap-2 text-lg leading-6 font-bold text-foreground before:h-4 before:w-1 before:shrink-0 before:rounded-[2px] before:bg-[var(--tbox-domain-sg-accent,#096bfa)]">{data.mallName} · 楼层目录</div>
|
|
22
22
|
{data.buildings.map((b) => {
|
|
23
23
|
const open = openBuilding === b.buildingCode;
|
|
24
24
|
return (
|
|
25
|
-
<div key={b.buildingCode} className="sg-dir-building">
|
|
25
|
+
<div key={b.buildingCode} className="sg-dir-building mt-2 overflow-hidden rounded-[10px] border-[0.5px] border-border">
|
|
26
26
|
<button
|
|
27
27
|
type="button"
|
|
28
|
-
className="sg-dir-building__head"
|
|
28
|
+
className="sg-dir-building__head flex w-full cursor-pointer items-center gap-2 border-0 bg-card p-3 text-left text-foreground [font-family:inherit] tracking-normal"
|
|
29
29
|
aria-expanded={open}
|
|
30
30
|
onClick={() => setOpenBuilding(open ? null : b.buildingCode)}
|
|
31
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} />
|
|
32
|
+
<Storefront size={18} className="text-[var(--tbox-domain-sg-accent,#096bfa)]" />
|
|
33
|
+
<span className="sg-dir-building__name min-w-0 flex-1 text-sm font-semibold">{b.buildingName}</span>
|
|
34
|
+
<span className="sg-dir-building__count text-xs text-muted-foreground">{b.floors.length} 层</span>
|
|
35
|
+
<CaretDown size={16} className="sg-dir-building__chevron text-[var(--tbox-domain-sg-accent,#096bfa)] data-[rotated]:rotate-180 data-[rotated]:transition-transform" data-rotated={open || undefined} />
|
|
36
36
|
</button>
|
|
37
37
|
{open && (
|
|
38
|
-
<ul className="sg-dir-floors">
|
|
38
|
+
<ul className="sg-dir-floors m-0 list-none border-t-[0.5px] border-border bg-muted p-0">
|
|
39
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">
|
|
40
|
+
<li key={f.floorCode} className="sg-dir-floor flex items-center justify-between gap-2 border-b-[0.5px] border-border px-3 py-2 last:border-b-0">
|
|
41
|
+
<div className="sg-dir-floor__info grid min-w-0 gap-1">
|
|
42
|
+
<span className="sg-dir-floor__name text-sm font-medium text-foreground">{f.floorName}</span>
|
|
43
|
+
<span className="sg-dir-floor__cats truncate text-xs text-muted-foreground">
|
|
44
44
|
{f.businessCategories.join(' / ') || `${f.merchantCount} 家商户`}
|
|
45
45
|
</span>
|
|
46
46
|
</div>
|
|
47
47
|
{f.itemActions && f.itemActions.length > 0 && (
|
|
48
48
|
<button
|
|
49
49
|
type="button"
|
|
50
|
-
className="sg-chip sg-dir-floor__action"
|
|
50
|
+
className="sg-chip sg-dir-floor__action inline-flex min-h-[28px] shrink-0 cursor-pointer items-center justify-center rounded-[9px] border border-border bg-[var(--tbox-domain-sg-surface,#f7faff)] px-2.5 text-xs font-medium whitespace-nowrap text-[var(--tbox-domain-sg-accent,#096bfa)] disabled:cursor-not-allowed disabled:opacity-50 [font-family:inherit] tracking-normal"
|
|
51
51
|
disabled={isHistory}
|
|
52
52
|
onClick={() => {
|
|
53
53
|
if (isHistory) return;
|
|
@@ -5,6 +5,18 @@ import { ItemActionsRow } from '@tbox.cn/app-agent-sdk-client';
|
|
|
5
5
|
import { formatDistance } from '../view';
|
|
6
6
|
import type { NearbyMallListCardData } from '@tbox.cn/app-contracts-mall';
|
|
7
7
|
|
|
8
|
+
/** 营业状态徽章:基础规格 + 按状态码取色(完整字面量,禁止拼接) */
|
|
9
|
+
const STATUS_BASE_CLASS = 'sg-status inline-block rounded-full px-2 py-0.5 text-xs leading-4 whitespace-nowrap';
|
|
10
|
+
const STATUS_TONE_CLASS: Record<string, string> = {
|
|
11
|
+
enabled: 'sg-status-enabled text-success bg-success-soft',
|
|
12
|
+
available: 'sg-status-available text-success bg-success-soft',
|
|
13
|
+
open: 'sg-status-open bg-[#e9f8ef] text-[#237a48]',
|
|
14
|
+
offline: 'sg-status-offline bg-[#fff4df] text-[#986415]',
|
|
15
|
+
closed: 'sg-status-closed bg-[#fff4df] text-[#986415]',
|
|
16
|
+
disabled: 'sg-status-disabled bg-[#fff4df] text-[#986415]',
|
|
17
|
+
unknown: 'sg-status-unknown bg-[#fff4df] text-[#986415]',
|
|
18
|
+
};
|
|
19
|
+
|
|
8
20
|
export function NearbyMallListCard(props: {
|
|
9
21
|
data: NearbyMallListCardData;
|
|
10
22
|
cardId: string;
|
|
@@ -12,24 +24,30 @@ export function NearbyMallListCard(props: {
|
|
|
12
24
|
}) {
|
|
13
25
|
const { data, cardId, isHistory } = props;
|
|
14
26
|
if (data.malls.length === 0) {
|
|
15
|
-
return <section className="sg-card"><div className="sg-empty">暂无附近商场</div></section>;
|
|
27
|
+
return <section className="sg-card p-5 text-foreground"><div className="sg-empty py-6 text-center text-sm text-muted-foreground">暂无附近商场</div></section>;
|
|
16
28
|
}
|
|
17
29
|
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">
|
|
30
|
+
<section className="sg-card sg-nearby-malls p-5 text-foreground">
|
|
31
|
+
<div className="sg-card-title mb-2 flex items-center gap-2 text-lg leading-6 font-bold text-foreground before:h-4 before:w-1 before:shrink-0 before:rounded-[2px] before:bg-[var(--tbox-domain-sg-accent,#096bfa)]">附近商场</div>
|
|
32
|
+
{data.query && <div className="sg-card-summary mb-3 text-sm text-secondary-foreground">查询「{data.query}」</div>}
|
|
33
|
+
<ul className="sg-nearby-list m-0 list-none p-0">
|
|
22
34
|
{data.malls.map((m) => (
|
|
23
|
-
<li key={m.mallId} className="sg-nearby-item">
|
|
35
|
+
<li key={m.mallId} className="sg-nearby-item border-b-[0.5px] border-border py-3 last:border-b-0">
|
|
24
36
|
<div className="sg-nearby-item__head">
|
|
25
|
-
<span className="sg-merchant-name">{m.name}</span>
|
|
26
|
-
<span className={
|
|
37
|
+
<span className="sg-merchant-name min-w-0 flex-1 truncate text-base font-semibold text-foreground">{m.name}</span>
|
|
38
|
+
<span className={`${STATUS_BASE_CLASS} ${STATUS_TONE_CLASS[m.status.code] ?? STATUS_TONE_CLASS.unknown}`}>{m.status.label}</span>
|
|
27
39
|
</div>
|
|
28
|
-
<div className="sg-nearby-item__meta">
|
|
40
|
+
<div className="sg-nearby-item__meta mt-1 flex justify-between gap-2 text-xs text-secondary-foreground">
|
|
29
41
|
<span>{m.address}</span>
|
|
30
|
-
<span className="sg-nearby-item__distance">{formatDistance(m.distanceKm)}</span>
|
|
42
|
+
<span className="sg-nearby-item__distance shrink-0 font-medium text-[var(--tbox-domain-sg-accent,#096bfa)]">{formatDistance(m.distanceKm)}</span>
|
|
31
43
|
</div>
|
|
32
|
-
<ItemActionsRow
|
|
44
|
+
<ItemActionsRow
|
|
45
|
+
actions={m.itemActions}
|
|
46
|
+
cardId={cardId}
|
|
47
|
+
isHistory={isHistory}
|
|
48
|
+
className="sg-item-actions mt-2 flex flex-wrap gap-1.5"
|
|
49
|
+
chipClassName="sg-chip inline-flex min-h-[30px] cursor-pointer items-center justify-center rounded-[9px] border border-border bg-[var(--tbox-domain-sg-surface,#f7faff)] px-3 text-xs font-medium whitespace-nowrap text-[var(--tbox-domain-sg-accent,#096bfa)] disabled:cursor-not-allowed disabled:opacity-50 [font-family:inherit] tracking-normal"
|
|
50
|
+
/>
|
|
33
51
|
</li>
|
|
34
52
|
))}
|
|
35
53
|
</ul>
|
|
@@ -5,6 +5,17 @@ import { useEffect, useState } from 'react';
|
|
|
5
5
|
import { ImageWithFallback } from '../../components/ImageWithFallback';
|
|
6
6
|
import type { ProductComparisonCardData } from '@tbox.cn/app-contracts-mall';
|
|
7
7
|
|
|
8
|
+
/** 可用性徽章:基础规格 + 按状态码取色(完整字面量,禁止拼接) */
|
|
9
|
+
const AVAILABILITY_BASE_CLASS = 'sg-availability mt-1 inline-block text-xs text-secondary-foreground';
|
|
10
|
+
const AVAILABILITY_TONE_CLASS: Record<string, string> = {
|
|
11
|
+
in_stock: 'sg-availability-in_stock text-success',
|
|
12
|
+
available: 'sg-availability-available text-success',
|
|
13
|
+
out_of_stock: 'sg-availability-out_of_stock text-warning',
|
|
14
|
+
limited: 'sg-availability-limited',
|
|
15
|
+
unknown: 'sg-availability-unknown',
|
|
16
|
+
};
|
|
17
|
+
const CELL_CLASS = 'border-b-[0.5px] border-border p-2 text-left align-top';
|
|
18
|
+
|
|
8
19
|
export function ProductComparisonCard(props: {
|
|
9
20
|
data: ProductComparisonCardData;
|
|
10
21
|
isHistory: boolean;
|
|
@@ -25,36 +36,36 @@ export function ProductComparisonCard(props: {
|
|
|
25
36
|
const attrNames = Array.from(new Set(data.products.flatMap((p) => p.attributes.map((a) => a.name))));
|
|
26
37
|
|
|
27
38
|
return (
|
|
28
|
-
<section className={`sg-card sg-product-comparison${stale ? ' sg-product-comparison--stale' : ''}`}>
|
|
29
|
-
<div className="sg-card-title">商品对比</div>
|
|
39
|
+
<section className={`sg-card sg-product-comparison p-5 text-foreground ${stale ? ' sg-product-comparison--stale' : ''}`}>
|
|
40
|
+
<div className="sg-card-title mb-2 flex items-center gap-2 text-lg leading-6 font-bold text-foreground before:h-4 before:w-1 before:shrink-0 before:rounded-[2px] before:bg-[var(--tbox-domain-sg-accent,#096bfa)]">商品对比</div>
|
|
30
41
|
{stale && (
|
|
31
|
-
<div className="sg-stale-notice">
|
|
42
|
+
<div className="sg-stale-notice mb-2.5 rounded-[8px] bg-warning-soft px-2.5 py-2 text-xs leading-4.5 text-warning">
|
|
32
43
|
<span>对比数据已过期,请重新发起对比</span>
|
|
33
44
|
</div>
|
|
34
45
|
)}
|
|
35
46
|
|
|
36
|
-
<div className="sg-compare-wrap">
|
|
37
|
-
<table className=
|
|
47
|
+
<div className="sg-compare-wrap overflow-x-auto">
|
|
48
|
+
<table className={`sg-compare w-full border-collapse text-xs ${stale ? ' opacity-60' : ''}`}>
|
|
38
49
|
<thead>
|
|
39
50
|
<tr>
|
|
40
|
-
<th scope="col" className=
|
|
51
|
+
<th scope="col" className={`sg-compare__label ${CELL_CLASS} font-medium whitespace-nowrap text-secondary-foreground`} />
|
|
41
52
|
{data.products.map((p) => (
|
|
42
|
-
<th key={p.productId} scope="col">
|
|
43
|
-
<ImageWithFallback src={p.imageUrl} alt={p.name} className="sg-compare__img" size={40} />
|
|
44
|
-
<div className="sg-compare__name">{p.name}</div>
|
|
45
|
-
<div className="sg-price-sale">{p.price.sale?.display ?? '—'}</div>
|
|
53
|
+
<th key={p.productId} scope="col" className={CELL_CLASS}>
|
|
54
|
+
<ImageWithFallback src={p.imageUrl} alt={p.name} className="sg-compare__img size-14 max-w-full rounded-[8px] object-cover" size={40} />
|
|
55
|
+
<div className="sg-compare__name mt-1 leading-4.5 font-semibold text-foreground">{p.name}</div>
|
|
56
|
+
<div className="sg-price-sale text-base font-bold tabular-nums text-[#ef4f43]">{p.price.sale?.display ?? '—'}</div>
|
|
46
57
|
</th>
|
|
47
58
|
))}
|
|
48
59
|
</tr>
|
|
49
60
|
</thead>
|
|
50
61
|
<tbody>
|
|
51
62
|
<tr>
|
|
52
|
-
<th scope="row" className=
|
|
63
|
+
<th scope="row" className={`sg-compare__label ${CELL_CLASS} font-medium whitespace-nowrap text-secondary-foreground`}>
|
|
53
64
|
库存
|
|
54
65
|
</th>
|
|
55
66
|
{data.products.map((p) => (
|
|
56
|
-
<td key={p.productId}>
|
|
57
|
-
<span className={
|
|
67
|
+
<td key={p.productId} className={CELL_CLASS}>
|
|
68
|
+
<span className={`${AVAILABILITY_BASE_CLASS} ${AVAILABILITY_TONE_CLASS[p.availability.status] ?? ''}`}>
|
|
58
69
|
{p.availability.label}
|
|
59
70
|
</span>
|
|
60
71
|
</td>
|
|
@@ -62,13 +73,13 @@ export function ProductComparisonCard(props: {
|
|
|
62
73
|
</tr>
|
|
63
74
|
{attrNames.map((name) => (
|
|
64
75
|
<tr key={name}>
|
|
65
|
-
<th scope="row" className=
|
|
76
|
+
<th scope="row" className={`sg-compare__label ${CELL_CLASS} font-medium whitespace-nowrap text-secondary-foreground`}>
|
|
66
77
|
{name}
|
|
67
78
|
</th>
|
|
68
79
|
{data.products.map((p) => {
|
|
69
80
|
const attr = p.attributes.find((a) => a.name === name);
|
|
70
81
|
return (
|
|
71
|
-
<td key={p.productId} className={attr ? '' : 'sg-compare__cell-empty'}>
|
|
82
|
+
<td key={p.productId} className={`${CELL_CLASS}${attr ? '' : ' sg-compare__cell-empty text-muted-foreground'}`}>
|
|
72
83
|
{attr?.value ?? '—'}
|
|
73
84
|
</td>
|
|
74
85
|
);
|
|
@@ -80,9 +91,9 @@ export function ProductComparisonCard(props: {
|
|
|
80
91
|
</div>
|
|
81
92
|
|
|
82
93
|
{data.products.some((p) => p.caveats.length > 0) && (
|
|
83
|
-
<div className="sg-item-caveats">
|
|
94
|
+
<div className="sg-item-caveats mt-1.5">
|
|
84
95
|
{data.products.flatMap((p) => p.caveats.map((c, i) => ({ key: `${p.productId}-${i}`, text: c }))).map(({ key, text }) => (
|
|
85
|
-
<div key={key} className="sg-caveat-item">
|
|
96
|
+
<div key={key} className="sg-caveat-item text-xs leading-4 text-muted-foreground">
|
|
86
97
|
⚠️ {text}
|
|
87
98
|
</div>
|
|
88
99
|
))}
|
|
@@ -90,7 +101,7 @@ export function ProductComparisonCard(props: {
|
|
|
90
101
|
)}
|
|
91
102
|
|
|
92
103
|
{/* 到期后整卡降透明(交互全禁)。标记仅 stale 态显示——isHistory 是"历史不可交互"而非"数据过期",两者语义分离 */}
|
|
93
|
-
<span className="sg-compare__stale-marker" hidden={!stale}>
|
|
104
|
+
<span className="sg-compare__stale-marker mt-2 block text-xs text-warning" hidden={!stale}>
|
|
94
105
|
对比数据可能已过期
|
|
95
106
|
</span>
|
|
96
107
|
</section>
|
|
@@ -6,6 +6,16 @@ import { ImageWithFallback } from '../../components/ImageWithFallback';
|
|
|
6
6
|
import { ItemActionsRow } from '@tbox.cn/app-agent-sdk-client';
|
|
7
7
|
import type { ProductDetailCardData } from '@tbox.cn/app-contracts-mall';
|
|
8
8
|
|
|
9
|
+
/** 可用性徽章:基础规格 + 按状态码取色(完整字面量,禁止拼接) */
|
|
10
|
+
const AVAILABILITY_BASE_CLASS = 'sg-availability mt-1 inline-block text-xs text-secondary-foreground';
|
|
11
|
+
const AVAILABILITY_TONE_CLASS: Record<string, string> = {
|
|
12
|
+
in_stock: 'sg-availability-in_stock text-success',
|
|
13
|
+
available: 'sg-availability-available text-success',
|
|
14
|
+
out_of_stock: 'sg-availability-out_of_stock text-warning',
|
|
15
|
+
limited: 'sg-availability-limited',
|
|
16
|
+
unknown: 'sg-availability-unknown',
|
|
17
|
+
};
|
|
18
|
+
|
|
9
19
|
export function ProductDetailCard(props: {
|
|
10
20
|
data: ProductDetailCardData;
|
|
11
21
|
cardId: string;
|
|
@@ -17,30 +27,30 @@ export function ProductDetailCard(props: {
|
|
|
17
27
|
const current = Math.min(active, Math.max(images.length - 1, 0));
|
|
18
28
|
|
|
19
29
|
return (
|
|
20
|
-
<section className="sg-card sg-product-detail">
|
|
21
|
-
<div className="sg-card-title">{data.name}</div>
|
|
22
|
-
{data.brand && <div className="sg-card-subtitle">{data.brand}</div>}
|
|
30
|
+
<section className="sg-card sg-product-detail p-5 text-foreground">
|
|
31
|
+
<div className="sg-card-title -mx-5 -mt-5 mb-3 flex items-center gap-2 bg-[linear-gradient(135deg,#0e2f80_0%,#1e5ed7_100%)] p-3.5 text-base leading-6 font-bold text-white">{data.name}</div>
|
|
32
|
+
{data.brand && <div className="sg-card-subtitle mb-3 text-sm text-secondary-foreground">{data.brand}</div>}
|
|
23
33
|
|
|
24
34
|
{images.length > 0 && (
|
|
25
|
-
<div className="sg-carousel">
|
|
26
|
-
<ImageWithFallback src={images[current]} alt={data.name} className="sg-carousel__stage" size={72} />
|
|
35
|
+
<div className="sg-carousel relative">
|
|
36
|
+
<ImageWithFallback src={images[current]} alt={data.name} className="sg-carousel__stage h-60 w-full max-w-full rounded-[12px] object-cover" size={72} />
|
|
27
37
|
{images.length > 1 && (
|
|
28
|
-
<span className="sg-carousel__count">
|
|
38
|
+
<span className="sg-carousel__count absolute right-2.5 bottom-2.5 rounded-full bg-[rgba(0,0,0,0.5)] px-2 py-0.5 text-xs leading-4 text-white">
|
|
29
39
|
{current + 1}/{images.length}
|
|
30
40
|
</span>
|
|
31
41
|
)}
|
|
32
42
|
{images.length > 1 && (
|
|
33
|
-
<div className="sg-carousel__thumbs">
|
|
43
|
+
<div className="sg-carousel__thumbs mt-2 flex gap-2 overflow-x-auto">
|
|
34
44
|
{images.map((src, i) => (
|
|
35
45
|
<button
|
|
36
46
|
key={i}
|
|
37
47
|
type="button"
|
|
38
|
-
className="sg-carousel__thumb"
|
|
48
|
+
className="sg-carousel__thumb size-12 shrink-0 cursor-pointer overflow-hidden rounded-[8px] border-2 border-transparent p-0 aria-[current=true]:border-[var(--tbox-domain-sg-accent,#096bfa)] [font-family:inherit]"
|
|
39
49
|
aria-current={i === current}
|
|
40
50
|
aria-label={`查看第 ${i + 1} 张图`}
|
|
41
51
|
onClick={() => setActive(i)}
|
|
42
52
|
>
|
|
43
|
-
<img src={src} alt="" loading="lazy" referrerPolicy="no-referrer" />
|
|
53
|
+
<img className="h-full w-full max-w-full object-cover" src={src} alt="" loading="lazy" referrerPolicy="no-referrer" />
|
|
44
54
|
</button>
|
|
45
55
|
))}
|
|
46
56
|
</div>
|
|
@@ -48,48 +58,54 @@ export function ProductDetailCard(props: {
|
|
|
48
58
|
</div>
|
|
49
59
|
)}
|
|
50
60
|
|
|
51
|
-
<div className="sg-price-block sg-price-block--detail">
|
|
52
|
-
{data.price.sale && <span className="sg-price-sale sg-price-sale--lg">{data.price.sale.display}</span>}
|
|
61
|
+
<div className="sg-price-block sg-price-block--detail mt-1 flex flex-wrap items-baseline gap-2">
|
|
62
|
+
{data.price.sale && <span className="sg-price-sale sg-price-sale--lg text-2xl leading-7 font-bold tabular-nums text-[#ef4f43]">{data.price.sale.display}</span>}
|
|
53
63
|
{data.price.original && data.price.sale && (
|
|
54
|
-
<span className="sg-price-original">{data.price.original.display}</span>
|
|
64
|
+
<span className="sg-price-original text-xs line-through text-muted-foreground">{data.price.original.display}</span>
|
|
55
65
|
)}
|
|
56
|
-
{data.price.promotion && <span className="sg-price-promotion">{data.price.promotion.display}</span>}
|
|
66
|
+
{data.price.promotion && <span className="sg-price-promotion rounded-[8px] bg-[#fff1f3] px-1.5 py-[0.5px] text-xs leading-4 text-[#ef4f43]">{data.price.promotion.display}</span>}
|
|
57
67
|
</div>
|
|
58
68
|
|
|
59
|
-
<div className={
|
|
69
|
+
<div className={`${AVAILABILITY_BASE_CLASS} ${AVAILABILITY_TONE_CLASS[data.availability.status] ?? ''}`}>
|
|
60
70
|
{data.availability.label}
|
|
61
|
-
{data.humanGuideAvailable && <span className="sg-availability__guide">支持人工导购</span>}
|
|
71
|
+
{data.humanGuideAvailable && <span className="sg-availability__guide ml-2 rounded-[8px] bg-muted px-1.5 py-[0.5px] text-xs">支持人工导购</span>}
|
|
62
72
|
</div>
|
|
63
73
|
|
|
64
|
-
{data.description && <div className="sg-product-desc">{data.description}</div>}
|
|
74
|
+
{data.description && <div className="sg-product-desc mt-2.5 text-sm leading-5 text-foreground">{data.description}</div>}
|
|
65
75
|
|
|
66
|
-
<dl className="sg-attr-table">
|
|
76
|
+
<dl className="sg-attr-table m-0 mt-2.5 overflow-hidden rounded-[8px] border-[0.5px] border-border p-0">
|
|
67
77
|
{data.attributes.map((a) => (
|
|
68
|
-
<div key={a.name} className="sg-attr-row">
|
|
69
|
-
<dt>{a.name}</dt>
|
|
70
|
-
<dd>{a.value}</dd>
|
|
78
|
+
<div key={a.name} className="sg-attr-row flex gap-3 border-b-[0.5px] border-border px-3 py-2 text-sm last:border-b-0">
|
|
79
|
+
<dt className="flex-none text-secondary-foreground">{a.name}</dt>
|
|
80
|
+
<dd className="m-0 flex-1 text-right text-foreground">{a.value}</dd>
|
|
71
81
|
</div>
|
|
72
82
|
))}
|
|
73
83
|
</dl>
|
|
74
84
|
|
|
75
|
-
<div className="sg-product-merchant">
|
|
85
|
+
<div className="sg-product-merchant mt-1.5 text-xs text-secondary-foreground">
|
|
76
86
|
{data.merchant.name}
|
|
77
87
|
{data.merchant.location?.displayText && (
|
|
78
|
-
<span className="sg-merchant-location"> · {data.merchant.location.displayText}</span>
|
|
88
|
+
<span className="sg-merchant-location mt-1 flex flex-wrap items-center gap-[3px] text-xs text-secondary-foreground"> · {data.merchant.location.displayText}</span>
|
|
79
89
|
)}
|
|
80
90
|
</div>
|
|
81
91
|
|
|
82
92
|
{data.promotionFacts.map((p) => (
|
|
83
|
-
<div key={p} className="sg-promo-fact">
|
|
93
|
+
<div key={p} className="sg-promo-fact mt-1 text-xs leading-4.5 text-[#ef4f43]">
|
|
84
94
|
{p}
|
|
85
95
|
</div>
|
|
86
96
|
))}
|
|
87
97
|
|
|
88
98
|
{data.categoryPath.length > 0 && (
|
|
89
|
-
<div className="sg-category-path">{data.categoryPath.join(' / ')}</div>
|
|
99
|
+
<div className="sg-category-path mt-2 text-xs text-muted-foreground">{data.categoryPath.join(' / ')}</div>
|
|
90
100
|
)}
|
|
91
101
|
|
|
92
|
-
<ItemActionsRow
|
|
102
|
+
<ItemActionsRow
|
|
103
|
+
actions={data.itemActions}
|
|
104
|
+
cardId={cardId}
|
|
105
|
+
isHistory={isHistory}
|
|
106
|
+
className="sg-item-actions mt-2 flex flex-wrap gap-1.5"
|
|
107
|
+
chipClassName="sg-chip inline-flex min-h-[30px] cursor-pointer items-center justify-center rounded-[9px] border border-border bg-[var(--tbox-domain-sg-surface,#f7faff)] px-3 text-xs font-medium whitespace-nowrap text-[var(--tbox-domain-sg-accent,#096bfa)] disabled:cursor-not-allowed disabled:opacity-50 [font-family:inherit] tracking-normal"
|
|
108
|
+
/>
|
|
93
109
|
</section>
|
|
94
110
|
);
|
|
95
111
|
}
|