@tbox.cn/app-module-activity-play 0.4.0 → 1.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/INTEGRATION.md +12 -7
- package/README.md +8 -6
- package/dist/chunk-OFPXH7OI.js +469 -0
- package/dist/{chunk-XIDGKP5D.js → chunk-YH6HTRSS.js} +7 -76
- package/dist/client/index.d.ts +0 -1
- package/dist/client/index.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -4
- package/dist/server/index.d.ts +261 -156
- package/dist/server/index.js +1 -3
- package/package.json +15 -10
- package/skills/activity-play/SKILL.md +13 -0
- package/src/client/cards/ListPresentation.tsx +83 -0
- package/src/client/cards/activity-play/ActivityDetailSheet.tsx +143 -0
- package/src/client/cards/activity-play/ActivityPlayCard.tsx +60 -40
- package/src/client/cards/activity-play-prize/ActivityPlayPrizeListCard.tsx +55 -44
- package/src/client/cards/activity-play-prize/PrizeDetailContent.tsx +33 -0
- package/src/client/cards/activity-play-prize/PrizeDetailSheet.tsx +52 -0
- package/src/client/cards/activity-play-prize/index.ts +0 -7
- package/src/client/cards/view.ts +16 -0
- package/src/client/index.ts +2 -13
- package/src/server/cards/index.ts +1 -3
- package/src/server/index.ts +2 -19
- package/src/server/prizes/cards.ts +6 -6
- package/src/server/prizes/tools.ts +4 -6
- package/src/server/tools.ts +1 -1
- package/tbox.module.json +1 -6
- package/tests/activity-card.test.tsx +169 -0
- package/tests/prizes-tools.test.ts +7 -4
- package/tests/prizes.test.ts +6 -12
- package/tests/routes.test.ts +13 -0
- package/tests/smoke.test.ts +7 -5
- package/tsup.config.ts +1 -0
- package/dist/chunk-GDHTMID6.js +0 -185
- package/dist/client/index.css +0 -107
- package/dist/index.css +0 -107
- package/src/client/cards/activity-play-prize/ActivityPlayPrizeDetailCard.tsx +0 -44
- package/src/client/styles/activity-play.css +0 -136
- package/src/server/cards/activity-play-prize-detail/meta.ts +0 -29
- package/src/server/cards/activity-play-prize-detail/samples.ts +0 -54
package/INTEGRATION.md
CHANGED
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
- 消费并归属 `activity-play.query` + `activity-play.prizes` 双槽(TIER1 词汇域槽);供给须由
|
|
22
22
|
provider 包承担(当前唯一供给 = `provider-hupo` 远端连接形态——query→`hupo-activity-play@2`、
|
|
23
23
|
prizes→`hupo-prize@1`;不得把绑定指向其他域槽)。entry 槽已退场。
|
|
24
|
-
- 依赖 `contracts-mall ≥ 0.
|
|
24
|
+
- 依赖 `contracts-mall ≥ 1.0.0-alpha.1`(`ACTIVITY_PLAY_QUERY_SERVICE`/`ACTIVITY_PLAY_PRIZES_SERVICE` /
|
|
25
25
|
双 Port / 字段级单源)。
|
|
26
|
-
- 接入顺序:安装本模块(`
|
|
26
|
+
- 接入顺序:安装本模块(`pnpm exec tbox-app module add @tbox.cn/app-module-activity-play`,
|
|
27
27
|
显式加装,不在 mall profile 默认清单)→ 配置业务连接(integrations.json 归属层连接 +
|
|
28
28
|
双槽 `instances` 激活——激活恒显式;连接形态见 provider-hupo README「任务 07 复用交接」节)
|
|
29
|
-
→ `
|
|
29
|
+
→ `pnpm exec tbox-app module doctor` 复查。
|
|
30
30
|
|
|
31
31
|
## 智能体消费面(四只读工具 + 服务端出卡 + 模块技能)
|
|
32
32
|
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
包装注册;上下文/商圈恒取 execute 第二参可信上下文(输入不含任何身份/scope 覆盖字段)。
|
|
36
36
|
- 奖品工具(任务07):`listMyPrizes`(零入参——主体恒为当前登录用户)与 `getMyPrizeDetail`
|
|
37
37
|
(prizeRecordRef 必填——原字符串收参,含首尾空白原样);成功(含供应商确认无记录的空态)
|
|
38
|
-
|
|
38
|
+
恒出奖品卡(列表空态卡/指定记录单条列表卡——失败路径**无 cards 键**,失败≠未中奖);缺运行上下文
|
|
39
39
|
抛平台 AuthError(不经 502 兜底),缺有效主体失败事实 LOGIN_REQUIRED 且零供给接触。
|
|
40
40
|
- 出卡:非空查询经 cards 出参产出 `activity-play` 单卡型(data = mallId/mode/items——mode
|
|
41
41
|
list|detail;契约 `@tbox.cn/app-contracts-mall` `activityPlayCardDataSchema`,条目为供应商
|
|
@@ -43,9 +43,12 @@
|
|
|
43
43
|
unknown 状态的详情卡附保守提示(不引导参与)。
|
|
44
44
|
- 技能:`skills/activity-play/SKILL.md`(文件化 loadModuleSkills——玩法查询 SOP 与旧域分流)。
|
|
45
45
|
- 前端联调要点:卡渲染器按 mode 组织(列表/详情),读取 data.mallId/mode/items(key 用
|
|
46
|
-
activityId);历史态卡片(isHistory
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
activityId);历史态卡片(isHistory)禁用一切业务动作;查看全部仅本地展开快照,历史态可用;
|
|
47
|
+
活动列表“去参与”先调用活动详情 HTTP 打开统一 BottomSheet;弹层底部“立即参与”在详情 status=active 时构造
|
|
48
|
+
`dynamic-plugin://2021007119624628/activity?activityId=<encodeURIComponent(activityId)>`,经
|
|
49
|
+
`callJsapi('navigateTo', {url})` 交给宿主打开动态插件公开页;不传 userid/openid,不调用任何本模块入口接口。
|
|
50
|
+
宿主需关联动态插件(`useDynamicPlugins` + 插件声明)并允许 `my.navigateTo`。
|
|
51
|
+
奖品列表查看详情调用本人奖品详情 HTTP,在半屏展示重新查询的事实;关闭取消请求,失败展示提示。
|
|
49
52
|
|
|
50
53
|
## HTTP 面(详情只服务展示——不承担参与前检查)
|
|
51
54
|
|
|
@@ -71,3 +74,5 @@
|
|
|
71
74
|
provider import);连接共享归属层商家连接(见 provider-hupo README「任务 07 复用交接」节
|
|
72
75
|
——userid 逐请求、连接/实例零缓存);隔离应用全链路实证见
|
|
73
76
|
`scripts/tests/activity-play-prize-verify.test.mjs`(registry→transport→provider→HTTP/工具)。
|
|
77
|
+
|
|
78
|
+
奖品详情工具也返回 `activity-play-prize-list`,`total=1`、`items` 仅一条;没有独立详情卡型。完整详情只在列表“查看详情”触发的半屏中展示。
|
package/README.md
CHANGED
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
琥珀 API),提供消费面:HTTP 活动列表/详情 + 本人奖品列表/详情(activityId/prizeRecordRef
|
|
6
6
|
原字符串语义、成功/错误响应恒 no-store)、只读工具 `listActivityPlays`/
|
|
7
7
|
`getActivityPlayDetail`/`listMyPrizes`/`getMyPrizeDetail` 与服务端出卡(活动单卡型按 mode
|
|
8
|
-
组织 +
|
|
9
|
-
已随远端活动改造(2026-11-17
|
|
8
|
+
组织 + 奖品统一列表卡,详情工具返回单条记录)、模块技能(skills/activity-play)。参与前检查(POST entry)
|
|
9
|
+
已随远端活动改造(2026-11-17)退场——参与跳转由前端构造动态插件公开页链接并经宿主 `my.navigateTo` 处理;
|
|
10
10
|
详情只服务展示。本人奖品恒按当前可信用户查询(主体检查先于供给调用——缺用户 LOGIN_REQUIRED
|
|
11
|
-
零奖品 API
|
|
12
|
-
|
|
11
|
+
零奖品 API 调用;领取/核销归供应商)。活动与奖品列表采用门店导览式标题区、图文行和状态标签,图片缺失或加载失败时展示中立图标。
|
|
12
|
+
两类列表默认展示前 3 条,点击底部查看全部在卡片内展开本次已返回条目,不额外查询;奖品截断提示保留。
|
|
13
|
+
活动列表“去参与”重新查询活动详情并打开统一 BottomSheet,展示详情主图、标题简介、状态时间、玩法规则和奖品设置;缺少规则或奖品时隐藏对应区块;弹层底部“立即参与”才构造 `dynamic-plugin://2021007119624628/activity?activityId=<编码后的活动ID>` 并经 `callJsapi('navigateTo', {url})` 交给宿主(详情非 active 时禁用);奖品查看详情重新查询本人记录并通过模板 kit 的统一 BottomSheet 打开半屏弹层。
|
|
14
|
+
历史卡禁用参与和奖品详情查询,查看全部仅展开已有快照。宿主需关联动态插件并允许 `my.navigateTo`。
|
|
13
15
|
接入语义见 [INTEGRATION.md](INTEGRATION.md)。
|
|
14
16
|
|
|
15
17
|
本文描述当前代码契约。远端活动、直接宿主导航及奖品卡片的目标调整见 [实施计划](../../docs/plans/activity-play-plugin/implementation-plan.md);文档方案不表示本包已完成改造。
|
|
@@ -21,14 +23,14 @@ renderer(活动单文件 + 奖品目录 activity-play-prize——中立保形
|
|
|
21
23
|
- import 边界:只 import contracts/sdk 公开入口;全禁直接 import `@tbox-dev-js/sdk`;`client/**` 引同包 `server/**` 类型必须 `import type`
|
|
22
24
|
- `register` 只注册不解析;跨模块交互一律经 ctx(Port + 事件总线)
|
|
23
25
|
|
|
24
|
-
完整铁律与 doctor
|
|
26
|
+
完整铁律与 doctor 32 条规则见 `docs/reference/modules.md`。
|
|
25
27
|
|
|
26
28
|
## 开发循环
|
|
27
29
|
|
|
28
30
|
```sh
|
|
29
31
|
pnpm install # workspace 成员(modules/* 已在根 workspace glob 内)
|
|
30
32
|
pnpm --filter @tbox.cn/app-module-activity-play typecheck && pnpm --filter @tbox.cn/app-module-activity-play test
|
|
31
|
-
|
|
33
|
+
pnpm exec tbox-app module doctor
|
|
32
34
|
```
|
|
33
35
|
|
|
34
36
|
## 交付清单(新增能力后)
|
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
// src/client/cards/view.ts
|
|
2
|
+
function activityPlayStatusText(status) {
|
|
3
|
+
switch (status) {
|
|
4
|
+
case "active":
|
|
5
|
+
return "\u8FDB\u884C\u4E2D";
|
|
6
|
+
case "not_started":
|
|
7
|
+
return "\u672A\u5F00\u59CB";
|
|
8
|
+
case "ended":
|
|
9
|
+
return "\u5DF2\u7ED3\u675F";
|
|
10
|
+
case "disabled":
|
|
11
|
+
return "\u5DF2\u4E0B\u7EBF";
|
|
12
|
+
case "unknown":
|
|
13
|
+
return "\u72B6\u6001\u672A\u77E5";
|
|
14
|
+
default:
|
|
15
|
+
return status;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function activityPlayStatusTone(status) {
|
|
19
|
+
switch (status) {
|
|
20
|
+
case "active":
|
|
21
|
+
return "success";
|
|
22
|
+
case "not_started":
|
|
23
|
+
return "warning";
|
|
24
|
+
case "disabled":
|
|
25
|
+
case "unknown":
|
|
26
|
+
return "muted";
|
|
27
|
+
default:
|
|
28
|
+
return "muted";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function formatActivityPlayTime(value) {
|
|
32
|
+
if (!value) return "";
|
|
33
|
+
const d = new Date(value);
|
|
34
|
+
if (Number.isNaN(d.getTime())) return value;
|
|
35
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
36
|
+
return `${d.getFullYear()}.${pad(d.getMonth() + 1)}.${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
|
37
|
+
}
|
|
38
|
+
function prizeStatusLabel(value) {
|
|
39
|
+
const labels = {
|
|
40
|
+
PHYSICAL: "\u5B9E\u7269",
|
|
41
|
+
COUPON: "\u7EA2\u5305",
|
|
42
|
+
PENDING: "\u5F85\u9886\u53D6",
|
|
43
|
+
CLAIMED: "\u5DF2\u9886\u53D6",
|
|
44
|
+
NOT_APPLICABLE: "\u4E0D\u9002\u7528",
|
|
45
|
+
UNKNOWN: "\u72B6\u6001\u672A\u77E5",
|
|
46
|
+
QRCODE: "\u626B\u7801",
|
|
47
|
+
PASSWORD: "\u5BC6\u7801",
|
|
48
|
+
SLIDE: "\u6ED1\u52A8",
|
|
49
|
+
ALIPAY_CLAIM_PAGE: "\u652F\u4ED8\u5B9D\u9886\u5238"
|
|
50
|
+
};
|
|
51
|
+
return labels[value] ?? value;
|
|
52
|
+
}
|
|
53
|
+
function activityPlayBadgeClass(status) {
|
|
54
|
+
const tone = activityPlayStatusTone(status);
|
|
55
|
+
return tone === "success" ? "bg-success-soft text-success" : tone === "warning" ? "bg-warning-soft text-warning" : "bg-neutral-soft text-secondary-foreground";
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// src/client/cards/activity-play/ActivityPlayCard.tsx
|
|
59
|
+
import { useState as useState3 } from "react";
|
|
60
|
+
import { markSelfRendering } from "@tbox.cn/app-agent-sdk-client";
|
|
61
|
+
|
|
62
|
+
// src/client/cards/activity-play/ActivityDetailSheet.tsx
|
|
63
|
+
import { useEffect, useRef, useState } from "react";
|
|
64
|
+
import { toast } from "@tbox.cn/app-agent-ui-kit/toast";
|
|
65
|
+
import { BottomSheet } from "@tbox.cn/app-agent-ui-kit/bottom-sheet";
|
|
66
|
+
import { callJsapi, httpGet } from "@tbox.cn/app-agent-sdk-client";
|
|
67
|
+
import { activityPlayActivitySchema } from "@tbox.cn/app-contracts-mall";
|
|
68
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
69
|
+
var ACTIVITY_PLAY_PLUGIN_URL = "dynamic-plugin://2021007119624628/activity";
|
|
70
|
+
function buildActivityPlayPluginUrl(activityId) {
|
|
71
|
+
return `${ACTIVITY_PLAY_PLUGIN_URL}?activityId=${encodeURIComponent(activityId)}`;
|
|
72
|
+
}
|
|
73
|
+
function ActivityDetailSheet({ mallId, activityId, onClose }) {
|
|
74
|
+
const [detail, setDetail] = useState();
|
|
75
|
+
const [error, setError] = useState("");
|
|
76
|
+
const [opening, setOpening] = useState(false);
|
|
77
|
+
const navigating = useRef(false);
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
const controller = new AbortController();
|
|
80
|
+
const load = async () => {
|
|
81
|
+
try {
|
|
82
|
+
const result = await httpGet(
|
|
83
|
+
`/api/m/activity-play/activities/${encodeURIComponent(activityId)}?mallId=${encodeURIComponent(mallId)}`,
|
|
84
|
+
{ signal: controller.signal, cache: "no-store" }
|
|
85
|
+
);
|
|
86
|
+
if (controller.signal.aborted) return;
|
|
87
|
+
if (result.status !== 200) {
|
|
88
|
+
setError("\u6D3B\u52A8\u8BE6\u60C5\u67E5\u8BE2\u5931\u8D25\uFF0C\u8BF7\u5173\u95ED\u540E\u91CD\u8BD5");
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const parsed = activityPlayActivitySchema.safeParse(result.data.data);
|
|
92
|
+
if (!parsed.success || parsed.data.activityId !== activityId) {
|
|
93
|
+
setError("\u6D3B\u52A8\u8BE6\u60C5\u6570\u636E\u5F02\u5E38\uFF0C\u8BF7\u5173\u95ED\u540E\u91CD\u8BD5");
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
setDetail(parsed.data);
|
|
97
|
+
} catch {
|
|
98
|
+
if (!controller.signal.aborted) setError("\u6D3B\u52A8\u8BE6\u60C5\u67E5\u8BE2\u5931\u8D25\uFF0C\u8BF7\u5173\u95ED\u540E\u91CD\u8BD5");
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
void load();
|
|
102
|
+
return () => controller.abort();
|
|
103
|
+
}, [activityId, mallId]);
|
|
104
|
+
const participate = async () => {
|
|
105
|
+
if (!detail || detail.status !== "active" || navigating.current) return;
|
|
106
|
+
navigating.current = true;
|
|
107
|
+
setOpening(true);
|
|
108
|
+
try {
|
|
109
|
+
await callJsapi("navigateTo", { url: buildActivityPlayPluginUrl(detail.activityId) });
|
|
110
|
+
} catch {
|
|
111
|
+
void toast("\u6D3B\u52A8\u6682\u65F6\u65E0\u6CD5\u6253\u5F00\uFF0C\u8BF7\u5728\u5BBF\u4E3B\u5C0F\u7A0B\u5E8F\u4E2D\u91CD\u8BD5");
|
|
112
|
+
} finally {
|
|
113
|
+
navigating.current = false;
|
|
114
|
+
setOpening(false);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
return /* @__PURE__ */ jsx(BottomSheet, { open: true, title: "\u6D3B\u52A8\u8BE6\u60C5", onClose, className: "ap-activity-sheet", children: error ? /* @__PURE__ */ jsx("p", { role: "alert", children: error }) : detail ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
118
|
+
/* @__PURE__ */ jsxs("section", { className: "ap-card ap-card--detail flex flex-col gap-2 bg-transparent p-0", children: [
|
|
119
|
+
(detail.detailCoverUrl || detail.imageUrl) && /* @__PURE__ */ jsx(
|
|
120
|
+
"img",
|
|
121
|
+
{
|
|
122
|
+
className: "ap-activity-sheet__image block aspect-[2.2] w-full rounded-lg object-cover",
|
|
123
|
+
src: detail.detailCoverUrl || detail.imageUrl,
|
|
124
|
+
alt: "",
|
|
125
|
+
onError: (event) => {
|
|
126
|
+
if (detail.imageUrl && event.currentTarget.getAttribute("src") !== detail.imageUrl) {
|
|
127
|
+
event.currentTarget.src = detail.imageUrl;
|
|
128
|
+
} else event.currentTarget.style.display = "none";
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
),
|
|
132
|
+
/* @__PURE__ */ jsx("h3", { className: "ap-activity-sheet__title m-0 text-base leading-5.5 text-foreground", children: detail.title }),
|
|
133
|
+
detail.description && /* @__PURE__ */ jsx("p", { className: "ap-card__detail-desc m-0 whitespace-pre-wrap text-[13px] leading-[19px] text-secondary-foreground [overflow-wrap:anywhere]", children: detail.description }),
|
|
134
|
+
/* @__PURE__ */ jsx("span", { className: `w-fit max-w-full shrink-0 self-start rounded-[3.5px] px-1.5 py-px text-[11px] leading-4 [overflow-wrap:anywhere] ap-badge ap-badge--${activityPlayStatusTone(detail.status)} ${activityPlayBadgeClass(detail.status)}`, children: activityPlayStatusText(detail.status) }),
|
|
135
|
+
(detail.startsAt || detail.endsAt) && /* @__PURE__ */ jsxs("section", { className: "ap-activity-sheet__time w-full rounded-xl border border-border bg-muted p-3", children: [
|
|
136
|
+
/* @__PURE__ */ jsxs("h4", { className: "m-0 flex items-center gap-1.5 text-xs font-medium leading-5 text-foreground", children: [
|
|
137
|
+
/* @__PURE__ */ jsxs("svg", { className: "size-4 shrink-0 text-muted-foreground", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
138
|
+
/* @__PURE__ */ jsx("rect", { x: "3", y: "5", width: "18", height: "16", rx: "3" }),
|
|
139
|
+
/* @__PURE__ */ jsx("path", { d: "M7 3v4M17 3v4M3 11h18M8 15h2M14 15h2" })
|
|
140
|
+
] }),
|
|
141
|
+
"\u6D3B\u52A8\u65F6\u95F4"
|
|
142
|
+
] }),
|
|
143
|
+
/* @__PURE__ */ jsxs("dl", { className: "mt-2 mb-0 grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-1.5 text-xs leading-5", children: [
|
|
144
|
+
detail.startsAt && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
145
|
+
/* @__PURE__ */ jsx("dt", { className: "text-muted-foreground", children: "\u5F00\u59CB\u65F6\u95F4" }),
|
|
146
|
+
/* @__PURE__ */ jsx("dd", { className: "m-0 font-medium text-foreground tabular-nums [overflow-wrap:anywhere]", children: formatActivityPlayTime(detail.startsAt) })
|
|
147
|
+
] }),
|
|
148
|
+
detail.endsAt && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
149
|
+
/* @__PURE__ */ jsx("dt", { className: "text-muted-foreground", children: "\u7ED3\u675F\u65F6\u95F4" }),
|
|
150
|
+
/* @__PURE__ */ jsx("dd", { className: "m-0 font-medium text-foreground tabular-nums [overflow-wrap:anywhere]", children: formatActivityPlayTime(detail.endsAt) })
|
|
151
|
+
] })
|
|
152
|
+
] })
|
|
153
|
+
] }),
|
|
154
|
+
!!detail.participationRules?.ruleTexts.length && /* @__PURE__ */ jsxs("section", { className: "ap-activity-sheet__section mt-1 w-full [&>h4]:mt-0 [&>h4]:mb-2 [&>h4]:text-sm [&>h4]:leading-5", children: [
|
|
155
|
+
/* @__PURE__ */ jsx("h4", { children: "\u73A9\u6CD5\u89C4\u5219" }),
|
|
156
|
+
/* @__PURE__ */ jsx("ul", { className: "ap-activity-sheet__rules m-0 pl-4 text-xs leading-[21px] text-secondary-foreground [&>li]:whitespace-pre-wrap [&>li]:[overflow-wrap:anywhere]", children: detail.participationRules.ruleTexts.map((text, index) => /* @__PURE__ */ jsx("li", { children: text }, index)) })
|
|
157
|
+
] }),
|
|
158
|
+
!!detail.rewardSummary?.items.length && /* @__PURE__ */ jsxs("section", { className: "ap-activity-sheet__section mt-1 w-full [&>h4]:mt-0 [&>h4]:mb-2 [&>h4]:text-sm [&>h4]:leading-5", children: [
|
|
159
|
+
/* @__PURE__ */ jsx("h4", { children: "\u5956\u54C1\u8BBE\u7F6E" }),
|
|
160
|
+
/* @__PURE__ */ jsx("ul", { className: "ap-activity-sheet__rewards m-0 grid list-none grid-cols-2 gap-[7px] p-0 [&>li]:flex [&>li]:min-w-0 [&>li]:items-center [&>li]:gap-[7px] [&>li]:rounded-[9px] [&>li]:bg-muted [&>li]:p-2 [&>li>div]:min-w-0 [&>li>div>span]:block [&>li>div>span]:text-[11px] [&>li>div>span]:leading-[15px] [&>li>div>span]:text-secondary-foreground [&_strong]:block [&_strong]:text-xs [&_strong]:font-medium [&_strong]:leading-[17px] [&_strong]:[overflow-wrap:anywhere]", children: detail.rewardSummary.items.map((reward, index) => /* @__PURE__ */ jsxs("li", { children: [
|
|
161
|
+
/* @__PURE__ */ jsxs("span", { className: "ap-activity-sheet__reward-icon relative flex h-[34px] w-[30px] shrink-0 items-center justify-center overflow-hidden rounded-lg bg-[#fff8e8] text-[#cb9737] [&>svg]:size-5.5 [&>img]:absolute [&>img]:inset-0 [&>img]:size-full [&>img]:bg-[#fff8e8] [&>img]:object-contain", children: [
|
|
162
|
+
reward.imageUrl ? /* @__PURE__ */ jsx("img", { src: reward.imageUrl, alt: "", onError: (event) => {
|
|
163
|
+
event.currentTarget.hidden = true;
|
|
164
|
+
} }) : null,
|
|
165
|
+
/* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M3 8h18v4H3zM5 12v9h14v-9M12 8v13M12 8C5 8 5 1 9 3c2 1 3 5 3 5Zm0 0c7 0 7-7 3-5-2 1-3 5-3 5Z" }) })
|
|
166
|
+
] }),
|
|
167
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
168
|
+
/* @__PURE__ */ jsx("span", { children: reward.tierName }),
|
|
169
|
+
/* @__PURE__ */ jsx("strong", { children: reward.title })
|
|
170
|
+
] })
|
|
171
|
+
] }, index)) })
|
|
172
|
+
] })
|
|
173
|
+
] }),
|
|
174
|
+
/* @__PURE__ */ jsx("footer", { className: "ap-activity-sheet__footer sticky bottom-0 mt-3.5 bg-card pt-2.5 [&>button]:min-h-10 [&>button]:w-full", children: /* @__PURE__ */ jsx(
|
|
175
|
+
"button",
|
|
176
|
+
{
|
|
177
|
+
type: "button",
|
|
178
|
+
className: "ap-list__action shrink-0 cursor-pointer rounded-full border-0 bg-primary px-3 py-1 text-xs font-semibold leading-4.5 text-white disabled:cursor-default disabled:opacity-45",
|
|
179
|
+
disabled: opening || detail.status !== "active",
|
|
180
|
+
onClick: () => {
|
|
181
|
+
void participate();
|
|
182
|
+
},
|
|
183
|
+
children: opening ? "\u6253\u5F00\u4E2D" : detail.status === "active" ? "\u7ACB\u5373\u53C2\u4E0E" : activityPlayStatusText(detail.status)
|
|
184
|
+
}
|
|
185
|
+
) })
|
|
186
|
+
] }) : /* @__PURE__ */ jsx("p", { role: "status", children: "\u6B63\u5728\u67E5\u8BE2\u6D3B\u52A8\u8BE6\u60C5\u2026" }) });
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// src/client/cards/ListPresentation.tsx
|
|
190
|
+
import { useState as useState2 } from "react";
|
|
191
|
+
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
192
|
+
var LIST_PREVIEW_COUNT = 3;
|
|
193
|
+
function ListHeader({ title, subtitle, kind }) {
|
|
194
|
+
return /* @__PURE__ */ jsxs2("header", { className: "ap-list__header relative -mx-3.5 flex min-h-18 items-center gap-2.5 overflow-hidden bg-[#fcefe2] px-4 py-3.5 after:pointer-events-none after:absolute after:-right-[15px] after:-bottom-[15px] after:h-10 after:w-[150px] after:-rotate-18 after:rounded-full after:border-8 after:border-[rgba(246,179,82,0.13)] after:content-['']", children: [
|
|
195
|
+
/* @__PURE__ */ jsx2("span", { className: "ap-list__header-icon flex size-7 shrink-0 items-center justify-center rounded-md bg-[#bb8124] text-white [&>svg]:size-4.5", "aria-hidden": "true", children: /* @__PURE__ */ jsx2("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", children: kind === "activity" ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
196
|
+
/* @__PURE__ */ jsx2("rect", { x: "4", y: "5", width: "16", height: "16", rx: "2" }),
|
|
197
|
+
/* @__PURE__ */ jsx2("path", { d: "M4 10h16M8 3v4m8-4v4m-4 5 1 2 2.2.3-1.6 1.6.4 2.2-2-1-2 1 .4-2.2-1.6-1.6L11 14Z" })
|
|
198
|
+
] }) : /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
199
|
+
/* @__PURE__ */ jsx2("path", { d: "M3 9h18v5H3zM5 14v7h14v-7M12 9v12" }),
|
|
200
|
+
/* @__PURE__ */ jsx2("path", { d: "M12 9C4 9 5 2 8 3c3 0 4 6 4 6Zm0 0c8 0 7-7 4-6-3 0-4 6-4 6Z" })
|
|
201
|
+
] }) }) }),
|
|
202
|
+
/* @__PURE__ */ jsxs2("div", { className: "ap-list__header-copy relative z-1 min-w-0", children: [
|
|
203
|
+
/* @__PURE__ */ jsx2("h3", { className: "ap-list__title m-0 text-base font-semibold leading-5.5 text-foreground", children: title }),
|
|
204
|
+
/* @__PURE__ */ jsx2("p", { className: "ap-list__subtitle mt-[3px] mb-0 text-xs leading-[17px] text-secondary-foreground", children: subtitle })
|
|
205
|
+
] })
|
|
206
|
+
] });
|
|
207
|
+
}
|
|
208
|
+
function ListTime({ children }) {
|
|
209
|
+
return /* @__PURE__ */ jsxs2("p", { className: "ap-list__meta mt-1.5 mb-0 flex items-start gap-[3px] text-[11px] leading-[15px] text-secondary-foreground [overflow-wrap:anywhere] [&>svg]:mt-[2.5px] [&>svg]:size-2.5 [&>svg]:shrink-0", children: [
|
|
210
|
+
/* @__PURE__ */ jsxs2("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", children: [
|
|
211
|
+
/* @__PURE__ */ jsx2("circle", { cx: "8", cy: "8", r: "7", fill: "currentColor" }),
|
|
212
|
+
/* @__PURE__ */ jsx2("path", { d: "M8 4v4l3 2", fill: "none", stroke: "white", strokeWidth: "1.5" })
|
|
213
|
+
] }),
|
|
214
|
+
/* @__PURE__ */ jsx2("span", { children })
|
|
215
|
+
] });
|
|
216
|
+
}
|
|
217
|
+
function ViewAll({ label, onExpand }) {
|
|
218
|
+
return /* @__PURE__ */ jsxs2("button", { type: "button", className: "ap-list__view-all flex min-h-[38px] w-full cursor-pointer items-center justify-center gap-[7px] border-0 border-t border-border bg-transparent py-2 text-xs leading-[17px] text-secondary-foreground focus-visible:outline-2 focus-visible:outline-primary focus-visible:-outline-offset-2 [&>svg]:size-3", "aria-expanded": false, onClick: onExpand, children: [
|
|
219
|
+
label,
|
|
220
|
+
/* @__PURE__ */ jsx2("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ jsx2("path", { d: "m6 4 4 4-4 4" }) })
|
|
221
|
+
] });
|
|
222
|
+
}
|
|
223
|
+
function ListImage({ src, kind }) {
|
|
224
|
+
const [failedSrc, setFailedSrc] = useState2();
|
|
225
|
+
return /* @__PURE__ */ jsx2("div", { className: "ap-list__image flex size-[86px] shrink-0 items-center justify-center overflow-hidden rounded-[7px] bg-[linear-gradient(135deg,#faf7f0,#f0f2eb)] text-[#8a927c] [&>img]:block [&>img]:size-full [&>img]:object-cover [&>svg]:size-8", "aria-hidden": "true", children: src && src !== failedSrc ? /* @__PURE__ */ jsx2("img", { src, alt: "", loading: "lazy", onError: () => setFailedSrc(src) }) : /* @__PURE__ */ jsx2("svg", { viewBox: "0 0 48 48", fill: "none", stroke: "currentColor", strokeWidth: "2", children: kind === "prize" ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
226
|
+
/* @__PURE__ */ jsx2("path", { d: "M8 21h32v-9H8zM11 21v20h26V21M24 12v29" }),
|
|
227
|
+
/* @__PURE__ */ jsx2("path", { d: "M24 12c-12 0-13-10-7-10 5 0 7 10 7 10Zm0 0c12 0 13-10 7-10-5 0-7 10-7 10Z" })
|
|
228
|
+
] }) : /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
229
|
+
/* @__PURE__ */ jsx2("path", { d: "M8 10h32v10a4 4 0 0 0 0 8v10H8V28a4 4 0 0 0 0-8Z" }),
|
|
230
|
+
/* @__PURE__ */ jsx2("path", { d: "m24 16 2.5 5 5.5.8-4 3.9.9 5.5-4.9-2.6-4.9 2.6.9-5.5-4-3.9 5.5-.8Z" })
|
|
231
|
+
] }) }) });
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// src/client/cards/activity-play/ActivityPlayCard.tsx
|
|
235
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
236
|
+
function ActivityRow({ item, mallId, isHistory }) {
|
|
237
|
+
const [showDetail, setShowDetail] = useState3(false);
|
|
238
|
+
const tone = activityPlayStatusTone(item.status);
|
|
239
|
+
return /* @__PURE__ */ jsxs3("li", { className: "ap-card__row flex items-start gap-3 border-t border-border py-3.5 first:border-t-0", children: [
|
|
240
|
+
/* @__PURE__ */ jsx3(ListImage, { src: item.imageUrl, kind: "activity" }),
|
|
241
|
+
/* @__PURE__ */ jsxs3("div", { className: "ap-card__row-main min-w-0 flex-1", children: [
|
|
242
|
+
/* @__PURE__ */ jsx3("div", { className: "ap-card__row-title flex items-center gap-1.5 [&>strong]:truncate [&>strong]:text-sm [&>strong]:leading-5 [&>strong]:text-foreground", children: /* @__PURE__ */ jsx3("strong", { children: item.title }) }),
|
|
243
|
+
item.description && /* @__PURE__ */ jsx3("p", { className: "ap-card__row-desc mt-1 mb-0 line-clamp-1 text-xs leading-[17px] text-secondary-foreground [overflow-wrap:anywhere]", children: item.description }),
|
|
244
|
+
(item.startsAt || item.endsAt) && /* @__PURE__ */ jsxs3(ListTime, { children: [
|
|
245
|
+
item.startsAt && `\u5F00\u59CB ${formatActivityPlayTime(item.startsAt)}`,
|
|
246
|
+
item.startsAt && item.endsAt && " \xB7 ",
|
|
247
|
+
item.endsAt && `\u7ED3\u675F ${formatActivityPlayTime(item.endsAt)}`
|
|
248
|
+
] }),
|
|
249
|
+
/* @__PURE__ */ jsxs3("div", { className: "ap-list__row-bottom mt-1.5 flex items-center justify-between gap-1.5", children: [
|
|
250
|
+
/* @__PURE__ */ jsx3("span", { className: `max-w-full shrink-0 rounded-[3.5px] px-1.5 py-px text-[11px] leading-4 [overflow-wrap:anywhere] ap-badge ap-badge--${tone} ${activityPlayBadgeClass(item.status)}`, children: activityPlayStatusText(item.status) }),
|
|
251
|
+
item.status === "active" && /* @__PURE__ */ jsx3(
|
|
252
|
+
"button",
|
|
253
|
+
{
|
|
254
|
+
type: "button",
|
|
255
|
+
className: "ap-list__action shrink-0 cursor-pointer rounded-full border-0 bg-primary px-3 py-1 text-xs font-semibold leading-4.5 text-white disabled:cursor-default disabled:opacity-45",
|
|
256
|
+
disabled: isHistory,
|
|
257
|
+
onClick: () => setShowDetail(true),
|
|
258
|
+
children: "\u53BB\u53C2\u4E0E"
|
|
259
|
+
}
|
|
260
|
+
)
|
|
261
|
+
] })
|
|
262
|
+
] }),
|
|
263
|
+
showDetail && !isHistory && /* @__PURE__ */ jsx3(ActivityDetailSheet, { mallId, activityId: item.activityId, onClose: () => setShowDetail(false) })
|
|
264
|
+
] });
|
|
265
|
+
}
|
|
266
|
+
function ActivityPlayCard(props) {
|
|
267
|
+
const { data, isHistory = false } = props;
|
|
268
|
+
const [expanded, setExpanded] = useState3(false);
|
|
269
|
+
const visibleItems = expanded ? data.items : data.items.slice(0, LIST_PREVIEW_COUNT);
|
|
270
|
+
if (data.mode === "detail") {
|
|
271
|
+
const item = data.items[0];
|
|
272
|
+
if (!item) return null;
|
|
273
|
+
const range = [formatActivityPlayTime(item.startsAt), formatActivityPlayTime(item.endsAt)].filter(Boolean).join(" \u2014 ");
|
|
274
|
+
return /* @__PURE__ */ jsxs3("section", { className: "ap-card ap-card--detail flex flex-col gap-2 bg-transparent p-0", children: [
|
|
275
|
+
/* @__PURE__ */ jsx3("span", { className: "ap-card__eyebrow text-xs leading-4.5 text-muted-foreground", children: "\u6D3B\u52A8\u73A9\u6CD5" }),
|
|
276
|
+
/* @__PURE__ */ jsxs3("div", { className: "ap-card__detail-head flex flex-wrap items-center gap-2 [&>strong]:text-base [&>strong]:leading-5.5", children: [
|
|
277
|
+
/* @__PURE__ */ jsx3("strong", { children: item.title }),
|
|
278
|
+
/* @__PURE__ */ jsx3("span", { className: `max-w-full shrink-0 rounded-[3.5px] px-1.5 py-px text-[11px] leading-4 [overflow-wrap:anywhere] ap-badge ap-badge--${activityPlayStatusTone(item.status)} ${activityPlayBadgeClass(item.status)}`, children: activityPlayStatusText(item.status) })
|
|
279
|
+
] }),
|
|
280
|
+
item.description && /* @__PURE__ */ jsx3("p", { className: "ap-card__detail-desc m-0 whitespace-pre-wrap text-[13px] leading-[19px] text-secondary-foreground [overflow-wrap:anywhere]", children: item.description }),
|
|
281
|
+
item.imageUrl && /* @__PURE__ */ jsx3("img", { className: "ap-card__cover max-h-45 w-full rounded-md object-cover", src: item.imageUrl, alt: `${item.title}\u5C01\u9762`, loading: "lazy" }),
|
|
282
|
+
range && /* @__PURE__ */ jsxs3("p", { className: "ap-card__meta m-0 text-xs leading-4.5 text-muted-foreground [overflow-wrap:anywhere]", children: [
|
|
283
|
+
"\u6D3B\u52A8\u65F6\u95F4\uFF1A",
|
|
284
|
+
range
|
|
285
|
+
] })
|
|
286
|
+
] });
|
|
287
|
+
}
|
|
288
|
+
return /* @__PURE__ */ jsxs3("section", { className: "ap-card ap-card--list flex flex-col gap-0 bg-card px-3.5", children: [
|
|
289
|
+
/* @__PURE__ */ jsx3(ListHeader, { title: "\u5546\u5708\u6D3B\u52A8\u4E00\u89C8", subtitle: "\u8FD1\u671F\u6D3B\u52A8 \u4E00\u952E\u53C2\u4E0E", kind: "activity" }),
|
|
290
|
+
data.items.length === 0 ? /* @__PURE__ */ jsx3("p", { className: "ap-card__empty m-0 px-1.5 py-5 text-center text-xs leading-4.5 text-secondary-foreground", children: "\u6682\u65E0\u5339\u914D\u7684\u6D3B\u52A8\u73A9\u6CD5" }) : /* @__PURE__ */ jsx3("ul", { className: "ap-card__list m-0 flex list-none flex-col p-0", children: visibleItems.map((item) => /* @__PURE__ */ jsx3(ActivityRow, { item, mallId: data.mallId, isHistory }, item.activityId)) }),
|
|
291
|
+
!expanded && data.items.length > LIST_PREVIEW_COUNT && /* @__PURE__ */ jsx3(ViewAll, { label: "\u67E5\u770B\u5168\u90E8\u6D3B\u52A8", onExpand: () => setExpanded(true) })
|
|
292
|
+
] });
|
|
293
|
+
}
|
|
294
|
+
markSelfRendering(ActivityPlayCard);
|
|
295
|
+
|
|
296
|
+
// src/client/cards/activity-play-prize/ActivityPlayPrizeListCard.tsx
|
|
297
|
+
import { useState as useState5 } from "react";
|
|
298
|
+
import { markSelfRendering as markSelfRendering2 } from "@tbox.cn/app-agent-sdk-client";
|
|
299
|
+
|
|
300
|
+
// src/client/cards/activity-play-prize/PrizeDetailSheet.tsx
|
|
301
|
+
import { BottomSheet as BottomSheet2 } from "@tbox.cn/app-agent-ui-kit/bottom-sheet";
|
|
302
|
+
import { useEffect as useEffect2, useState as useState4 } from "react";
|
|
303
|
+
import { httpGet as httpGet2 } from "@tbox.cn/app-agent-sdk-client";
|
|
304
|
+
import { activityPlayPrizeDetailSchema } from "@tbox.cn/app-contracts-mall";
|
|
305
|
+
|
|
306
|
+
// src/client/cards/activity-play-prize/PrizeDetailContent.tsx
|
|
307
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
308
|
+
function PrizeDetailContent(props) {
|
|
309
|
+
const { data } = props;
|
|
310
|
+
return /* @__PURE__ */ jsxs4("section", { className: "ap-card ap-card--detail flex flex-col gap-2 bg-transparent p-0", children: [
|
|
311
|
+
/* @__PURE__ */ jsx4("span", { className: "ap-card__eyebrow text-xs leading-4.5 text-muted-foreground", children: "\u672C\u4EBA\u5956\u54C1" }),
|
|
312
|
+
/* @__PURE__ */ jsxs4("div", { className: "ap-card__detail-head flex flex-wrap items-center gap-2 [&>strong]:text-base [&>strong]:leading-5.5", children: [
|
|
313
|
+
/* @__PURE__ */ jsx4("strong", { children: data.title }),
|
|
314
|
+
/* @__PURE__ */ jsx4("span", { className: "ap-badge ap-badge--muted max-w-full shrink-0 rounded-[3.5px] px-1.5 py-px text-[11px] leading-4 [overflow-wrap:anywhere] bg-neutral-soft text-secondary-foreground", children: prizeStatusLabel(data.claimStatus) })
|
|
315
|
+
] }),
|
|
316
|
+
/* @__PURE__ */ jsxs4("p", { className: "ap-card__row-desc mt-1 mb-0 line-clamp-1 text-xs leading-[17px] text-secondary-foreground [overflow-wrap:anywhere]", children: [
|
|
317
|
+
prizeStatusLabel(data.prizeType),
|
|
318
|
+
" \xB7 \u4F7F\u7528\u72B6\u6001 ",
|
|
319
|
+
prizeStatusLabel(data.useStatus),
|
|
320
|
+
data.wonAt ? ` \xB7 ${formatActivityPlayTime(data.wonAt)}` : ""
|
|
321
|
+
] }),
|
|
322
|
+
data.activityTitle && /* @__PURE__ */ jsxs4("p", { className: "ap-card__meta m-0 text-xs leading-4.5 text-muted-foreground [overflow-wrap:anywhere]", children: [
|
|
323
|
+
"\u6765\u6E90\u6D3B\u52A8\uFF1A",
|
|
324
|
+
data.activityTitle
|
|
325
|
+
] }),
|
|
326
|
+
data.usageRuleText && /* @__PURE__ */ jsxs4("p", { className: "ap-card__detail-desc m-0 whitespace-pre-wrap text-[13px] leading-[19px] text-secondary-foreground [overflow-wrap:anywhere]", children: [
|
|
327
|
+
"\u4F7F\u7528\u89C4\u5219\uFF1A",
|
|
328
|
+
data.usageRuleText
|
|
329
|
+
] }),
|
|
330
|
+
data.redemptionMethod && /* @__PURE__ */ jsxs4("p", { className: "ap-card__detail-desc m-0 whitespace-pre-wrap text-[13px] leading-[19px] text-secondary-foreground [overflow-wrap:anywhere]", children: [
|
|
331
|
+
"\u9886\u53D6\u65B9\u5F0F\uFF1A",
|
|
332
|
+
prizeStatusLabel(data.redemptionMethod)
|
|
333
|
+
] }),
|
|
334
|
+
data.redemptionInstruction && /* @__PURE__ */ jsxs4("p", { className: "ap-card__detail-desc m-0 whitespace-pre-wrap text-[13px] leading-[19px] text-secondary-foreground [overflow-wrap:anywhere]", children: [
|
|
335
|
+
"\u9886\u53D6\u8BF4\u660E\uFF1A",
|
|
336
|
+
data.redemptionInstruction
|
|
337
|
+
] }),
|
|
338
|
+
data.prizeUrl && /* @__PURE__ */ jsxs4("p", { className: "ap-card__meta m-0 text-xs leading-4.5 text-muted-foreground [overflow-wrap:anywhere]", children: [
|
|
339
|
+
"\u9886\u53D6\u6307\u5F15\uFF1A",
|
|
340
|
+
data.prizeUrl,
|
|
341
|
+
"\uFF08\u4EE5\u6D3B\u52A8\u9875\u9762\u4E3A\u51C6\uFF09"
|
|
342
|
+
] })
|
|
343
|
+
] });
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// src/client/cards/activity-play-prize/PrizeDetailSheet.tsx
|
|
347
|
+
import { Fragment as Fragment3, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
348
|
+
function PrizeDetailSheet({ mallId, prizeRecordRef, onClose }) {
|
|
349
|
+
const [detail, setDetail] = useState4();
|
|
350
|
+
const [error, setError] = useState4("");
|
|
351
|
+
useEffect2(() => {
|
|
352
|
+
const controller = new AbortController();
|
|
353
|
+
const load = async () => {
|
|
354
|
+
try {
|
|
355
|
+
const result = await httpGet2(
|
|
356
|
+
`/api/m/activity-play/prizes/${encodeURIComponent(prizeRecordRef)}?mallId=${encodeURIComponent(mallId)}`,
|
|
357
|
+
{ signal: controller.signal, cache: "no-store" }
|
|
358
|
+
);
|
|
359
|
+
if (controller.signal.aborted) return;
|
|
360
|
+
if (result.status !== 200) {
|
|
361
|
+
setError(result.status === 401 ? "\u8BF7\u5148\u767B\u5F55\u540E\u67E5\u770B\u672C\u4EBA\u5956\u54C1" : "\u5956\u54C1\u8BE6\u60C5\u67E5\u8BE2\u5931\u8D25\uFF0C\u8BF7\u5173\u95ED\u540E\u91CD\u8BD5");
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
const parsed = activityPlayPrizeDetailSchema.safeParse(result.data.data);
|
|
365
|
+
if (!parsed.success || parsed.data.prizeRecordRef !== prizeRecordRef) {
|
|
366
|
+
setError("\u5956\u54C1\u8BE6\u60C5\u6570\u636E\u5F02\u5E38\uFF0C\u8BF7\u5173\u95ED\u540E\u91CD\u8BD5");
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
setDetail(parsed.data);
|
|
370
|
+
} catch {
|
|
371
|
+
if (!controller.signal.aborted) setError("\u5956\u54C1\u8BE6\u60C5\u67E5\u8BE2\u5931\u8D25\uFF0C\u8BF7\u5173\u95ED\u540E\u91CD\u8BD5");
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
void load();
|
|
375
|
+
return () => {
|
|
376
|
+
controller.abort();
|
|
377
|
+
};
|
|
378
|
+
}, [mallId, prizeRecordRef]);
|
|
379
|
+
return /* @__PURE__ */ jsx5(BottomSheet2, { open: true, title: "\u5956\u54C1\u8BE6\u60C5", onClose, className: "ap-prize-sheet", children: error ? /* @__PURE__ */ jsx5("p", { role: "alert", children: error }) : detail ? /* @__PURE__ */ jsxs5(Fragment3, { children: [
|
|
380
|
+
detail.imageUrl && /* @__PURE__ */ jsx5("img", { className: "ap-prize-sheet__image mx-auto mb-2.5 block h-30 max-w-full object-contain", src: detail.imageUrl, alt: "" }),
|
|
381
|
+
/* @__PURE__ */ jsx5(PrizeDetailContent, { data: detail })
|
|
382
|
+
] }) : /* @__PURE__ */ jsx5("p", { role: "status", children: "\u6B63\u5728\u67E5\u8BE2\u5956\u54C1\u8BE6\u60C5\u2026" }) });
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// src/client/cards/activity-play-prize/ActivityPlayPrizeListCard.tsx
|
|
386
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
387
|
+
function PrizeRow({ item, isHistory, onDetail }) {
|
|
388
|
+
return /* @__PURE__ */ jsxs6("li", { className: "ap-card__row flex items-start gap-3 border-t border-border py-3.5 first:border-t-0", children: [
|
|
389
|
+
/* @__PURE__ */ jsx6(ListImage, { src: item.imageUrl, kind: "prize" }),
|
|
390
|
+
/* @__PURE__ */ jsxs6("div", { className: "ap-card__row-main min-w-0 flex-1", children: [
|
|
391
|
+
/* @__PURE__ */ jsx6("div", { className: "ap-card__row-title flex items-center gap-1.5 [&>strong]:truncate [&>strong]:text-sm [&>strong]:leading-5 [&>strong]:text-foreground", children: /* @__PURE__ */ jsx6("strong", { children: item.title }) }),
|
|
392
|
+
/* @__PURE__ */ jsxs6("p", { className: "ap-card__row-desc mt-1 mb-0 line-clamp-1 text-xs leading-[17px] text-secondary-foreground [overflow-wrap:anywhere]", children: [
|
|
393
|
+
item.activityTitle ? `${item.activityTitle} \xB7 ` : "",
|
|
394
|
+
prizeStatusLabel(item.prizeType),
|
|
395
|
+
" \xB7 ",
|
|
396
|
+
"\u4F7F\u7528\u72B6\u6001 ",
|
|
397
|
+
prizeStatusLabel(item.useStatus)
|
|
398
|
+
] }),
|
|
399
|
+
item.wonAt && /* @__PURE__ */ jsx6(ListTime, { children: formatActivityPlayTime(item.wonAt) }),
|
|
400
|
+
/* @__PURE__ */ jsxs6("div", { className: "ap-list__row-bottom mt-1.5 flex items-center justify-between gap-1.5", children: [
|
|
401
|
+
/* @__PURE__ */ jsx6("span", { className: `max-w-full shrink-0 rounded-[3.5px] px-1.5 py-px text-[11px] leading-4 [overflow-wrap:anywhere] ap-badge ap-badge--${item.claimStatus === "PENDING" ? "warning" : "muted"} ${item.claimStatus === "PENDING" ? "bg-warning-soft text-warning" : "bg-neutral-soft text-secondary-foreground"}`, children: prizeStatusLabel(item.claimStatus) }),
|
|
402
|
+
/* @__PURE__ */ jsx6(
|
|
403
|
+
"button",
|
|
404
|
+
{
|
|
405
|
+
type: "button",
|
|
406
|
+
className: "ap-list__action shrink-0 cursor-pointer rounded-full border-0 bg-primary px-3 py-1 text-xs font-semibold leading-4.5 text-white disabled:cursor-default disabled:opacity-45",
|
|
407
|
+
disabled: isHistory,
|
|
408
|
+
onClick: () => {
|
|
409
|
+
if (!isHistory) onDetail();
|
|
410
|
+
},
|
|
411
|
+
children: "\u67E5\u770B\u8BE6\u60C5"
|
|
412
|
+
}
|
|
413
|
+
)
|
|
414
|
+
] })
|
|
415
|
+
] })
|
|
416
|
+
] });
|
|
417
|
+
}
|
|
418
|
+
function ActivityPlayPrizeListCard(props) {
|
|
419
|
+
const { data, isHistory = false } = props;
|
|
420
|
+
const [selectedRef, setSelectedRef] = useState5(null);
|
|
421
|
+
const [expanded, setExpanded] = useState5(false);
|
|
422
|
+
const visibleItems = expanded ? data.items : data.items.slice(0, LIST_PREVIEW_COUNT);
|
|
423
|
+
return /* @__PURE__ */ jsxs6("section", { className: "ap-card ap-card--list flex flex-col gap-0 bg-card px-3.5", children: [
|
|
424
|
+
/* @__PURE__ */ jsx6(ListHeader, { title: "\u6211\u7684\u5956\u54C1\u4E00\u89C8", subtitle: `\u4E2D\u5956\u597D\u793C \u5171 ${data.total} \u6761\u8BB0\u5F55`, kind: "prize" }),
|
|
425
|
+
data.items.length === 0 ? /* @__PURE__ */ jsx6("p", { className: "ap-card__empty m-0 px-1.5 py-5 text-center text-xs leading-4.5 text-secondary-foreground", children: data.total === 0 ? data.noResultsReason ?? "\u6682\u65E0\u4E2D\u5956\u8BB0\u5F55" : "\u672C\u6B21\u672A\u8FD4\u56DE\u5956\u54C1\u6761\u76EE" }) : /* @__PURE__ */ jsx6("ul", { className: "ap-card__list m-0 flex list-none flex-col p-0", children: visibleItems.map((item) => /* @__PURE__ */ jsx6(
|
|
426
|
+
PrizeRow,
|
|
427
|
+
{
|
|
428
|
+
item,
|
|
429
|
+
isHistory,
|
|
430
|
+
onDetail: () => setSelectedRef(item.prizeRecordRef)
|
|
431
|
+
},
|
|
432
|
+
item.prizeRecordRef
|
|
433
|
+
)) }),
|
|
434
|
+
!expanded && data.items.length > LIST_PREVIEW_COUNT && /* @__PURE__ */ jsx6(ViewAll, { label: "\u67E5\u770B\u5168\u90E8\u5956\u54C1", onExpand: () => setExpanded(true) }),
|
|
435
|
+
data.truncated && (expanded || data.items.length <= LIST_PREVIEW_COUNT) && /* @__PURE__ */ jsxs6("p", { className: "ap-card__meta ap-list__footer m-0 text-xs leading-4.5 text-muted-foreground [overflow-wrap:anywhere] m-0 border-t border-border py-2 text-[11px] leading-4", children: [
|
|
436
|
+
"\u5171 ",
|
|
437
|
+
data.total,
|
|
438
|
+
" \u6761\u8BB0\u5F55\uFF0C\u5F53\u524D\u5C55\u793A\u524D ",
|
|
439
|
+
data.items.length,
|
|
440
|
+
" \u6761"
|
|
441
|
+
] }),
|
|
442
|
+
selectedRef !== null && !isHistory && /* @__PURE__ */ jsx6(
|
|
443
|
+
PrizeDetailSheet,
|
|
444
|
+
{
|
|
445
|
+
mallId: data.mallId,
|
|
446
|
+
prizeRecordRef: selectedRef,
|
|
447
|
+
onClose: () => setSelectedRef(null)
|
|
448
|
+
},
|
|
449
|
+
`${data.mallId}:${selectedRef}`
|
|
450
|
+
)
|
|
451
|
+
] });
|
|
452
|
+
}
|
|
453
|
+
markSelfRendering2(ActivityPlayPrizeListCard);
|
|
454
|
+
|
|
455
|
+
// src/client/index.ts
|
|
456
|
+
var cards = {
|
|
457
|
+
"activity-play": ActivityPlayCard,
|
|
458
|
+
"activity-play-prize-list": ActivityPlayPrizeListCard
|
|
459
|
+
};
|
|
460
|
+
var clientModule = {
|
|
461
|
+
cards,
|
|
462
|
+
register(ctx) {
|
|
463
|
+
ctx.cards.registerMap(cards);
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
export {
|
|
468
|
+
clientModule
|
|
469
|
+
};
|