@tbox.cn/app-module-activity-play 1.0.0-alpha.16 → 1.0.0-alpha.18

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/README.md CHANGED
@@ -9,9 +9,10 @@
9
9
  已随远端活动改造(2026-11-17)退场——参与跳转由前端构造动态插件公开页链接并经宿主 `my.navigateTo` 处理;
10
10
  详情只服务展示。本人奖品恒按当前可信用户查询(主体检查先于供给调用——缺用户 LOGIN_REQUIRED
11
11
  零奖品 API 调用;领取/核销归供应商)。活动与奖品列表采用门店导览式标题区、图文行和状态标签,图片缺失或加载失败时展示中立图标。
12
- 两类列表默认展示前 3 条,点击底部查看全部在卡片内展开本次已返回条目,不额外查询;奖品截断提示保留。
13
- 活动列表“去参与”重新查询活动详情并打开统一 BottomSheet,展示详情主图、标题简介、状态时间、玩法规则和奖品设置;缺少规则或奖品时隐藏对应区块;弹层底部“立即参与”才构造 `dynamic-plugin://2021007119624628/activity?activityId=<编码后的活动ID>` 并经 `callJsapi('navigateTo', {url})` 交给宿主(详情非 active 时禁用);奖品查看详情重新查询本人记录并通过模板 kit 的统一 BottomSheet 打开半屏弹层。
12
+ 活动列表将进行中项置顶,同组保持返回顺序;排序作用于本次已返回条目,不改变供应商查询或截断范围。两类列表默认展示前 3 条,点击底部查看全部在卡片内展开本次已返回条目,不额外查询;奖品截断提示保留。
13
+ 活动卡的 list/detail 共用初始态的标题区、图文行与状态标签样式;card-preview 仅保留初始态、列表多状态、列表空态、详情进行中。活动列表“去参与”重新查询活动详情并打开统一 BottomSheet,展示详情主图、标题简介、状态时间、玩法规则和奖品设置;缺少规则或奖品时隐藏对应区块;弹层底部“立即参与”才构造 `dynamic-plugin://2021007119624628/activity?activityId=<编码后的活动ID>` 并经 `callJsapi('navigateTo', {url})` 交给宿主(详情非 active 时禁用);奖品查看详情重新查询本人记录并通过模板 kit 的统一 BottomSheet 打开半屏弹层。
14
14
  历史卡禁用参与和奖品详情查询,查看全部仅展开已有快照。宿主需关联动态插件并允许 `my.navigateTo`。
15
+ 参与导航失败时,容器标记或支付宝桥能力在场提示“跳转异常,请稍后重试”;非壳提示“电脑端不支持参与,请扫右下角「支付宝小程序」二维码体验”。
15
16
  接入语义见 [INTEGRATION.md](INTEGRATION.md)。
16
17
 
17
18
  本文描述当前代码契约。远端活动、直接宿主导航及奖品卡片的目标调整见 [实施计划](../../docs/plans/activity-play-plugin/implementation-plan.md);文档方案不表示本包已完成改造。
@@ -63,7 +63,7 @@ import { markSelfRendering } from "@tbox.cn/app-agent-sdk-client";
63
63
  import { useEffect, useRef, useState } from "react";
64
64
  import { toast } from "@tbox.cn/app-agent-ui-kit/toast";
65
65
  import { BottomSheet } from "@tbox.cn/app-agent-ui-kit/bottom-sheet";
66
- import { callJsapi, httpGet } from "@tbox.cn/app-agent-sdk-client";
66
+ import { callJsapi, hasAlipayBridge, httpGet, isInAlipayShell } from "@tbox.cn/app-agent-sdk-client";
67
67
  import { activityPlayActivitySchema } from "@tbox.cn/app-contracts-mall";
68
68
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
69
69
  var ACTIVITY_PLAY_PLUGIN_URL = "dynamic-plugin://2021007119624628/activity";
