@tbox.cn/app-module-promotion 0.10.8 → 1.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +3 -3
- package/README.md +4 -0
- package/dist/{chunk-ONDEOXMY.js → chunk-5GWOZC6X.js} +17 -5
- package/dist/chunk-OCTPGK3E.js +1340 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +1 -1
- package/dist/index.js +2 -2
- package/dist/server/index.d.ts +260 -260
- package/dist/server/index.js +1 -1
- package/package.json +12 -9
- package/skills/promotion/SKILL.md +5 -15
- package/src/client/cards/promotion-activity-category-list/index.tsx +14 -10
- package/src/client/cards/promotion-activity-detail/index.tsx +42 -30
- package/src/client/cards/promotion-activity-list/index.tsx +16 -12
- package/src/client/cards/promotion-best-deal/index.tsx +4 -4
- package/src/client/cards/promotion-entitlement-list/index.tsx +24 -20
- package/src/client/cards/promotion-offer-detail/index.tsx +47 -37
- package/src/client/cards/promotion-offer-list/index.tsx +69 -53
- package/src/client/components/CouponQrCode.tsx +2 -2
- package/src/client/components/CouponSheet.tsx +35 -62
- package/src/client/components/ImageWithFallback.tsx +1 -1
- package/src/client/components/class-names.ts +57 -0
- package/src/client/index.ts +1 -2
- package/src/server/handler.ts +10 -3
- package/src/server/index.ts +15 -2
- package/tbox.module.json +0 -6
- package/tests/activity-visibility.test.ts +54 -0
- package/tests/cards-render.test.tsx +3 -1
- package/tsup.config.ts +0 -5
- package/dist/chunk-HZIEXNVQ.js +0 -1332
- package/dist/promotion-ESTNS7IL.css +0 -2139
- package/src/client/styles/promotion.css +0 -2139
- package/src/client/types/css.d.ts +0 -2
package/dist/server/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tbox.cn/app-module-promotion",
|
|
3
|
-
"version": "0.10
|
|
3
|
+
"version": "1.0.0-alpha.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "商圈营销模块:资格校验、推荐降级链、券卡(codegen 源)。",
|
|
6
6
|
"exports": {
|
|
@@ -18,17 +18,18 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@tbox.cn/app-contracts": "0.13.3",
|
|
22
|
-
"@tbox.cn/app-contracts-mall": "0.13.2",
|
|
23
21
|
"jsbarcode": "^3.12.3",
|
|
24
22
|
"qrcode": "^1.5.4",
|
|
25
|
-
"@tbox.cn/app-
|
|
26
|
-
"@tbox.cn/app-agent-sdk-server": "0.
|
|
23
|
+
"@tbox.cn/app-contracts": "1.0.0-alpha.10",
|
|
24
|
+
"@tbox.cn/app-agent-sdk-server": "1.0.0-alpha.10",
|
|
25
|
+
"@tbox.cn/app-contracts-mall": "1.0.0-alpha.10",
|
|
26
|
+
"@tbox.cn/app-agent-sdk-client": "1.0.0-alpha.10"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@phosphor-icons/react": "2.1.10",
|
|
30
30
|
"react": "18.3.1",
|
|
31
|
-
"zod": "3.25.76"
|
|
31
|
+
"zod": "3.25.76",
|
|
32
|
+
"@tbox.cn/app-agent-ui-kit": "^1.0.0-alpha.10"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@types/express": "4.17.25",
|
|
@@ -64,9 +65,11 @@
|
|
|
64
65
|
"access": "public"
|
|
65
66
|
},
|
|
66
67
|
"license": "MIT",
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
|
|
68
|
+
"peerDependenciesMeta": {
|
|
69
|
+
"@tbox.cn/app-agent-ui-kit": {
|
|
70
|
+
"optional": true
|
|
71
|
+
}
|
|
72
|
+
},
|
|
70
73
|
"scripts": {
|
|
71
74
|
"typecheck": "tsc --noEmit",
|
|
72
75
|
"test": "vitest run",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: promotion
|
|
3
|
-
description: 商圈营销 SOP
|
|
3
|
+
description: 商圈营销 SOP——优惠券搜索/领取、我的券查询、最优优惠测算、营销专题查询的标准流程。
|
|
4
4
|
routingTerms:
|
|
5
5
|
- 领券
|
|
6
6
|
- 优惠券
|
|
@@ -8,8 +8,6 @@ routingTerms:
|
|
|
8
8
|
- 券
|
|
9
9
|
- 折扣
|
|
10
10
|
- 团购
|
|
11
|
-
- 活动
|
|
12
|
-
- 市集
|
|
13
11
|
- 我的券
|
|
14
12
|
- 券码
|
|
15
13
|
- 满减
|
|
@@ -40,8 +38,6 @@ routingTerms:
|
|
|
40
38
|
| 领券 | `listCoupons(mode=CLAIMABLE)`(用户在券行浮层内领取) | `promotion-offer-list` → `promotion-entitlement-list` |
|
|
41
39
|
| 我的券/已领取/卡包 | `listEntitlements` 或 `listCoupons(mode=OWNED)` | `promotion-entitlement-list` |
|
|
42
40
|
| 最优优惠测算 | `calculateBestDeal` | `promotion-best-deal` |
|
|
43
|
-
| 活动列表/详情/场次/指南 | `listActivities` / `getActivityDetail` / `listActivitySessions` / `getActivityGuide` | 活动系列卡 |
|
|
44
|
-
| 活动类型 | `listActivityCategories` | `promotion-activity-category-list` |
|
|
45
41
|
| 营销专题 | `listPromotions` / `getPromotionDetail` / `getParticipationGuide` | 专题系列卡 |
|
|
46
42
|
|
|
47
43
|
## 出卡规则
|
|
@@ -95,17 +91,11 @@ routingTerms:
|
|
|
95
91
|
|
|
96
92
|
调 `calculateBestDeal`(需传 `currentAmountCents` 消费金额)。厂商支持时返回确定性最优方案;厂商不支持时只返回文字说明,不得构造 `promotion-best-deal` 旧卡或伪造测算结论。
|
|
97
93
|
|
|
98
|
-
###
|
|
94
|
+
### 五:查询活动
|
|
99
95
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
- 活动详情 → 调 `getActivityDetail`
|
|
104
|
-
- 可选场次 → 调 `listActivitySessions`(只读,不执行报名)
|
|
105
|
-
- 参与步骤/报名条件 → 调 `getActivityGuide`
|
|
106
|
-
- 用户只问活动有哪些类型 → 调 `listActivityCategories`,出 `promotion-activity-category-list` 卡
|
|
107
|
-
|
|
108
|
-
**报名由用户在厂商页面确认**:活动详情卡提供报名入口,**模型不代用户报名**,结果以厂商页面为准。
|
|
96
|
+
用户问「有什么活动」「活动中心」「查询活动列表」或活动详情时,使用活动玩法域的
|
|
97
|
+
`listActivityPlays` / `getActivityPlayDetail`,不使用优惠搜索或营销专题替代活动查询。
|
|
98
|
+
活动玩法未装配或查询失败时如实说明,不返回演示活动。
|
|
109
99
|
|
|
110
100
|
### 六:查营销专题/促销活动
|
|
111
101
|
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { GameController, Palette, Sparkle, Storefront } from '@phosphor-icons/react';
|
|
2
2
|
import { ItemActionsRow } from '@tbox.cn/app-agent-sdk-client';
|
|
3
|
+
import {
|
|
4
|
+
PROMOTION_CATEGORY_ICON_TONE_CLASS,
|
|
5
|
+
PROMOTION_CHIP_ACTIVITY_CLASS,
|
|
6
|
+
} from '../../components/class-names';
|
|
3
7
|
import type { PromotionActivityCategoryListCardData } from '@tbox.cn/app-contracts-mall';
|
|
4
8
|
|
|
5
9
|
const icons = [GameController, Storefront, Palette, Sparkle] as const;
|
|
@@ -11,22 +15,22 @@ export function PromotionActivityCategoryListCard(props: {
|
|
|
11
15
|
}) {
|
|
12
16
|
const { data, cardId = '', isHistory = false } = props;
|
|
13
17
|
return (
|
|
14
|
-
<section className="promotion-card promotion-activity promotion-activity--categories">
|
|
15
|
-
<header className="promotion-card__header promotion-card__header--compact">
|
|
16
|
-
<span className="promotion-card__mark"><Sparkle weight="fill" /></span>
|
|
17
|
-
<div><span className="promotion-card__eyebrow">会员活动</span><h3>探索会员活动</h3><p>按兴趣找到你的专属周末</p></div>
|
|
18
|
+
<section className="promotion-card promotion-activity promotion-activity--categories relative w-full overflow-hidden bg-card text-sm leading-[normal] tracking-[0] text-foreground">
|
|
19
|
+
<header className="promotion-card__header promotion-card__header--compact flex min-w-0 items-center gap-2.5 px-4 pt-3.5 pb-2.5 max-[380px]:px-[13px] min-[760px]:pt-[15px]">
|
|
20
|
+
<span className="promotion-card__mark grid h-[38px] w-[38px] flex-[0_0_38px] place-items-center rounded-[10px] border border-[rgba(8,119,95,0.18)] bg-[#dff6ed] text-[#08775f] shadow-[0_5px_14px_rgba(8,119,95,0.08)] [&_svg]:size-5"><Sparkle weight="fill" /></span>
|
|
21
|
+
<div className="min-w-0 flex-1"><span className="promotion-card__eyebrow mb-0.5 block text-xs font-bold leading-[14px] text-[#2368ec]">会员活动</span><h3 className="text-lg font-bold leading-[22px] text-foreground [overflow-wrap:anywhere] max-[380px]:text-base">探索会员活动</h3><p className="mt-0.5 truncate text-xs leading-4 text-secondary-foreground">按兴趣找到你的专属周末</p></div>
|
|
18
22
|
</header>
|
|
19
|
-
<div className="promotion-activity__categories">
|
|
23
|
+
<div className="promotion-activity__categories grid grid-cols-2 gap-[7px] px-3.5 pb-3.5">
|
|
20
24
|
{data.items.map((item, index) => {
|
|
21
25
|
const Icon = icons[index % icons.length];
|
|
22
|
-
return <article key={item.categoryId}>
|
|
23
|
-
<span className={`promotion-activity__category-icon promotion-activity__category-icon--${index % 4}`}><Icon weight="duotone" /></span>
|
|
24
|
-
<span><strong>{item.name}</strong><small>发现精彩活动</small></span>
|
|
25
|
-
<ItemActionsRow actions={item.itemActions ?? []} cardId={cardId} isHistory={isHistory} className="promotion-item-actions" chipClassName=
|
|
26
|
+
return <article key={item.categoryId} className="grid min-h-[46px] cursor-pointer grid-cols-[27px_minmax(0,1fr)_9px] items-center gap-1.5 rounded-[7px] border border-[#e5ece9] bg-[rgba(255,255,255,0.92)] px-2 py-1.75 text-left text-[#15372f] shadow-[0_5px_13px_rgba(23,74,61,0.08)] transition-[border-color,box-shadow,background] duration-[180ms] ease-[ease] motion-reduce:transition-none">
|
|
27
|
+
<span className={`promotion-activity__category-icon promotion-activity__category-icon--${index % 4} grid size-[27px] place-items-center rounded-[8px] [&_svg]:size-[15px] ${PROMOTION_CATEGORY_ICON_TONE_CLASS[index % 4] ?? ''}`}><Icon weight="duotone" /></span>
|
|
28
|
+
<span className="grid min-w-0 gap-[1px]"><strong className="truncate text-xs leading-[15px]">{item.name}</strong><small className="text-xs leading-3 text-[#687a74]">发现精彩活动</small></span>
|
|
29
|
+
<ItemActionsRow actions={item.itemActions ?? []} cardId={cardId} isHistory={isHistory} className="promotion-item-actions contents" chipClassName={PROMOTION_CHIP_ACTIVITY_CLASS} />
|
|
26
30
|
</article>;
|
|
27
31
|
})}
|
|
28
32
|
</div>
|
|
29
|
-
{!data.items.length && <div className="promotion-card__empty"><Sparkle size={28} /><span>{data.noResultsReason ?? '暂无活动分类'}</span></div>}
|
|
33
|
+
{!data.items.length && <div className="promotion-card__empty flex min-h-[94px] items-center justify-center gap-2 p-5 text-xs leading-[normal] text-secondary-foreground"><Sparkle size={28} /><span>{data.noResultsReason ?? '暂无活动分类'}</span></div>}
|
|
30
34
|
</section>
|
|
31
35
|
);
|
|
32
36
|
}
|
|
@@ -2,6 +2,18 @@ import { ArrowSquareOut, CalendarDots, CheckCircle, Clock, Crown, ListChecks, Ma
|
|
|
2
2
|
import type { PromotionActivityDetailCardData } from '@tbox.cn/app-contracts-mall';
|
|
3
3
|
import { sendCardAction } from '@tbox.cn/app-agent-sdk-client';
|
|
4
4
|
import { ImageWithFallback } from '../../components/ImageWithFallback';
|
|
5
|
+
import {
|
|
6
|
+
PROMOTION_ACTIVITY_STATUS_CLASS,
|
|
7
|
+
PROMOTION_ACTIVITY_STATUS_TONE_CLASS,
|
|
8
|
+
} from '../../components/class-names';
|
|
9
|
+
|
|
10
|
+
/** 活动卡头(promotion-card__header + --compact):三张 activity 子形态共用 */
|
|
11
|
+
const ACTIVITY_HEADER_COMPACT = 'flex min-w-0 items-center gap-2.5 px-4 pt-3.5 pb-2.5 max-[380px]:px-[13px] min-[760px]:pt-[15px]';
|
|
12
|
+
const ACTIVITY_MARK = 'grid h-[38px] w-[38px] flex-[0_0_38px] place-items-center rounded-[10px] border border-[rgba(8,119,95,0.18)] bg-[#dff6ed] text-[#08775f] shadow-[0_5px_14px_rgba(8,119,95,0.08)] [&_svg]:size-5';
|
|
13
|
+
const ACTIVITY_EYEBROW = 'mb-1 block text-xs font-bold leading-[14px] text-[#2368ec]';
|
|
14
|
+
const ACTIVITY_H3 = 'text-lg font-bold leading-[22px] text-foreground [overflow-wrap:anywhere] max-[380px]:text-base';
|
|
15
|
+
const ACTIVITY_HP = 'mt-0.5 truncate text-xs leading-4 text-secondary-foreground';
|
|
16
|
+
const ACTIVITY_READONLY = 'mx-3.5 mb-3 flex items-center gap-1 rounded-[6px] bg-[#f2f7f5] px-[7.5px] py-[6.5px] text-xs leading-[12.5px] text-[#596d66] [&_svg]:size-3 [&_svg]:shrink-0 [&_svg]:text-[#0b8a6f]';
|
|
5
17
|
|
|
6
18
|
const sessionText: Record<string, string> = { OPEN: '可选', FULL: '已满', CLOSED: '已结束', UNKNOWN: '待确认' };
|
|
7
19
|
|
|
@@ -14,28 +26,28 @@ export function PromotionActivityDetailCard({ data, cardId = '', isHistory = fal
|
|
|
14
26
|
function ActivityDetail({ data, cardId, isHistory }: { data: PromotionActivityDetailCardData; cardId: string; isHistory: boolean }) {
|
|
15
27
|
const status = data.remainingQuota === 0 ? 'FULL' : 'AVAILABLE';
|
|
16
28
|
return (
|
|
17
|
-
<section className="promotion-card promotion-activity promotion-activity--detail">
|
|
18
|
-
<div className="promotion-activity__cover">
|
|
19
|
-
<ImageWithFallback src={data.coverUrl} alt={data.title} className="promotion-activity__cover-image" />
|
|
20
|
-
<span className="promotion-activity__cover-shade" />
|
|
21
|
-
<div className="promotion-activity__cover-meta"><span><Crown weight="fill" />会员专享体验</span><span className={`promotion-activity__status promotion-activity__status--${status.toLowerCase()}`}>{status === 'FULL' ? '已满' : '可报名'}</span></div>
|
|
29
|
+
<section className="promotion-card promotion-activity promotion-activity--detail relative w-full overflow-hidden bg-card text-sm leading-[normal] tracking-[0] text-foreground">
|
|
30
|
+
<div className="promotion-activity__cover relative h-[124px] bg-[#dfeee9]">
|
|
31
|
+
<ImageWithFallback src={data.coverUrl} alt={data.title} className="promotion-activity__cover-image h-full w-full object-cover" />
|
|
32
|
+
<span className="promotion-activity__cover-shade absolute inset-0 bg-[linear-gradient(90deg,rgba(12,39,32,0.82),rgba(12,39,32,0.3)_68%,transparent)]" />
|
|
33
|
+
<div className="promotion-activity__cover-meta absolute top-2.5 right-[11px] left-[11px] flex items-center justify-between"><span className="flex items-center gap-[3.5px] rounded-full border border-[rgba(255,255,255,0.58)] bg-[rgba(18,48,40,0.56)] px-[6.5px] py-2 text-xs font-bold leading-[normal] text-[#fff5d6] backdrop-blur-[7px]"><Crown weight="fill" />会员专享体验</span><span className={`promotion-activity__status promotion-activity__status--${status.toLowerCase()} ${PROMOTION_ACTIVITY_STATUS_CLASS} ${PROMOTION_ACTIVITY_STATUS_TONE_CLASS[status.toLowerCase()] ?? ''}`}>{status === 'FULL' ? '已满' : '可报名'}</span></div>
|
|
22
34
|
</div>
|
|
23
|
-
<div className="promotion-activity__detail-body">
|
|
24
|
-
<small>{data.jumpOnly ? '首页精选 · 可跳转内容' : `活动详情 · ${data.categoryName ?? '会员活动'}`}</small>
|
|
25
|
-
<h3>{data.title}</h3>
|
|
26
|
-
{(data.subtitle ?? data.description) && <p>{data.subtitle ?? data.description}</p>}
|
|
27
|
-
<div className="promotion-activity__spotlight">
|
|
28
|
-
<span><CalendarDots weight="duotone" /><small>{data.jumpOnly ? '内容说明' : '活动时间'}</small><strong>{data.periodText ?? (data.jumpOnly ? '详情以跳转页面为准' : '以活动页为准')}</strong></span>
|
|
29
|
-
<span><Users weight="duotone" /><small>活动名额</small><strong>{data.remainingQuota !== undefined ? `剩余 ${data.remainingQuota} 席` : data.registrationRequired ? '需提前报名' : '无需报名'}</strong></span>
|
|
35
|
+
<div className="promotion-activity__detail-body px-3.5 pt-[11px] pb-3.5">
|
|
36
|
+
<small className="text-xs font-bold leading-3 text-[#b8862e]">{data.jumpOnly ? '首页精选 · 可跳转内容' : `活动详情 · ${data.categoryName ?? '会员活动'}`}</small>
|
|
37
|
+
<h3 className="mt-[3px] mb-0.5 text-base font-bold leading-[20.5px] [overflow-wrap:anywhere]">{data.title}</h3>
|
|
38
|
+
{(data.subtitle ?? data.description) && <p className="text-xs leading-[14.5px] text-[#62736d]">{data.subtitle ?? data.description}</p>}
|
|
39
|
+
<div className="promotion-activity__spotlight mt-2.5 grid grid-cols-2 gap-1.5">
|
|
40
|
+
<span className="grid grid-cols-[18px_minmax(0,1fr)] gap-x-1 rounded-[7px] border border-[#e1ebe7] bg-[#f8fbfa] px-2 py-[7.5px] [&_svg]:row-span-2 [&_svg]:size-4 [&_svg]:self-center [&_svg]:text-[#0b8b70]"><CalendarDots weight="duotone" /><small className="text-xs leading-[11px] text-[#71817c]">{data.jumpOnly ? '内容说明' : '活动时间'}</small><strong className="truncate text-xs leading-[13px] text-[#213b34]">{data.periodText ?? (data.jumpOnly ? '详情以跳转页面为准' : '以活动页为准')}</strong></span>
|
|
41
|
+
<span className="grid grid-cols-[18px_minmax(0,1fr)] gap-x-1 rounded-[7px] border border-[#e1ebe7] bg-[#f8fbfa] px-2 py-[7.5px] [&_svg]:row-span-2 [&_svg]:size-4 [&_svg]:self-center [&_svg]:text-[#0b8b70]"><Users weight="duotone" /><small className="text-xs leading-[11px] text-[#71817c]">活动名额</small><strong className="truncate text-xs leading-[13px] text-[#213b34]">{data.remainingQuota !== undefined ? `剩余 ${data.remainingQuota} 席` : data.registrationRequired ? '需提前报名' : '无需报名'}</strong></span>
|
|
30
42
|
</div>
|
|
31
|
-
<div className="promotion-activity__venue"><MapPin weight="fill" /><span><small>活动地点</small><strong>{data.location ?? '当前商场'}</strong></span></div>
|
|
32
|
-
{data.registrationRequired && <div className="promotion-activity__benefit"><Crown weight="fill" /><span><b>会员专享礼遇</b>完成会员身份校验后可参与</span></div>}
|
|
33
|
-
{data.notice && <div className="promotion-activity__detail-notice"><Clock weight="duotone" /><span>{data.notice}</span></div>}
|
|
34
|
-
{(data.sessions.length > 0 || data.guideSteps.length > 0) && <div className=
|
|
43
|
+
<div className="promotion-activity__venue mt-1.5 flex items-center gap-[5.5px] rounded-[7px] border border-[#e7ecea] px-2 py-1.75 [&>svg]:size-4 [&>svg]:text-[#e75c47]"><MapPin weight="fill" /><span className="grid"><small className="text-xs leading-[11px] text-[#71817c]">活动地点</small><strong className="text-xs leading-[13.5px]">{data.location ?? '当前商场'}</strong></span></div>
|
|
44
|
+
{data.registrationRequired && <div className="promotion-activity__benefit mt-1.5 flex items-center gap-1.5 rounded-[7px] border border-[rgba(184,134,46,0.2)] bg-[#fff6df] px-2 py-1.75 text-[#805616] [&>svg]:size-[17px] [&>svg]:shrink-0"><Crown weight="fill" /><span className="grid text-xs leading-3"><b className="text-xs leading-[13.5px]">会员专享礼遇</b>完成会员身份校验后可参与</span></div>}
|
|
45
|
+
{data.notice && <div className="promotion-activity__detail-notice mt-1.5 flex items-center gap-[5px] rounded-[6px] border border-[#e4e9e7] bg-[#f4f7f6] px-[7.5px] py-[6.5px] text-xs leading-[12.5px] text-[#596d66] [&>svg]:size-3 [&>svg]:shrink-0 [&>svg]:text-[#7b8e87]"><Clock weight="duotone" /><span>{data.notice}</span></div>}
|
|
46
|
+
{(data.sessions.length > 0 || data.guideSteps.length > 0) && <div className={`promotion-activity__readonly ${ACTIVITY_READONLY}`}><ListChecks weight="fill" />可继续询问参与指南和可选场次</div>}
|
|
35
47
|
{(data.registrationRequired || data.jumpOnly) && data.registrationUrl && (
|
|
36
48
|
<button
|
|
37
49
|
type="button"
|
|
38
|
-
className="promotion-activity__register"
|
|
50
|
+
className="promotion-activity__register flex min-h-[42px] w-full cursor-pointer touch-manipulation items-center justify-center gap-[5px] rounded-full border-0 bg-[linear-gradient(135deg,#ff8c33_0%,#ff6f1f_100%)] mt-[9px] text-xs font-bold leading-[14px] text-white shadow-[0_3px_7px_rgba(255,111,31,0.2)] [font-family:inherit] hover:not-disabled:opacity-80 focus-visible:outline-3 focus-visible:outline-offset-3 focus-visible:outline-[#0b8b70] disabled:cursor-default disabled:bg-[#e3e7ee] disabled:bg-none disabled:opacity-50 disabled:shadow-none [&_svg]:size-[13.5px] [&_svg]:shrink-0"
|
|
39
51
|
disabled={isHistory}
|
|
40
52
|
onClick={() => sendCardAction(cardId, { type: 'openLink', url: data.registrationUrl! })}
|
|
41
53
|
>
|
|
@@ -43,7 +55,7 @@ function ActivityDetail({ data, cardId, isHistory }: { data: PromotionActivityDe
|
|
|
43
55
|
{data.jumpOnly ? (data.jumpLabel ?? '打开小程序') : '去支付宝报名'}
|
|
44
56
|
</button>
|
|
45
57
|
)}
|
|
46
|
-
{data.jumpOnly && !data.registrationUrl && <div className="promotion-activity__detail-notice"><Clock weight="duotone" /><span>该首页资源暂无可用跳转链接</span></div>}
|
|
58
|
+
{data.jumpOnly && !data.registrationUrl && <div className="promotion-activity__detail-notice mt-1.5 flex items-center gap-[5px] rounded-[6px] border border-[#e4e9e7] bg-[#f4f7f6] px-[7.5px] py-[6.5px] text-xs leading-[12.5px] text-[#596d66] [&>svg]:size-3 [&>svg]:shrink-0 [&>svg]:text-[#7b8e87]"><Clock weight="duotone" /><span>该首页资源暂无可用跳转链接</span></div>}
|
|
47
59
|
</div>
|
|
48
60
|
</section>
|
|
49
61
|
);
|
|
@@ -51,14 +63,14 @@ function ActivityDetail({ data, cardId, isHistory }: { data: PromotionActivityDe
|
|
|
51
63
|
|
|
52
64
|
function ActivitySchedule({ data }: { data: PromotionActivityDetailCardData }) {
|
|
53
65
|
return (
|
|
54
|
-
<section className="promotion-card promotion-activity promotion-activity--schedule">
|
|
66
|
+
<section className="promotion-card promotion-activity promotion-activity--schedule relative w-full overflow-hidden bg-card text-sm leading-[normal] tracking-[0] text-foreground">
|
|
55
67
|
<ActivityHeader title="选择心仪场次" subtitle={data.title} icon="calendar" />
|
|
56
|
-
<div className="promotion-activity__session-summary"><CalendarDots weight="duotone" /><span><small>可选场次</small><strong>{data.sessions.length} 场</strong></span><em>实时名额</em></div>
|
|
57
|
-
<div className="promotion-activity__sessions">
|
|
58
|
-
{data.sessions.map((session, index) => <article key={session.sessionRef} className={session.status === 'OPEN' ? 'is-available' : 'is-full'}><b>{String(index + 1).padStart(2, '0')}</b><span><strong>{session.title}</strong><small>{session.startText}{session.endText ? ` - ${session.endText}` : ''}</small></span><span><Users weight="duotone" />{session.remainingQuota !== undefined ? `余 ${session.remainingQuota} 席` : session.location ?? '名额实时'}</span><em>{sessionText[session.status]}</em></article>)}
|
|
59
|
-
{!data.sessions.length && <div className="promotion-activity__empty-state"><Clock weight="duotone" /><span><strong>场次正在确认</strong><small>稍后再来查看最新安排</small></span></div>}
|
|
68
|
+
<div className="promotion-activity__session-summary mx-3.5 mb-[9px] grid grid-cols-[27px_minmax(0,1fr)_auto] items-center gap-1.5 rounded-[7px] border border-[rgba(184,134,46,0.2)] bg-[linear-gradient(105deg,#fff9eb,#fff4d8)] px-[8.5px] py-[7.5px] [&>svg]:size-[19px] [&>svg]:text-[#b8862e]"><CalendarDots weight="duotone" /><span className="grid"><small className="text-xs leading-[11px] text-[#806b43]">可选场次</small><strong className="text-xs leading-[14.5px] text-[#5c451c]">{data.sessions.length} 场</strong></span><em className="text-xs font-bold not-italic leading-[normal] text-[#9a6813]">实时名额</em></div>
|
|
69
|
+
<div className="promotion-activity__sessions grid gap-1.5 px-3.5 pb-[9px]">
|
|
70
|
+
{data.sessions.map((session, index) => <article key={session.sessionRef} className={`grid min-h-[46px] grid-cols-[25px_minmax(0,1fr)_auto_auto] items-center gap-[7px] rounded-[7px] border border-[#e0eae6] px-2 py-1.75 shadow-[0_4px_11px_rgba(31,77,65,0.06)] ${session.status === 'OPEN' ? 'is-available' : 'is-full opacity-[0.68]'}`}><b className="grid size-[25px] place-items-center rounded-[7px] bg-[#e5f7f1] text-xs leading-[normal] text-[#08735d]">{String(index + 1).padStart(2, '0')}</b><span className="grid gap-[0.5px]"><strong className="text-xs leading-[14px]">{session.title}</strong><small className="text-xs leading-3 text-[#71817c]">{session.startText}{session.endText ? ` - ${session.endText}` : ''}</small></span><span className="flex items-center gap-[2.5px] whitespace-nowrap text-xs text-[#61736d]"><Users weight="duotone" />{session.remainingQuota !== undefined ? `余 ${session.remainingQuota} 席` : session.location ?? '名额实时'}</span><em className="rounded-full bg-[#e7f8f2] px-[5px] py-[3px] text-xs font-bold not-italic leading-[normal] text-[#08735d]">{sessionText[session.status]}</em></article>)}
|
|
71
|
+
{!data.sessions.length && <div className="promotion-activity__empty-state flex min-h-[53px] items-center justify-center gap-[7px] rounded-[7px] border border-dashed border-[#cadbd5] bg-[#f8fbfa] text-xs text-[#667973] [&_svg]:size-[19px]"><Clock weight="duotone" /><span className="grid"><strong className="text-xs leading-[normal]">场次正在确认</strong><small className="text-xs leading-[normal]">稍后再来查看最新安排</small></span></div>}
|
|
60
72
|
</div>
|
|
61
|
-
<p className=
|
|
73
|
+
<p className={`promotion-activity__readonly ${ACTIVITY_READONLY}`}><CheckCircle weight="fill" />当前仅展示场次与名额,不会直接提交报名</p>
|
|
62
74
|
</section>
|
|
63
75
|
);
|
|
64
76
|
}
|
|
@@ -67,18 +79,18 @@ function ActivityGuide({ data }: { data: PromotionActivityDetailCardData }) {
|
|
|
67
79
|
const steps: Array<{ title: string; description?: string }> =
|
|
68
80
|
data.guideItems ?? data.guideSteps.map((title) => ({ title }));
|
|
69
81
|
return (
|
|
70
|
-
<section className="promotion-card promotion-activity promotion-activity--guide">
|
|
82
|
+
<section className="promotion-card promotion-activity promotion-activity--guide relative w-full overflow-hidden bg-card text-sm leading-[normal] tracking-[0] text-foreground">
|
|
71
83
|
<ActivityHeader title="参与指南" subtitle={data.title} icon="guide" />
|
|
72
|
-
<div className="promotion-activity__guide-banner"><Sparkle weight="fill" /><span><small>HOW TO JOIN</small><strong>提前准备,到场更从容</strong></span></div>
|
|
73
|
-
<ol className="promotion-activity__steps">{steps.map((step, index) => <li key={index}><b>{index + 1}</b><span><strong>{step.title}</strong><small>{step.description ?? ''}</small></span></li>)}</ol>
|
|
74
|
-
{data.conditions.length > 0 && <div className="promotion-activity__requirements"><b>参与条件</b><div>{data.conditions.map((item) => <span key={item}><CheckCircle weight="fill" />{item}</span>)}</div></div>}
|
|
75
|
-
<p className=
|
|
84
|
+
<div className="promotion-activity__guide-banner mx-3.5 mb-2.5 flex items-center gap-[7px] rounded-[7px] border border-[rgba(184,134,46,0.18)] bg-[linear-gradient(105deg,#fff9ed,#fff3d6)] px-[9px] py-2 text-[#78531a] [&>svg]:size-[19px]"><Sparkle weight="fill" /><span className="grid"><small className="text-xs font-extrabold leading-[11px]">HOW TO JOIN</small><strong className="text-xs leading-[14px]">提前准备,到场更从容</strong></span></div>
|
|
85
|
+
<ol className="promotion-activity__steps grid list-none px-3.5 pb-[9px]">{steps.map((step, index) => <li key={index} className="relative grid min-h-[41px] grid-cols-[24px_minmax(0,1fr)] items-start gap-[7px] [&:not(:last-child)]:after:absolute [&:not(:last-child)]:after:top-6 [&:not(:last-child)]:after:bottom-0.5 [&:not(:last-child)]:after:left-[11.5px] [&:not(:last-child)]:after:w-px [&:not(:last-child)]:after:bg-[#cbe6de] [&:not(:last-child)]:after:content-['']"><b className="z-[1] grid size-6 place-items-center rounded-full bg-[linear-gradient(145deg,#0e9a79,#08745f)] text-xs leading-[normal] text-white shadow-[0_3.5px_9px_rgba(8,116,95,0.18)]">{index + 1}</b><span className="grid gap-[1.5px] pt-[1.5px]"><strong className="text-xs leading-[14.5px]">{step.title}</strong><small className="text-xs leading-[13px] text-[#687a74]">{step.description ?? ''}</small></span></li>)}</ol>
|
|
86
|
+
{data.conditions.length > 0 && <div className="promotion-activity__requirements mx-3.5 mb-[9px] rounded-[7px] border border-[#dfebe7] bg-[#f8fbfa] px-[8.5px] py-[7.5px]"><b className="mb-[4.5px] block text-xs leading-[normal] text-[#29473e]">参与条件</b><div className="flex flex-wrap gap-1">{data.conditions.map((item) => <span key={item} className="flex items-center gap-[2.5px] rounded-full bg-[#e6f7f1] px-[5px] py-[3px] text-xs leading-[normal] text-[#08745f] [&_svg]:size-2.5"><CheckCircle weight="fill" />{item}</span>)}</div></div>}
|
|
87
|
+
<p className={`promotion-activity__readonly ${ACTIVITY_READONLY}`}><CheckCircle weight="fill" />{data.notice ?? '当前仅提供参与说明,不会直接提交报名'}</p>
|
|
76
88
|
</section>
|
|
77
89
|
);
|
|
78
90
|
}
|
|
79
91
|
|
|
80
92
|
function ActivityHeader({ title, subtitle, icon }: { title: string; subtitle: string; icon: 'calendar' | 'guide' }) {
|
|
81
|
-
return <header className=
|
|
93
|
+
return <header className={`promotion-card__header promotion-card__header--compact ${ACTIVITY_HEADER_COMPACT}`}><span className={`promotion-card__mark ${ACTIVITY_MARK}`}>{icon === 'calendar' ? <CalendarDots weight="duotone" /> : <ListChecks weight="duotone" />}</span><div className="min-w-0 flex-1"><span className={`promotion-card__eyebrow ${ACTIVITY_EYEBROW}`}>会员活动</span><h3 className={ACTIVITY_H3}>{title}</h3><p className={ACTIVITY_HP}>{subtitle}</p></div></header>;
|
|
82
94
|
}
|
|
83
95
|
|
|
84
96
|
export default PromotionActivityDetailCard;
|
|
@@ -2,6 +2,10 @@ import { CalendarDots, Sparkle, Ticket } from '@phosphor-icons/react';
|
|
|
2
2
|
import { sendCardAction } from '@tbox.cn/app-agent-sdk-client';
|
|
3
3
|
import type { PromotionActivityListCardData } from '@tbox.cn/app-contracts-mall';
|
|
4
4
|
import { ImageWithFallback } from '../../components/ImageWithFallback';
|
|
5
|
+
import {
|
|
6
|
+
PROMOTION_ACTIVITY_STATUS_CLASS,
|
|
7
|
+
PROMOTION_ACTIVITY_STATUS_TONE_CLASS,
|
|
8
|
+
} from '../../components/class-names';
|
|
5
9
|
|
|
6
10
|
const statusText: Record<string, string> = { AVAILABLE: '可报名', FULL: '已满', ENDED: '已结束', UPCOMING: '即将开始', UNKNOWN: '待确认' };
|
|
7
11
|
|
|
@@ -12,17 +16,17 @@ export function PromotionActivityListCard(props: {
|
|
|
12
16
|
}) {
|
|
13
17
|
const { data, cardId = '', isHistory = false } = props;
|
|
14
18
|
return (
|
|
15
|
-
<section className="promotion-card promotion-activity promotion-activity--list">
|
|
16
|
-
<header className="promotion-activity__header promotion-activity__header--pea">
|
|
17
|
-
<div className="promotion-activity__header-copy">
|
|
18
|
-
<div className="promotion-activity__header-title-row">
|
|
19
|
+
<section className="promotion-card promotion-activity promotion-activity--list relative w-full overflow-hidden bg-card text-sm leading-[normal] tracking-[0] text-foreground">
|
|
20
|
+
<header className="promotion-activity__header promotion-activity__header--pea relative flex min-h-[87px] items-center overflow-hidden bg-[#f9f1e2] bg-cover bg-center bg-[image:var(--tbox-asset-promotion-activity-header,linear-gradient(135deg,#fff1f3,#ffe4e8))] px-3.5 pt-3 pb-2.5">
|
|
21
|
+
<div className="promotion-activity__header-copy relative z-[1] w-[52%] min-w-0">
|
|
22
|
+
<div className="promotion-activity__header-title-row flex items-center gap-2.5 text-[#2f3a22] [&_svg]:size-[15px] [&_svg]:shrink-0 [&_svg]:text-[#4f7b37]">
|
|
19
23
|
<Sparkle weight="fill" />
|
|
20
|
-
<h3>活动中心</h3>
|
|
24
|
+
<h3 className="text-base font-bold leading-[21px] text-[#2f3a22] [overflow-wrap:anywhere]">活动中心</h3>
|
|
21
25
|
</div>
|
|
22
|
-
<p>发现商场近期精彩活动</p>
|
|
26
|
+
<p className="mt-1 text-xs leading-4 text-[#626b5c]">发现商场近期精彩活动</p>
|
|
23
27
|
</div>
|
|
24
28
|
</header>
|
|
25
|
-
<div className="promotion-activity__list">
|
|
29
|
+
<div className="promotion-activity__list grid px-3.5 pt-0.5 pb-1.25">
|
|
26
30
|
{data.items.map((item) => {
|
|
27
31
|
const status = item.availabilityStatus ?? (item.remainingQuota === 0 ? 'FULL' : 'UNKNOWN');
|
|
28
32
|
const action = item.itemActions?.find((candidate) => candidate.kind === 'send' || candidate.kind === 'link');
|
|
@@ -32,7 +36,7 @@ export function PromotionActivityListCard(props: {
|
|
|
32
36
|
type="button"
|
|
33
37
|
disabled={isHistory || !action}
|
|
34
38
|
aria-label={action?.label ?? (jumpOnly ? `打开${item.title}` : `查看${item.title}详情`)}
|
|
35
|
-
className={status === 'FULL' || status === 'ENDED' ? 'is-muted' : ''}
|
|
39
|
+
className={`grid min-h-[71px] w-full cursor-pointer touch-manipulation grid-cols-[71px_minmax(0,1fr)] items-center gap-[9px] border-0 border-t border-[#e6ecea] bg-transparent py-[9px] text-left text-inherit transition-[background-color] duration-[180ms] ease-[ease] first:border-t-0 hover:not-disabled:bg-[#f5f8ff] focus-visible:outline-3 focus-visible:outline-offset-[-3px] focus-visible:outline-[#0b8b70] disabled:cursor-default ${status === 'FULL' || status === 'ENDED' ? 'is-muted opacity-[0.68]' : ''}`}
|
|
36
40
|
onClick={() => {
|
|
37
41
|
if (!action || isHistory) return;
|
|
38
42
|
if (action.kind === 'link') {
|
|
@@ -42,13 +46,13 @@ export function PromotionActivityListCard(props: {
|
|
|
42
46
|
}
|
|
43
47
|
}}
|
|
44
48
|
>
|
|
45
|
-
<span className="promotion-activity__visual"><ImageWithFallback src={item.coverUrl} alt={item.title} className="promotion-activity__thumb" /><span className={`promotion-activity__status promotion-activity__status--${status.toLowerCase()}`}>{statusText[status]}</span></span>
|
|
46
|
-
<span className="promotion-activity__copy"><small><Sparkle weight="fill" />{item.categoryName ?? (jumpOnly ? '首页精选' : '会员活动')}</small><strong>{item.title}</strong><span><CalendarDots weight="duotone" />{item.periodText ?? (jumpOnly ? '点击打开查看内容' : '时间以活动页为准')}</span><em>{item.remainingQuota !== undefined ? item.remainingQuota > 0 ? `仅余 ${item.remainingQuota} 席` : '名额已满' : jumpOnly ? (item.jumpLabel ?? '打开查看') : item.registrationRequired ? '需提前报名' : '无需报名'}</em></span>
|
|
49
|
+
<span className="promotion-activity__visual relative h-[53px] w-[71px]"><ImageWithFallback src={item.coverUrl} alt={item.title} className="promotion-activity__thumb h-[53px] w-[71px] rounded-[7px] object-cover shadow-[0_5px_12px_rgba(22,62,51,0.14)]" /><span className={`promotion-activity__status promotion-activity__status--${status.toLowerCase()} absolute right-1 bottom-1 ${PROMOTION_ACTIVITY_STATUS_CLASS} ${PROMOTION_ACTIVITY_STATUS_TONE_CLASS[status.toLowerCase()] ?? ''}`}>{statusText[status]}</span></span>
|
|
50
|
+
<span className="promotion-activity__copy grid min-w-0 gap-[2.5px]"><small className="flex items-center gap-[2.5px] text-xs font-bold leading-3 text-[#b8862e]"><Sparkle weight="fill" />{item.categoryName ?? (jumpOnly ? '首页精选' : '会员活动')}</small><strong className="line-clamp-2 text-xs leading-[15.5px]">{item.title}</strong><span className="flex items-center gap-[3px] text-xs leading-[12.5px] text-[#60726c]"><CalendarDots weight="duotone" />{item.periodText ?? (jumpOnly ? '点击打开查看内容' : '时间以活动页为准')}</span><em className="text-xs font-bold not-italic leading-3 text-[#e75c47]">{item.remainingQuota !== undefined ? item.remainingQuota > 0 ? `仅余 ${item.remainingQuota} 席` : '名额已满' : jumpOnly ? (item.jumpLabel ?? '打开查看') : item.registrationRequired ? '需提前报名' : '无需报名'}</em></span>
|
|
47
51
|
</button>;
|
|
48
52
|
})}
|
|
49
53
|
</div>
|
|
50
|
-
{!data.items.length && <div className="promotion-card__empty"><CalendarDots size={28} /><span>{data.noResultsReason ?? '近期暂无活动'}</span></div>}
|
|
51
|
-
<footer className="promotion-activity__footer"><Ticket weight="duotone" />会员活动名额实时变化,以活动详情为准</footer>
|
|
54
|
+
{!data.items.length && <div className="promotion-card__empty flex min-h-[94px] items-center justify-center gap-2 p-5 text-xs leading-[normal] text-secondary-foreground"><CalendarDots size={28} /><span>{data.noResultsReason ?? '近期暂无活动'}</span></div>}
|
|
55
|
+
<footer className="promotion-activity__footer flex items-center justify-center gap-1 border-t border-[#e7eeeb] px-3.5 pt-2 pb-2.5 text-xs leading-3 text-[#6c7c77]"><Ticket weight="duotone" />会员活动名额实时变化,以活动详情为准</footer>
|
|
52
56
|
</section>
|
|
53
57
|
);
|
|
54
58
|
}
|
|
@@ -7,10 +7,10 @@ export function PromotionBestDealCard({ data }: { data: PromotionBestDealCardDat
|
|
|
7
7
|
const savings = data.savingsCents ?? 0;
|
|
8
8
|
const payable = data.expectedPayCents ?? Math.max(0, data.originalAmountCents - savings);
|
|
9
9
|
return (
|
|
10
|
-
<section className="promotion-card promotion-deal" aria-label="优惠测算">
|
|
11
|
-
<header className="promotion-card__header"><span className="promotion-card__mark promotion-card__mark--cyan"><Calculator weight="duotone" /></span><div><span className="promotion-card__eyebrow">优惠方案</span><h3>优惠测算</h3><p>{data.authoritative ? '实时优惠测算' : '结算前优惠建议'}</p></div></header>
|
|
12
|
-
{data.authoritative ? <div className="promotion-deal__hero"><span><small>预计实付</small><strong>¥{money(payable)}</strong></span><em>预计节省 ¥{money(savings)}</em></div> : <div className="promotion-deal__notice"><TrendUp weight="duotone" /><span><b>当前为建议结果</b>{data.message ?? '最终金额请在结算页确认'}</span></div>}
|
|
13
|
-
<div className="promotion-deal__metrics"><span><small>消费金额</small><strong>¥{money(data.originalAmountCents)}</strong></span><span><small>预计节省</small><strong>¥{money(savings)}</strong></span><span><small>候选优惠</small><strong>{data.candidates?.length ?? data.appliedOfferRefs.length}</strong></span></div>
|
|
10
|
+
<section className="promotion-card promotion-deal relative w-full overflow-hidden bg-card pb-[15px] text-sm leading-[normal] tracking-[0] text-foreground" aria-label="优惠测算">
|
|
11
|
+
<header className="promotion-card__header flex min-w-0 items-center gap-2.5 px-4 pt-3.5 pb-3 max-[380px]:px-[13px] min-[760px]:pt-[15px]"><span className="promotion-card__mark promotion-card__mark--cyan grid h-[38px] w-[38px] flex-[0_0_38px] place-items-center rounded-[10px] border border-[rgba(13,115,132,0.18)] bg-[#e1f5f7] text-[#0d7384] shadow-[0_5px_14px_rgba(8,119,95,0.08)] [&_svg]:size-5"><Calculator weight="duotone" /></span><div className="min-w-0 flex-1"><span className="promotion-card__eyebrow mb-0.5 block text-xs font-bold leading-[14px] text-[#2368ec]">优惠方案</span><h3 className="text-lg font-bold leading-[22px] text-foreground [overflow-wrap:anywhere] max-[380px]:text-base">优惠测算</h3><p className="mt-0.5 truncate text-xs leading-4 text-secondary-foreground">{data.authoritative ? '实时优惠测算' : '结算前优惠建议'}</p></div></header>
|
|
12
|
+
{data.authoritative ? <div className="promotion-deal__hero mx-4 flex items-center justify-between gap-2.5 rounded-[8px] bg-[linear-gradient(135deg,#eaf8f1,var(--tbox-domain-promotion-surface,#fff1f3))] px-3 py-[11px]"><span className="grid"><small className="text-xs leading-[normal] text-secondary-foreground">预计实付</small><strong className="text-2xl tabular-nums leading-[normal] text-[var(--tbox-domain-promotion-accent,#e42f46)]">¥{money(payable)}</strong></span><em className="rounded-full bg-card px-2 py-1.25 text-xs font-bold not-italic leading-[normal] text-[var(--tbox-domain-promotion-accent,#e42f46)] shadow-[0_4px_12px_rgba(69,69,69,0.08)]">预计节省 ¥{money(savings)}</em></div> : <div className="promotion-deal__notice mx-4 mt-2.5 flex items-start gap-[7px] rounded-[7px] bg-[var(--tbox-domain-promotion-surface,#fff1f3)] px-[9px] py-2 text-xs leading-[normal] text-[#744333] [&_svg]:shrink-0 [&_svg]:text-[var(--tbox-domain-promotion-accent,#e42f46)]"><TrendUp weight="duotone" /><span className="grid gap-[1px]"><b>当前为建议结果</b>{data.message ?? '最终金额请在结算页确认'}</span></div>}
|
|
13
|
+
<div className="promotion-deal__metrics mx-4 mt-[9px] grid grid-cols-3 gap-1.5"><span className="grid min-w-0 gap-[0.5px] rounded-[6px] border border-border bg-[#f9fbfa] px-1.5 py-2 text-center"><small className="text-xs leading-[normal] text-secondary-foreground">消费金额</small><strong className="overflow-hidden text-ellipsis text-sm leading-[normal] text-[#128356]">¥{money(data.originalAmountCents)}</strong></span><span className="grid min-w-0 gap-[0.5px] rounded-[6px] border border-border bg-[#f9fbfa] px-1.5 py-2 text-center"><small className="text-xs leading-[normal] text-secondary-foreground">预计节省</small><strong className="overflow-hidden text-ellipsis text-sm leading-[normal] text-[#128356]">¥{money(savings)}</strong></span><span className="grid min-w-0 gap-[0.5px] rounded-[6px] border border-border bg-[#f9fbfa] px-1.5 py-2 text-center"><small className="text-xs leading-[normal] text-secondary-foreground">候选优惠</small><strong className="overflow-hidden text-ellipsis text-sm leading-[normal] text-[#128356]">{data.candidates?.length ?? data.appliedOfferRefs.length}</strong></span></div>
|
|
14
14
|
</section>
|
|
15
15
|
);
|
|
16
16
|
}
|
|
@@ -9,6 +9,10 @@ import { ImageWithFallback } from '../../components/ImageWithFallback';
|
|
|
9
9
|
import { sanitizeActivityHtml } from '../../utils/sanitize-activity-html';
|
|
10
10
|
import { scrollCardBottom } from '../../utils/scroll-card-bottom';
|
|
11
11
|
import { entitlementStatusLabel } from '../view';
|
|
12
|
+
import {
|
|
13
|
+
PROMOTION_CHIP_COUPON_CLASS,
|
|
14
|
+
PROMOTION_CHIP_COUPON_OFF_CLASS,
|
|
15
|
+
} from '../../components/class-names';
|
|
12
16
|
|
|
13
17
|
export function PromotionEntitlementListCard(props: {
|
|
14
18
|
data: PromotionEntitlementListCardData;
|
|
@@ -72,40 +76,40 @@ export function PromotionEntitlementListCard(props: {
|
|
|
72
76
|
try { await navigator.clipboard?.writeText(code); setCopied(true); window.setTimeout(() => setCopied(false), 1600); } catch { setCopied(false); }
|
|
73
77
|
};
|
|
74
78
|
return (
|
|
75
|
-
<section className="promotion-card promotion-list--coupon promotion-entitlements" aria-label="我的优惠权益">
|
|
76
|
-
<header className="promotion-activity__header promotion-activity__header--pea promotion-coupon__header">
|
|
77
|
-
<div className="promotion-activity__header-copy">
|
|
78
|
-
<div className="promotion-activity__header-title-row">
|
|
79
|
+
<section className="promotion-card promotion-list--coupon promotion-entitlements relative w-full overflow-hidden bg-card text-sm leading-[normal] tracking-[0] text-foreground" aria-label="我的优惠权益">
|
|
80
|
+
<header className="promotion-activity__header promotion-activity__header--pea promotion-coupon__header relative flex min-h-[87px] items-center overflow-hidden bg-[#f9f1e2] bg-cover bg-center bg-[image:var(--tbox-asset-promotion-coupon-header,linear-gradient(135deg,#fff1f3,#ffe4e8))] px-3.5 pt-3 pb-2.5">
|
|
81
|
+
<div className="promotion-activity__header-copy relative z-[1] w-[52%] min-w-0">
|
|
82
|
+
<div className="promotion-activity__header-title-row flex items-center gap-2.5 text-[#2f3a22] [&_svg]:size-[15px] [&_svg]:shrink-0 [&_svg]:text-[#4f7b37]">
|
|
79
83
|
<Ticket weight="fill" />
|
|
80
|
-
<h3>我的优惠券</h3>
|
|
84
|
+
<h3 className="text-base font-bold leading-[21px] text-[#2f3a22] [overflow-wrap:anywhere]">我的优惠券</h3>
|
|
81
85
|
</div>
|
|
82
|
-
<p>当前账户 · 券包权益</p>
|
|
86
|
+
<p className="mt-1 text-xs leading-4 text-[#626b5c]">当前账户 · 券包权益</p>
|
|
83
87
|
</div>
|
|
84
88
|
</header>
|
|
85
|
-
{!data.items.length ? <div className="promotion-card__empty"><Ticket size={28} weight="duotone" /><span>{data.noResultsReason ?? '当前账户暂无可用权益'}</span></div> : (
|
|
86
|
-
<div ref={listRef} className={`promotion-list__items${expanded ? ' promotion-list__items--expanded' : ''}`} style={{ maxHeight: expanded ? listHeights.expanded || undefined : listHeights.collapsed || undefined }} onTransitionEnd={() => { if (bottomRef.current) scrollCardBottom(bottomRef.current); }}>
|
|
89
|
+
{!data.items.length ? <div className="promotion-card__empty flex min-h-[94px] items-center justify-center gap-2 p-5 text-xs leading-[normal] text-secondary-foreground"><Ticket size={28} weight="duotone" /><span>{data.noResultsReason ?? '当前账户暂无可用权益'}</span></div> : (
|
|
90
|
+
<div ref={listRef} className={`promotion-list__items overflow-hidden px-3.5 pb-1 ${expanded ? ' promotion-list__items--expanded transition-none' : ' transition-[max-height] duration-[320ms] ease-[ease]'}`} style={{ maxHeight: expanded ? listHeights.expanded || undefined : listHeights.collapsed || undefined }} onTransitionEnd={() => { if (bottomRef.current) scrollCardBottom(bottomRef.current); }}>
|
|
87
91
|
{data.items.map((item) => (
|
|
88
92
|
<article
|
|
89
93
|
key={item.entitlementRef}
|
|
90
|
-
className={`promotion-coupon-row${item.status === 'EFFECTIVE' ? '' : ' promotion-coupon-row--disabled'}`}
|
|
94
|
+
className={`promotion-coupon-row relative grid min-h-[77px] w-full cursor-pointer grid-cols-[56px_minmax(0,1fr)_auto] items-center gap-x-2 gap-y-0 overflow-hidden border-t border-[#f0f1f4] py-[9px] text-left text-inherit first:border-t-0 focus-visible:rounded-[6px] focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-[#2368ec] ${item.status === 'EFFECTIVE' ? '' : ' promotion-coupon-row--disabled opacity-72'}`}
|
|
91
95
|
role="button"
|
|
92
96
|
tabIndex={0}
|
|
93
97
|
aria-label={`查看「${item.title}」`}
|
|
94
98
|
onClick={() => setOpenRef(item.entitlementRef)}
|
|
95
99
|
onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); setOpenRef(item.entitlementRef); } }}
|
|
96
100
|
>
|
|
97
|
-
<ImageWithFallback src={item.imageUrl} alt={item.title} className="promotion-coupon-row__thumb" />
|
|
98
|
-
<div className="promotion-coupon-row__main">
|
|
99
|
-
<strong className="promotion-coupon-row__title">{item.title}</strong>
|
|
101
|
+
<ImageWithFallback src={item.imageUrl} alt={item.title} className="promotion-coupon-row__thumb h-14 w-14 shrink-0 rounded-[6px] object-cover shadow-[inset_0_0_0_1px_rgba(11,15,23,0.04)] [&:not(.promotion-image--fallback)]:block" />
|
|
102
|
+
<div className="promotion-coupon-row__main relative flex min-w-0 flex-col justify-center gap-[3.5px] self-stretch pr-0.5">
|
|
103
|
+
<strong className="promotion-coupon-row__title line-clamp-2 text-xs font-bold leading-4 text-[rgba(11,15,23,0.9)]">{item.title}</strong>
|
|
100
104
|
{item.usageNotice
|
|
101
|
-
&& <span className="promotion-coupon-row__sub" dangerouslySetInnerHTML={{ __html: sanitizeActivityHtml(item.usageNotice) }} />}
|
|
102
|
-
<span className="promotion-coupon-row__price">
|
|
103
|
-
<b>{item.benefitText ?? entitlementStatusLabel(item.status)}</b>
|
|
104
|
-
{item.thresholdText && <em className="promotion-coupon-row__discount">{item.thresholdText}</em>}
|
|
105
|
+
&& <span className="promotion-coupon-row__sub line-clamp-2 text-xs leading-[11.5px] text-[rgba(11,15,23,0.55)]" dangerouslySetInnerHTML={{ __html: sanitizeActivityHtml(item.usageNotice) }} />}
|
|
106
|
+
<span className="promotion-coupon-row__price mt-[1px] flex min-w-0 items-baseline gap-1">
|
|
107
|
+
<b className="shrink-0 text-sm font-extrabold leading-[17px] text-[#e8471c]">{item.benefitText ?? entitlementStatusLabel(item.status)}</b>
|
|
108
|
+
{item.thresholdText && <em className="promotion-coupon-row__discount shrink-0 rounded-[2px] bg-[#fff1eb] px-[3.5px] py-[1px] text-xs font-bold not-italic leading-[10.5px] text-[#e8471c]">{item.thresholdText}</em>}
|
|
105
109
|
</span>
|
|
106
110
|
</div>
|
|
107
111
|
<span
|
|
108
|
-
className={`promotion-owned-action promotion-chip promotion-chip--coupon promotion-coupon-row__state--${item.status.toLowerCase()}${item.status === 'EFFECTIVE' ?
|
|
112
|
+
className={`promotion-owned-action promotion-chip promotion-chip--coupon promotion-coupon-row__state--${item.status.toLowerCase()} justify-self-end pointer-events-none ${item.status === 'EFFECTIVE' ? PROMOTION_CHIP_COUPON_CLASS : `promotion-chip--coupon-off ${PROMOTION_CHIP_COUPON_OFF_CLASS}`}`}
|
|
109
113
|
aria-hidden="true"
|
|
110
114
|
>
|
|
111
115
|
{item.status === 'EFFECTIVE' ? '去使用' : entitlementStatusLabel(item.status)}
|
|
@@ -117,7 +121,7 @@ export function PromotionEntitlementListCard(props: {
|
|
|
117
121
|
{data.items.length > maxItems && (
|
|
118
122
|
<button
|
|
119
123
|
type="button"
|
|
120
|
-
className="promotion-list__toggle"
|
|
124
|
+
className="promotion-list__toggle inline-flex w-full cursor-pointer items-center justify-center gap-[3px] mt-0.5 border-0 border-t border-[rgba(188,205,191,0.42)] bg-[linear-gradient(105deg,#fffaf0_0%,#f9f5e9_46%,#eaf6f3_100%)] px-3 pt-[7px] pb-2 text-xs font-semibold leading-[normal] text-foreground [font-family:inherit] hover:brightness-[0.94] focus-visible:outline-3 focus-visible:outline-foreground focus-visible:outline-offset-[-3px] [&_svg]:transition-transform [&_svg]:duration-[160ms] [&_svg]:ease-[ease] [&_svg[data-rotated=true]]:rotate-180"
|
|
121
125
|
aria-expanded={expanded}
|
|
122
126
|
onClick={toggleExpanded}
|
|
123
127
|
>
|
|
@@ -125,7 +129,7 @@ export function PromotionEntitlementListCard(props: {
|
|
|
125
129
|
{expanded ? '收起' : `查看更多(${data.items.length - maxItems} 条)`}
|
|
126
130
|
</button>
|
|
127
131
|
)}
|
|
128
|
-
{data.items.length > maxItems && <div ref={bottomRef} className="promotion-list__bottom-anchor" aria-hidden="true" />}
|
|
132
|
+
{data.items.length > maxItems && <div ref={bottomRef} className="promotion-list__bottom-anchor h-0 flex-none scroll-mb-[max(96px,calc(var(--tbox-chat-bottom-height,0px)_+_24px))]" aria-hidden="true" />}
|
|
129
133
|
{sheetTarget && (() => {
|
|
130
134
|
const facts = [
|
|
131
135
|
sheetFact(<MapPinLine weight="duotone" />, '使用场景', sheetTarget.usageSceneText),
|
|
@@ -145,7 +149,7 @@ export function PromotionEntitlementListCard(props: {
|
|
|
145
149
|
guaranteeText={sheetTarget.guaranteeText}
|
|
146
150
|
facts={facts}
|
|
147
151
|
onClose={() => setOpenRef(null)}
|
|
148
|
-
beforeFacts={<>{sheetTarget.qrCodeEnabled && sheetTarget.code && <><CouponBarcode value={sheetTarget.code} disabled={sheetTarget.status !== 'EFFECTIVE'} /><CouponQrCode value={sheetTarget.code} disabled={sheetTarget.status !== 'EFFECTIVE'} /></>}{(sheetTarget.code || sheetTarget.codeMasked) && <div className={`promotion-sheet__code${sheetTarget.status === 'EFFECTIVE' ? '' : ' promotion-sheet__code--disabled'}`}><span>券码</span><strong>{sheetTarget.code || sheetTarget.codeMasked}</strong><button type="button" className="promotion-sheet__copy" onClick={() => copyCode(sheetTarget.code || sheetTarget.codeMasked!)}><Copy size={16} />{copied ? '已复制' : '复制'}</button></div>}{sheetTarget.stores?.length ? <><div className="promotion-sheet__section">适用商家</div><div className="promotion-sheet__stores">{sheetTarget.stores.map((store) => <div className=
|
|
152
|
+
beforeFacts={<>{sheetTarget.qrCodeEnabled && sheetTarget.code && <><CouponBarcode value={sheetTarget.code} disabled={sheetTarget.status !== 'EFFECTIVE'} /><CouponQrCode value={sheetTarget.code} disabled={sheetTarget.status !== 'EFFECTIVE'} /></>}{(sheetTarget.code || sheetTarget.codeMasked) && <div className={`promotion-sheet__code mx-4 mt-[11px] flex items-center gap-1.5 rounded-[10px] bg-card px-3 py-[11px] ${sheetTarget.status === 'EFFECTIVE' ? '' : ' promotion-sheet__code--disabled'}`}><span className="flex-none text-xs font-bold leading-[normal] text-[rgba(11,15,23,0.86)]">券码</span><strong className={`min-w-0 text-sm font-semibold leading-[normal] tracking-[1px] [overflow-wrap:anywhere] ${sheetTarget.status === 'EFFECTIVE' ? 'text-[rgba(11,15,23,0.9)]' : 'text-[#999] line-through'}`}>{sheetTarget.code || sheetTarget.codeMasked}</strong><button type="button" className="promotion-sheet__copy my-0 ml-auto inline-flex min-h-6 flex-none cursor-pointer items-center gap-[2.5px] rounded-full border-0 bg-[#c8a45e] px-2.5 py-[3.5px] text-xs leading-[normal] text-white [font-family:inherit]" onClick={() => copyCode(sheetTarget.code || sheetTarget.codeMasked!)}><Copy size={16} />{copied ? '已复制' : '复制'}</button></div>}{sheetTarget.stores?.length ? <><div className="promotion-sheet__section mx-4 mt-[17px] text-sm font-bold leading-5 text-[rgba(11,15,23,0.9)]">适用商家</div><div className="promotion-sheet__stores mx-4 mt-2 rounded-[10px] bg-card px-3 py-1">{sheetTarget.stores.map((store, storeIndex) => <div className={`promotion-sheet__store flex items-center gap-2 py-[9px] text-xs leading-[normal] text-[#493d36] ${storeIndex > 0 ? ' border-t border-[#ecedf1]' : ''}`} key={store.storeId}>{store.imageUrl && <ImageWithFallback src={store.imageUrl} alt={store.storeName} className="promotion-sheet__store-image h-8 w-8 rounded-[6px] object-cover" />}<span className="flex min-w-0 flex-col gap-0.5"><strong className="text-sm font-semibold leading-[normal] text-[rgba(11,15,23,0.9)]">{store.storeName}</strong>{store.businessName && store.businessName !== store.storeName && <small className="truncate text-xs leading-4 text-[rgba(11,15,23,0.55)]">{store.businessName}</small>}{store.floor && <small className="truncate text-xs leading-4 text-[rgba(11,15,23,0.55)]">{store.floor}</small>}{store.address && <small className="truncate text-xs leading-4 text-[rgba(11,15,23,0.55)]">{store.address}</small>}</span>{store.latitude !== undefined && store.longitude !== undefined && <button type="button" className="promotion-sheet__navigate ml-auto inline-flex flex-none cursor-pointer items-center gap-0.5 rounded-[4px] border-0 bg-[#fff1eb] px-[5px] py-1 text-xs leading-[normal] text-[#d4512d] [font-family:inherit]" aria-label={`导航到${store.storeName}`} onClick={(event) => { event.stopPropagation(); void callJsapi('openLocation', { latitude: store.latitude, longitude: store.longitude, name: store.storeName, address: store.address ?? '' }).catch(() => undefined); }}><NavigationArrow size={18} />导航</button>}</div>)}</div></> : null}</>}
|
|
149
153
|
/>
|
|
150
154
|
);
|
|
151
155
|
})()}
|