@tbox.cn/app-module-shopping-guide 0.2.1 → 0.8.3
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 +16 -0
- package/README.md +96 -0
- package/dist/chunk-AYQZO2FV.js +1496 -0
- package/dist/chunk-VKDA6RXQ.js +1676 -0
- package/dist/client/index.d.ts +3 -3
- package/dist/client/index.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -8
- package/dist/server/index.d.ts +2512 -608
- package/dist/server/index.js +1 -7
- package/dist/shopping-guide-EGRHPEDA.css +2598 -0
- package/package.json +25 -16
- package/skills/shopping-guide/SKILL.md +127 -24
- package/src/client/cards/category-list/index.tsx +113 -0
- package/src/client/cards/human-guide-list/index.tsx +72 -0
- package/src/client/cards/index.ts +14 -0
- package/src/client/cards/location-handoff/index.tsx +52 -0
- package/src/client/cards/mall-directory/index.tsx +77 -0
- package/src/client/cards/nearby-mall-list/index.tsx +40 -0
- package/src/client/cards/product-comparison/index.tsx +100 -0
- package/src/client/cards/product-detail/index.tsx +97 -0
- package/src/client/cards/product-list/index.tsx +223 -0
- package/src/client/cards/recommend-merchants/index.tsx +147 -0
- package/src/client/cards/shop-detail/index.tsx +133 -0
- package/src/client/cards/shop-list/index.tsx +216 -0
- package/src/client/cards/view.ts +147 -0
- package/src/client/categories.ts +38 -0
- package/src/client/components/ImageWithFallback.tsx +34 -0
- package/src/client/components/MerchantRow.tsx +78 -0
- package/src/client/components/ShopDetailSheet.tsx +383 -0
- package/src/client/components/ShopGuideHeader.tsx +23 -0
- package/src/client/components/ShopGuideSectionLabel.tsx +10 -0
- package/src/client/components/ShopListSheet.tsx +293 -0
- package/src/client/index.ts +8 -6
- package/src/client/styles/shopping-guide.css +2598 -0
- package/src/client/types/css.d.ts +2 -0
- package/src/server/cards/category-list/meta.ts +0 -2
- package/src/server/cards/human-guide-list/meta.ts +0 -2
- package/src/server/cards/index.ts +10 -10
- package/src/server/cards/location-handoff/meta.ts +0 -2
- package/src/server/cards/mall-directory/meta.ts +0 -2
- package/src/server/cards/nearby-mall-list/meta.ts +1 -3
- package/src/server/cards/product-comparison/meta.ts +0 -2
- package/src/server/cards/product-detail/meta.ts +0 -2
- package/src/server/cards/product-list/meta.ts +0 -2
- package/src/server/cards/recommend-merchants/meta.ts +37 -0
- package/src/server/cards/recommend-merchants/samples.ts +189 -0
- package/src/server/cards/{merchant-detail → shop-detail}/meta.ts +6 -6
- package/src/server/cards/shop-detail/samples.ts +72 -0
- package/src/server/cards/{merchant-list → shop-list}/meta.ts +9 -9
- package/src/server/cards/shop-list/samples.ts +154 -0
- package/src/server/domain/value-objects.ts +1 -2
- package/src/server/handler.ts +63 -0
- package/src/server/index.ts +161 -101
- package/src/server/ports/index.ts +120 -91
- package/src/server/ports/local-adapters.ts +5 -55
- package/src/server/projections/index.ts +159 -41
- package/src/server/tools/index.ts +590 -315
- package/tbox.module.json +137 -0
- package/tests/cards-render.test.tsx +830 -0
- package/tests/floor-pretool.test.ts +275 -0
- package/tests/handler.test.ts +259 -0
- package/tests/merchant-list-limit.test.ts +53 -0
- package/tests/ports-resolve.test.ts +112 -0
- package/tests/samples.test.ts +71 -0
- package/tests/shopping-guide.test.ts +402 -234
- package/tests/skill.test.ts +86 -0
- package/tests/view.test.ts +42 -0
- package/tsup.config.ts +9 -1
- package/dist/chunk-AGBLC6XI.js +0 -1294
- package/dist/chunk-U4WDS5PQ.js +0 -173
- package/skills/shopping-guide/references/comparison-format.md +0 -5
- package/skills/shopping-guide/references/faq-answers.md +0 -5
- package/skills/shopping-guide/references/floor-directory.md +0 -4
- package/skills/shopping-guide/references/intent-patterns.md +0 -5
- package/skills/shopping-guide/references/location-format.md +0 -5
- package/skills/shopping-guide/references/policy-lookup.md +0 -5
- package/skills/shopping-guide/references/product-search-tips.md +0 -6
- package/skills/shopping-guide/references/recommendation-style.md +0 -5
- package/src/client/cards/index.tsx +0 -267
- package/src/server/cards/customer-service-faq/meta.ts +0 -18
- package/src/server/integrations/joycity/adapter.ts +0 -226
- package/src/server/integrations/joycity/auth-strategy.ts +0 -38
- package/src/server/integrations/joycity/gateway.ts +0 -128
- package/tbox.component.json +0 -48
|
@@ -0,0 +1,1676 @@
|
|
|
1
|
+
// src/client/index.ts
|
|
2
|
+
import "./shopping-guide-EGRHPEDA.css";
|
|
3
|
+
|
|
4
|
+
// src/client/cards/product-list/index.tsx
|
|
5
|
+
import { useState as useState2 } from "react";
|
|
6
|
+
import { createPortal } from "react-dom";
|
|
7
|
+
import { X } from "@phosphor-icons/react";
|
|
8
|
+
import { ItemActionsRow, sendCardAction } from "@tbox.cn/app-sdk/client";
|
|
9
|
+
|
|
10
|
+
// src/client/components/ImageWithFallback.tsx
|
|
11
|
+
import { useState } from "react";
|
|
12
|
+
import { ImageSquare } from "@phosphor-icons/react";
|
|
13
|
+
import { jsx } from "react/jsx-runtime";
|
|
14
|
+
function ImageWithFallback(props) {
|
|
15
|
+
const { src, alt, className, size = 40 } = props;
|
|
16
|
+
const [failed, setFailed] = useState(false);
|
|
17
|
+
if (!src || failed) {
|
|
18
|
+
return /* @__PURE__ */ jsx("div", { className: `img-fallback ${className ?? ""}`.trim(), "aria-label": alt, role: "img", children: /* @__PURE__ */ jsx(ImageSquare, { weight: "duotone", size: Math.round(size * 0.45) }) });
|
|
19
|
+
}
|
|
20
|
+
return /* @__PURE__ */ jsx(
|
|
21
|
+
"img",
|
|
22
|
+
{
|
|
23
|
+
className,
|
|
24
|
+
src,
|
|
25
|
+
alt,
|
|
26
|
+
loading: "lazy",
|
|
27
|
+
referrerPolicy: "no-referrer",
|
|
28
|
+
onError: () => setFailed(true)
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// src/client/cards/product-list/index.tsx
|
|
34
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
35
|
+
function ProductDetailSheet({
|
|
36
|
+
item,
|
|
37
|
+
cardId,
|
|
38
|
+
isHistory,
|
|
39
|
+
onClose
|
|
40
|
+
}) {
|
|
41
|
+
return createPortal(
|
|
42
|
+
/* @__PURE__ */ jsxs("div", { className: "sg-product-sheet", role: "dialog", "aria-modal": "true", "aria-label": item.name, children: [
|
|
43
|
+
/* @__PURE__ */ jsx2("div", { className: "sg-product-sheet__mask", onClick: onClose }),
|
|
44
|
+
/* @__PURE__ */ jsxs("div", { className: "sg-product-sheet__panel", children: [
|
|
45
|
+
/* @__PURE__ */ jsxs("div", { className: "sg-product-sheet__header", children: [
|
|
46
|
+
/* @__PURE__ */ jsx2("span", { className: "sg-product-sheet__title", children: "\u5546\u54C1\u8BE6\u60C5" }),
|
|
47
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: "sg-product-sheet__close", onClick: onClose, "aria-label": "\u5173\u95ED", children: /* @__PURE__ */ jsx2(X, { size: 18 }) })
|
|
48
|
+
] }),
|
|
49
|
+
/* @__PURE__ */ jsxs("div", { className: "sg-product-sheet__body", children: [
|
|
50
|
+
item.imageUrl && /* @__PURE__ */ jsx2(
|
|
51
|
+
ImageWithFallback,
|
|
52
|
+
{
|
|
53
|
+
src: item.imageUrl,
|
|
54
|
+
alt: item.name,
|
|
55
|
+
className: "sg-product-sheet__cover",
|
|
56
|
+
size: 240
|
|
57
|
+
}
|
|
58
|
+
),
|
|
59
|
+
/* @__PURE__ */ jsxs("div", { className: "sg-product-sheet__main", children: [
|
|
60
|
+
item.badges.length > 0 && /* @__PURE__ */ jsx2("div", { className: "sg-badges", children: item.badges.map((b) => /* @__PURE__ */ jsx2("span", { className: "sg-badge", children: b }, b)) }),
|
|
61
|
+
/* @__PURE__ */ jsx2("div", { className: "sg-product-sheet__name", children: item.name }),
|
|
62
|
+
item.brand && /* @__PURE__ */ jsx2("div", { className: "sg-product-sheet__brand", children: item.brand }),
|
|
63
|
+
/* @__PURE__ */ jsxs("div", { className: "sg-product-sheet__price-row", children: [
|
|
64
|
+
item.price.sale && /* @__PURE__ */ jsx2("span", { className: "sg-price-sale", children: item.price.sale.display }),
|
|
65
|
+
item.price.original && item.price.sale && /* @__PURE__ */ jsx2("span", { className: "sg-price-original", children: item.price.original.display }),
|
|
66
|
+
item.price.promotion && /* @__PURE__ */ jsx2("span", { className: "sg-price-promotion", children: item.price.promotion.display }),
|
|
67
|
+
!item.price.sale && !item.price.original && !item.price.promotion && /* @__PURE__ */ jsx2("span", { className: "sg-price-unavailable", children: "\u4EF7\u683C\u6682\u65E0" })
|
|
68
|
+
] }),
|
|
69
|
+
/* @__PURE__ */ jsx2("div", { className: `sg-availability sg-availability-${item.availability.status}`, children: item.availability.label }),
|
|
70
|
+
/* @__PURE__ */ jsxs("div", { className: "sg-product-sheet__merchant", children: [
|
|
71
|
+
/* @__PURE__ */ jsx2("span", { children: item.merchant.name }),
|
|
72
|
+
item.merchant.location?.displayText && /* @__PURE__ */ jsxs("span", { className: "sg-merchant-location", children: [
|
|
73
|
+
" \xB7 ",
|
|
74
|
+
item.merchant.location.displayText
|
|
75
|
+
] })
|
|
76
|
+
] }),
|
|
77
|
+
item.reasons && item.reasons.length > 0 && /* @__PURE__ */ jsx2("div", { className: "sg-reasons", children: item.reasons.map((r) => /* @__PURE__ */ jsx2("span", { className: "sg-reason-tag", children: r.label }, r.code)) }),
|
|
78
|
+
item.caveats.length > 0 && /* @__PURE__ */ jsx2("div", { className: "sg-item-caveats", children: item.caveats.map((c, i) => /* @__PURE__ */ jsxs("div", { className: "sg-caveat-item", children: [
|
|
79
|
+
"\u26A0\uFE0F ",
|
|
80
|
+
c
|
|
81
|
+
] }, i)) })
|
|
82
|
+
] }),
|
|
83
|
+
item.availability.marketable && /* @__PURE__ */ jsx2("div", { className: "sg-product-sheet__actions", children: /* @__PURE__ */ jsx2(
|
|
84
|
+
ItemActionsRow,
|
|
85
|
+
{
|
|
86
|
+
actions: item.itemActions,
|
|
87
|
+
cardId,
|
|
88
|
+
isHistory,
|
|
89
|
+
className: "sg-product-sheet__action-row",
|
|
90
|
+
chipClassName: "sg-product-sheet__chip"
|
|
91
|
+
}
|
|
92
|
+
) })
|
|
93
|
+
] })
|
|
94
|
+
] })
|
|
95
|
+
] }),
|
|
96
|
+
document.body
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
function ProductListCard(props) {
|
|
100
|
+
const { data, cardId, isHistory } = props;
|
|
101
|
+
const [activeItem, setActiveItem] = useState2(null);
|
|
102
|
+
return /* @__PURE__ */ jsxs("section", { className: "sg-card sg-product-list", children: [
|
|
103
|
+
data.summary && /* @__PURE__ */ jsx2("div", { className: "sg-card-summary", children: data.summary }),
|
|
104
|
+
data.items.length === 0 ? /* @__PURE__ */ jsx2("div", { className: "sg-empty", children: data.noResultsReason ?? "\u6682\u65E0\u76F8\u5173\u5546\u54C1" }) : /* @__PURE__ */ jsx2("ul", { className: "sg-product-list-items", children: data.items.map((item) => /* @__PURE__ */ jsxs(
|
|
105
|
+
"li",
|
|
106
|
+
{
|
|
107
|
+
className: "sg-product-item sg-product-item--clickable",
|
|
108
|
+
onClick: () => setActiveItem(item),
|
|
109
|
+
role: "button",
|
|
110
|
+
tabIndex: 0,
|
|
111
|
+
onKeyDown: (e) => e.key === "Enter" && setActiveItem(item),
|
|
112
|
+
children: [
|
|
113
|
+
/* @__PURE__ */ jsx2(
|
|
114
|
+
ImageWithFallback,
|
|
115
|
+
{
|
|
116
|
+
src: item.imageUrl,
|
|
117
|
+
alt: item.name,
|
|
118
|
+
className: "sg-product-image",
|
|
119
|
+
size: 44
|
|
120
|
+
}
|
|
121
|
+
),
|
|
122
|
+
/* @__PURE__ */ jsxs("div", { className: "sg-product-info", children: [
|
|
123
|
+
item.badges.length > 0 && /* @__PURE__ */ jsx2("div", { className: "sg-badges", children: item.badges.map((b) => /* @__PURE__ */ jsx2("span", { className: "sg-badge", children: b }, b)) }),
|
|
124
|
+
/* @__PURE__ */ jsx2("div", { className: "sg-product-name", children: item.name }),
|
|
125
|
+
item.brand && /* @__PURE__ */ jsx2("div", { className: "sg-product-brand", children: item.brand }),
|
|
126
|
+
/* @__PURE__ */ jsxs("div", { className: "sg-price-block", children: [
|
|
127
|
+
item.price.sale && /* @__PURE__ */ jsx2("span", { className: "sg-price-sale", children: item.price.sale.display }),
|
|
128
|
+
item.price.original && item.price.sale && /* @__PURE__ */ jsx2("span", { className: "sg-price-original", children: item.price.original.display }),
|
|
129
|
+
item.price.promotion && /* @__PURE__ */ jsx2("span", { className: "sg-price-promotion", children: item.price.promotion.display }),
|
|
130
|
+
!item.price.sale && !item.price.original && !item.price.promotion && /* @__PURE__ */ jsx2("span", { className: "sg-price-unavailable", children: "\u4EF7\u683C\u6682\u65E0" })
|
|
131
|
+
] }),
|
|
132
|
+
/* @__PURE__ */ jsxs("div", { className: "sg-product-sheet__merchant", children: [
|
|
133
|
+
/* @__PURE__ */ jsx2("span", { children: item.merchant.name }),
|
|
134
|
+
item.merchant.location?.displayText && /* @__PURE__ */ jsxs("span", { className: "sg-merchant-location", children: [
|
|
135
|
+
" \xB7 ",
|
|
136
|
+
item.merchant.location.displayText
|
|
137
|
+
] })
|
|
138
|
+
] })
|
|
139
|
+
] }),
|
|
140
|
+
/* @__PURE__ */ jsx2("div", { className: "sg-product-item__arrow", "aria-hidden": "true", children: "\u203A" })
|
|
141
|
+
]
|
|
142
|
+
},
|
|
143
|
+
item.productId
|
|
144
|
+
)) }),
|
|
145
|
+
data.pageInfo?.hasMore && /* @__PURE__ */ jsxs("div", { className: "sg-page-info", children: [
|
|
146
|
+
"\u5DF2\u5C55\u793A ",
|
|
147
|
+
data.items.length,
|
|
148
|
+
" / ",
|
|
149
|
+
data.pageInfo.total,
|
|
150
|
+
" \u4EF6\u5546\u54C1"
|
|
151
|
+
] }),
|
|
152
|
+
data.refinements.length > 0 && /* @__PURE__ */ jsx2("div", { className: "sg-refinements", children: data.refinements.map((r, i) => /* @__PURE__ */ jsx2(
|
|
153
|
+
"button",
|
|
154
|
+
{
|
|
155
|
+
type: "button",
|
|
156
|
+
className: "sg-refinement-chip",
|
|
157
|
+
disabled: isHistory,
|
|
158
|
+
onClick: () => {
|
|
159
|
+
if (isHistory) return;
|
|
160
|
+
sendCardAction(cardId, { type: "sendMessage", value: r.queryText || r.label, visible: true });
|
|
161
|
+
},
|
|
162
|
+
children: r.label
|
|
163
|
+
},
|
|
164
|
+
i
|
|
165
|
+
)) }),
|
|
166
|
+
activeItem && /* @__PURE__ */ jsx2(
|
|
167
|
+
ProductDetailSheet,
|
|
168
|
+
{
|
|
169
|
+
item: activeItem,
|
|
170
|
+
cardId,
|
|
171
|
+
isHistory,
|
|
172
|
+
onClose: () => setActiveItem(null)
|
|
173
|
+
}
|
|
174
|
+
)
|
|
175
|
+
] });
|
|
176
|
+
}
|
|
177
|
+
var product_list_default = ProductListCard;
|
|
178
|
+
|
|
179
|
+
// src/client/cards/product-detail/index.tsx
|
|
180
|
+
import { useState as useState3 } from "react";
|
|
181
|
+
import { ItemActionsRow as ItemActionsRow2 } from "@tbox.cn/app-sdk/client";
|
|
182
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
183
|
+
function ProductDetailCard(props) {
|
|
184
|
+
const { data, cardId, isHistory } = props;
|
|
185
|
+
const [active, setActive] = useState3(0);
|
|
186
|
+
const images = data.imageUrls;
|
|
187
|
+
const current = Math.min(active, Math.max(images.length - 1, 0));
|
|
188
|
+
return /* @__PURE__ */ jsxs2("section", { className: "sg-card sg-product-detail", children: [
|
|
189
|
+
/* @__PURE__ */ jsx3("div", { className: "sg-card-title", children: data.name }),
|
|
190
|
+
data.brand && /* @__PURE__ */ jsx3("div", { className: "sg-card-subtitle", children: data.brand }),
|
|
191
|
+
images.length > 0 && /* @__PURE__ */ jsxs2("div", { className: "sg-carousel", children: [
|
|
192
|
+
/* @__PURE__ */ jsx3(ImageWithFallback, { src: images[current], alt: data.name, className: "sg-carousel__stage", size: 72 }),
|
|
193
|
+
images.length > 1 && /* @__PURE__ */ jsxs2("span", { className: "sg-carousel__count", children: [
|
|
194
|
+
current + 1,
|
|
195
|
+
"/",
|
|
196
|
+
images.length
|
|
197
|
+
] }),
|
|
198
|
+
images.length > 1 && /* @__PURE__ */ jsx3("div", { className: "sg-carousel__thumbs", children: images.map((src, i) => /* @__PURE__ */ jsx3(
|
|
199
|
+
"button",
|
|
200
|
+
{
|
|
201
|
+
type: "button",
|
|
202
|
+
className: "sg-carousel__thumb",
|
|
203
|
+
"aria-current": i === current,
|
|
204
|
+
"aria-label": `\u67E5\u770B\u7B2C ${i + 1} \u5F20\u56FE`,
|
|
205
|
+
onClick: () => setActive(i),
|
|
206
|
+
children: /* @__PURE__ */ jsx3("img", { src, alt: "", loading: "lazy", referrerPolicy: "no-referrer" })
|
|
207
|
+
},
|
|
208
|
+
i
|
|
209
|
+
)) })
|
|
210
|
+
] }),
|
|
211
|
+
/* @__PURE__ */ jsxs2("div", { className: "sg-price-block sg-price-block--detail", children: [
|
|
212
|
+
data.price.sale && /* @__PURE__ */ jsx3("span", { className: "sg-price-sale sg-price-sale--lg", children: data.price.sale.display }),
|
|
213
|
+
data.price.original && data.price.sale && /* @__PURE__ */ jsx3("span", { className: "sg-price-original", children: data.price.original.display }),
|
|
214
|
+
data.price.promotion && /* @__PURE__ */ jsx3("span", { className: "sg-price-promotion", children: data.price.promotion.display })
|
|
215
|
+
] }),
|
|
216
|
+
/* @__PURE__ */ jsxs2("div", { className: `sg-availability sg-availability-${data.availability.status}`, children: [
|
|
217
|
+
data.availability.label,
|
|
218
|
+
data.humanGuideAvailable && /* @__PURE__ */ jsx3("span", { className: "sg-availability__guide", children: "\u652F\u6301\u4EBA\u5DE5\u5BFC\u8D2D" })
|
|
219
|
+
] }),
|
|
220
|
+
data.description && /* @__PURE__ */ jsx3("div", { className: "sg-product-desc", children: data.description }),
|
|
221
|
+
/* @__PURE__ */ jsx3("dl", { className: "sg-attr-table", children: data.attributes.map((a) => /* @__PURE__ */ jsxs2("div", { className: "sg-attr-row", children: [
|
|
222
|
+
/* @__PURE__ */ jsx3("dt", { children: a.name }),
|
|
223
|
+
/* @__PURE__ */ jsx3("dd", { children: a.value })
|
|
224
|
+
] }, a.name)) }),
|
|
225
|
+
/* @__PURE__ */ jsxs2("div", { className: "sg-product-merchant", children: [
|
|
226
|
+
data.merchant.name,
|
|
227
|
+
data.merchant.location?.displayText && /* @__PURE__ */ jsxs2("span", { className: "sg-merchant-location", children: [
|
|
228
|
+
" \xB7 ",
|
|
229
|
+
data.merchant.location.displayText
|
|
230
|
+
] })
|
|
231
|
+
] }),
|
|
232
|
+
data.promotionFacts.map((p) => /* @__PURE__ */ jsx3("div", { className: "sg-promo-fact", children: p }, p)),
|
|
233
|
+
data.categoryPath.length > 0 && /* @__PURE__ */ jsx3("div", { className: "sg-category-path", children: data.categoryPath.join(" / ") }),
|
|
234
|
+
/* @__PURE__ */ jsx3(ItemActionsRow2, { actions: data.itemActions, cardId, isHistory, className: "sg-item-actions", chipClassName: "sg-chip" })
|
|
235
|
+
] });
|
|
236
|
+
}
|
|
237
|
+
var product_detail_default = ProductDetailCard;
|
|
238
|
+
|
|
239
|
+
// src/client/cards/shop-list/index.tsx
|
|
240
|
+
import { useCallback as useCallback3, useMemo as useMemo2, useRef as useRef3, useState as useState6 } from "react";
|
|
241
|
+
import { CaretRight } from "@phosphor-icons/react";
|
|
242
|
+
import { markSelfRendering } from "@tbox.cn/app-sdk/client";
|
|
243
|
+
|
|
244
|
+
// src/client/components/ShopDetailSheet.tsx
|
|
245
|
+
import { useCallback, useEffect, useId, useRef, useState as useState4 } from "react";
|
|
246
|
+
import { createPortal as createPortal2 } from "react-dom";
|
|
247
|
+
import { Clock, MapPin, Phone, Star, Tag, X as X2 } from "@phosphor-icons/react";
|
|
248
|
+
import { ItemActionsRow as ItemActionsRow3, navigateToAlipayPage, sendCardAction as sendCardAction2 } from "@tbox.cn/app-sdk/client";
|
|
249
|
+
import { Fragment, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
250
|
+
var HIDDEN_DETAIL_ACTION_LABELS = /* @__PURE__ */ new Set(["\u67E5\u770B\u8BE6\u60C5", "\u5BFC\u822A", "\u95EE\u95EE\u5BFC\u8D2D"]);
|
|
251
|
+
function ShopDetailSheet(props) {
|
|
252
|
+
const { open, data, loading = false, cardId, isHistory, onClose, actionTokens, claimActionId } = props;
|
|
253
|
+
const [closing, setClosing] = useState4(false);
|
|
254
|
+
const [claimingRef, setClaimingRef] = useState4(null);
|
|
255
|
+
const [claimedRefs, setClaimedRefs] = useState4(() => /* @__PURE__ */ new Set());
|
|
256
|
+
const panelRef = useRef(null);
|
|
257
|
+
const closeButtonRef = useRef(null);
|
|
258
|
+
const closingRef = useRef(false);
|
|
259
|
+
const closeTimerRef = useRef();
|
|
260
|
+
const onCloseRef = useRef(onClose);
|
|
261
|
+
onCloseRef.current = onClose;
|
|
262
|
+
const titleId = useId();
|
|
263
|
+
const finishClose = useCallback(() => {
|
|
264
|
+
if (!closingRef.current) return;
|
|
265
|
+
window.clearTimeout(closeTimerRef.current);
|
|
266
|
+
closingRef.current = false;
|
|
267
|
+
setClosing(false);
|
|
268
|
+
onCloseRef.current();
|
|
269
|
+
}, []);
|
|
270
|
+
useEffect(() => {
|
|
271
|
+
if (!cardId || typeof window === "undefined") return void 0;
|
|
272
|
+
const onNotice = (event) => {
|
|
273
|
+
const detail = event.detail;
|
|
274
|
+
if (!detail?.text || detail.surfaceId && detail.surfaceId !== cardId) return;
|
|
275
|
+
const ref = claimingRef;
|
|
276
|
+
if (!ref) return;
|
|
277
|
+
setClaimingRef(null);
|
|
278
|
+
if (detail.level === "success" || /领取成功|已存入卡包|已领取/.test(detail.text)) {
|
|
279
|
+
setClaimedRefs((current) => new Set(current).add(ref));
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
window.addEventListener("tbox:notice", onNotice);
|
|
283
|
+
return () => window.removeEventListener("tbox:notice", onNotice);
|
|
284
|
+
}, [cardId, claimingRef]);
|
|
285
|
+
const claimCoupon = useCallback(
|
|
286
|
+
(offerRef) => {
|
|
287
|
+
if (!claimActionId) return;
|
|
288
|
+
const token = actionTokens?.[claimActionId];
|
|
289
|
+
if (!token) return;
|
|
290
|
+
setClaimingRef(offerRef);
|
|
291
|
+
sendCardAction2(cardId, { type: "moduleAction", actionId: claimActionId, contextToken: token }, { offerRef });
|
|
292
|
+
},
|
|
293
|
+
[actionTokens, cardId, claimActionId]
|
|
294
|
+
);
|
|
295
|
+
const requestClose = useCallback(() => {
|
|
296
|
+
if (closingRef.current) return;
|
|
297
|
+
closingRef.current = true;
|
|
298
|
+
setClosing(true);
|
|
299
|
+
const reducedMotion = window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches ?? false;
|
|
300
|
+
closeTimerRef.current = window.setTimeout(finishClose, reducedMotion ? 1 : 200);
|
|
301
|
+
}, [finishClose]);
|
|
302
|
+
useEffect(() => {
|
|
303
|
+
if (!open || !data) return;
|
|
304
|
+
closingRef.current = false;
|
|
305
|
+
setClosing(false);
|
|
306
|
+
const previousFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
307
|
+
const previousOverflow = document.body.style.overflow;
|
|
308
|
+
document.body.style.overflow = "hidden";
|
|
309
|
+
closeButtonRef.current?.focus();
|
|
310
|
+
const onKeyDown = (event) => {
|
|
311
|
+
if (event.key === "Escape") {
|
|
312
|
+
event.preventDefault();
|
|
313
|
+
requestClose();
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
if (event.key !== "Tab") return;
|
|
317
|
+
const focusable = panelRef.current?.querySelectorAll(
|
|
318
|
+
'button:not(:disabled), a[href], input:not(:disabled), [tabindex]:not([tabindex="-1"])'
|
|
319
|
+
);
|
|
320
|
+
if (!focusable || focusable.length === 0) return;
|
|
321
|
+
const first = focusable[0];
|
|
322
|
+
const last = focusable[focusable.length - 1];
|
|
323
|
+
if (event.shiftKey && document.activeElement === first) {
|
|
324
|
+
event.preventDefault();
|
|
325
|
+
last.focus();
|
|
326
|
+
} else if (!event.shiftKey && document.activeElement === last) {
|
|
327
|
+
event.preventDefault();
|
|
328
|
+
first.focus();
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
document.addEventListener("keydown", onKeyDown);
|
|
332
|
+
return () => {
|
|
333
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
334
|
+
document.body.style.overflow = previousOverflow;
|
|
335
|
+
previousFocus?.focus();
|
|
336
|
+
};
|
|
337
|
+
}, [open, requestClose]);
|
|
338
|
+
useEffect(() => () => window.clearTimeout(closeTimerRef.current), []);
|
|
339
|
+
if (!open || !data || typeof document === "undefined") return null;
|
|
340
|
+
const phone = data.contactInfo?.find((item) => /phone|电话/i.test(item.channel));
|
|
341
|
+
const hoursText = data.contactInfo?.find((item) => /hours|营业时间/i.test(item.channel))?.value ?? "\u5468\u4E00-\u5468\u65E5 10:00-22:00";
|
|
342
|
+
const detailActions = data.itemActions?.filter(
|
|
343
|
+
(action) => !HIDDEN_DETAIL_ACTION_LABELS.has(action.label.trim())
|
|
344
|
+
) ?? [];
|
|
345
|
+
return createPortal2(
|
|
346
|
+
/* @__PURE__ */ jsxs3(
|
|
347
|
+
"div",
|
|
348
|
+
{
|
|
349
|
+
className: `sg-shop-sheet${closing ? " sg-shop-sheet--closing" : ""}`,
|
|
350
|
+
role: "presentation",
|
|
351
|
+
onAnimationEnd: (event) => {
|
|
352
|
+
if (closing && event.target === event.currentTarget) finishClose();
|
|
353
|
+
},
|
|
354
|
+
children: [
|
|
355
|
+
/* @__PURE__ */ jsx4("div", { className: "sg-shop-sheet__mask", "aria-hidden": "true", onClick: requestClose }),
|
|
356
|
+
/* @__PURE__ */ jsxs3(
|
|
357
|
+
"section",
|
|
358
|
+
{
|
|
359
|
+
ref: panelRef,
|
|
360
|
+
className: "sg-shop-sheet__panel",
|
|
361
|
+
role: "dialog",
|
|
362
|
+
"aria-modal": "true",
|
|
363
|
+
"aria-labelledby": titleId,
|
|
364
|
+
"aria-busy": loading || void 0,
|
|
365
|
+
children: [
|
|
366
|
+
/* @__PURE__ */ jsxs3("header", { className: "sg-shop-sheet__header", children: [
|
|
367
|
+
/* @__PURE__ */ jsx4("h2", { id: titleId, children: "\u95E8\u5E97\u8BE6\u60C5" }),
|
|
368
|
+
/* @__PURE__ */ jsx4(
|
|
369
|
+
"button",
|
|
370
|
+
{
|
|
371
|
+
ref: closeButtonRef,
|
|
372
|
+
type: "button",
|
|
373
|
+
className: "sg-shop-sheet__close",
|
|
374
|
+
"aria-label": "\u5173\u95ED\u95E8\u5E97\u8BE6\u60C5",
|
|
375
|
+
onClick: requestClose,
|
|
376
|
+
children: /* @__PURE__ */ jsx4(X2, { size: 20, weight: "bold" })
|
|
377
|
+
}
|
|
378
|
+
)
|
|
379
|
+
] }),
|
|
380
|
+
/* @__PURE__ */ jsxs3("div", { className: "sg-shop-sheet__body", children: [
|
|
381
|
+
(data.coverUrl || data.logoUrl) && /* @__PURE__ */ jsx4(
|
|
382
|
+
ImageWithFallback,
|
|
383
|
+
{
|
|
384
|
+
src: data.coverUrl ?? data.logoUrl,
|
|
385
|
+
alt: "",
|
|
386
|
+
className: "sg-shop-sheet__cover",
|
|
387
|
+
size: 176
|
|
388
|
+
}
|
|
389
|
+
),
|
|
390
|
+
/* @__PURE__ */ jsxs3("div", { className: "sg-shop-sheet__identity", children: [
|
|
391
|
+
/* @__PURE__ */ jsxs3("div", { className: "sg-shop-sheet__identity-copy", children: [
|
|
392
|
+
/* @__PURE__ */ jsx4("div", { className: "sg-shop-sheet__name-row", children: /* @__PURE__ */ jsx4("h3", { children: data.name }) }),
|
|
393
|
+
(data.rating || data.avgSpend || data.status.code !== "unknown" && data.status.label || loading) && /* @__PURE__ */ jsxs3("div", { className: "sg-shop-sheet__stats", children: [
|
|
394
|
+
data.rating && /* @__PURE__ */ jsxs3("span", { className: "sg-shop-sheet__rating", children: [
|
|
395
|
+
/* @__PURE__ */ jsx4(Star, { size: 15, weight: "fill" }),
|
|
396
|
+
data.rating
|
|
397
|
+
] }),
|
|
398
|
+
data.avgSpend && /* @__PURE__ */ jsxs3("span", { children: [
|
|
399
|
+
"\u4EBA\u5747 ",
|
|
400
|
+
data.avgSpend
|
|
401
|
+
] }),
|
|
402
|
+
loading ? /* @__PURE__ */ jsx4("span", { className: "sg-shop-sheet__skeleton sg-shop-sheet__skeleton--status", "aria-hidden": "true" }) : data.status.code !== "unknown" && /* @__PURE__ */ jsx4("span", { className: `sg-status sg-status-${data.status.code}`, children: data.status.label })
|
|
403
|
+
] })
|
|
404
|
+
] }),
|
|
405
|
+
loading ? /* @__PURE__ */ jsx4("span", { className: "sg-shop-sheet__phone-skeleton", "aria-hidden": "true" }) : phone && /* @__PURE__ */ jsxs3(
|
|
406
|
+
"a",
|
|
407
|
+
{
|
|
408
|
+
className: "sg-shop-sheet__phone",
|
|
409
|
+
href: phone.value.startsWith("tel:") ? phone.value : `tel:${phone.value}`,
|
|
410
|
+
"aria-label": `\u62E8\u6253${data.name}\u7535\u8BDD`,
|
|
411
|
+
children: [
|
|
412
|
+
/* @__PURE__ */ jsx4(Phone, { size: 20, weight: "fill" }),
|
|
413
|
+
/* @__PURE__ */ jsx4("span", { children: "\u7535\u8BDD" })
|
|
414
|
+
]
|
|
415
|
+
}
|
|
416
|
+
)
|
|
417
|
+
] }),
|
|
418
|
+
/* @__PURE__ */ jsxs3("div", { className: "sg-shop-sheet__facts", children: [
|
|
419
|
+
/* @__PURE__ */ jsxs3("div", { children: [
|
|
420
|
+
data.businessCategories.length > 0 && /* @__PURE__ */ jsx4("span", { children: data.businessCategories.join(" \xB7 ") }),
|
|
421
|
+
/* @__PURE__ */ jsx4(MapPin, { size: 17, weight: "fill" }),
|
|
422
|
+
/* @__PURE__ */ jsx4("span", { className: "sg-shop-sheet__location", children: data.location.displayText })
|
|
423
|
+
] }),
|
|
424
|
+
!loading && data.operatingStatus && /* @__PURE__ */ jsx4("div", { children: data.operatingStatus }),
|
|
425
|
+
!loading && /* @__PURE__ */ jsxs3("div", { children: [
|
|
426
|
+
/* @__PURE__ */ jsx4(Clock, { size: 18 }),
|
|
427
|
+
/* @__PURE__ */ jsx4("span", { children: hoursText })
|
|
428
|
+
] }),
|
|
429
|
+
!loading && data.services && data.services.length > 0 && /* @__PURE__ */ jsxs3("div", { children: [
|
|
430
|
+
"\u652F\u6301",
|
|
431
|
+
data.services.join("\u3001")
|
|
432
|
+
] }),
|
|
433
|
+
loading && /* @__PURE__ */ jsxs3("div", { className: "sg-shop-sheet__facts-skeleton", role: "status", "aria-label": "\u95E8\u5E97\u8BE6\u60C5\u52A0\u8F7D\u4E2D", children: [
|
|
434
|
+
/* @__PURE__ */ jsx4("span", { className: "sg-shop-sheet__skeleton sg-shop-sheet__skeleton--fact", "aria-hidden": "true" }),
|
|
435
|
+
/* @__PURE__ */ jsx4("span", { className: "sg-shop-sheet__skeleton sg-shop-sheet__skeleton--fact-short", "aria-hidden": "true" })
|
|
436
|
+
] })
|
|
437
|
+
] }),
|
|
438
|
+
loading && /* @__PURE__ */ jsxs3("div", { className: "sg-shop-sheet__details-skeleton", "aria-hidden": "true", children: [
|
|
439
|
+
/* @__PURE__ */ jsx4("span", { className: "sg-shop-sheet__skeleton sg-shop-sheet__skeleton--detail-line" }),
|
|
440
|
+
/* @__PURE__ */ jsx4("span", { className: "sg-shop-sheet__skeleton sg-shop-sheet__skeleton--detail-line-short" }),
|
|
441
|
+
/* @__PURE__ */ jsx4("span", { className: "sg-shop-sheet__skeleton sg-shop-sheet__skeleton--detail-block" })
|
|
442
|
+
] }),
|
|
443
|
+
!loading && data.description && /* @__PURE__ */ jsx4("p", { className: "sg-shop-sheet__description", children: data.description }),
|
|
444
|
+
!loading && data.coupons && data.coupons.length > 0 && /* @__PURE__ */ jsxs3("div", { className: "sg-shop-sheet__coupons", "aria-label": "\u95E8\u5E97\u4F18\u60E0", children: [
|
|
445
|
+
/* @__PURE__ */ jsxs3("h3", { className: "sg-shop-sheet__section-title", children: [
|
|
446
|
+
/* @__PURE__ */ jsx4(Tag, { size: 16, weight: "fill", "aria-hidden": "true" }),
|
|
447
|
+
"\u4F18\u60E0\u6D3B\u52A8"
|
|
448
|
+
] }),
|
|
449
|
+
/* @__PURE__ */ jsx4("div", { className: "sg-shop-sheet__coupon-list", children: data.coupons.map((coupon, index) => {
|
|
450
|
+
const purchaseOnly = coupon.salePrice !== void 0 && coupon.salePrice > 0;
|
|
451
|
+
const redirectOnly = purchaseOnly || coupon.freeCouponClaimMode === "REDIRECT";
|
|
452
|
+
const claimToken = coupon.offerRef && claimActionId ? actionTokens?.[claimActionId] : void 0;
|
|
453
|
+
const claimable = Boolean(!redirectOnly && coupon.offerRef && claimToken && !isHistory);
|
|
454
|
+
const redirectAction = redirectOnly && Boolean(coupon.offerRef || coupon.purchaseUrl);
|
|
455
|
+
const claimed = coupon.offerRef !== void 0 && claimedRefs.has(coupon.offerRef);
|
|
456
|
+
return /* @__PURE__ */ jsxs3("div", { className: "sg-shop-sheet__coupon-row", children: [
|
|
457
|
+
coupon.applicableCategories && coupon.applicableCategories.length > 0 && /* @__PURE__ */ jsx4("span", { className: "sg-shop-sheet__coupon-tag", children: coupon.applicableCategories.join("\u3001") }),
|
|
458
|
+
coupon.imageUrl && /* @__PURE__ */ jsx4(
|
|
459
|
+
ImageWithFallback,
|
|
460
|
+
{
|
|
461
|
+
src: coupon.imageUrl,
|
|
462
|
+
alt: coupon.name,
|
|
463
|
+
className: "sg-shop-sheet__coupon-img",
|
|
464
|
+
size: 112
|
|
465
|
+
}
|
|
466
|
+
),
|
|
467
|
+
/* @__PURE__ */ jsxs3("div", { className: "sg-shop-sheet__coupon-body", children: [
|
|
468
|
+
/* @__PURE__ */ jsx4("strong", { className: "sg-shop-sheet__coupon-name", children: coupon.name }),
|
|
469
|
+
coupon.faceValue !== void 0 && /* @__PURE__ */ jsx4("p", { className: "sg-shop-sheet__coupon-price", children: coupon.salePrice === 0 ? /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
470
|
+
/* @__PURE__ */ jsx4("span", { className: "sg-shop-sheet__coupon-free", children: "\u514D\u8D39" }),
|
|
471
|
+
/* @__PURE__ */ jsxs3("s", { className: "sg-shop-sheet__coupon-face--strike", children: [
|
|
472
|
+
"\xA5",
|
|
473
|
+
coupon.faceValue
|
|
474
|
+
] })
|
|
475
|
+
] }) : coupon.salePrice !== void 0 ? /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
476
|
+
/* @__PURE__ */ jsxs3("span", { className: "sg-shop-sheet__coupon-face", children: [
|
|
477
|
+
"\xA5",
|
|
478
|
+
coupon.salePrice
|
|
479
|
+
] }),
|
|
480
|
+
/* @__PURE__ */ jsxs3("s", { className: "sg-shop-sheet__coupon-face--strike", children: [
|
|
481
|
+
"\xA5",
|
|
482
|
+
coupon.faceValue
|
|
483
|
+
] })
|
|
484
|
+
] }) : /* @__PURE__ */ jsxs3("span", { className: "sg-shop-sheet__coupon-face", children: [
|
|
485
|
+
"\xA5",
|
|
486
|
+
coupon.faceValue
|
|
487
|
+
] }) }),
|
|
488
|
+
coupon.usageTimeText && /* @__PURE__ */ jsx4("p", { className: "sg-shop-sheet__coupon-sub", children: coupon.usageTimeText })
|
|
489
|
+
] }),
|
|
490
|
+
redirectAction ? /* @__PURE__ */ jsx4(
|
|
491
|
+
"button",
|
|
492
|
+
{
|
|
493
|
+
type: "button",
|
|
494
|
+
className: "sg-shop-sheet__coupon-claim",
|
|
495
|
+
disabled: !coupon.purchaseUrl,
|
|
496
|
+
onClick: () => {
|
|
497
|
+
if (!coupon.purchaseUrl) return;
|
|
498
|
+
void navigateToAlipayPage(coupon.purchaseUrl).catch((err) => {
|
|
499
|
+
console.warn("[ShopDetailSheet] navigateTo failed", err);
|
|
500
|
+
});
|
|
501
|
+
},
|
|
502
|
+
children: coupon.purchaseUrl ? `\u53BB\u5C0F\u7A0B\u5E8F${purchaseOnly ? "\u62A2\u8D2D" : "\u9886\u53D6"}` : `${purchaseOnly ? "\u62A2\u8D2D" : "\u9886\u53D6"}\u94FE\u63A5\u6682\u4E0D\u53EF\u7528`
|
|
503
|
+
}
|
|
504
|
+
) : claimable && coupon.offerRef ? /* @__PURE__ */ jsx4(
|
|
505
|
+
"button",
|
|
506
|
+
{
|
|
507
|
+
type: "button",
|
|
508
|
+
className: "sg-shop-sheet__coupon-claim",
|
|
509
|
+
onClick: () => claimCoupon(coupon.offerRef),
|
|
510
|
+
disabled: claimingRef === coupon.offerRef || claimed,
|
|
511
|
+
children: claimed ? "\u5DF2\u9886\u53D6" : claimingRef === coupon.offerRef ? "\u9886\u53D6\u4E2D\uFF0C\u8BF7\u7A0D\u5019\u2026" : "\u9886\u53D6"
|
|
512
|
+
}
|
|
513
|
+
) : null
|
|
514
|
+
] }, index);
|
|
515
|
+
}) })
|
|
516
|
+
] }),
|
|
517
|
+
!loading && detailActions.length > 0 && /* @__PURE__ */ jsx4(
|
|
518
|
+
ItemActionsRow3,
|
|
519
|
+
{
|
|
520
|
+
actions: detailActions,
|
|
521
|
+
cardId,
|
|
522
|
+
isHistory,
|
|
523
|
+
className: "sg-shop-sheet__actions",
|
|
524
|
+
chipClassName: "sg-shop-sheet__action"
|
|
525
|
+
}
|
|
526
|
+
)
|
|
527
|
+
] })
|
|
528
|
+
]
|
|
529
|
+
}
|
|
530
|
+
)
|
|
531
|
+
]
|
|
532
|
+
}
|
|
533
|
+
),
|
|
534
|
+
document.body
|
|
535
|
+
);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// src/client/components/MerchantRow.tsx
|
|
539
|
+
import { MapPin as MapPin2, Star as Star2 } from "@phosphor-icons/react";
|
|
540
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
541
|
+
function MerchantRow(props) {
|
|
542
|
+
const { merchant, disabled = false, className, onSelect } = props;
|
|
543
|
+
return /* @__PURE__ */ jsxs4(
|
|
544
|
+
"button",
|
|
545
|
+
{
|
|
546
|
+
type: "button",
|
|
547
|
+
className: ["sg-rm-item-head", "sg-merchant-row", className].filter(Boolean).join(" "),
|
|
548
|
+
"aria-label": `\u67E5\u770B${merchant.name}\u8BE6\u60C5`,
|
|
549
|
+
disabled,
|
|
550
|
+
onClick: onSelect,
|
|
551
|
+
children: [
|
|
552
|
+
/* @__PURE__ */ jsx5(ImageWithFallback, { src: merchant.logoUrl, alt: "", className: "sg-rm-item-image", size: 96 }),
|
|
553
|
+
/* @__PURE__ */ jsxs4("div", { className: "sg-rm-item-meta", children: [
|
|
554
|
+
/* @__PURE__ */ jsx5("div", { className: "sg-rm-item-name-row", children: /* @__PURE__ */ jsx5("span", { className: "sg-rm-item-name", children: merchant.name }) }),
|
|
555
|
+
(merchant.rating || merchant.avgSpend) && /* @__PURE__ */ jsxs4("div", { className: "sg-rm-item-stats", children: [
|
|
556
|
+
merchant.rating && /* @__PURE__ */ jsxs4("span", { className: "sg-rm-item-rating", children: [
|
|
557
|
+
/* @__PURE__ */ jsx5(Star2, { size: 14, weight: "fill" }),
|
|
558
|
+
merchant.rating
|
|
559
|
+
] }),
|
|
560
|
+
merchant.avgSpend && /* @__PURE__ */ jsxs4("span", { className: "sg-rm-item-avg-spend", children: [
|
|
561
|
+
"\u4EBA\u5747 ",
|
|
562
|
+
merchant.avgSpend
|
|
563
|
+
] })
|
|
564
|
+
] }),
|
|
565
|
+
merchant.businessCategories.length > 0 && /* @__PURE__ */ jsx5("div", { className: "sg-rm-item-tags", "aria-label": "\u95E8\u5E97\u4E1A\u6001", children: merchant.businessCategories.map((category) => /* @__PURE__ */ jsx5("span", { className: "sg-rm-item-tag", children: category }, category)) }),
|
|
566
|
+
/* @__PURE__ */ jsxs4("div", { className: "sg-rm-item-location", children: [
|
|
567
|
+
/* @__PURE__ */ jsx5(MapPin2, { size: 13, weight: "fill" }),
|
|
568
|
+
/* @__PURE__ */ jsx5("span", { children: merchant.location.displayText })
|
|
569
|
+
] })
|
|
570
|
+
] })
|
|
571
|
+
]
|
|
572
|
+
}
|
|
573
|
+
);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
// src/client/categories.ts
|
|
577
|
+
function resolveCategoryTabs(categoryTabs, items) {
|
|
578
|
+
const result = [];
|
|
579
|
+
const seenNames = /* @__PURE__ */ new Set();
|
|
580
|
+
for (const tab of categoryTabs ?? []) {
|
|
581
|
+
const name = tab.name.trim();
|
|
582
|
+
if (!name || seenNames.has(name)) continue;
|
|
583
|
+
seenNames.add(name);
|
|
584
|
+
result.push({ code: tab.code, name });
|
|
585
|
+
}
|
|
586
|
+
for (const item of items) {
|
|
587
|
+
for (const category of item.businessCategories) {
|
|
588
|
+
const name = category.trim();
|
|
589
|
+
if (!name || seenNames.has(name)) continue;
|
|
590
|
+
seenNames.add(name);
|
|
591
|
+
result.push({ code: `derived-${name}`, name });
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
return result;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
// src/client/components/ShopGuideHeader.tsx
|
|
598
|
+
import { Storefront } from "@phosphor-icons/react";
|
|
599
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
600
|
+
function ShopGuideHeader(props) {
|
|
601
|
+
return /* @__PURE__ */ jsxs5("header", { className: "sg-rm-header", children: [
|
|
602
|
+
/* @__PURE__ */ jsxs5("div", { className: "sg-rm-header-copy", children: [
|
|
603
|
+
/* @__PURE__ */ jsxs5("div", { className: "sg-rm-header-title-row", children: [
|
|
604
|
+
/* @__PURE__ */ jsx6(Storefront, { size: 22, weight: "fill" }),
|
|
605
|
+
/* @__PURE__ */ jsx6("h3", { className: "sg-rm-header-title", children: "\u95E8\u5E97\u5BFC\u89C8" })
|
|
606
|
+
] }),
|
|
607
|
+
/* @__PURE__ */ jsx6("p", { className: "sg-rm-header-subtitle", children: props.subtitle })
|
|
608
|
+
] }),
|
|
609
|
+
/* @__PURE__ */ jsx6("span", { className: "sg-rm-header-badge", children: "\u5546\u573A\u5BFC\u89C8" })
|
|
610
|
+
] });
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
// src/client/components/ShopGuideSectionLabel.tsx
|
|
614
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
615
|
+
function ShopGuideSectionLabel() {
|
|
616
|
+
return /* @__PURE__ */ jsx7("div", { className: "sg-rm-section-label", children: "\u95E8\u5E97" });
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
// src/client/components/ShopListSheet.tsx
|
|
620
|
+
import { useCallback as useCallback2, useEffect as useEffect2, useId as useId2, useMemo, useRef as useRef2, useState as useState5 } from "react";
|
|
621
|
+
import { createPortal as createPortal3 } from "react-dom";
|
|
622
|
+
import { MagnifyingGlass, X as X3 } from "@phosphor-icons/react";
|
|
623
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
624
|
+
function normalizeSearchText(value) {
|
|
625
|
+
return value.trim().toLocaleLowerCase();
|
|
626
|
+
}
|
|
627
|
+
function floorOrder(a, b) {
|
|
628
|
+
const parse = (value) => {
|
|
629
|
+
const normalized = value.trim().toUpperCase();
|
|
630
|
+
const basement = normalized.match(/^B(\d+)$/);
|
|
631
|
+
if (basement) return -Number(basement[1]);
|
|
632
|
+
const aboveGround = normalized.match(/^(?:L|F)?(\d+)F?$/);
|
|
633
|
+
if (aboveGround) return Number(aboveGround[1]);
|
|
634
|
+
return Number.POSITIVE_INFINITY;
|
|
635
|
+
};
|
|
636
|
+
const numeric = parse(a) - parse(b);
|
|
637
|
+
return Number.isNaN(numeric) || numeric === 0 ? a.localeCompare(b, "zh-CN", { numeric: true }) : numeric;
|
|
638
|
+
}
|
|
639
|
+
function ShopListSheet(props) {
|
|
640
|
+
const { open, items, categoryTabs, activeTabCode, onSelect, onClose } = props;
|
|
641
|
+
const [query, setQuery] = useState5("");
|
|
642
|
+
const [sheetTabCode, setSheetTabCode] = useState5("");
|
|
643
|
+
const [activeFloor, setActiveFloor] = useState5("");
|
|
644
|
+
const [closing, setClosing] = useState5(false);
|
|
645
|
+
const panelRef = useRef2(null);
|
|
646
|
+
const bodyRef = useRef2(null);
|
|
647
|
+
const closeButtonRef = useRef2(null);
|
|
648
|
+
const closingRef = useRef2(false);
|
|
649
|
+
const closeTimerRef = useRef2();
|
|
650
|
+
const onCloseRef = useRef2(onClose);
|
|
651
|
+
onCloseRef.current = onClose;
|
|
652
|
+
const titleId = useId2();
|
|
653
|
+
const searchId = useId2();
|
|
654
|
+
const finishClose = useCallback2(() => {
|
|
655
|
+
if (!closingRef.current) return;
|
|
656
|
+
window.clearTimeout(closeTimerRef.current);
|
|
657
|
+
closingRef.current = false;
|
|
658
|
+
setClosing(false);
|
|
659
|
+
onCloseRef.current();
|
|
660
|
+
}, []);
|
|
661
|
+
const requestClose = useCallback2(() => {
|
|
662
|
+
if (closingRef.current) return;
|
|
663
|
+
closingRef.current = true;
|
|
664
|
+
setClosing(true);
|
|
665
|
+
const reducedMotion = window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches ?? false;
|
|
666
|
+
closeTimerRef.current = window.setTimeout(finishClose, reducedMotion ? 1 : 200);
|
|
667
|
+
}, [finishClose]);
|
|
668
|
+
const allCategories = useMemo(() => resolveCategoryTabs(categoryTabs, items), [categoryTabs, items]);
|
|
669
|
+
const activeCategory = allCategories.find((tab) => tab.code === sheetTabCode)?.name;
|
|
670
|
+
const matchedItems = useMemo(() => {
|
|
671
|
+
const normalizedQuery = normalizeSearchText(query);
|
|
672
|
+
return items.filter((item) => {
|
|
673
|
+
if (activeCategory && !item.businessCategories.includes(activeCategory)) return false;
|
|
674
|
+
if (!normalizedQuery) return true;
|
|
675
|
+
return normalizeSearchText([
|
|
676
|
+
item.name,
|
|
677
|
+
item.brand,
|
|
678
|
+
...item.businessCategories,
|
|
679
|
+
item.location.displayText
|
|
680
|
+
].filter(Boolean).join(" ")).includes(normalizedQuery);
|
|
681
|
+
});
|
|
682
|
+
}, [activeCategory, items, query]);
|
|
683
|
+
const floorNames = useMemo(() => [...new Set(
|
|
684
|
+
matchedItems.map((item) => item.location.floorName?.trim()).filter((floor) => Boolean(floor))
|
|
685
|
+
)].sort((a, b) => floorOrder(b, a)), [matchedItems]);
|
|
686
|
+
const showFloorRail = floorNames.length >= 2 && matchedItems.length >= 5;
|
|
687
|
+
const filteredItems = useMemo(
|
|
688
|
+
() => activeFloor ? matchedItems.filter((item) => item.location.floorName?.trim() === activeFloor) : matchedItems,
|
|
689
|
+
[activeFloor, matchedItems]
|
|
690
|
+
);
|
|
691
|
+
useEffect2(() => {
|
|
692
|
+
bodyRef.current?.scrollTo({ top: 0 });
|
|
693
|
+
}, [sheetTabCode, activeFloor, query]);
|
|
694
|
+
useEffect2(() => {
|
|
695
|
+
setActiveFloor((current) => current && floorNames.includes(current) ? current : "");
|
|
696
|
+
}, [floorNames]);
|
|
697
|
+
useEffect2(() => {
|
|
698
|
+
if (!open) return;
|
|
699
|
+
setQuery("");
|
|
700
|
+
setSheetTabCode(allCategories.some((tab) => tab.code === activeTabCode) ? activeTabCode : "");
|
|
701
|
+
closingRef.current = false;
|
|
702
|
+
setClosing(false);
|
|
703
|
+
const previousFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
704
|
+
const previousOverflow = document.body.style.overflow;
|
|
705
|
+
document.body.style.overflow = "hidden";
|
|
706
|
+
closeButtonRef.current?.focus();
|
|
707
|
+
const onKeyDown = (event) => {
|
|
708
|
+
if (event.key === "Escape") {
|
|
709
|
+
event.preventDefault();
|
|
710
|
+
requestClose();
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
713
|
+
if (event.key !== "Tab") return;
|
|
714
|
+
const focusable = panelRef.current?.querySelectorAll(
|
|
715
|
+
'button:not(:disabled), input:not(:disabled), a[href], [tabindex]:not([tabindex="-1"])'
|
|
716
|
+
);
|
|
717
|
+
if (!focusable || focusable.length === 0) return;
|
|
718
|
+
const first = focusable[0];
|
|
719
|
+
const last = focusable[focusable.length - 1];
|
|
720
|
+
if (event.shiftKey && document.activeElement === first) {
|
|
721
|
+
event.preventDefault();
|
|
722
|
+
last.focus();
|
|
723
|
+
} else if (!event.shiftKey && document.activeElement === last) {
|
|
724
|
+
event.preventDefault();
|
|
725
|
+
first.focus();
|
|
726
|
+
}
|
|
727
|
+
};
|
|
728
|
+
document.addEventListener("keydown", onKeyDown);
|
|
729
|
+
return () => {
|
|
730
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
731
|
+
document.body.style.overflow = previousOverflow;
|
|
732
|
+
previousFocus?.focus();
|
|
733
|
+
};
|
|
734
|
+
}, [activeTabCode, allCategories, open, requestClose]);
|
|
735
|
+
useEffect2(() => () => window.clearTimeout(closeTimerRef.current), []);
|
|
736
|
+
if (!open || typeof document === "undefined") return null;
|
|
737
|
+
return createPortal3(
|
|
738
|
+
/* @__PURE__ */ jsxs6(
|
|
739
|
+
"div",
|
|
740
|
+
{
|
|
741
|
+
className: `sg-store-list-sheet${closing ? " sg-store-list-sheet--closing" : ""}`,
|
|
742
|
+
role: "presentation",
|
|
743
|
+
onAnimationEnd: (event) => {
|
|
744
|
+
if (closing && event.target === event.currentTarget) finishClose();
|
|
745
|
+
},
|
|
746
|
+
children: [
|
|
747
|
+
/* @__PURE__ */ jsx8("div", { className: "sg-store-list-sheet__mask", "aria-hidden": "true", onClick: requestClose }),
|
|
748
|
+
/* @__PURE__ */ jsxs6("section", { ref: panelRef, className: "sg-store-list-sheet__panel", role: "dialog", "aria-modal": "true", "aria-labelledby": titleId, children: [
|
|
749
|
+
/* @__PURE__ */ jsxs6("header", { className: "sg-store-list-sheet__header", children: [
|
|
750
|
+
/* @__PURE__ */ jsx8("h2", { id: titleId, children: "\u95E8\u5E97\u5BFC\u89C8" }),
|
|
751
|
+
/* @__PURE__ */ jsx8("button", { ref: closeButtonRef, type: "button", className: "sg-store-list-sheet__close", "aria-label": "\u5173\u95ED\u95E8\u5E97\u5217\u8868", onClick: requestClose, children: /* @__PURE__ */ jsx8(X3, { size: 20, weight: "bold" }) })
|
|
752
|
+
] }),
|
|
753
|
+
/* @__PURE__ */ jsxs6("div", { className: "sg-store-list-sheet__search", children: [
|
|
754
|
+
/* @__PURE__ */ jsx8("label", { className: "sg-visually-hidden", htmlFor: searchId, children: "\u641C\u7D22\u95E8\u5E97" }),
|
|
755
|
+
/* @__PURE__ */ jsx8(MagnifyingGlass, { size: 18, "aria-hidden": "true" }),
|
|
756
|
+
/* @__PURE__ */ jsx8(
|
|
757
|
+
"input",
|
|
758
|
+
{
|
|
759
|
+
id: searchId,
|
|
760
|
+
type: "search",
|
|
761
|
+
value: query,
|
|
762
|
+
placeholder: "\u8BF7\u8F93\u5165\u8981\u641C\u7D22\u7684\u5E97\u94FA\u540D",
|
|
763
|
+
onChange: (event) => setQuery(event.target.value)
|
|
764
|
+
}
|
|
765
|
+
),
|
|
766
|
+
query && /* @__PURE__ */ jsx8("button", { type: "button", "aria-label": "\u6E05\u7A7A\u95E8\u5E97\u641C\u7D22", onClick: () => setQuery(""), children: /* @__PURE__ */ jsx8(X3, { size: 14, weight: "bold" }) })
|
|
767
|
+
] }),
|
|
768
|
+
/* @__PURE__ */ jsxs6("div", { className: "sg-store-list-sheet__content", children: [
|
|
769
|
+
/* @__PURE__ */ jsxs6("nav", { className: "sg-store-list-sheet__categories", "aria-label": "\u6309\u95E8\u5E97\u4E1A\u6001\u7B5B\u9009", children: [
|
|
770
|
+
/* @__PURE__ */ jsx8(
|
|
771
|
+
"button",
|
|
772
|
+
{
|
|
773
|
+
type: "button",
|
|
774
|
+
className: !sheetTabCode ? "is-active" : void 0,
|
|
775
|
+
"aria-pressed": !sheetTabCode,
|
|
776
|
+
onClick: () => setSheetTabCode(""),
|
|
777
|
+
children: "\u5168\u90E8"
|
|
778
|
+
}
|
|
779
|
+
),
|
|
780
|
+
allCategories.map((tab) => {
|
|
781
|
+
const isActive = sheetTabCode === tab.code;
|
|
782
|
+
return /* @__PURE__ */ jsx8(
|
|
783
|
+
"button",
|
|
784
|
+
{
|
|
785
|
+
type: "button",
|
|
786
|
+
className: isActive ? "is-active" : void 0,
|
|
787
|
+
"aria-pressed": isActive,
|
|
788
|
+
onClick: () => setSheetTabCode(tab.code),
|
|
789
|
+
children: tab.name
|
|
790
|
+
},
|
|
791
|
+
tab.code
|
|
792
|
+
);
|
|
793
|
+
})
|
|
794
|
+
] }),
|
|
795
|
+
/* @__PURE__ */ jsxs6("div", { ref: bodyRef, className: "sg-store-list-sheet__body", children: [
|
|
796
|
+
/* @__PURE__ */ jsxs6("p", { className: "sg-store-list-sheet__count", "aria-live": "polite", children: [
|
|
797
|
+
"\u5F53\u524D\u663E\u793A ",
|
|
798
|
+
filteredItems.length,
|
|
799
|
+
" \u5BB6\u95E8\u5E97"
|
|
800
|
+
] }),
|
|
801
|
+
filteredItems.length === 0 ? /* @__PURE__ */ jsx8("div", { className: "sg-store-list-sheet__empty", children: "\u6682\u65F6\u6CA1\u6709\u7B26\u5408\u6761\u4EF6\u7684\u95E8\u5E97" }) : /* @__PURE__ */ jsx8("ul", { className: "sg-store-list-sheet__list", children: filteredItems.map((item) => /* @__PURE__ */ jsx8("li", { children: /* @__PURE__ */ jsx8(
|
|
802
|
+
MerchantRow,
|
|
803
|
+
{
|
|
804
|
+
merchant: item,
|
|
805
|
+
className: "sg-store-list-sheet__item",
|
|
806
|
+
onSelect: () => onSelect(item)
|
|
807
|
+
}
|
|
808
|
+
) }, item.merchantId)) })
|
|
809
|
+
] }),
|
|
810
|
+
showFloorRail && /* @__PURE__ */ jsxs6("nav", { className: "sg-store-list-sheet__floors", "aria-label": "\u6309\u697C\u5C42\u7B5B\u9009", children: [
|
|
811
|
+
/* @__PURE__ */ jsx8(
|
|
812
|
+
"button",
|
|
813
|
+
{
|
|
814
|
+
type: "button",
|
|
815
|
+
className: !activeFloor ? "is-active" : void 0,
|
|
816
|
+
"aria-pressed": !activeFloor,
|
|
817
|
+
onClick: () => setActiveFloor(""),
|
|
818
|
+
children: "\u5168"
|
|
819
|
+
}
|
|
820
|
+
),
|
|
821
|
+
floorNames.map((floor) => /* @__PURE__ */ jsx8(
|
|
822
|
+
"button",
|
|
823
|
+
{
|
|
824
|
+
type: "button",
|
|
825
|
+
className: activeFloor === floor ? "is-active" : void 0,
|
|
826
|
+
"aria-pressed": activeFloor === floor,
|
|
827
|
+
onClick: () => setActiveFloor(floor),
|
|
828
|
+
children: floor
|
|
829
|
+
},
|
|
830
|
+
floor
|
|
831
|
+
))
|
|
832
|
+
] })
|
|
833
|
+
] })
|
|
834
|
+
] })
|
|
835
|
+
]
|
|
836
|
+
}
|
|
837
|
+
),
|
|
838
|
+
document.body
|
|
839
|
+
);
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
// src/client/cards/shop-list/index.tsx
|
|
843
|
+
import { httpGet } from "@tbox.cn/app-sdk/client";
|
|
844
|
+
import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
845
|
+
var PREVIEW_ITEM_COUNT = 3;
|
|
846
|
+
function projectSheetDataFromItem(merchant) {
|
|
847
|
+
return {
|
|
848
|
+
name: merchant.name,
|
|
849
|
+
logoUrl: merchant.logoUrl,
|
|
850
|
+
coverUrl: merchant.coverUrl,
|
|
851
|
+
brand: merchant.brand,
|
|
852
|
+
businessCategories: merchant.businessCategories,
|
|
853
|
+
location: merchant.location,
|
|
854
|
+
status: merchant.status,
|
|
855
|
+
contactInfo: merchant.contactInfo,
|
|
856
|
+
services: merchant.services,
|
|
857
|
+
itemActions: merchant.itemActions,
|
|
858
|
+
coupons: merchant.coupons
|
|
859
|
+
};
|
|
860
|
+
}
|
|
861
|
+
function projectSheetDataFromDetail(detail) {
|
|
862
|
+
return {
|
|
863
|
+
name: detail.name,
|
|
864
|
+
logoUrl: detail.logoUrl,
|
|
865
|
+
coverUrl: detail.coverUrls[0],
|
|
866
|
+
brand: detail.brand,
|
|
867
|
+
businessCategories: detail.businessCategories,
|
|
868
|
+
location: detail.location,
|
|
869
|
+
status: detail.status,
|
|
870
|
+
description: detail.description,
|
|
871
|
+
contactInfo: detail.contactInfo,
|
|
872
|
+
services: detail.services,
|
|
873
|
+
itemActions: detail.itemActions,
|
|
874
|
+
coupons: detail.coupons
|
|
875
|
+
};
|
|
876
|
+
}
|
|
877
|
+
function ShopListCard(props) {
|
|
878
|
+
const { data, cardId, isHistory, actionTokens } = props;
|
|
879
|
+
const [activeTabCode, setActiveTabCode] = useState6("");
|
|
880
|
+
const [overlay, setOverlay] = useState6({ kind: "closed" });
|
|
881
|
+
const [sheetData, setSheetData] = useState6(null);
|
|
882
|
+
const [detailLoading, setDetailLoading] = useState6(false);
|
|
883
|
+
const openedMerchantIdRef = useRef3(null);
|
|
884
|
+
const fetchControllerRef = useRef3(null);
|
|
885
|
+
const allTabs = useMemo2(() => resolveCategoryTabs(data.categoryTabs, data.items), [data.categoryTabs, data.items]);
|
|
886
|
+
const activeTab = allTabs.find((tab) => tab.code === activeTabCode);
|
|
887
|
+
const filteredItems = activeTab ? data.items.filter((item) => item.businessCategories.includes(activeTab.name)) : data.items;
|
|
888
|
+
const previewItems = filteredItems.slice(0, PREVIEW_ITEM_COUNT);
|
|
889
|
+
const closeOverlay = useCallback3(() => {
|
|
890
|
+
fetchControllerRef.current?.abort();
|
|
891
|
+
fetchControllerRef.current = null;
|
|
892
|
+
openedMerchantIdRef.current = null;
|
|
893
|
+
setDetailLoading(false);
|
|
894
|
+
setOverlay({ kind: "closed" });
|
|
895
|
+
setSheetData(null);
|
|
896
|
+
}, []);
|
|
897
|
+
const openDetail = useCallback3((merchant) => {
|
|
898
|
+
fetchControllerRef.current?.abort();
|
|
899
|
+
const controller = new AbortController();
|
|
900
|
+
fetchControllerRef.current = controller;
|
|
901
|
+
openedMerchantIdRef.current = merchant.merchantId;
|
|
902
|
+
setSheetData(projectSheetDataFromItem(merchant));
|
|
903
|
+
setOverlay({ kind: "detail", merchant });
|
|
904
|
+
const { mallId, miniAppId } = data;
|
|
905
|
+
if (!mallId || !miniAppId) {
|
|
906
|
+
setDetailLoading(false);
|
|
907
|
+
return;
|
|
908
|
+
}
|
|
909
|
+
setDetailLoading(true);
|
|
910
|
+
const url = `/api/m/shopping-guide/shop-detail?shopId=${encodeURIComponent(merchant.merchantId)}&mallId=${encodeURIComponent(mallId)}&miniAppId=${encodeURIComponent(miniAppId)}`;
|
|
911
|
+
httpGet(url, { signal: controller.signal }).then(({ data: payload }) => {
|
|
912
|
+
if (openedMerchantIdRef.current === merchant.merchantId && fetchControllerRef.current === controller) {
|
|
913
|
+
if (payload) setSheetData(projectSheetDataFromDetail(payload.data));
|
|
914
|
+
setDetailLoading(false);
|
|
915
|
+
}
|
|
916
|
+
}).catch(() => {
|
|
917
|
+
if (openedMerchantIdRef.current === merchant.merchantId && fetchControllerRef.current === controller) {
|
|
918
|
+
setDetailLoading(false);
|
|
919
|
+
}
|
|
920
|
+
});
|
|
921
|
+
}, [data]);
|
|
922
|
+
return /* @__PURE__ */ jsxs7(Fragment2, { children: [
|
|
923
|
+
/* @__PURE__ */ jsxs7("section", { className: "sg-card sg-recommend-merchants sg-shop-list", children: [
|
|
924
|
+
/* @__PURE__ */ jsx9(ShopGuideHeader, { subtitle: data.summary ?? "\u6309\u54C1\u7C7B\u5FEB\u901F\u627E\u5230\u60F3\u901B\u7684\u95E8\u5E97" }),
|
|
925
|
+
allTabs.length > 0 && /* @__PURE__ */ jsxs7("div", { className: "sg-rm-tabs", "aria-label": "\u6309\u95E8\u5E97\u54C1\u7C7B\u7B5B\u9009", children: [
|
|
926
|
+
/* @__PURE__ */ jsx9(
|
|
927
|
+
"button",
|
|
928
|
+
{
|
|
929
|
+
type: "button",
|
|
930
|
+
"aria-pressed": !activeTabCode,
|
|
931
|
+
className: `sg-rm-tab${!activeTabCode ? " sg-rm-tab--active" : ""}`,
|
|
932
|
+
onClick: () => setActiveTabCode(""),
|
|
933
|
+
children: /* @__PURE__ */ jsx9("span", { children: "\u5168\u90E8" })
|
|
934
|
+
}
|
|
935
|
+
),
|
|
936
|
+
allTabs.map((tab) => {
|
|
937
|
+
const isActive = tab.code === activeTabCode;
|
|
938
|
+
return /* @__PURE__ */ jsx9(
|
|
939
|
+
"button",
|
|
940
|
+
{
|
|
941
|
+
type: "button",
|
|
942
|
+
"aria-pressed": isActive,
|
|
943
|
+
className: `sg-rm-tab${isActive ? " sg-rm-tab--active" : ""}`,
|
|
944
|
+
onClick: () => setActiveTabCode(tab.code),
|
|
945
|
+
children: /* @__PURE__ */ jsx9("span", { children: tab.name })
|
|
946
|
+
},
|
|
947
|
+
tab.code
|
|
948
|
+
);
|
|
949
|
+
})
|
|
950
|
+
] }),
|
|
951
|
+
filteredItems.length === 0 ? /* @__PURE__ */ jsx9("div", { className: "sg-empty", children: data.noResultsReason ?? "\u6682\u65F6\u6CA1\u6709\u7B26\u5408\u6761\u4EF6\u7684\u95E8\u5E97" }) : /* @__PURE__ */ jsxs7(Fragment2, { children: [
|
|
952
|
+
/* @__PURE__ */ jsx9(ShopGuideSectionLabel, {}),
|
|
953
|
+
/* @__PURE__ */ jsx9("ul", { className: "sg-rm-list", children: previewItems.map((item) => /* @__PURE__ */ jsx9("li", { className: "sg-rm-item", children: /* @__PURE__ */ jsx9(MerchantRow, { merchant: item, onSelect: () => openDetail(item) }) }, item.merchantId)) }),
|
|
954
|
+
filteredItems.length > PREVIEW_ITEM_COUNT && /* @__PURE__ */ jsxs7(
|
|
955
|
+
"button",
|
|
956
|
+
{
|
|
957
|
+
type: "button",
|
|
958
|
+
className: "sg-rm-view-all",
|
|
959
|
+
onClick: () => setOverlay({ kind: "list" }),
|
|
960
|
+
children: [
|
|
961
|
+
"\u67E5\u770B\u5168\u90E8\u95E8\u5E97",
|
|
962
|
+
/* @__PURE__ */ jsx9(CaretRight, { size: 17 })
|
|
963
|
+
]
|
|
964
|
+
}
|
|
965
|
+
)
|
|
966
|
+
] })
|
|
967
|
+
] }),
|
|
968
|
+
/* @__PURE__ */ jsx9(
|
|
969
|
+
ShopListSheet,
|
|
970
|
+
{
|
|
971
|
+
open: overlay.kind === "list",
|
|
972
|
+
items: data.items,
|
|
973
|
+
categoryTabs: allTabs,
|
|
974
|
+
activeTabCode,
|
|
975
|
+
isHistory,
|
|
976
|
+
onSelect: openDetail,
|
|
977
|
+
onClose: closeOverlay
|
|
978
|
+
}
|
|
979
|
+
),
|
|
980
|
+
/* @__PURE__ */ jsx9(
|
|
981
|
+
ShopDetailSheet,
|
|
982
|
+
{
|
|
983
|
+
open: overlay.kind === "detail",
|
|
984
|
+
data: sheetData,
|
|
985
|
+
loading: detailLoading,
|
|
986
|
+
cardId,
|
|
987
|
+
isHistory,
|
|
988
|
+
actionTokens,
|
|
989
|
+
claimActionId: "promotion.acquire-from-shop-list",
|
|
990
|
+
onClose: closeOverlay
|
|
991
|
+
}
|
|
992
|
+
)
|
|
993
|
+
] });
|
|
994
|
+
}
|
|
995
|
+
markSelfRendering(ShopListCard);
|
|
996
|
+
var shop_list_default = ShopListCard;
|
|
997
|
+
|
|
998
|
+
// src/client/cards/shop-detail/index.tsx
|
|
999
|
+
import { useCallback as useCallback4, useRef as useRef4, useState as useState7 } from "react";
|
|
1000
|
+
import { Clock as Clock2, Phone as Phone2 } from "@phosphor-icons/react";
|
|
1001
|
+
import { httpGet as httpGet2, markSelfRendering as markSelfRendering2 } from "@tbox.cn/app-sdk/client";
|
|
1002
|
+
import { Fragment as Fragment3, jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1003
|
+
function projectSheetDataFromCardData(data) {
|
|
1004
|
+
return {
|
|
1005
|
+
name: data.name,
|
|
1006
|
+
logoUrl: data.logoUrl,
|
|
1007
|
+
coverUrl: data.coverUrls[0],
|
|
1008
|
+
brand: data.brand,
|
|
1009
|
+
businessCategories: data.businessCategories,
|
|
1010
|
+
location: data.location,
|
|
1011
|
+
status: data.status,
|
|
1012
|
+
description: data.description,
|
|
1013
|
+
contactInfo: data.contactInfo,
|
|
1014
|
+
services: data.services,
|
|
1015
|
+
itemActions: data.itemActions,
|
|
1016
|
+
coupons: data.coupons
|
|
1017
|
+
};
|
|
1018
|
+
}
|
|
1019
|
+
function ShopDetailCard(props) {
|
|
1020
|
+
const { data, cardId, isHistory, actionTokens } = props;
|
|
1021
|
+
const [sheetOpen, setSheetOpen] = useState7(false);
|
|
1022
|
+
const [sheetData, setSheetData] = useState7(null);
|
|
1023
|
+
const [detailLoading, setDetailLoading] = useState7(false);
|
|
1024
|
+
const fetchControllerRef = useRef4(null);
|
|
1025
|
+
const openDetail = useCallback4(() => {
|
|
1026
|
+
fetchControllerRef.current?.abort();
|
|
1027
|
+
const controller = new AbortController();
|
|
1028
|
+
fetchControllerRef.current = controller;
|
|
1029
|
+
setSheetData(projectSheetDataFromCardData(data));
|
|
1030
|
+
setSheetOpen(true);
|
|
1031
|
+
const { merchantId, mallId, miniAppId } = data;
|
|
1032
|
+
if (!mallId || !miniAppId) {
|
|
1033
|
+
setDetailLoading(false);
|
|
1034
|
+
return;
|
|
1035
|
+
}
|
|
1036
|
+
setDetailLoading(true);
|
|
1037
|
+
const url = `/api/m/shopping-guide/shop-detail?shopId=${encodeURIComponent(merchantId)}&mallId=${encodeURIComponent(mallId)}&miniAppId=${encodeURIComponent(miniAppId)}`;
|
|
1038
|
+
httpGet2(url, { signal: controller.signal }).then(({ data: payload }) => {
|
|
1039
|
+
if (fetchControllerRef.current === controller) {
|
|
1040
|
+
if (payload) setSheetData(projectSheetDataFromCardData(payload.data));
|
|
1041
|
+
setDetailLoading(false);
|
|
1042
|
+
}
|
|
1043
|
+
}).catch((err) => {
|
|
1044
|
+
if (fetchControllerRef.current !== controller) return;
|
|
1045
|
+
if (err instanceof Error && err.name === "AbortError") return;
|
|
1046
|
+
setDetailLoading(false);
|
|
1047
|
+
});
|
|
1048
|
+
}, [data]);
|
|
1049
|
+
const closeDetail = useCallback4(() => {
|
|
1050
|
+
fetchControllerRef.current?.abort();
|
|
1051
|
+
fetchControllerRef.current = null;
|
|
1052
|
+
setDetailLoading(false);
|
|
1053
|
+
setSheetOpen(false);
|
|
1054
|
+
setSheetData(null);
|
|
1055
|
+
}, []);
|
|
1056
|
+
const hoursText = data.contactInfo?.find((item) => /hours|营业时间/i.test(item.channel))?.value ?? "\u5468\u4E00-\u5468\u65E5 10:00-22:00";
|
|
1057
|
+
const phone = data.contactInfo?.find((item) => /phone|电话/i.test(item.channel));
|
|
1058
|
+
return /* @__PURE__ */ jsxs8(Fragment3, { children: [
|
|
1059
|
+
/* @__PURE__ */ jsxs8("section", { className: "sg-card sg-recommend-merchants sg-shop-detail", children: [
|
|
1060
|
+
/* @__PURE__ */ jsx10(ShopGuideHeader, { subtitle: data.brand ?? data.businessCategories.join(" \xB7 ") ?? "\u95E8\u5E97\u8BE6\u60C5" }),
|
|
1061
|
+
/* @__PURE__ */ jsx10("ul", { className: "sg-rm-list", children: /* @__PURE__ */ jsx10("li", { className: "sg-rm-item", children: /* @__PURE__ */ jsx10(MerchantRow, { merchant: data, onSelect: openDetail }) }) }),
|
|
1062
|
+
(hoursText || phone) && /* @__PURE__ */ jsxs8("div", { className: "sg-shop-detail__facts", children: [
|
|
1063
|
+
/* @__PURE__ */ jsxs8("span", { className: "sg-shop-detail__fact", children: [
|
|
1064
|
+
/* @__PURE__ */ jsx10(Clock2, { size: 15, weight: "duotone", "aria-hidden": "true" }),
|
|
1065
|
+
hoursText
|
|
1066
|
+
] }),
|
|
1067
|
+
phone && /* @__PURE__ */ jsxs8("span", { className: "sg-shop-detail__fact", children: [
|
|
1068
|
+
/* @__PURE__ */ jsx10(Phone2, { size: 15, weight: "duotone", "aria-hidden": "true" }),
|
|
1069
|
+
phone.value
|
|
1070
|
+
] })
|
|
1071
|
+
] })
|
|
1072
|
+
] }),
|
|
1073
|
+
/* @__PURE__ */ jsx10(
|
|
1074
|
+
ShopDetailSheet,
|
|
1075
|
+
{
|
|
1076
|
+
open: sheetOpen,
|
|
1077
|
+
data: sheetData,
|
|
1078
|
+
loading: detailLoading,
|
|
1079
|
+
cardId,
|
|
1080
|
+
isHistory,
|
|
1081
|
+
actionTokens,
|
|
1082
|
+
claimActionId: "promotion.acquire-from-shop-detail",
|
|
1083
|
+
onClose: closeDetail
|
|
1084
|
+
}
|
|
1085
|
+
)
|
|
1086
|
+
] });
|
|
1087
|
+
}
|
|
1088
|
+
markSelfRendering2(ShopDetailCard);
|
|
1089
|
+
var shop_detail_default = ShopDetailCard;
|
|
1090
|
+
|
|
1091
|
+
// src/client/cards/category-list/index.tsx
|
|
1092
|
+
import { useState as useState8 } from "react";
|
|
1093
|
+
import { CaretDown } from "@phosphor-icons/react";
|
|
1094
|
+
import { sendCardAction as sendCardAction3 } from "@tbox.cn/app-sdk/client";
|
|
1095
|
+
|
|
1096
|
+
// src/client/cards/view.ts
|
|
1097
|
+
function formatDistance(distanceKm) {
|
|
1098
|
+
if (distanceKm === void 0 || distanceKm < 0) return "\u2014";
|
|
1099
|
+
if (distanceKm < 1) return `${Math.round(distanceKm * 1e3)}m`;
|
|
1100
|
+
return `${distanceKm.toFixed(1)} km`;
|
|
1101
|
+
}
|
|
1102
|
+
function deriveLocationLevel(data) {
|
|
1103
|
+
const { location, itemActions } = data;
|
|
1104
|
+
const hasRoute = itemActions.some((a) => a.kind === "link");
|
|
1105
|
+
if (hasRoute) return "route_available";
|
|
1106
|
+
const locationComplete = Boolean(location.displayText);
|
|
1107
|
+
return locationComplete ? "location_only" : "unavailable";
|
|
1108
|
+
}
|
|
1109
|
+
var CATEGORY_ICONS = {
|
|
1110
|
+
// 英文 key
|
|
1111
|
+
food: "\u{1F35C}",
|
|
1112
|
+
restaurant: "\u{1F35C}",
|
|
1113
|
+
dining: "\u{1F35C}",
|
|
1114
|
+
drinks: "\u{1F964}",
|
|
1115
|
+
beverage: "\u{1F964}",
|
|
1116
|
+
fashion: "\u{1F457}",
|
|
1117
|
+
clothing: "\u{1F457}",
|
|
1118
|
+
apparel: "\u{1F457}",
|
|
1119
|
+
beauty: "\u{1F484}",
|
|
1120
|
+
cosmetics: "\u{1F484}",
|
|
1121
|
+
supermarket: "\u{1F6D2}",
|
|
1122
|
+
groceries: "\u{1F6D2}",
|
|
1123
|
+
cinema: "\u{1F3AC}",
|
|
1124
|
+
entertainment: "\u{1F3AE}",
|
|
1125
|
+
kids: "\u{1F9F8}",
|
|
1126
|
+
children: "\u{1F9F8}",
|
|
1127
|
+
parent_child: "\u{1F9F8}",
|
|
1128
|
+
sports: "\u{1F3C3}",
|
|
1129
|
+
fitness: "\u{1F4AA}",
|
|
1130
|
+
electronics: "\u{1F4F1}",
|
|
1131
|
+
digital: "\u{1F4F1}",
|
|
1132
|
+
home: "\u{1F6CB}\uFE0F",
|
|
1133
|
+
furniture: "\u{1F6CB}\uFE0F",
|
|
1134
|
+
jewelry: "\u{1F48D}",
|
|
1135
|
+
gold: "\u{1F48D}",
|
|
1136
|
+
watch: "\u231A",
|
|
1137
|
+
eyewear: "\u{1F453}",
|
|
1138
|
+
books: "\u{1F4DA}",
|
|
1139
|
+
education: "\u{1F4D6}",
|
|
1140
|
+
hotel: "\u{1F3E8}",
|
|
1141
|
+
travel: "\u{1F9F3}",
|
|
1142
|
+
service: "\u{1F9FE}",
|
|
1143
|
+
lifestyle: "\u{1F9FE}",
|
|
1144
|
+
parking: "\u{1F17F}\uFE0F",
|
|
1145
|
+
car: "\u{1F697}",
|
|
1146
|
+
pharmacy: "\u{1F48A}",
|
|
1147
|
+
healthcare: "\u{1F48A}",
|
|
1148
|
+
flower: "\u{1F490}",
|
|
1149
|
+
pet: "\u{1F43E}",
|
|
1150
|
+
exhibition: "\u{1F5BC}\uFE0F",
|
|
1151
|
+
office: "\u{1F3E2}"
|
|
1152
|
+
};
|
|
1153
|
+
var CATEGORY_ICONS_ZH = [
|
|
1154
|
+
["\u9910\u996E", "\u{1F35C}"],
|
|
1155
|
+
["\u7F8E\u98DF", "\u{1F35C}"],
|
|
1156
|
+
["\u5496\u5561", "\u2615"],
|
|
1157
|
+
["\u8336\u996E", "\u{1F9CB}"],
|
|
1158
|
+
["\u5976\u8336", "\u{1F9CB}"],
|
|
1159
|
+
["\u996E\u54C1", "\u{1F964}"],
|
|
1160
|
+
["\u96F6\u552E", "\u{1F6CD}\uFE0F"],
|
|
1161
|
+
["\u65F6\u5C1A", "\u{1F457}"],
|
|
1162
|
+
["\u670D\u88C5", "\u{1F457}"],
|
|
1163
|
+
["\u5973\u88C5", "\u{1F457}"],
|
|
1164
|
+
["\u7537\u88C5", "\u{1F9E5}"],
|
|
1165
|
+
["\u8FD0\u52A8", "\u{1F3C3}"],
|
|
1166
|
+
["\u5065\u8EAB", "\u{1F4AA}"],
|
|
1167
|
+
["\u7F8E\u5986", "\u{1F484}"],
|
|
1168
|
+
["\u62A4\u80A4", "\u{1F9F4}"],
|
|
1169
|
+
["\u7F8E\u5BB9", "\u{1F486}"],
|
|
1170
|
+
["\u6BCD\u5A74", "\u{1F9F8}"],
|
|
1171
|
+
["\u513F\u7AE5", "\u{1F9F8}"],
|
|
1172
|
+
["\u4EB2\u5B50", "\u{1F9F8}"],
|
|
1173
|
+
["\u8D85\u5E02", "\u{1F6D2}"],
|
|
1174
|
+
["\u4FBF\u5229", "\u{1F6D2}"],
|
|
1175
|
+
["\u751F\u9C9C", "\u{1F966}"],
|
|
1176
|
+
["\u6570\u7801", "\u{1F4F1}"],
|
|
1177
|
+
["\u7535\u5B50", "\u{1F4F1}"],
|
|
1178
|
+
["\u5BB6\u5C45", "\u{1F6CB}\uFE0F"],
|
|
1179
|
+
["\u5BB6\u7535", "\u{1F50C}"],
|
|
1180
|
+
["\u73E0\u5B9D", "\u{1F48D}"],
|
|
1181
|
+
["\u9EC4\u91D1", "\u{1F3C5}"],
|
|
1182
|
+
["\u624B\u8868", "\u231A"],
|
|
1183
|
+
["\u773C\u955C", "\u{1F453}"],
|
|
1184
|
+
["\u4E66\u5E97", "\u{1F4DA}"],
|
|
1185
|
+
["\u6587\u5177", "\u270F\uFE0F"],
|
|
1186
|
+
["\u6559\u80B2", "\u{1F4D6}"],
|
|
1187
|
+
["\u57F9\u8BAD", "\u{1F4D6}"],
|
|
1188
|
+
["\u5F71\u9662", "\u{1F3AC}"],
|
|
1189
|
+
["\u7535\u5F71", "\u{1F3AC}"],
|
|
1190
|
+
["\u5A31\u4E50", "\u{1F3AE}"],
|
|
1191
|
+
["\u6E38\u620F", "\u{1F3AE}"],
|
|
1192
|
+
["\u6587\u4F53", "\u{1F3AD}"],
|
|
1193
|
+
["\u6587\u5316", "\u{1F3A8}"],
|
|
1194
|
+
["\u827A\u672F", "\u{1F3A8}"],
|
|
1195
|
+
["\u5BA0\u7269", "\u{1F43E}"],
|
|
1196
|
+
["\u9C9C\u82B1", "\u{1F490}"],
|
|
1197
|
+
["\u533B\u7597", "\u{1F48A}"],
|
|
1198
|
+
["\u836F\u5E97", "\u{1F48A}"],
|
|
1199
|
+
["\u5065\u5EB7", "\u{1F3E5}"],
|
|
1200
|
+
["\u9152\u5E97", "\u{1F3E8}"],
|
|
1201
|
+
["\u65C5\u884C", "\u{1F9F3}"],
|
|
1202
|
+
["\u505C\u8F66", "\u{1F17F}\uFE0F"],
|
|
1203
|
+
["\u6C7D\u8F66", "\u{1F697}"],
|
|
1204
|
+
["\u670D\u52A1", "\u{1F9FE}"],
|
|
1205
|
+
["\u751F\u6D3B", "\u{1F9FE}"],
|
|
1206
|
+
["\u94F6\u884C", "\u{1F3E6}"],
|
|
1207
|
+
["\u91D1\u878D", "\u{1F4B3}"],
|
|
1208
|
+
["\u672A\u5F52\u7C7B", "\u{1F3EA}"]
|
|
1209
|
+
];
|
|
1210
|
+
function categoryIcon(code) {
|
|
1211
|
+
const key = code.toLowerCase();
|
|
1212
|
+
if (CATEGORY_ICONS[key]) return CATEGORY_ICONS[key];
|
|
1213
|
+
for (const [k, icon] of Object.entries(CATEGORY_ICONS)) {
|
|
1214
|
+
if (key.startsWith(k)) return icon;
|
|
1215
|
+
}
|
|
1216
|
+
for (const [keyword, icon] of CATEGORY_ICONS_ZH) {
|
|
1217
|
+
if (code.includes(keyword)) return icon;
|
|
1218
|
+
}
|
|
1219
|
+
return "\u{1F3EA}";
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
// src/client/cards/category-list/index.tsx
|
|
1223
|
+
import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1224
|
+
var PAGE = 9;
|
|
1225
|
+
function CategoryListCard(props) {
|
|
1226
|
+
const { data, cardId, isHistory } = props;
|
|
1227
|
+
const [expanded, setExpanded] = useState8(false);
|
|
1228
|
+
const collapsible = data.categories.length > PAGE;
|
|
1229
|
+
const visible = collapsible && !expanded ? data.categories.slice(0, PAGE) : data.categories;
|
|
1230
|
+
function handleCategoryClick(c) {
|
|
1231
|
+
if (isHistory) return;
|
|
1232
|
+
const sendAction = c.itemActions?.find((a) => a.kind === "send");
|
|
1233
|
+
sendCardAction3(cardId, {
|
|
1234
|
+
type: "sendMessage",
|
|
1235
|
+
value: sendAction?.value ?? sendAction?.label ?? `\u67E5\u770B${c.name}\u7684\u95E8\u5E97\u5217\u8868`,
|
|
1236
|
+
visible: true
|
|
1237
|
+
});
|
|
1238
|
+
}
|
|
1239
|
+
return /* @__PURE__ */ jsxs9("section", { className: "sg-card sg-category-list", children: [
|
|
1240
|
+
/* @__PURE__ */ jsx11("div", { className: "sg-card-title", children: "\u4E1A\u6001\u5206\u7C7B" }),
|
|
1241
|
+
/* @__PURE__ */ jsx11("ul", { className: "sg-category-grid", children: visible.map((c) => /* @__PURE__ */ jsx11("li", { children: /* @__PURE__ */ jsxs9(
|
|
1242
|
+
"button",
|
|
1243
|
+
{
|
|
1244
|
+
type: "button",
|
|
1245
|
+
className: "sg-category-cell",
|
|
1246
|
+
disabled: isHistory,
|
|
1247
|
+
onClick: () => handleCategoryClick(c),
|
|
1248
|
+
"aria-label": `\u67E5\u770B${c.name}\uFF08${c.merchantCount} \u5BB6\u95E8\u5E97\uFF09`,
|
|
1249
|
+
children: [
|
|
1250
|
+
/* @__PURE__ */ jsx11("span", { className: "sg-category-icon-wrap", "aria-hidden": "true", children: /* @__PURE__ */ jsx11("span", { className: "sg-category-icon", children: categoryIcon(c.code) }) }),
|
|
1251
|
+
/* @__PURE__ */ jsx11("span", { className: "sg-category-name", children: c.name }),
|
|
1252
|
+
c.merchantCount > 0 && /* @__PURE__ */ jsxs9("span", { className: "sg-category-count", children: [
|
|
1253
|
+
c.merchantCount,
|
|
1254
|
+
" \u5BB6"
|
|
1255
|
+
] })
|
|
1256
|
+
]
|
|
1257
|
+
}
|
|
1258
|
+
) }, c.code)) }),
|
|
1259
|
+
collapsible && /* @__PURE__ */ jsxs9(
|
|
1260
|
+
"button",
|
|
1261
|
+
{
|
|
1262
|
+
type: "button",
|
|
1263
|
+
className: "sg-category-toggle",
|
|
1264
|
+
"aria-expanded": expanded,
|
|
1265
|
+
onClick: () => setExpanded((v) => !v),
|
|
1266
|
+
children: [
|
|
1267
|
+
/* @__PURE__ */ jsx11(
|
|
1268
|
+
CaretDown,
|
|
1269
|
+
{
|
|
1270
|
+
size: 14,
|
|
1271
|
+
className: "sg-category-toggle__icon",
|
|
1272
|
+
"data-rotated": expanded || void 0
|
|
1273
|
+
}
|
|
1274
|
+
),
|
|
1275
|
+
expanded ? "\u6536\u8D77" : `\u5C55\u5F00\u5168\u90E8 ${data.categories.length} \u7C7B`
|
|
1276
|
+
]
|
|
1277
|
+
}
|
|
1278
|
+
),
|
|
1279
|
+
data.buildings && data.buildings.length > 0 && /* @__PURE__ */ jsxs9("div", { className: "sg-category-floors", children: [
|
|
1280
|
+
/* @__PURE__ */ jsx11("div", { className: "sg-category-floors__title", children: "\u697C\u5C42\u5BFC\u89C8" }),
|
|
1281
|
+
data.buildings.map((building) => /* @__PURE__ */ jsxs9("div", { className: "sg-category-floors__building", children: [
|
|
1282
|
+
data.buildings.length > 1 && /* @__PURE__ */ jsx11("div", { className: "sg-category-floors__building-name", children: building.buildingName }),
|
|
1283
|
+
/* @__PURE__ */ jsx11("div", { className: "sg-category-floors__floor-list", children: building.floors.map((floor) => /* @__PURE__ */ jsxs9(
|
|
1284
|
+
"button",
|
|
1285
|
+
{
|
|
1286
|
+
type: "button",
|
|
1287
|
+
className: "sg-category-floor-chip",
|
|
1288
|
+
disabled: isHistory,
|
|
1289
|
+
onClick: () => {
|
|
1290
|
+
if (isHistory) return;
|
|
1291
|
+
sendCardAction3(cardId, {
|
|
1292
|
+
type: "sendMessage",
|
|
1293
|
+
value: `\u5C55\u793A\u5546\u573A${building.buildingName}${floor.floorName}\u7684\u95E8\u5E97\u5217\u8868`,
|
|
1294
|
+
visible: true
|
|
1295
|
+
});
|
|
1296
|
+
},
|
|
1297
|
+
children: [
|
|
1298
|
+
/* @__PURE__ */ jsx11("span", { className: "sg-category-floor-chip__name", children: floor.floorName }),
|
|
1299
|
+
floor.merchantCount > 0 && /* @__PURE__ */ jsx11("span", { className: "sg-category-floor-chip__count", children: floor.merchantCount })
|
|
1300
|
+
]
|
|
1301
|
+
},
|
|
1302
|
+
floor.floorCode
|
|
1303
|
+
)) })
|
|
1304
|
+
] }, building.buildingCode))
|
|
1305
|
+
] })
|
|
1306
|
+
] });
|
|
1307
|
+
}
|
|
1308
|
+
var category_list_default = CategoryListCard;
|
|
1309
|
+
|
|
1310
|
+
// src/client/cards/product-comparison/index.tsx
|
|
1311
|
+
import { useEffect as useEffect3, useState as useState9 } from "react";
|
|
1312
|
+
import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1313
|
+
function ProductComparisonCard(props) {
|
|
1314
|
+
const { data } = props;
|
|
1315
|
+
const [stale, setStale] = useState9(false);
|
|
1316
|
+
useEffect3(() => {
|
|
1317
|
+
if (!data.refreshRequiredAt) return;
|
|
1318
|
+
const deadline = new Date(data.refreshRequiredAt).getTime();
|
|
1319
|
+
const delay = Math.max(0, deadline - Date.now());
|
|
1320
|
+
const timer = window.setTimeout(() => setStale(true), delay);
|
|
1321
|
+
return () => window.clearTimeout(timer);
|
|
1322
|
+
}, [data.refreshRequiredAt]);
|
|
1323
|
+
const attrNames = Array.from(new Set(data.products.flatMap((p) => p.attributes.map((a) => a.name))));
|
|
1324
|
+
return /* @__PURE__ */ jsxs10("section", { className: `sg-card sg-product-comparison${stale ? " sg-product-comparison--stale" : ""}`, children: [
|
|
1325
|
+
/* @__PURE__ */ jsx12("div", { className: "sg-card-title", children: "\u5546\u54C1\u5BF9\u6BD4" }),
|
|
1326
|
+
stale && /* @__PURE__ */ jsx12("div", { className: "sg-stale-notice", children: /* @__PURE__ */ jsx12("span", { children: "\u5BF9\u6BD4\u6570\u636E\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0\u53D1\u8D77\u5BF9\u6BD4" }) }),
|
|
1327
|
+
/* @__PURE__ */ jsx12("div", { className: "sg-compare-wrap", children: /* @__PURE__ */ jsxs10("table", { className: "sg-compare", children: [
|
|
1328
|
+
/* @__PURE__ */ jsx12("thead", { children: /* @__PURE__ */ jsxs10("tr", { children: [
|
|
1329
|
+
/* @__PURE__ */ jsx12("th", { scope: "col", className: "sg-compare__label" }),
|
|
1330
|
+
data.products.map((p) => /* @__PURE__ */ jsxs10("th", { scope: "col", children: [
|
|
1331
|
+
/* @__PURE__ */ jsx12(ImageWithFallback, { src: p.imageUrl, alt: p.name, className: "sg-compare__img", size: 40 }),
|
|
1332
|
+
/* @__PURE__ */ jsx12("div", { className: "sg-compare__name", children: p.name }),
|
|
1333
|
+
/* @__PURE__ */ jsx12("div", { className: "sg-price-sale", children: p.price.sale?.display ?? "\u2014" })
|
|
1334
|
+
] }, p.productId))
|
|
1335
|
+
] }) }),
|
|
1336
|
+
/* @__PURE__ */ jsxs10("tbody", { children: [
|
|
1337
|
+
/* @__PURE__ */ jsxs10("tr", { children: [
|
|
1338
|
+
/* @__PURE__ */ jsx12("th", { scope: "row", className: "sg-compare__label", children: "\u5E93\u5B58" }),
|
|
1339
|
+
data.products.map((p) => /* @__PURE__ */ jsx12("td", { children: /* @__PURE__ */ jsx12("span", { className: `sg-availability sg-availability-${p.availability.status}`, children: p.availability.label }) }, p.productId))
|
|
1340
|
+
] }),
|
|
1341
|
+
attrNames.map((name) => /* @__PURE__ */ jsxs10("tr", { children: [
|
|
1342
|
+
/* @__PURE__ */ jsx12("th", { scope: "row", className: "sg-compare__label", children: name }),
|
|
1343
|
+
data.products.map((p) => {
|
|
1344
|
+
const attr = p.attributes.find((a) => a.name === name);
|
|
1345
|
+
return /* @__PURE__ */ jsx12("td", { className: attr ? "" : "sg-compare__cell-empty", children: attr?.value ?? "\u2014" }, p.productId);
|
|
1346
|
+
})
|
|
1347
|
+
] }, name))
|
|
1348
|
+
] })
|
|
1349
|
+
] }) }),
|
|
1350
|
+
data.products.some((p) => p.caveats.length > 0) && /* @__PURE__ */ jsx12("div", { className: "sg-item-caveats", children: data.products.flatMap((p) => p.caveats.map((c, i) => ({ key: `${p.productId}-${i}`, text: c }))).map(({ key, text }) => /* @__PURE__ */ jsxs10("div", { className: "sg-caveat-item", children: [
|
|
1351
|
+
"\u26A0\uFE0F ",
|
|
1352
|
+
text
|
|
1353
|
+
] }, key)) }),
|
|
1354
|
+
/* @__PURE__ */ jsx12("span", { className: "sg-compare__stale-marker", hidden: !stale, children: "\u5BF9\u6BD4\u6570\u636E\u53EF\u80FD\u5DF2\u8FC7\u671F" })
|
|
1355
|
+
] });
|
|
1356
|
+
}
|
|
1357
|
+
var product_comparison_default = ProductComparisonCard;
|
|
1358
|
+
|
|
1359
|
+
// src/client/cards/mall-directory/index.tsx
|
|
1360
|
+
import { useState as useState10 } from "react";
|
|
1361
|
+
import { CaretDown as CaretDown2, Storefront as Storefront2 } from "@phosphor-icons/react";
|
|
1362
|
+
import { sendCardAction as sendCardAction4 } from "@tbox.cn/app-sdk/client";
|
|
1363
|
+
import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1364
|
+
function MallDirectoryCard(props) {
|
|
1365
|
+
const { data, cardId, isHistory } = props;
|
|
1366
|
+
const [openBuilding, setOpenBuilding] = useState10(
|
|
1367
|
+
data.buildings.length > 0 ? data.buildings[0].buildingCode : null
|
|
1368
|
+
);
|
|
1369
|
+
return /* @__PURE__ */ jsxs11("section", { className: "sg-card sg-mall-directory", children: [
|
|
1370
|
+
/* @__PURE__ */ jsxs11("div", { className: "sg-card-title", children: [
|
|
1371
|
+
data.mallName,
|
|
1372
|
+
" \xB7 \u697C\u5C42\u76EE\u5F55"
|
|
1373
|
+
] }),
|
|
1374
|
+
data.buildings.map((b) => {
|
|
1375
|
+
const open = openBuilding === b.buildingCode;
|
|
1376
|
+
return /* @__PURE__ */ jsxs11("div", { className: "sg-dir-building", children: [
|
|
1377
|
+
/* @__PURE__ */ jsxs11(
|
|
1378
|
+
"button",
|
|
1379
|
+
{
|
|
1380
|
+
type: "button",
|
|
1381
|
+
className: "sg-dir-building__head",
|
|
1382
|
+
"aria-expanded": open,
|
|
1383
|
+
onClick: () => setOpenBuilding(open ? null : b.buildingCode),
|
|
1384
|
+
children: [
|
|
1385
|
+
/* @__PURE__ */ jsx13(Storefront2, { size: 18 }),
|
|
1386
|
+
/* @__PURE__ */ jsx13("span", { className: "sg-dir-building__name", children: b.buildingName }),
|
|
1387
|
+
/* @__PURE__ */ jsxs11("span", { className: "sg-dir-building__count", children: [
|
|
1388
|
+
b.floors.length,
|
|
1389
|
+
" \u5C42"
|
|
1390
|
+
] }),
|
|
1391
|
+
/* @__PURE__ */ jsx13(CaretDown2, { size: 16, className: "sg-dir-building__chevron", "data-rotated": open || void 0 })
|
|
1392
|
+
]
|
|
1393
|
+
}
|
|
1394
|
+
),
|
|
1395
|
+
open && /* @__PURE__ */ jsx13("ul", { className: "sg-dir-floors", children: b.floors.map((f) => /* @__PURE__ */ jsxs11("li", { className: "sg-dir-floor", children: [
|
|
1396
|
+
/* @__PURE__ */ jsxs11("div", { className: "sg-dir-floor__info", children: [
|
|
1397
|
+
/* @__PURE__ */ jsx13("span", { className: "sg-dir-floor__name", children: f.floorName }),
|
|
1398
|
+
/* @__PURE__ */ jsx13("span", { className: "sg-dir-floor__cats", children: f.businessCategories.join(" / ") || `${f.merchantCount} \u5BB6\u5546\u6237` })
|
|
1399
|
+
] }),
|
|
1400
|
+
f.itemActions && f.itemActions.length > 0 && /* @__PURE__ */ jsx13(
|
|
1401
|
+
"button",
|
|
1402
|
+
{
|
|
1403
|
+
type: "button",
|
|
1404
|
+
className: "sg-chip sg-dir-floor__action",
|
|
1405
|
+
disabled: isHistory,
|
|
1406
|
+
onClick: () => {
|
|
1407
|
+
if (isHistory) return;
|
|
1408
|
+
const a = f.itemActions[0];
|
|
1409
|
+
sendCardAction4(
|
|
1410
|
+
cardId,
|
|
1411
|
+
a.kind === "send" ? { type: "sendMessage", value: a.value ?? a.label, visible: true } : { type: "openLink", url: a.url }
|
|
1412
|
+
);
|
|
1413
|
+
},
|
|
1414
|
+
children: f.itemActions[0].label
|
|
1415
|
+
}
|
|
1416
|
+
)
|
|
1417
|
+
] }, f.floorCode)) })
|
|
1418
|
+
] }, b.buildingCode);
|
|
1419
|
+
})
|
|
1420
|
+
] });
|
|
1421
|
+
}
|
|
1422
|
+
var mall_directory_default = MallDirectoryCard;
|
|
1423
|
+
|
|
1424
|
+
// src/client/cards/nearby-mall-list/index.tsx
|
|
1425
|
+
import { ItemActionsRow as ItemActionsRow4 } from "@tbox.cn/app-sdk/client";
|
|
1426
|
+
import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1427
|
+
function NearbyMallListCard(props) {
|
|
1428
|
+
const { data, cardId, isHistory } = props;
|
|
1429
|
+
if (data.malls.length === 0) {
|
|
1430
|
+
return /* @__PURE__ */ jsx14("section", { className: "sg-card", children: /* @__PURE__ */ jsx14("div", { className: "sg-empty", children: "\u6682\u65E0\u9644\u8FD1\u5546\u573A" }) });
|
|
1431
|
+
}
|
|
1432
|
+
return /* @__PURE__ */ jsxs12("section", { className: "sg-card sg-nearby-malls", children: [
|
|
1433
|
+
/* @__PURE__ */ jsx14("div", { className: "sg-card-title", children: "\u9644\u8FD1\u5546\u573A" }),
|
|
1434
|
+
data.query && /* @__PURE__ */ jsxs12("div", { className: "sg-card-summary", children: [
|
|
1435
|
+
"\u67E5\u8BE2\u300C",
|
|
1436
|
+
data.query,
|
|
1437
|
+
"\u300D"
|
|
1438
|
+
] }),
|
|
1439
|
+
/* @__PURE__ */ jsx14("ul", { className: "sg-nearby-list", children: data.malls.map((m) => /* @__PURE__ */ jsxs12("li", { className: "sg-nearby-item", children: [
|
|
1440
|
+
/* @__PURE__ */ jsxs12("div", { className: "sg-nearby-item__head", children: [
|
|
1441
|
+
/* @__PURE__ */ jsx14("span", { className: "sg-merchant-name", children: m.name }),
|
|
1442
|
+
/* @__PURE__ */ jsx14("span", { className: `sg-status sg-status-${m.status.code}`, children: m.status.label })
|
|
1443
|
+
] }),
|
|
1444
|
+
/* @__PURE__ */ jsxs12("div", { className: "sg-nearby-item__meta", children: [
|
|
1445
|
+
/* @__PURE__ */ jsx14("span", { children: m.address }),
|
|
1446
|
+
/* @__PURE__ */ jsx14("span", { className: "sg-nearby-item__distance", children: formatDistance(m.distanceKm) })
|
|
1447
|
+
] }),
|
|
1448
|
+
/* @__PURE__ */ jsx14(ItemActionsRow4, { actions: m.itemActions, cardId, isHistory, className: "sg-item-actions", chipClassName: "sg-chip" })
|
|
1449
|
+
] }, m.mallId)) })
|
|
1450
|
+
] });
|
|
1451
|
+
}
|
|
1452
|
+
var nearby_mall_list_default = NearbyMallListCard;
|
|
1453
|
+
|
|
1454
|
+
// src/client/cards/human-guide-list/index.tsx
|
|
1455
|
+
import { sendCardAction as sendCardAction5 } from "@tbox.cn/app-sdk/client";
|
|
1456
|
+
import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1457
|
+
function HumanGuideListCard(props) {
|
|
1458
|
+
const { data, cardId, isHistory } = props;
|
|
1459
|
+
return /* @__PURE__ */ jsxs13("section", { className: "sg-card sg-human-guide", children: [
|
|
1460
|
+
/* @__PURE__ */ jsxs13("div", { className: "sg-card-title", children: [
|
|
1461
|
+
data.merchantName,
|
|
1462
|
+
" \xB7 \u4EBA\u5DE5\u5BFC\u8D2D"
|
|
1463
|
+
] }),
|
|
1464
|
+
data.guides.length === 0 ? /* @__PURE__ */ jsx15("div", { className: "sg-empty", children: "\u6682\u65E0\u5BFC\u8D2D\u5458\u4FE1\u606F" }) : /* @__PURE__ */ jsx15("ul", { className: "sg-guide-list", children: data.guides.map((g) => {
|
|
1465
|
+
const contact = g.itemActions[0];
|
|
1466
|
+
const contactDisabled = isHistory || !contact;
|
|
1467
|
+
return /* @__PURE__ */ jsxs13("li", { className: "sg-guide-item", children: [
|
|
1468
|
+
/* @__PURE__ */ jsx15(ImageWithFallback, { src: g.avatarUrl, alt: g.name, className: "sg-guide-avatar", size: 48 }),
|
|
1469
|
+
/* @__PURE__ */ jsxs13("div", { className: "sg-guide-info", children: [
|
|
1470
|
+
/* @__PURE__ */ jsxs13("div", { className: "sg-guide-head", children: [
|
|
1471
|
+
/* @__PURE__ */ jsx15("span", { className: "sg-merchant-name", children: g.name }),
|
|
1472
|
+
/* @__PURE__ */ jsx15("span", { className: `sg-status sg-status-${g.available ? "available" : "offline"}`, children: g.available ? "\u5728\u7EBF" : "\u79BB\u7EBF" })
|
|
1473
|
+
] }),
|
|
1474
|
+
g.title && /* @__PURE__ */ jsx15("div", { className: "sg-guide-title", children: g.title }),
|
|
1475
|
+
g.contactInfo && g.contactInfo.length > 0 && /* @__PURE__ */ jsx15("div", { className: "sg-guide-channels", children: g.contactInfo.map((c, i) => /* @__PURE__ */ jsx15("span", { className: "sg-guide-channel", children: c.channel }, i)) })
|
|
1476
|
+
] }),
|
|
1477
|
+
/* @__PURE__ */ jsx15(
|
|
1478
|
+
"button",
|
|
1479
|
+
{
|
|
1480
|
+
type: "button",
|
|
1481
|
+
className: "sg-guide-contact",
|
|
1482
|
+
disabled: contactDisabled,
|
|
1483
|
+
title: contact ? contact.label : "\u6682\u65E0\u53EF\u7528\u7684\u8054\u7CFB\u65B9\u5F0F",
|
|
1484
|
+
onClick: () => {
|
|
1485
|
+
if (!contact || isHistory) return;
|
|
1486
|
+
sendCardAction5(
|
|
1487
|
+
cardId,
|
|
1488
|
+
contact.kind === "send" ? { type: "sendMessage", value: contact.value ?? contact.label, visible: true } : { type: "openLink", url: contact.url }
|
|
1489
|
+
);
|
|
1490
|
+
},
|
|
1491
|
+
children: contact?.label ?? "\u8054\u7CFB"
|
|
1492
|
+
}
|
|
1493
|
+
)
|
|
1494
|
+
] }, g.guideId);
|
|
1495
|
+
}) }),
|
|
1496
|
+
/* @__PURE__ */ jsx15("p", { className: "sg-guide-privacy", children: "\u5BFC\u8D2D\u4FE1\u606F\u7531\u95E8\u5E97\u63D0\u4F9B\uFF0C\u8054\u7CFB\u65B9\u5F0F\u4EC5\u7528\u4E8E\u672C\u6B21\u54A8\u8BE2" })
|
|
1497
|
+
] });
|
|
1498
|
+
}
|
|
1499
|
+
var human_guide_list_default = HumanGuideListCard;
|
|
1500
|
+
|
|
1501
|
+
// src/client/cards/location-handoff/index.tsx
|
|
1502
|
+
import { MapPin as MapPin3, NavigationArrow } from "@phosphor-icons/react";
|
|
1503
|
+
import { sendCardAction as sendCardAction6 } from "@tbox.cn/app-sdk/client";
|
|
1504
|
+
import { jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1505
|
+
function LocationHandoffCard(props) {
|
|
1506
|
+
const { data, cardId } = props;
|
|
1507
|
+
const level = deriveLocationLevel({ location: data.location, itemActions: data.itemActions });
|
|
1508
|
+
const navAction = data.itemActions.find((a) => a.kind === "link");
|
|
1509
|
+
return /* @__PURE__ */ jsxs14("section", { className: "sg-card sg-location-handoff", children: [
|
|
1510
|
+
/* @__PURE__ */ jsxs14("div", { className: "sg-card-title", children: [
|
|
1511
|
+
data.merchantName,
|
|
1512
|
+
" \xB7 \u4F4D\u7F6E"
|
|
1513
|
+
] }),
|
|
1514
|
+
data.mapUrl && /* @__PURE__ */ jsx16(ImageWithFallback, { src: data.mapUrl, alt: `${data.merchantName} \u4F4D\u7F6E\u793A\u610F`, className: "sg-lh-map", size: 88 }),
|
|
1515
|
+
/* @__PURE__ */ jsxs14("div", { className: "sg-lh-address", children: [
|
|
1516
|
+
/* @__PURE__ */ jsx16(MapPin3, { size: 16 }),
|
|
1517
|
+
/* @__PURE__ */ jsx16("span", { children: data.location.displayText })
|
|
1518
|
+
] }),
|
|
1519
|
+
(data.location.buildingName || data.location.floorName || data.location.unitName) && /* @__PURE__ */ jsxs14("div", { className: "sg-lh-detail", children: [
|
|
1520
|
+
data.location.buildingName && /* @__PURE__ */ jsx16("span", { children: data.location.buildingName }),
|
|
1521
|
+
data.location.floorName && /* @__PURE__ */ jsx16("span", { children: data.location.floorName }),
|
|
1522
|
+
data.location.unitName && /* @__PURE__ */ jsx16("span", { children: data.location.unitName })
|
|
1523
|
+
] }),
|
|
1524
|
+
level === "route_available" && navAction && /* @__PURE__ */ jsxs14(
|
|
1525
|
+
"button",
|
|
1526
|
+
{
|
|
1527
|
+
type: "button",
|
|
1528
|
+
className: "sg-lh-nav",
|
|
1529
|
+
onClick: () => {
|
|
1530
|
+
sendCardAction6(cardId, { type: "openLink", url: navAction.url });
|
|
1531
|
+
},
|
|
1532
|
+
children: [
|
|
1533
|
+
/* @__PURE__ */ jsx16(NavigationArrow, { size: 16 }),
|
|
1534
|
+
navAction.label
|
|
1535
|
+
]
|
|
1536
|
+
}
|
|
1537
|
+
)
|
|
1538
|
+
] });
|
|
1539
|
+
}
|
|
1540
|
+
var location_handoff_default = LocationHandoffCard;
|
|
1541
|
+
|
|
1542
|
+
// src/client/cards/recommend-merchants/index.tsx
|
|
1543
|
+
import { useCallback as useCallback5, useMemo as useMemo3, useState as useState11 } from "react";
|
|
1544
|
+
import { CaretRight as CaretRight2 } from "@phosphor-icons/react";
|
|
1545
|
+
import { Fragment as Fragment4, jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1546
|
+
var PREVIEW_ITEM_COUNT2 = 3;
|
|
1547
|
+
function RecommendMerchantsCard(props) {
|
|
1548
|
+
const { data, cardId, isHistory } = props;
|
|
1549
|
+
const [activeTabCode, setActiveTabCode] = useState11("");
|
|
1550
|
+
const [overlay, setOverlay] = useState11({ kind: "closed" });
|
|
1551
|
+
const visibleTabs = useMemo3(() => resolveCategoryTabs(data.categoryTabs, data.items), [data.categoryTabs, data.items]);
|
|
1552
|
+
function getFilteredItems() {
|
|
1553
|
+
if (!activeTabCode) return data.items;
|
|
1554
|
+
const activeTab = visibleTabs.find((tab) => tab.code === activeTabCode);
|
|
1555
|
+
if (!activeTab) return data.items;
|
|
1556
|
+
return data.items.filter((item) => item.businessCategories.includes(activeTab.name));
|
|
1557
|
+
}
|
|
1558
|
+
const filteredItems = getFilteredItems();
|
|
1559
|
+
const previewItems = filteredItems.slice(0, PREVIEW_ITEM_COUNT2);
|
|
1560
|
+
const selectedMerchant = overlay.kind === "detail" ? overlay.merchant : null;
|
|
1561
|
+
const detailData = useMemo3(() => selectedMerchant ? {
|
|
1562
|
+
name: selectedMerchant.name,
|
|
1563
|
+
logoUrl: selectedMerchant.logoUrl,
|
|
1564
|
+
coverUrl: selectedMerchant.coverUrl,
|
|
1565
|
+
brand: selectedMerchant.brand,
|
|
1566
|
+
businessCategories: selectedMerchant.businessCategories,
|
|
1567
|
+
location: selectedMerchant.location,
|
|
1568
|
+
status: selectedMerchant.status,
|
|
1569
|
+
rating: selectedMerchant.rating,
|
|
1570
|
+
avgSpend: selectedMerchant.avgSpend,
|
|
1571
|
+
operatingStatus: selectedMerchant.operatingStatus,
|
|
1572
|
+
description: selectedMerchant.description,
|
|
1573
|
+
contactInfo: selectedMerchant.contactInfo,
|
|
1574
|
+
services: selectedMerchant.services,
|
|
1575
|
+
itemActions: selectedMerchant.itemActions
|
|
1576
|
+
} : null, [selectedMerchant]);
|
|
1577
|
+
const closeOverlay = useCallback5(() => setOverlay({ kind: "closed" }), []);
|
|
1578
|
+
const openDetail = useCallback5((merchant) => {
|
|
1579
|
+
setOverlay({ kind: "detail", merchant });
|
|
1580
|
+
}, []);
|
|
1581
|
+
return /* @__PURE__ */ jsxs15(Fragment4, { children: [
|
|
1582
|
+
/* @__PURE__ */ jsxs15("section", { className: "sg-card sg-recommend-merchants", children: [
|
|
1583
|
+
/* @__PURE__ */ jsx17(ShopGuideHeader, { subtitle: data.summary ?? "\u6309\u54C1\u7C7B\u53D1\u73B0\u503C\u5F97\u901B\u7684\u95E8\u5E97" }),
|
|
1584
|
+
visibleTabs.length > 0 && /* @__PURE__ */ jsxs15("div", { className: "sg-rm-tabs", "aria-label": "\u6309\u95E8\u5E97\u54C1\u7C7B\u7B5B\u9009", children: [
|
|
1585
|
+
/* @__PURE__ */ jsx17(
|
|
1586
|
+
"button",
|
|
1587
|
+
{
|
|
1588
|
+
type: "button",
|
|
1589
|
+
"aria-pressed": !activeTabCode,
|
|
1590
|
+
className: `sg-rm-tab${!activeTabCode ? " sg-rm-tab--active" : ""}`,
|
|
1591
|
+
onClick: () => setActiveTabCode(""),
|
|
1592
|
+
children: /* @__PURE__ */ jsx17("span", { children: "\u5168\u90E8" })
|
|
1593
|
+
}
|
|
1594
|
+
),
|
|
1595
|
+
visibleTabs.map((tab) => {
|
|
1596
|
+
const isActive = tab.code === activeTabCode;
|
|
1597
|
+
return /* @__PURE__ */ jsx17(
|
|
1598
|
+
"button",
|
|
1599
|
+
{
|
|
1600
|
+
type: "button",
|
|
1601
|
+
"aria-pressed": isActive,
|
|
1602
|
+
className: `sg-rm-tab${isActive ? " sg-rm-tab--active" : ""}`,
|
|
1603
|
+
onClick: () => setActiveTabCode(tab.code),
|
|
1604
|
+
children: /* @__PURE__ */ jsx17("span", { children: tab.name })
|
|
1605
|
+
},
|
|
1606
|
+
tab.code
|
|
1607
|
+
);
|
|
1608
|
+
})
|
|
1609
|
+
] }),
|
|
1610
|
+
filteredItems.length === 0 ? /* @__PURE__ */ jsx17("div", { className: "sg-empty", children: data.noResultsReason ?? "\u6682\u65F6\u6CA1\u6709\u7B26\u5408\u6761\u4EF6\u7684\u95E8\u5E97" }) : /* @__PURE__ */ jsxs15(Fragment4, { children: [
|
|
1611
|
+
/* @__PURE__ */ jsx17(ShopGuideSectionLabel, {}),
|
|
1612
|
+
/* @__PURE__ */ jsx17("ul", { className: "sg-rm-list", children: previewItems.map((item) => /* @__PURE__ */ jsx17("li", { className: "sg-rm-item", children: /* @__PURE__ */ jsx17(MerchantRow, { merchant: item, onSelect: () => openDetail(item) }) }, item.merchantId)) }),
|
|
1613
|
+
filteredItems.length > PREVIEW_ITEM_COUNT2 && /* @__PURE__ */ jsxs15(
|
|
1614
|
+
"button",
|
|
1615
|
+
{
|
|
1616
|
+
type: "button",
|
|
1617
|
+
className: "sg-rm-view-all",
|
|
1618
|
+
onClick: () => setOverlay({ kind: "list" }),
|
|
1619
|
+
children: [
|
|
1620
|
+
"\u67E5\u770B\u5168\u90E8\u95E8\u5E97",
|
|
1621
|
+
/* @__PURE__ */ jsx17(CaretRight2, { size: 17 })
|
|
1622
|
+
]
|
|
1623
|
+
}
|
|
1624
|
+
)
|
|
1625
|
+
] })
|
|
1626
|
+
] }),
|
|
1627
|
+
/* @__PURE__ */ jsx17(
|
|
1628
|
+
ShopListSheet,
|
|
1629
|
+
{
|
|
1630
|
+
open: overlay.kind === "list",
|
|
1631
|
+
items: data.items,
|
|
1632
|
+
categoryTabs: data.categoryTabs ?? [],
|
|
1633
|
+
activeTabCode,
|
|
1634
|
+
isHistory,
|
|
1635
|
+
onSelect: openDetail,
|
|
1636
|
+
onClose: closeOverlay
|
|
1637
|
+
}
|
|
1638
|
+
),
|
|
1639
|
+
/* @__PURE__ */ jsx17(
|
|
1640
|
+
ShopDetailSheet,
|
|
1641
|
+
{
|
|
1642
|
+
open: overlay.kind === "detail",
|
|
1643
|
+
data: detailData,
|
|
1644
|
+
cardId,
|
|
1645
|
+
isHistory,
|
|
1646
|
+
onClose: closeOverlay
|
|
1647
|
+
}
|
|
1648
|
+
)
|
|
1649
|
+
] });
|
|
1650
|
+
}
|
|
1651
|
+
var recommend_merchants_default = RecommendMerchantsCard;
|
|
1652
|
+
|
|
1653
|
+
// src/client/index.ts
|
|
1654
|
+
var cards = {
|
|
1655
|
+
"product-list": product_list_default,
|
|
1656
|
+
"product-detail": product_detail_default,
|
|
1657
|
+
"shop-list": shop_list_default,
|
|
1658
|
+
"shop-detail": shop_detail_default,
|
|
1659
|
+
"category-list": category_list_default,
|
|
1660
|
+
"product-comparison": product_comparison_default,
|
|
1661
|
+
"mall-directory": mall_directory_default,
|
|
1662
|
+
"nearby-mall-list": nearby_mall_list_default,
|
|
1663
|
+
"human-guide-list": human_guide_list_default,
|
|
1664
|
+
"location-handoff": location_handoff_default,
|
|
1665
|
+
"recommend-merchants": recommend_merchants_default
|
|
1666
|
+
};
|
|
1667
|
+
var clientModule = {
|
|
1668
|
+
cards,
|
|
1669
|
+
register(ctx) {
|
|
1670
|
+
ctx.cards.registerMap(cards);
|
|
1671
|
+
}
|
|
1672
|
+
};
|
|
1673
|
+
|
|
1674
|
+
export {
|
|
1675
|
+
clientModule
|
|
1676
|
+
};
|