@@ -108,13 +108,13 @@ function ActivityDetailSheet({ mallId, activityId, onClose }) {
108
108
  try {
109
109
  await callJsapi("navigateTo", { url: buildActivityPlayPluginUrl(detail.activityId) });
110
110
  } catch {
111
- void toast("\u6D3B\u52A8\u6682\u65F6\u65E0\u6CD5\u6253\u5F00\uFF0C\u8BF7\u5728\u5BBF\u4E3B\u5C0F\u7A0B\u5E8F\u4E2D\u91CD\u8BD5");
111
+ void toast(isInAlipayShell() || hasAlipayBridge() ? "\u8DF3\u8F6C\u5F02\u5E38\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5" : "\u7535\u8111\u7AEF\u4E0D\u652F\u6301\u53C2\u4E0E\uFF0C\u8BF7\u626B\u53F3\u4E0B\u89D2\u300C\u652F\u4ED8\u5B9D\u5C0F\u7A0B\u5E8F\u300D\u4E8C\u7EF4\u7801\u4F53\u9A8C");
112
112
  } finally {
113
113
  navigating.current = false;
114
114
  setOpening(false);
115
115
  }
116
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: [
117
+ return /* @__PURE__ */ jsx(BottomSheet, { open: true, title: "\u6D3B\u52A8\u8BE6\u60C5", onClose, size: "large", className: "ap-activity-sheet", children: error ? /* @__PURE__ */ jsx("p", { role: "alert", children: error }) : detail ? /* @__PURE__ */ jsxs(Fragment, { children: [
118
118
  /* @__PURE__ */ jsxs("section", { className: "ap-card ap-card--detail flex flex-col gap-2 bg-transparent p-0", children: [
119
119
  (detail.detailCoverUrl || detail.imageUrl) && /* @__PURE__ */ jsx(
120
120
  "img",
@@ -171,7 +171,7 @@ function ActivityDetailSheet({ mallId, activityId, onClose }) {
171
171
  ] }, index)) })
172
172
  ] })
173
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(
174
+ /* @__PURE__ */ jsx("footer", { className: "ap-activity-sheet__footer mt-3.5 bg-card pt-2.5 [&>button]:min-h-10 [&>button]:w-full", children: /* @__PURE__ */ jsx(
175
175
  "button",
176
176
  {
177
177
  type: "button",
@@ -266,25 +266,8 @@ function ActivityRow({ item, mallId, isHistory }) {
266
266
  function ActivityPlayCard(props) {
267
267
  const { data, isHistory = false } = props;
268
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
- }
269
+ const sortedItems = [...data.items].sort((a, b) => Number(b.status === "active") - Number(a.status === "active"));
270
+ const visibleItems = expanded ? sortedItems : sortedItems.slice(0, LIST_PREVIEW_COUNT);
288
271
  return /* @__PURE__ */ jsxs3("section", { className: "ap-card ap-card--list flex flex-col gap-0 bg-card px-3.5", children: [
289
272
  /* @__PURE__ */ jsx3(ListHeader, { title: "\u5546\u5708\u6D3B\u52A8\u4E00\u89C8", subtitle: "\u8FD1\u671F\u6D3B\u52A8 \u4E00\u952E\u53C2\u4E0E", kind: "activity" }),
290
273
  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)) }),
@@ -776,32 +776,9 @@ var activityPlayCardSamples = [
776
776
  items: [
777
777
  { activityId: "demo-wheel", title: "\u5E78\u8FD0\u5927\u8F6C\u76D8", description: "\u8FDB\u5165\u6D3B\u52A8\u9875\u9762\u67E5\u770B\u53C2\u4E0E\u89C4\u5219", status: "active" },
778
778
  { activityId: "demo-points", title: "\u79EF\u5206\u7FFB\u500D", startsAt: "2026-12-01T10:00:00+08:00", endsAt: "2026-12-31T22:00:00+08:00", status: "not_started" },
779
- { activityId: "demo-ended", title: "\u5468\u5E74\u5E86\u62BD\u5956", description: "\u6D3B\u52A8\u5DF2\u7ED3\u675F", endsAt: "2026-10-31T22:00:00+08:00", status: "ended" }
780
- ]
781
- }
782
- },
783
- {
784
- label: "\u5217\u8868\xB7\u5E26\u5C01\u9762",
785
- group: "\u6D3B\u52A8\u73A9\u6CD5\xB7\u5217\u8868",
786
- note: "\u53EF\u9009 imageUrl \u5B57\u6BB5\u5728\u573A\uFF08HTTPS \u5360\u4F4D\u2014\u2014\u7F3A\u7701\u56FE\u515C\u5E95\u5206\u652F\u7684\u7B49\u4EF7\u793A\u8303\uFF09",
787
- data: {
788
- mallId: "mall-demo",
789
- mode: "list",
790
- items: [
791
- { activityId: "demo-wheel", title: "\u5E78\u8FD0\u5927\u8F6C\u76D8", imageUrl: "https://example.com/wheel.png", status: "active" }
792
- ]
793
- }
794
- },
795
- {
796
- label: "\u5217\u8868\xB7\u6570\u5B57\u5F62\u6001 ID",
797
- group: "\u6D3B\u52A8\u73A9\u6CD5\xB7\u5217\u8868",
798
- note: 'activityId \u6309\u539F\u5B57\u7B26\u4E32\u5904\u7406\u2014\u2014"001" \u4E0E "1" \u662F\u4E0D\u540C\u6D3B\u52A8\uFF08\u4F9B\u5E94\u5546\u5B9A\u4E49\u6807\u8BC6\u7A7A\u95F4\uFF09',
799
- data: {
800
- mallId: "mall-demo",
801
- mode: "list",
802
- items: [
803
- { activityId: "001", title: "\u96F6\u4E00\u6D3B\u52A8", status: "active" },
804
- { activityId: "1", title: "\u58F9\u53F7\u6D3B\u52A8", status: "active" }
779
+ { activityId: "demo-ended", title: "\u5468\u5E74\u5E86\u62BD\u5956", description: "\u6D3B\u52A8\u5DF2\u7ED3\u675F", endsAt: "2026-10-31T22:00:00+08:00", status: "ended" },
780
+ { activityId: "demo-paused", title: "\u6682\u505C\u4E2D\u7684\u6D3B\u52A8", status: "disabled" },
781
+ { activityId: "demo-weird", title: "\u795E\u79D8\u65B0\u73A9\u6CD5", status: "unknown" }
805
782
  ]
806
783
  }
807
784
  },
@@ -834,61 +811,6 @@ var activityPlayCardSamples = [
834
811
  }
835
812
  ]
836
813
  }
837
- },
838
- {
839
- label: "\u8BE6\u60C5\xB7\u672A\u5F00\u59CB",
840
- group: "\u6D3B\u52A8\u73A9\u6CD5\xB7\u8BE6\u60C5",
841
- note: "\u65F6\u95F4\u4E0E\u72B6\u6001\u5E76\u5B58\uFF08\u56DE\u590D\u300C\u4EC0\u4E48\u65F6\u5019\u5F00\u59CB\u300D\u7684\u5C55\u793A\u5206\u652F\uFF09",
842
- data: {
843
- mallId: "mall-demo",
844
- mode: "detail",
845
- items: [
846
- {
847
- activityId: "demo-points",
848
- title: "\u79EF\u5206\u7FFB\u500D",
849
- description: "\u6D3B\u52A8\u671F\u95F4\u6D88\u8D39\u79EF\u5206\u53CC\u500D",
850
- startsAt: "2026-12-01T10:00:00+08:00",
851
- endsAt: "2026-12-31T22:00:00+08:00",
852
- status: "not_started"
853
- }
854
- ]
855
- }
856
- },
857
- {
858
- label: "\u8BE6\u60C5\xB7\u72B6\u6001\u672A\u77E5",
859
- group: "\u6D3B\u52A8\u73A9\u6CD5\xB7\u8BE6\u60C5",
860
- note: "unknown \u4FDD\u5B88\u5C55\u793A\uFF08\u4E0A\u6E38\u672A\u77E5\u679A\u4E3E\u2014\u2014\u4E0D\u63A8\u65AD\u4E3A\u8FDB\u884C\u4E2D\uFF0C\u4E0D\u5F15\u5BFC\u53C2\u4E0E\u52A8\u4F5C\uFF09",
861
- data: {
862
- mallId: "mall-demo",
863
- mode: "detail",
864
- items: [
865
- { activityId: "demo-weird", title: "\u795E\u79D8\u65B0\u73A9\u6CD5", status: "unknown" }
866
- ]
867
- }
868
- },
869
- {
870
- label: "\u8BE6\u60C5\xB7\u5DF2\u4E0B\u7EBF",
871
- group: "\u6D3B\u52A8\u73A9\u6CD5\xB7\u8BE6\u60C5",
872
- note: "\u8BE6\u60C5\u5141\u8BB8\u8FD4\u56DE disabled\uFF08\u4F9B\u5E94\u5546\u5DF2\u505C\u7528\u2014\u2014\u8BF4\u660E\u72B6\u6001\uFF0C\u4E0D\u7B49\u4E8E\u4E0D\u5B58\u5728\uFF09",
873
- data: {
874
- mallId: "mall-demo",
875
- mode: "detail",
876
- items: [
877
- { activityId: "demo-paused", title: "\u6682\u505C\u4E2D\u7684\u6D3B\u52A8", status: "disabled" }
878
- ]
879
- }
880
- },
881
- {
882
- label: "\u8BE6\u60C5\xB7\u5DF2\u7ED3\u675F",
883
- group: "\u6D3B\u52A8\u73A9\u6CD5\xB7\u8BE6\u60C5",
884
- note: "ended \u6001\uFF08\u5386\u53F2\u8BF4\u660E\u7528\uFF09",
885
- data: {
886
- mallId: "mall-demo",
887
- mode: "detail",
888
- items: [
889
- { activityId: "demo-ended", title: "\u5468\u5E74\u5E86\u62BD\u5956", description: "\u6D3B\u52A8\u5DF2\u7ED3\u675F", endsAt: "2026-10-31T22:00:00+08:00", status: "ended" }
890
- ]
891
- }
892
814
  }
893
815
  ];
894
816
 
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  clientModule
3
- } from "../chunk-OFPXH7OI.js";
3
+ } from "../chunk-3JWG2EQT.js";
4
4
  export {
5
5
  clientModule
6
6
  };
package/dist/index.js CHANGED
@@ -31,10 +31,10 @@ import {
31
31
  toActivityPlayPrizeError,
32
32
  toPrizeDetailCardData,
33
33
  toPrizeListCardData
34
- } from "./chunk-YH6HTRSS.js";
34
+ } from "./chunk-ZT6G6NZQ.js";
35
35
  import {
36
36
  clientModule
37
- } from "./chunk-OFPXH7OI.js";
37
+ } from "./chunk-3JWG2EQT.js";
38
38
  export {
39
39
  ACTIVITY_PLAY_CARD_TYPE,
40
40
  ACTIVITY_PLAY_LIMIT_DEFAULT,
@@ -160,9 +160,9 @@ declare const activityPlayCards: {
160
160
  endsAt: zod.ZodOptional<zod.ZodString>;
161
161
  status: zod.ZodEnum<["not_started", "active", "ended", "disabled", "unknown"]>;
162
162
  }, "strict", zod.ZodTypeAny, {
163
- status: "unknown" | "not_started" | "active" | "ended" | "disabled";
164
- activityId: string;
163
+ status: "unknown" | "disabled" | "not_started" | "active" | "ended";
165
164
  title: string;
165
+ activityId: string;
166
166
  description?: string | undefined;
167
167
  imageUrl?: string | undefined;
168
168
  detailCoverUrl?: string | undefined;
@@ -179,9 +179,9 @@ declare const activityPlayCards: {
179
179
  startsAt?: string | undefined;
180
180
  endsAt?: string | undefined;
181
181
  }, {
182
- status: "unknown" | "not_started" | "active" | "ended" | "disabled";
183
- activityId: string;
182
+ status: "unknown" | "disabled" | "not_started" | "active" | "ended";
184
183
  title: string;
184
+ activityId: string;
185
185
  description?: string | undefined;
186
186
  imageUrl?: string | undefined;
187
187
  detailCoverUrl?: string | undefined;
@@ -199,12 +199,10 @@ declare const activityPlayCards: {
199
199
  endsAt?: string | undefined;
200
200
  }>, "many">;
201
201
  }, "strip", zod.ZodTypeAny, {
202
- mallId: string;
203
- mode: "list" | "detail";
204
202
  items: {
205
- status: "unknown" | "not_started" | "active" | "ended" | "disabled";
206
- activityId: string;
203
+ status: "unknown" | "disabled" | "not_started" | "active" | "ended";
207
204
  title: string;
205
+ activityId: string;
208
206
  description?: string | undefined;
209
207
  imageUrl?: string | undefined;
210
208
  detailCoverUrl?: string | undefined;
@@ -221,13 +219,13 @@ declare const activityPlayCards: {
221
219
  startsAt?: string | undefined;
222
220
  endsAt?: string | undefined;
223
221
  }[];
224
- }, {
222
+ mode: "detail" | "list";
225
223
  mallId: string;
226
- mode: "list" | "detail";
224
+ }, {
227
225
  items: {
228
- status: "unknown" | "not_started" | "active" | "ended" | "disabled";
229
- activityId: string;
226
+ status: "unknown" | "disabled" | "not_started" | "active" | "ended";
230
227
  title: string;
228
+ activityId: string;
231
229
  description?: string | undefined;
232
230
  imageUrl?: string | undefined;
233
231
  detailCoverUrl?: string | undefined;
@@ -244,13 +242,13 @@ declare const activityPlayCards: {
244
242
  startsAt?: string | undefined;
245
243
  endsAt?: string | undefined;
246
244
  }[];
247
- }>, {
245
+ mode: "detail" | "list";
248
246
  mallId: string;
249
- mode: "list" | "detail";
247
+ }>, {
250
248
  items: {
251
- status: "unknown" | "not_started" | "active" | "ended" | "disabled";
252
- activityId: string;
249
+ status: "unknown" | "disabled" | "not_started" | "active" | "ended";
253
250
  title: string;
251
+ activityId: string;
254
252
  description?: string | undefined;
255
253
  imageUrl?: string | undefined;
256
254
  detailCoverUrl?: string | undefined;
@@ -267,13 +265,13 @@ declare const activityPlayCards: {
267
265
  startsAt?: string | undefined;
268
266
  endsAt?: string | undefined;
269
267
  }[];
270
- }, {
268
+ mode: "detail" | "list";
271
269
  mallId: string;
272
- mode: "list" | "detail";
270
+ }, {
273
271
  items: {
274
- status: "unknown" | "not_started" | "active" | "ended" | "disabled";
275
- activityId: string;
272
+ status: "unknown" | "disabled" | "not_started" | "active" | "ended";
276
273
  title: string;
274
+ activityId: string;
277
275
  description?: string | undefined;
278
276
  imageUrl?: string | undefined;
279
277
  detailCoverUrl?: string | undefined;
@@ -290,6 +288,8 @@ declare const activityPlayCards: {
290
288
  startsAt?: string | undefined;
291
289
  endsAt?: string | undefined;
292
290
  }[];
291
+ mode: "detail" | "list";
292
+ mallId: string;
293
293
  }>>;
294
294
  readonly 'activity-play-prize-list': _tbox_cn_app_contracts.CardMeta<zod.ZodObject<{
295
295
  mallId: zod.ZodString;
@@ -312,13 +312,13 @@ declare const activityPlayCards: {
312
312
  value: zod.ZodOptional<zod.ZodString>;
313
313
  visibleValue: zod.ZodOptional<zod.ZodString>;
314
314
  }, "strip", zod.ZodTypeAny, {
315
- kind: "send";
316
315
  label: string;
316
+ kind: "send";
317
317
  value?: string | undefined;
318
318
  visibleValue?: string | undefined;
319
319
  }, {
320
- kind: "send";
321
320
  label: string;
321
+ kind: "send";
322
322
  value?: string | undefined;
323
323
  visibleValue?: string | undefined;
324
324
  }>, zod.ZodObject<{
@@ -326,12 +326,12 @@ declare const activityPlayCards: {
326
326
  label: zod.ZodString;
327
327
  url: zod.ZodString;
328
328
  }, "strip", zod.ZodTypeAny, {
329
- kind: "link";
330
329
  label: string;
330
+ kind: "link";
331
331
  url: string;
332
332
  }, {
333
- kind: "link";
334
333
  label: string;
334
+ kind: "link";
335
335
  url: string;
336
336
  }>]>, "many">>;
337
337
  }, "strict", zod.ZodTypeAny, {
@@ -346,13 +346,13 @@ declare const activityPlayCards: {
346
346
  wonAt?: string | undefined;
347
347
  usageRuleText?: string | undefined;
348
348
  itemActions?: ({
349
- kind: "send";
350
349
  label: string;
350
+ kind: "send";
351
351
  value?: string | undefined;
352
352
  visibleValue?: string | undefined;
353
353
  } | {
354
- kind: "link";
355
354
  label: string;
355
+ kind: "link";
356
356
  url: string;
357
357
  })[] | undefined;
358
358
  }, {
@@ -367,20 +367,19 @@ declare const activityPlayCards: {
367
367
  wonAt?: string | undefined;
368
368
  usageRuleText?: string | undefined;
369
369
  itemActions?: ({
370
- kind: "send";
371
370
  label: string;
371
+ kind: "send";
372
372
  value?: string | undefined;
373
373
  visibleValue?: string | undefined;
374
374
  } | {
375
- kind: "link";
376
375
  label: string;
376
+ kind: "link";
377
377
  url: string;
378
378
  })[] | undefined;
379
379
  }>, "many">;
380
380
  noResultsReason: zod.ZodOptional<zod.ZodString>;
381
381
  truncated: zod.ZodOptional<zod.ZodBoolean>;
382
382
  }, "strict", zod.ZodTypeAny, {
383
- mallId: string;
384
383
  items: {
385
384
  title: string;
386
385
  prizeRecordRef: string;
@@ -393,21 +392,21 @@ declare const activityPlayCards: {
393
392
  wonAt?: string | undefined;
394
393
  usageRuleText?: string | undefined;
395
394
  itemActions?: ({
396
- kind: "send";
397
395
  label: string;
396
+ kind: "send";
398
397
  value?: string | undefined;
399
398
  visibleValue?: string | undefined;
400
399
  } | {
401
- kind: "link";
402
400
  label: string;
401
+ kind: "link";
403
402
  url: string;
404
403
  })[] | undefined;
405
404
  }[];
406
405
  total: number;
407
- noResultsReason?: string | undefined;
406
+ mallId: string;
408
407
  truncated?: boolean | undefined;
408
+ noResultsReason?: string | undefined;
409
409
  }, {
410
- mallId: string;
411
410
  items: {
412
411
  title: string;
413
412
  prizeRecordRef: string;
@@ -420,19 +419,20 @@ declare const activityPlayCards: {
420
419
  wonAt?: string | undefined;
421
420
  usageRuleText?: string | undefined;
422
421
  itemActions?: ({
423
- kind: "send";
424
422
  label: string;
423
+ kind: "send";
425
424
  value?: string | undefined;
426
425
  visibleValue?: string | undefined;
427
426
  } | {
428
- kind: "link";
429
427
  label: string;
428
+ kind: "link";
430
429
  url: string;
431
430
  })[] | undefined;
432
431
  }[];
433
432
  total: number;
434
- noResultsReason?: string | undefined;
433
+ mallId: string;
435
434
  truncated?: boolean | undefined;
435
+ noResultsReason?: string | undefined;
436
436
  }>>;
437
437
  };
438
438
 
@@ -638,9 +638,9 @@ declare const serverModule: {
638
638
  endsAt: zod.ZodOptional<zod.ZodString>;
639
639
  status: zod.ZodEnum<["not_started", "active", "ended", "disabled", "unknown"]>;
640
640
  }, "strict", zod.ZodTypeAny, {
641
- status: "unknown" | "not_started" | "active" | "ended" | "disabled";
642
- activityId: string;
641
+ status: "unknown" | "disabled" | "not_started" | "active" | "ended";
643
642
  title: string;
643
+ activityId: string;
644
644
  description?: string | undefined;
645
645
  imageUrl?: string | undefined;
646
646
  detailCoverUrl?: string | undefined;
@@ -657,9 +657,9 @@ declare const serverModule: {
657
657
  startsAt?: string | undefined;
658
658
  endsAt?: string | undefined;
659
659
  }, {
660
- status: "unknown" | "not_started" | "active" | "ended" | "disabled";
661
- activityId: string;
660
+ status: "unknown" | "disabled" | "not_started" | "active" | "ended";
662
661
  title: string;
662
+ activityId: string;
663
663
  description?: string | undefined;
664
664
  imageUrl?: string | undefined;
665
665
  detailCoverUrl?: string | undefined;
@@ -677,12 +677,10 @@ declare const serverModule: {
677
677
  endsAt?: string | undefined;
678
678
  }>, "many">;
679
679
  }, "strip", zod.ZodTypeAny, {
680
- mallId: string;
681
- mode: "list" | "detail";
682
680
  items: {
683
- status: "unknown" | "not_started" | "active" | "ended" | "disabled";
684
- activityId: string;
681
+ status: "unknown" | "disabled" | "not_started" | "active" | "ended";
685
682
  title: string;
683
+ activityId: string;
686
684
  description?: string | undefined;
687
685
  imageUrl?: string | undefined;
688
686
  detailCoverUrl?: string | undefined;
@@ -699,13 +697,13 @@ declare const serverModule: {
699
697
  startsAt?: string | undefined;
700
698
  endsAt?: string | undefined;
701
699
  }[];
702
- }, {
700
+ mode: "detail" | "list";
703
701
  mallId: string;
704
- mode: "list" | "detail";
702
+ }, {
705
703
  items: {
706
- status: "unknown" | "not_started" | "active" | "ended" | "disabled";
707
- activityId: string;
704
+ status: "unknown" | "disabled" | "not_started" | "active" | "ended";
708
705
  title: string;
706
+ activityId: string;
709
707
  description?: string | undefined;
710
708
  imageUrl?: string | undefined;
711
709
  detailCoverUrl?: string | undefined;
@@ -722,13 +720,13 @@ declare const serverModule: {
722
720
  startsAt?: string | undefined;
723
721
  endsAt?: string | undefined;
724
722
  }[];
725
- }>, {
723
+ mode: "detail" | "list";
726
724
  mallId: string;
727
- mode: "list" | "detail";
725
+ }>, {
728
726
  items: {
729
- status: "unknown" | "not_started" | "active" | "ended" | "disabled";
730
- activityId: string;
727
+ status: "unknown" | "disabled" | "not_started" | "active" | "ended";
731
728
  title: string;
729
+ activityId: string;
732
730
  description?: string | undefined;
733
731
  imageUrl?: string | undefined;
734
732
  detailCoverUrl?: string | undefined;
@@ -745,13 +743,13 @@ declare const serverModule: {
745
743
  startsAt?: string | undefined;
746
744
  endsAt?: string | undefined;
747
745
  }[];
748
- }, {
746
+ mode: "detail" | "list";
749
747
  mallId: string;
750
- mode: "list" | "detail";
748
+ }, {
751
749
  items: {
752
- status: "unknown" | "not_started" | "active" | "ended" | "disabled";
753
- activityId: string;
750
+ status: "unknown" | "disabled" | "not_started" | "active" | "ended";
754
751
  title: string;
752
+ activityId: string;
755
753
  description?: string | undefined;
756
754
  imageUrl?: string | undefined;
757
755
  detailCoverUrl?: string | undefined;
@@ -768,6 +766,8 @@ declare const serverModule: {
768
766
  startsAt?: string | undefined;
769
767
  endsAt?: string | undefined;
770
768
  }[];
769
+ mode: "detail" | "list";
770
+ mallId: string;
771
771
  }>>;
772
772
  readonly 'activity-play-prize-list': _tbox_cn_app_contracts.CardMeta<zod.ZodObject<{
773
773
  mallId: zod.ZodString;
@@ -790,13 +790,13 @@ declare const serverModule: {
790
790
  value: zod.ZodOptional<zod.ZodString>;
791
791
  visibleValue: zod.ZodOptional<zod.ZodString>;
792
792
  }, "strip", zod.ZodTypeAny, {
793
- kind: "send";
794
793
  label: string;
794
+ kind: "send";
795
795
  value?: string | undefined;
796
796
  visibleValue?: string | undefined;
797
797
  }, {
798
- kind: "send";
799
798
  label: string;
799
+ kind: "send";
800
800
  value?: string | undefined;
801
801
  visibleValue?: string | undefined;
802
802
  }>, zod.ZodObject<{
@@ -804,12 +804,12 @@ declare const serverModule: {
804
804
  label: zod.ZodString;
805
805
  url: zod.ZodString;
806
806
  }, "strip", zod.ZodTypeAny, {
807
- kind: "link";
808
807
  label: string;
808
+ kind: "link";
809
809
  url: string;
810
810
  }, {
811
- kind: "link";
812
811
  label: string;
812
+ kind: "link";
813
813
  url: string;
814
814
  }>]>, "many">>;
815
815
  }, "strict", zod.ZodTypeAny, {
@@ -824,13 +824,13 @@ declare const serverModule: {
824
824
  wonAt?: string | undefined;
825
825
  usageRuleText?: string | undefined;
826
826
  itemActions?: ({
827
- kind: "send";
828
827
  label: string;
828
+ kind: "send";
829
829
  value?: string | undefined;
830
830
  visibleValue?: string | undefined;
831
831
  } | {
832
- kind: "link";
833
832
  label: string;
833
+ kind: "link";
834
834
  url: string;
835
835
  })[] | undefined;
836
836
  }, {
@@ -845,20 +845,19 @@ declare const serverModule: {
845
845
  wonAt?: string | undefined;
846
846
  usageRuleText?: string | undefined;
847
847
  itemActions?: ({
848
- kind: "send";
849
848
  label: string;
849
+ kind: "send";
850
850
  value?: string | undefined;
851
851
  visibleValue?: string | undefined;
852
852
  } | {
853
- kind: "link";
854
853
  label: string;
854
+ kind: "link";
855
855
  url: string;
856
856
  })[] | undefined;
857
857
  }>, "many">;
858
858
  noResultsReason: zod.ZodOptional<zod.ZodString>;
859
859
  truncated: zod.ZodOptional<zod.ZodBoolean>;
860
860
  }, "strict", zod.ZodTypeAny, {
861
- mallId: string;
862
861
  items: {
863
862
  title: string;
864
863
  prizeRecordRef: string;
@@ -871,21 +870,21 @@ declare const serverModule: {
871
870
  wonAt?: string | undefined;
872
871
  usageRuleText?: string | undefined;
873
872
  itemActions?: ({
874
- kind: "send";
875
873
  label: string;
874
+ kind: "send";
876
875
  value?: string | undefined;
877
876
  visibleValue?: string | undefined;
878
877
  } | {
879
- kind: "link";
880
878
  label: string;
879
+ kind: "link";
881
880
  url: string;
882
881
  })[] | undefined;
883
882
  }[];
884
883
  total: number;
885
- noResultsReason?: string | undefined;
884
+ mallId: string;
886
885
  truncated?: boolean | undefined;
886
+ noResultsReason?: string | undefined;
887
887
  }, {
888
- mallId: string;
889
888
  items: {
890
889
  title: string;
891
890
  prizeRecordRef: string;
@@ -898,19 +897,20 @@ declare const serverModule: {
898
897
  wonAt?: string | undefined;
899
898
  usageRuleText?: string | undefined;
900
899
  itemActions?: ({
901
- kind: "send";
902
900
  label: string;
901
+ kind: "send";
903
902
  value?: string | undefined;
904
903
  visibleValue?: string | undefined;
905
904
  } | {
906
- kind: "link";
907
905
  label: string;
906
+ kind: "link";
908
907
  url: string;
909
908
  })[] | undefined;
910
909
  }[];
911
910
  total: number;
912
- noResultsReason?: string | undefined;
911
+ mallId: string;
913
912
  truncated?: boolean | undefined;
913
+ noResultsReason?: string | undefined;
914
914
  }>>;
915
915
  };
916
916
  skills: {
@@ -31,7 +31,7 @@ import {
31
31
  toActivityPlayPrizeError,
32
32
  toPrizeDetailCardData,
33
33
  toPrizeListCardData
34
- } from "../chunk-YH6HTRSS.js";
34
+ } from "../chunk-ZT6G6NZQ.js";
35
35
  export {
36
36
  ACTIVITY_PLAY_CARD_TYPE,
37
37
  ACTIVITY_PLAY_LIMIT_DEFAULT,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tbox.cn/app-module-activity-play",
3
- "version": "1.0.0-alpha.16",
3
+ "version": "1.0.0-alpha.18",
4
4
  "type": "module",
5
5
  "description": "活动玩法业务模块:供应商活动查询(HTTP/工具/出卡)",
6
6
  "exports": {
@@ -19,15 +19,15 @@
19
19
  "./package.json": "./package.json"
20
20
  },
21
21
  "dependencies": {
22
- "@tbox.cn/app-contracts": "1.0.0-alpha.16",
23
- "@tbox.cn/app-contracts-mall": "1.0.0-alpha.16",
24
- "@tbox.cn/app-agent-sdk-client": "1.0.0-alpha.16",
25
- "@tbox.cn/app-agent-sdk-server": "1.0.0-alpha.16"
22
+ "@tbox.cn/app-contracts": "1.0.0-alpha.18",
23
+ "@tbox.cn/app-contracts-mall": "1.0.0-alpha.18",
24
+ "@tbox.cn/app-agent-sdk-client": "1.0.0-alpha.18",
25
+ "@tbox.cn/app-agent-sdk-server": "1.0.0-alpha.18"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "zod": "3.25.76",
29
29
  "react": "18.3.1",
30
- "@tbox.cn/app-agent-ui-kit": "^1.0.0-alpha.16"
30
+ "@tbox.cn/app-agent-ui-kit": "^1.0.0-alpha.18"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/express": "4.17.25",
@@ -2,7 +2,7 @@ import { activityPlayBadgeClass } from '../view';
2
2
  import { useEffect, useRef, useState } from 'react';
3
3
  import { toast } from '@tbox.cn/app-agent-ui-kit/toast';
4
4
  import { BottomSheet } from '@tbox.cn/app-agent-ui-kit/bottom-sheet';
5
- import { callJsapi, httpGet } from '@tbox.cn/app-agent-sdk-client';
5
+ import { callJsapi, hasAlipayBridge, httpGet, isInAlipayShell } from '@tbox.cn/app-agent-sdk-client';
6
6
  import { activityPlayActivitySchema } from '@tbox.cn/app-contracts-mall';
7
7
  import type { ActivityPlayActivity } from '@tbox.cn/app-contracts-mall';
8
8
  import { activityPlayStatusText, activityPlayStatusTone, formatActivityPlayTime } from '../view';
@@ -57,7 +57,9 @@ export function ActivityDetailSheet({ mallId, activityId, onClose }: {
57
57
  try {
58
58
  await callJsapi('navigateTo', { url: buildActivityPlayPluginUrl(detail.activityId) });
59
59
  } catch {
60
- void toast('活动暂时无法打开,请在宿主小程序中重试');
60
+ void toast(isInAlipayShell() || hasAlipayBridge()
61
+ ? '跳转异常,请稍后重试'
62
+ : '电脑端不支持参与,请扫右下角「支付宝小程序」二维码体验');
61
63
  } finally {
62
64
  navigating.current = false;
63
65
  setOpening(false);
@@ -65,7 +67,7 @@ export function ActivityDetailSheet({ mallId, activityId, onClose }: {
65
67
  };
66
68
 
67
69
  return (
68
- <BottomSheet open title="活动详情" onClose={onClose} className="ap-activity-sheet">
70
+ <BottomSheet open title="活动详情" onClose={onClose} size="large" className="ap-activity-sheet">
69
71
  {error ? <p role="alert">{error}</p> : detail ? (
70
72
  <>
71
73
  <section className="ap-card ap-card--detail flex flex-col gap-2 bg-transparent p-0">
@@ -130,7 +132,7 @@ export function ActivityDetailSheet({ mallId, activityId, onClose }: {
130
132
  </section>
131
133
  )}
132
134
  </section>
133
- <footer className="ap-activity-sheet__footer sticky bottom-0 mt-3.5 bg-card pt-2.5 [&>button]:min-h-10 [&>button]:w-full">
135
+ <footer className="ap-activity-sheet__footer mt-3.5 bg-card pt-2.5 [&>button]:min-h-10 [&>button]:w-full">
134
136
  <button type="button" 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" disabled={opening || detail.status !== 'active'}
135
137
  onClick={() => { void participate(); }}>
136
138
  {opening ? '打开中' : detail.status === 'active' ? '立即参与' : activityPlayStatusText(detail.status)}
@@ -50,30 +50,8 @@ function ActivityRow({ item, mallId, isHistory }: {
50
50
  export function ActivityPlayCard(props: { data: ActivityPlayCardData; isHistory?: boolean }) {
51
51
  const { data, isHistory = false } = props;
52
52
  const [expanded, setExpanded] = useState(false);
53
- const visibleItems = expanded ? data.items : data.items.slice(0, LIST_PREVIEW_COUNT);
54
- if (data.mode === 'detail') {
55
- const item = data.items[0];
56
- if (!item) return null; // 契约保证 detail 恰 1 项;防御性渲染
57
- const range = [formatActivityPlayTime(item.startsAt), formatActivityPlayTime(item.endsAt)]
58
- .filter(Boolean)
59
- .join(' — ');
60
- return (
61
- <section className="ap-card ap-card--detail flex flex-col gap-2 bg-transparent p-0">
62
- <span className="ap-card__eyebrow text-xs leading-4.5 text-muted-foreground">活动玩法</span>
63
- <div className="ap-card__detail-head flex flex-wrap items-center gap-2 [&>strong]:text-base [&>strong]:leading-5.5">
64
- <strong>{item.title}</strong>
65
- <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)}`}>
66
- {activityPlayStatusText(item.status)}
67
- </span>
68
- </div>
69
- {item.description && <p className="ap-card__detail-desc m-0 whitespace-pre-wrap text-[13px] leading-[19px] text-secondary-foreground [overflow-wrap:anywhere]">{item.description}</p>}
70
- {item.imageUrl && (
71
- <img className="ap-card__cover max-h-45 w-full rounded-md object-cover" src={item.imageUrl} alt={`${item.title}封面`} loading="lazy" />
72
- )}
73
- {range && <p className="ap-card__meta m-0 text-xs leading-4.5 text-muted-foreground [overflow-wrap:anywhere]">活动时间:{range}</p>}
74
- </section>
75
- );
76
- }
53
+ const sortedItems = [...data.items].sort((a, b) => Number(b.status === 'active') - Number(a.status === 'active'));
54
+ const visibleItems = expanded ? sortedItems : sortedItems.slice(0, LIST_PREVIEW_COUNT);
77
55
  return (
78
56
  <section className="ap-card ap-card--list flex flex-col gap-0 bg-card px-3.5">
79
57
  <ListHeader title="商圈活动一览" subtitle="近期活动 一键参与" kind="activity" />
@@ -2,7 +2,7 @@
2
2
  * activity-play 卡元数据(单一稳定传输卡型;mode 区分列表/详情——视觉由前端渲染器组织)。
3
3
  * 数据契约单源 = contracts-mall activityPlayCardDataSchema(条目复用供应商活动对象
4
4
  * activityPlayActivitySchema——不含本地目录/入口配置字段)。信封字段(ID/时间戳/历史
5
- * 标记)由 SDK 生成。unknown 状态样本覆盖见 samples。
5
+ * 标记)由 SDK 生成。unknown 状态由列表多状态样本覆盖。
6
6
  */
7
7
  import type { CardMeta } from '@tbox.cn/app-contracts';
8
8
  import { activityPlayCardDataSchema } from '@tbox.cn/app-contracts-mall';
@@ -1,15 +1,4 @@
1
- /**
2
- * activity-play 卡附加预览样本(远端活动改造 2026-11-17——覆盖列表/详情/空态/
3
- * 四种已知状态与 unknown/可空字段缺席)。
4
- *
5
- * 方法论(对齐 member/parking 画廊沉淀约定):
6
- * - 样本即契约:全样本 data 必须 activityPlayCardDataSchema 校验通过且无 shape 外键
7
- * (module tests/samples.test.ts 双断言);
8
- * - mallId 恒用 demo 商圈标识(卡片 data 的 mallId 来自执行上下文——样本仅预览展示位);
9
- * - activityId 用字符形态多样的假值('001' 引用形态示例——原字符串语义示范);
10
- * - imageUrl 只用 example.com 占位(缺省图兜底分支的等价示范);
11
- * - 可选字段(说明/图片/起止时间)缺席样本在场(外部缺事实不编造)。
12
- */
1
+ /** 活动玩法附加预览:列表多状态、列表空态、详情进行中;初始态由 meta.sampleData 提供。 */
13
2
  import type { CardSample } from '@tbox.cn/app-contracts';
14
3
  import type { ActivityPlayCardData } from '@tbox.cn/app-contracts-mall';
15
4
 
@@ -25,31 +14,8 @@ export const activityPlayCardSamples: CardSample<ActivityPlayCardData>[] = [
25
14
  { activityId: 'demo-wheel', title: '幸运大转盘', description: '进入活动页面查看参与规则', status: 'active' },
26
15
  { activityId: 'demo-points', title: '积分翻倍', startsAt: '2026-12-01T10:00:00+08:00', endsAt: '2026-12-31T22:00:00+08:00', status: 'not_started' },
27
16
  { activityId: 'demo-ended', title: '周年庆抽奖', description: '活动已结束', endsAt: '2026-10-31T22:00:00+08:00', status: 'ended' },
28
- ],
29
- },
30
- },
31
- {
32
- label: '列表·带封面',
33
- group: '活动玩法·列表',
34
- note: '可选 imageUrl 字段在场(HTTPS 占位——缺省图兜底分支的等价示范)',
35
- data: {
36
- mallId: 'mall-demo',
37
- mode: 'list',
38
- items: [
39
- { activityId: 'demo-wheel', title: '幸运大转盘', imageUrl: 'https://example.com/wheel.png', status: 'active' },
40
- ],
41
- },
42
- },
43
- {
44
- label: '列表·数字形态 ID',
45
- group: '活动玩法·列表',
46
- note: 'activityId 按原字符串处理——"001" 与 "1" 是不同活动(供应商定义标识空间)',
47
- data: {
48
- mallId: 'mall-demo',
49
- mode: 'list',
50
- items: [
51
- { activityId: '001', title: '零一活动', status: 'active' },
52
- { activityId: '1', title: '壹号活动', status: 'active' },
17
+ { activityId: 'demo-paused', title: '暂停中的活动', status: 'disabled' },
18
+ { activityId: 'demo-weird', title: '神秘新玩法', status: 'unknown' },
53
19
  ],
54
20
  },
55
21
  },
@@ -83,59 +49,4 @@ export const activityPlayCardSamples: CardSample<ActivityPlayCardData>[] = [
83
49
  ],
84
50
  },
85
51
  },
86
- {
87
- label: '详情·未开始',
88
- group: '活动玩法·详情',
89
- note: '时间与状态并存(回复「什么时候开始」的展示分支)',
90
- data: {
91
- mallId: 'mall-demo',
92
- mode: 'detail',
93
- items: [
94
- {
95
- activityId: 'demo-points',
96
- title: '积分翻倍',
97
- description: '活动期间消费积分双倍',
98
- startsAt: '2026-12-01T10:00:00+08:00',
99
- endsAt: '2026-12-31T22:00:00+08:00',
100
- status: 'not_started',
101
- },
102
- ],
103
- },
104
- },
105
- {
106
- label: '详情·状态未知',
107
- group: '活动玩法·详情',
108
- note: 'unknown 保守展示(上游未知枚举——不推断为进行中,不引导参与动作)',
109
- data: {
110
- mallId: 'mall-demo',
111
- mode: 'detail',
112
- items: [
113
- { activityId: 'demo-weird', title: '神秘新玩法', status: 'unknown' },
114
- ],
115
- },
116
- },
117
- {
118
- label: '详情·已下线',
119
- group: '活动玩法·详情',
120
- note: '详情允许返回 disabled(供应商已停用——说明状态,不等于不存在)',
121
- data: {
122
- mallId: 'mall-demo',
123
- mode: 'detail',
124
- items: [
125
- { activityId: 'demo-paused', title: '暂停中的活动', status: 'disabled' },
126
- ],
127
- },
128
- },
129
- {
130
- label: '详情·已结束',
131
- group: '活动玩法·详情',
132
- note: 'ended 态(历史说明用)',
133
- data: {
134
- mallId: 'mall-demo',
135
- mode: 'detail',
136
- items: [
137
- { activityId: 'demo-ended', title: '周年庆抽奖', description: '活动已结束', endsAt: '2026-10-31T22:00:00+08:00', status: 'ended' },
138
- ],
139
- },
140
- },
141
52
  ];
@@ -6,10 +6,13 @@ import type { Root } from 'react-dom/client';
6
6
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
7
7
  import { ActivityPlayPrizeListCard } from '../src/client/cards/activity-play-prize/ActivityPlayPrizeListCard';
8
8
  import { ActivityPlayCard } from '../src/client/cards/activity-play/ActivityPlayCard';
9
+ import activityMeta from '../src/server/cards/activity-play/meta';
9
10
 
10
- const { httpGet, callJsapi, toast } = vi.hoisted(() => ({ httpGet: vi.fn(), callJsapi: vi.fn(), toast: vi.fn() }));
11
+ const { httpGet, callJsapi, toast, isInAlipayShell, hasAlipayBridge } = vi.hoisted(() => ({
12
+ httpGet: vi.fn(), callJsapi: vi.fn(), toast: vi.fn(), isInAlipayShell: vi.fn(), hasAlipayBridge: vi.fn(),
13
+ }));
11
14
  vi.mock('@tbox.cn/app-agent-ui-kit/toast', () => ({ toast }));
12
- vi.mock('@tbox.cn/app-agent-sdk-client', () => ({ httpGet, callJsapi, markSelfRendering: vi.fn() }));
15
+ vi.mock('@tbox.cn/app-agent-sdk-client', () => ({ httpGet, callJsapi, isInAlipayShell, hasAlipayBridge, markSelfRendering: vi.fn() }));
13
16
  // 业务交互测试;通用弹层的 portal、焦点、遮罩由 kit 测试覆盖。
14
17
  vi.mock('@tbox.cn/app-agent-ui-kit/bottom-sheet', () => ({
15
18
  BottomSheet: ({ children, onClose }: { children: ReactNode; onClose: () => void }) => (
@@ -20,6 +23,8 @@ const item = { activityId: 'act_001', title: '列表活动', status: 'active' as
20
23
  let root: Root;
21
24
  beforeEach(() => {
22
25
  vi.clearAllMocks();
26
+ isInAlipayShell.mockReturnValue(true);
27
+ hasAlipayBridge.mockReturnValue(false);
23
28
  const container = document.createElement('div');
24
29
  document.body.append(container);
25
30
  root = createRoot(container);
@@ -39,6 +44,43 @@ async function click(label: string) {
39
44
  }
40
45
 
41
46
  describe('活动列表参与交互', () => {
47
+ it('四种预览状态共用初始态卡壳、标题区与图文行样式', async () => {
48
+ let initialShellClass: string | undefined;
49
+ let initialRowClass: string | undefined;
50
+ for (const data of [activityMeta.sampleData!, ...(activityMeta.samples ?? []).map((sample) => sample.data)]) {
51
+ await act(async () => root.render(<ActivityPlayCard data={data} />));
52
+ const shell = document.querySelector('.ap-card')!;
53
+ initialShellClass ??= shell.className;
54
+ expect(shell.className).toBe(initialShellClass);
55
+ expect(shell.textContent).toContain('商圈活动一览');
56
+ expect(shell.querySelector('.ap-card--detail')).toBeNull();
57
+ const row = shell.querySelector('.ap-card__row');
58
+ if (row) {
59
+ initialRowClass ??= row.className;
60
+ expect(row.className).toBe(initialRowClass);
61
+ } else {
62
+ expect(shell.textContent).toContain('暂无匹配的活动玩法');
63
+ }
64
+ }
65
+ });
66
+
67
+ it('进行中活动稳定置顶,预览与展开保持一致且不修改卡片快照', async () => {
68
+ const items = [
69
+ { ...item, activityId: 'ended', title: '已结束', status: 'ended' as const },
70
+ { ...item, activityId: 'active-1', title: '进行中一' },
71
+ { ...item, activityId: 'pending', title: '未开始', status: 'not_started' as const },
72
+ { ...item, activityId: 'active-2', title: '进行中二' },
73
+ { ...item, activityId: 'unknown', title: '未知', status: 'unknown' as const },
74
+ ];
75
+ const originalIds = items.map((entry) => entry.activityId);
76
+ await act(async () => root.render(<ActivityPlayCard data={{ mallId: 'mall-a', mode: 'list', items }} />));
77
+ const titles = () => [...document.querySelectorAll('.ap-card__row-title strong')].map((node) => node.textContent);
78
+ expect(titles()).toEqual(['进行中一', '进行中二', '已结束']);
79
+ await click('查看全部活动');
80
+ expect(titles()).toEqual(['进行中一', '进行中二', '已结束', '未开始', '未知']);
81
+ expect(items.map((entry) => entry.activityId)).toEqual(originalIds);
82
+ });
83
+
42
84
  it('列表按钮只查详情并打开弹层;立即参与才经宿主导航打开插件,重复点击只导航一次', async () => {
43
85
  await render();
44
86
  await click('去参与');
@@ -96,10 +138,24 @@ describe('活动列表参与交互', () => {
96
138
  await click('去参与');
97
139
  expect(httpGet).toHaveBeenCalledTimes(2);
98
140
  await click('立即参与');
99
- expect(toast).toHaveBeenCalledWith('活动暂时无法打开,请在宿主小程序中重试');
141
+ expect(toast).toHaveBeenCalledWith('跳转异常,请稍后重试');
100
142
  expect(document.querySelector('[role="alert"]')).toBeNull();
101
143
  });
102
144
 
145
+ it.each([
146
+ { shell: false, bridge: false, message: '电脑端不支持参与,请扫右下角「支付宝小程序」二维码体验' },
147
+ { shell: true, bridge: false, message: '跳转异常,请稍后重试' },
148
+ { shell: false, bridge: true, message: '跳转异常,请稍后重试' },
149
+ ])('导航失败提示按容器与实际桥能力区分:$shell/$bridge', async ({ shell, bridge, message }) => {
150
+ isInAlipayShell.mockReturnValue(shell);
151
+ hasAlipayBridge.mockReturnValue(bridge);
152
+ callJsapi.mockRejectedValueOnce({ code: 'BRIDGE_UNAVAILABLE' });
153
+ await render();
154
+ await click('去参与');
155
+ await click('立即参与');
156
+ expect(toast).toHaveBeenCalledWith(message);
157
+ });
158
+
103
159
  it('详情按接口展示主图、规则及奖品档位,空字段不显示对应区块', async () => {
104
160
  await render();
105
161
  httpGet.mockResolvedValueOnce({ status: 200, data: { data: {
@@ -15,6 +15,10 @@ const sampledStatuses = new Set(
15
15
  );
16
16
 
17
17
  describe('activity-play 样本即契约(T02-05)', () => {
18
+ it('预览仅保留初始态及三个指定附加状态', () => {
19
+ expect(meta.samples?.map((sample) => sample.label)).toEqual(['列表·多状态', '列表·空态', '详情·进行中']);
20
+ });
21
+
18
22
  it('sampleData 与全附加样本过 dataSchema + shape 无越界键', () => {
19
23
  expect(activityPlayCardDataSchema.safeParse(meta.sampleData).success).toBe(true);
20
24
  expect(findSampleShapeViolations(meta).violations).toEqual([]);