@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
|
@@ -5,6 +5,16 @@ import { markSelfRendering, navigateToAlipayPage, sendCardAction } from '@tbox.c
|
|
|
5
5
|
import { ImageWithFallback } from '../../components/ImageWithFallback';
|
|
6
6
|
import { offerTypeLabel } from '../view';
|
|
7
7
|
import { sanitizeActivityHtml } from '../../utils/sanitize-activity-html';
|
|
8
|
+
import { PROMOTION_STATUS_CLASS, PROMOTION_STATUS_TONE_CLASS } from '../../components/class-names';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 底部主 CTA(券详情:全宽不做票根斜切)。`hover/disabled` 变体自带更高优先级,
|
|
12
|
+
* 光标在 pending 分支单独给(cursor-wait 压过 cursor-pointer)。
|
|
13
|
+
*/
|
|
14
|
+
const COUPON_MAIN_ACTION_CLASS = 'flex min-h-[38px] w-full items-center justify-center rounded-[6px] border-0 bg-[#d9273d] mt-[9px] text-xs font-extrabold leading-[normal] text-white [font-family:inherit] hover:not-disabled:bg-[#c82036] focus-visible:shadow-[inset_0_0_0_3px_#fff,inset_0_0_0_6px_#5f101d] focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50';
|
|
15
|
+
|
|
16
|
+
/** 领取中:进度光带(keyframes 由宿主 tailwind 入口登记) */
|
|
17
|
+
const COUPON_MAIN_ACTION_PENDING_CLASS = 'relative overflow-hidden cursor-wait after:absolute after:inset-0 after:w-[38%] after:animate-[promotion-claim-progress_1.1s_ease-in-out_infinite] after:bg-[rgba(255,255,255,0.18)] after:content-[\'\'] after:[transform:translateX(-140%)_skewX(-18deg)] motion-reduce:after:animate-none';
|
|
8
18
|
|
|
9
19
|
const modeText: Record<string, string> = {
|
|
10
20
|
AUTOMATIC_DISCOUNT: '结算时自动优惠',
|
|
@@ -57,36 +67,36 @@ export function PromotionOfferDetailCard({ data, cardId = '', isHistory = false,
|
|
|
57
67
|
const purchaseOnly = coupon && data.claimActionLabel === '抢购';
|
|
58
68
|
const label = data.presentation === 'promotion' ? '本周活动' : data.presentation === 'package' ? '组合礼包' : '会员专享';
|
|
59
69
|
return (
|
|
60
|
-
<section className={`promotion-card promotion-detail${coupon ? ' promotion-detail--coupon' : ''}`} aria-label={data.title}>
|
|
61
|
-
<div className=
|
|
62
|
-
<ImageWithFallback src={data.imageUrl} alt={data.title} className="promotion-detail__image" />
|
|
63
|
-
<span className=
|
|
64
|
-
<div className=
|
|
70
|
+
<section className={`promotion-card promotion-detail relative w-full overflow-hidden bg-card text-sm leading-[normal] tracking-[0] text-foreground ${coupon ? ' promotion-detail--coupon' : ''}`} aria-label={data.title}>
|
|
71
|
+
<div className={coupon ? 'promotion-detail__hero relative mx-2.5 mt-[9px] h-[107px] overflow-hidden rounded-[8px] bg-[#f5f6f8]' : 'promotion-detail__hero relative h-[126px] overflow-hidden bg-[#eef2f8] min-[760px]:h-[138px]'}>
|
|
72
|
+
<ImageWithFallback src={data.imageUrl} alt={data.title} className="promotion-detail__image h-full w-full object-cover" />
|
|
73
|
+
<span className={coupon ? 'promotion-detail__hero-label absolute top-[7px] left-[7px] rounded-[3.5px] border-0 bg-[rgba(200,32,54,0.94)] px-[7px] py-1 text-xs font-bold leading-[normal] text-white backdrop-blur-[4px]' : 'promotion-detail__hero-label absolute top-2.5 left-3 rounded-full border border-[rgba(255,255,255,0.55)] bg-[rgba(6,42,101,0.66)] px-[7px] py-1 text-xs font-bold leading-[normal] text-white backdrop-blur-[4px]'}>{label}</span>
|
|
74
|
+
<div className={coupon ? 'promotion-detail__glass absolute right-[7px] bottom-[7px] left-[7px] grid grid-cols-[minmax(0,1fr)_auto] items-end gap-x-2.5 gap-y-[1px] rounded-[5px] border-0 bg-[rgba(255,241,243,0.94)] px-2 py-[6.5px] shadow-none backdrop-blur-[4px]' : 'promotion-detail__glass absolute right-3 bottom-2.5 left-3 grid grid-cols-[minmax(0,1fr)_auto] items-end gap-x-2.5 gap-y-[1px] rounded-[7px] border border-[rgba(255,255,255,0.62)] bg-[rgba(255,255,255,0.82)] px-2.5 py-2 shadow-[0_8px_22px_rgba(21,45,88,0.16)] backdrop-blur-[6px]'}><small className={coupon ? 'truncate text-xs font-bold leading-[normal] text-[#9f3d24]' : 'truncate text-xs font-bold leading-[normal] text-[#128356]'}>{data.claimable ? '可领取' : '详情'}</small><strong className={coupon ? 'col-start-2 row-span-2 text-lg leading-[21px] tabular-nums text-[var(--tbox-domain-promotion-accent,#e42f46)]' : 'col-start-2 row-span-2 text-2xl leading-6 tabular-nums text-[var(--tbox-domain-promotion-accent,#e42f46)]'}>{data.benefitText ?? offerTypeLabel(data.offerType)}</strong><em className={coupon ? 'truncate text-xs not-italic leading-[normal] text-[rgba(11,15,23,0.62)]' : 'truncate text-xs not-italic leading-[normal] text-secondary-foreground'}>{data.subtitle ?? '当前商场可用'}</em></div>
|
|
65
75
|
</div>
|
|
66
|
-
<div className=
|
|
67
|
-
<div className="promotion-detail__status"><span className={`promotion-status promotion-status--${data.claimable ? 'available' : 'unavailable'}`}><SealCheck weight="fill" />{data.claimable ? '可领取' : '暂不可领'}</span>{data.validityText && <small><Clock />{data.validityText}</small>}</div>
|
|
68
|
-
<h3>{data.title}</h3>
|
|
69
|
-
{(data.usageNoticeText || data.guaranteeText) && <div className="promotion-detail__notice-strip">
|
|
70
|
-
{data.usageNoticeText && <span><b>须知</b>{data.usageNoticeText}</span>}
|
|
71
|
-
{data.guaranteeText && <span><b>保障</b>{data.guaranteeText}</span>}
|
|
76
|
+
<div className={coupon ? 'promotion-detail__body px-3.5 pt-[11px] pb-3.5' : 'promotion-detail__body px-4 pt-[13px] pb-[15px] max-[380px]:px-[13px]'}>
|
|
77
|
+
<div className="promotion-detail__status flex items-center justify-between gap-2"><span className={`promotion-status promotion-status--${data.claimable ? 'available' : 'unavailable'} ${PROMOTION_STATUS_CLASS} ${PROMOTION_STATUS_TONE_CLASS[data.claimable ? 'available' : 'unavailable'] ?? ''}`}><SealCheck weight="fill" />{data.claimable ? '可领取' : '暂不可领'}</span>{data.validityText && <small className="flex items-center gap-1 text-xs leading-[normal] text-secondary-foreground [&_svg]:size-3"><Clock />{data.validityText}</small>}</div>
|
|
78
|
+
<h3 className={coupon ? 'mt-[6.5px] text-base font-bold leading-[19.5px] [overflow-wrap:anywhere]' : 'mt-2 text-lg font-bold leading-[22px] [overflow-wrap:anywhere]'}>{data.title}</h3>
|
|
79
|
+
{(data.usageNoticeText || data.guaranteeText) && <div className="promotion-detail__notice-strip mt-2 grid gap-[5px] rounded-[7px] bg-[#fff8ef] px-[9px] py-2">
|
|
80
|
+
{data.usageNoticeText && <span className="grid grid-cols-[46px_minmax(0,1fr)] items-baseline gap-2 text-xs leading-[15px] text-[#171717]"><b className="w-auto text-left text-xs leading-[normal] text-[#b38a3e]">须知</b>{data.usageNoticeText}</span>}
|
|
81
|
+
{data.guaranteeText && <span className="grid grid-cols-[46px_minmax(0,1fr)] items-baseline gap-2 text-xs leading-[15px] text-[#171717]"><b className="w-auto text-left text-xs leading-[normal] text-[#ef7654]">保障</b>{data.guaranteeText}</span>}
|
|
72
82
|
</div>}
|
|
73
|
-
{(data.usageSceneText || data.validityText || data.usageTimeText || data.thresholdText || data.claimTimeText) && <div className=
|
|
74
|
-
{data.usageSceneText && <div><dt><MapPin weight="duotone" />使用场景</dt><dd>{data.usageSceneText}</dd></div>}
|
|
75
|
-
{data.validityText && <div><dt><CalendarBlank weight="duotone" />有效期</dt><dd>{data.validityText}</dd></div>}
|
|
76
|
-
{data.usageTimeText && <div><dt><Clock weight="duotone" />使用时间</dt><dd>{data.usageTimeText}</dd></div>}
|
|
77
|
-
{data.thresholdText && <div><dt><Ticket weight="duotone" />使用限制</dt><dd>{data.thresholdText}</dd></div>}
|
|
78
|
-
{data.claimTimeText && <div><dt><CalendarBlank weight="duotone" />可领取时间</dt><dd>{data.claimTimeText}</dd></div>}
|
|
83
|
+
{(data.usageSceneText || data.validityText || data.usageTimeText || data.thresholdText || data.claimTimeText) && <div className={coupon ? 'promotion-detail__facts mt-2.5 grid grid-cols-[56px_minmax(0,1fr)] overflow-hidden rounded-[7px] border border-[#eceef2] bg-[#fafafb]' : 'promotion-detail__facts mt-2.5 grid grid-cols-[56px_minmax(0,1fr)] overflow-hidden rounded-[7px] border border-border bg-[#f8faf9]'}>
|
|
84
|
+
{data.usageSceneText && <div className="contents"><dt className="m-0 border-t border-border px-[9px] py-1.75 text-xs leading-[normal] text-secondary-foreground"><MapPin weight="duotone" />使用场景</dt><dd className="m-0 border-t border-border px-[9px] py-1.75 text-right text-xs font-semibold leading-[normal]">{data.usageSceneText}</dd></div>}
|
|
85
|
+
{data.validityText && <div className="contents"><dt className="m-0 border-t border-border px-[9px] py-1.75 text-xs leading-[normal] text-secondary-foreground"><CalendarBlank weight="duotone" />有效期</dt><dd className="m-0 border-t border-border px-[9px] py-1.75 text-right text-xs font-semibold leading-[normal]">{data.validityText}</dd></div>}
|
|
86
|
+
{data.usageTimeText && <div className="contents"><dt className="m-0 border-t border-border px-[9px] py-1.75 text-xs leading-[normal] text-secondary-foreground"><Clock weight="duotone" />使用时间</dt><dd className="m-0 border-t border-border px-[9px] py-1.75 text-right text-xs font-semibold leading-[normal]">{data.usageTimeText}</dd></div>}
|
|
87
|
+
{data.thresholdText && <div className="contents"><dt className="m-0 border-t border-border px-[9px] py-1.75 text-xs leading-[normal] text-secondary-foreground"><Ticket weight="duotone" />使用限制</dt><dd className="m-0 border-t border-border px-[9px] py-1.75 text-right text-xs font-semibold leading-[normal]">{data.thresholdText}</dd></div>}
|
|
88
|
+
{data.claimTimeText && <div className="contents"><dt className="m-0 border-t border-border px-[9px] py-1.75 text-xs leading-[normal] text-secondary-foreground"><CalendarBlank weight="duotone" />可领取时间</dt><dd className="m-0 border-t border-border px-[9px] py-1.75 text-right text-xs font-semibold leading-[normal]">{data.claimTimeText}</dd></div>}
|
|
79
89
|
</div>}
|
|
80
|
-
{(data.steps?.length ?? 0) > 0 && <div className="promotion-detail__rules">{data.steps?.slice(0, 3).map((step, index) => <span key={index}><CheckCircle weight="fill" /><b>{step.title}</b><small>{step.description ?? ''}</small></span>)}</div>}
|
|
81
|
-
{(data.usageRuleText || data.description) && <div className="promotion-detail__usage-rule"><strong>使用规则</strong><div dangerouslySetInnerHTML={{ __html: sanitizeActivityHtml(data.usageRuleText ?? data.description ?? '') }} /></div>}
|
|
82
|
-
{purchaseOnly ? <button className=
|
|
83
|
-
: data.claimable && actionTokens?.['promotion.acquire'] && <button className={`promotion-coupon-main-action${acquiring ?
|
|
84
|
-
{claimMessage && <p className="promotion-detail__claim-status" role="status">{claimMessage}</p>}
|
|
85
|
-
{(data.bundleItems?.length ?? 0) > 0 && <div className="promotion-detail__bundle">{data.bundleItems?.map((item, index) => <span key={index}><Gift weight="duotone" /><b>{item.name}</b><small>x{item.quantity}</small></span>)}</div>}
|
|
86
|
-
{data.notice && <div className=
|
|
87
|
-
{(data.stores?.length ?? 0) > 0 && <div className="promotion-detail__stores"><strong>适用门店</strong>{data.stores?.slice(0, 8).map((store) => <span key={store.storeId}><MapPin weight="fill" />{store.storeName}{store.floor ? ` · ${store.floor}` : ''}{store.address ? ` · ${store.address}` : ''}</span>)}</div>}
|
|
88
|
-
{!data.claimable && data.unavailableReason && <div className=
|
|
89
|
-
{data.caveats.length > 0 && <footer className="promotion-card__footer">{data.caveats.join(';')}</footer>}
|
|
90
|
+
{(data.steps?.length ?? 0) > 0 && <div className="promotion-detail__rules mt-[11px] grid gap-1.5">{data.steps?.slice(0, 3).map((step, index) => <span key={index} className="grid grid-cols-[14px_minmax(0,1fr)] items-start gap-x-1.5 gap-y-0 [&_svg]:row-span-2 [&_svg]:mt-0.5 [&_svg]:text-success"><CheckCircle weight="fill" /><b className="text-xs">{step.title}</b><small className="text-xs leading-[15px] text-secondary-foreground">{step.description ?? ''}</small></span>)}</div>}
|
|
91
|
+
{(data.usageRuleText || data.description) && <div className="promotion-detail__usage-rule mt-3 text-xs leading-4 text-secondary-foreground"><strong className="mb-1 block text-xs leading-[normal] text-[#171717]">使用规则</strong><div dangerouslySetInnerHTML={{ __html: sanitizeActivityHtml(data.usageRuleText ?? data.description ?? '') }} /></div>}
|
|
92
|
+
{purchaseOnly ? <button className={`promotion-coupon-main-action cursor-pointer ${COUPON_MAIN_ACTION_CLASS}`} type="button" disabled={!data.purchaseUrl || isHistory} onClick={() => { if (!data.purchaseUrl) return; void navigateToAlipayPage(data.purchaseUrl).catch((err: unknown) => console.warn('[PromotionOfferDetailCard] navigateTo failed', err)); }}>{data.purchaseUrl ? '去小程序抢购' : '抢购链接暂不可用'}</button>
|
|
93
|
+
: data.claimable && actionTokens?.['promotion.acquire'] && <button className={`promotion-coupon-main-action cursor-pointer ${COUPON_MAIN_ACTION_CLASS}${acquiring ? ` promotion-coupon-main-action--pending ${COUPON_MAIN_ACTION_PENDING_CLASS}` : ''}`} type="button" disabled={acquiring || claimed} onClick={() => { pendingClaimRef.current = true; setAcquiring(true); setClaimMessage('领取中,请稍候;领取成功后将自动展示我的券包'); sendCardAction(cardId, { type: 'moduleAction', actionId: 'promotion.acquire', contextToken: actionTokens['promotion.acquire'] }, { offerRef: data.offerRef }); }}>{claimed ? '已领取' : acquiring ? '领取中…' : '立即领取'}</button>}
|
|
94
|
+
{claimMessage && <p className="promotion-detail__claim-status mt-1.25 text-xs leading-[10px] text-[#9a4b12]" role="status">{claimMessage}</p>}
|
|
95
|
+
{(data.bundleItems?.length ?? 0) > 0 && <div className="promotion-detail__bundle mt-[11px] grid gap-[5px]">{data.bundleItems?.map((item, index) => <span key={index} className="grid grid-cols-[18px_minmax(0,1fr)_auto] items-center gap-1.5 rounded-[6px] border border-border bg-[#f8faf9] px-2 py-1.75 [&_svg]:text-[var(--tbox-domain-promotion-accent,#e42f46)]"><Gift weight="duotone" /><b className="text-xs leading-[normal]">{item.name}</b><small className="text-secondary-foreground">x{item.quantity}</small></span>)}</div>}
|
|
96
|
+
{data.notice && <div className={coupon ? 'promotion-detail__notice mt-2.5 flex items-start gap-1.5 rounded-[6px] border-0 bg-[var(--tbox-domain-promotion-surface,#fff1f3)] px-[9px] py-2 text-xs leading-[15px] text-[#8a4a3d] [&_svg]:mt-[1px] [&_svg]:size-3.5 [&_svg]:shrink-0' : 'promotion-detail__notice mt-2.5 flex items-start gap-1.5 rounded-[6px] border border-[rgba(228,47,70,0.12)] bg-[var(--tbox-domain-promotion-surface,#fff1f3)] px-[9px] py-2 text-xs leading-[15px] text-[#744333] [&_svg]:mt-[1px] [&_svg]:size-3.5 [&_svg]:shrink-0'}><Info />{data.notice}</div>}
|
|
97
|
+
{(data.stores?.length ?? 0) > 0 && <div className="promotion-detail__stores mt-1.5 grid gap-[3px] rounded-[4px] border border-[var(--promotion-line,#e5e7eb)] bg-[var(--promotion-surface-muted,#f8fafc)] px-1.5 py-1.25"><strong className="text-xs leading-[normal] text-[var(--promotion-ink,#17202a)]">适用门店</strong>{data.stores?.slice(0, 8).map((store) => <span key={store.storeId} className="flex gap-[2.5px] text-xs leading-[normal] text-[var(--promotion-muted,#667085)]"><MapPin weight="fill" />{store.storeName}{store.floor ? ` · ${store.floor}` : ''}{store.address ? ` · ${store.address}` : ''}</span>)}</div>}
|
|
98
|
+
{!data.claimable && data.unavailableReason && <div className={coupon ? 'promotion-detail__notice mt-2.5 flex items-start gap-1.5 rounded-[6px] border-0 bg-[var(--tbox-domain-promotion-surface,#fff1f3)] px-[9px] py-2 text-xs leading-[15px] text-[#8a4a3d] [&_svg]:mt-[1px] [&_svg]:size-3.5 [&_svg]:shrink-0' : 'promotion-detail__notice mt-2.5 flex items-start gap-1.5 rounded-[6px] border border-[rgba(228,47,70,0.12)] bg-[var(--tbox-domain-promotion-surface,#fff1f3)] px-[9px] py-2 text-xs leading-[15px] text-[#744333] [&_svg]:mt-[1px] [&_svg]:size-3.5 [&_svg]:shrink-0'}><Info />{data.unavailableReason}</div>}
|
|
99
|
+
{data.caveats.length > 0 && <footer className="promotion-card__footer flex items-center gap-[5px] border-t border-border px-4 pt-[9px] pb-[11px] text-xs leading-[15px] text-secondary-foreground">{data.caveats.join(';')}</footer>}
|
|
90
100
|
</div>
|
|
91
101
|
</section>
|
|
92
102
|
);
|
|
@@ -96,17 +106,17 @@ function PromotionGuide({ data }: { data: PromotionOfferDetailCardData }) {
|
|
|
96
106
|
const steps: Array<{ title: string; description?: string }> =
|
|
97
107
|
data.steps ?? data.rules.map((rule) => ({ title: rule }));
|
|
98
108
|
return (
|
|
99
|
-
<section className="promotion-card promotion-guide" aria-label="活动参与方式">
|
|
100
|
-
<header className="promotion-card__header promotion-card__header--compact">
|
|
101
|
-
<span className="promotion-card__mark promotion-card__mark--cyan"><ListChecks weight="duotone" /></span>
|
|
102
|
-
<div><span className="promotion-card__eyebrow">活动参与方式</span><h3>{data.title}</h3><p>{data.validityText ?? '当前活动有效期以现场为准'}</p></div>
|
|
103
|
-
<b className={`promotion-status promotion-status--${data.claimable ? 'available' : 'unavailable'}`}>{data.claimable ? '可参与' : '查看规则'}</b>
|
|
109
|
+
<section className="promotion-card promotion-guide relative w-full overflow-hidden bg-card text-sm leading-[normal] tracking-[0] text-foreground" aria-label="活动参与方式">
|
|
110
|
+
<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]">
|
|
111
|
+
<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"><ListChecks weight="duotone" /></span>
|
|
112
|
+
<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">{data.title}</h3><p className="mt-0.5 truncate text-xs leading-4 text-secondary-foreground">{data.validityText ?? '当前活动有效期以现场为准'}</p></div>
|
|
113
|
+
<b className={`promotion-status promotion-status--${data.claimable ? 'available' : 'unavailable'} ${PROMOTION_STATUS_CLASS} ${PROMOTION_STATUS_TONE_CLASS[data.claimable ? 'available' : 'unavailable'] ?? ''}`}>{data.claimable ? '可参与' : '查看规则'}</b>
|
|
104
114
|
</header>
|
|
105
|
-
<div className="promotion-guide__summary"><span><MapPin weight="fill" />当前商场</span><strong>{modeText[data.participationMode ?? 'UNKNOWN']}</strong></div>
|
|
106
|
-
<ol>{steps.map((step, index) => <li key={index}><b>{index + 1}</b><span><strong>{step.title}</strong><small>{step.description ?? ''}</small></span></li>)}</ol>
|
|
107
|
-
{(data.requirements?.length ?? 0) > 0 && <div className="promotion-guide__requirements">{data.requirements?.map((item) => <span key={item}><CheckCircle weight="fill" />{item}</span>)}</div>}
|
|
108
|
-
{data.notice && <div className="promotion-detail__notice"><Info weight="duotone" />{data.notice}</div>}
|
|
109
|
-
<footer className="promotion-card__footer">参与资格和场次以活动现场实时信息为准</footer>
|
|
115
|
+
<div className="promotion-guide__summary mx-4 flex items-center justify-between gap-2 rounded-[7px] border border-[rgba(35,104,236,0.13)] bg-[#eaf3ff] px-2.5 py-2 text-xs leading-[normal] text-[#2368ec] [&_svg]:w-[13px]"><span className="flex items-center gap-1"><MapPin weight="fill" />当前商场</span><strong>{modeText[data.participationMode ?? 'UNKNOWN']}</strong></div>
|
|
116
|
+
<ol className="my-3 mx-4 grid list-none gap-2">{steps.map((step, index) => <li key={index} className="grid grid-cols-[24px_minmax(0,1fr)] gap-2"><b className="grid size-6 place-items-center rounded-full bg-success text-xs leading-[normal] text-white">{index + 1}</b><span className="grid gap-0.5 pt-0.5"><strong className="text-xs leading-[normal]">{step.title}</strong><small className="text-xs leading-[15px] text-secondary-foreground">{step.description ?? ''}</small></span></li>)}</ol>
|
|
117
|
+
{(data.requirements?.length ?? 0) > 0 && <div className="promotion-guide__requirements mx-4 mb-[11px] flex flex-wrap gap-[5px]">{data.requirements?.map((item) => <span key={item} className="flex items-center gap-[3px] rounded-[5px] bg-[#eaf8f1] px-1.75 py-1 text-xs leading-[normal] text-[#128356] [&_svg]:w-[11px]"><CheckCircle weight="fill" />{item}</span>)}</div>}
|
|
118
|
+
{data.notice && <div className="promotion-detail__notice mx-4 mt-2.5 flex items-start gap-1.5 rounded-[6px] border border-[rgba(228,47,70,0.12)] bg-[var(--tbox-domain-promotion-surface,#fff1f3)] px-[9px] py-2 text-xs leading-[15px] text-[#744333] [&_svg]:mt-[1px] [&_svg]:size-3.5 [&_svg]:shrink-0"><Info weight="duotone" />{data.notice}</div>}
|
|
119
|
+
<footer className="promotion-card__footer flex items-center gap-[5px] border-t border-border px-4 pt-[9px] pb-[11px] text-xs leading-[15px] text-secondary-foreground">参与资格和场次以活动现场实时信息为准</footer>
|
|
110
120
|
</section>
|
|
111
121
|
);
|
|
112
122
|
}
|
|
@@ -7,6 +7,13 @@ import type { SheetFact } from '../../components/CouponSheet';
|
|
|
7
7
|
import { ImageWithFallback } from '../../components/ImageWithFallback';
|
|
8
8
|
import { offerTypeLabel } from '../view';
|
|
9
9
|
import { scrollCardBottom } from '../../utils/scroll-card-bottom';
|
|
10
|
+
import {
|
|
11
|
+
PROMOTION_CHIP_CLASS,
|
|
12
|
+
PROMOTION_CHIP_COUPON_CLASS,
|
|
13
|
+
PROMOTION_CHIP_COUPON_LG_CLASS,
|
|
14
|
+
PROMOTION_STATUS_CLASS,
|
|
15
|
+
PROMOTION_STATUS_TONE_CLASS,
|
|
16
|
+
} from '../../components/class-names';
|
|
10
17
|
|
|
11
18
|
const statusText = (status?: string, claimable?: boolean) => {
|
|
12
19
|
if (status === 'REQUIRES_ACTION') return '需操作';
|
|
@@ -17,6 +24,15 @@ const statusText = (status?: string, claimable?: boolean) => {
|
|
|
17
24
|
const statusTone = (status?: string, claimable?: boolean) =>
|
|
18
25
|
status?.toLowerCase() ?? (claimable ? 'available' : 'unavailable');
|
|
19
26
|
|
|
27
|
+
/** 状态徽章:hook 保留动态 BEM 修饰符,工具类按 tone 取完整字面量(禁运行时拼接)。 */
|
|
28
|
+
const statusBadgeClass = (status?: string, claimable?: boolean) => {
|
|
29
|
+
const tone = statusTone(status, claimable);
|
|
30
|
+
return `promotion-status promotion-status--${tone} ${PROMOTION_STATUS_CLASS} ${PROMOTION_STATUS_TONE_CLASS[tone] ?? ''}`;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** `.promotion-button` + `--primary`(票根紧凑钮,仅推荐卡动作 chip 使用) */
|
|
34
|
+
const PROMOTION_BUTTON_PRIMARY_CLASS = 'flex h-[38px] w-full cursor-pointer items-center justify-center gap-1.5 rounded-[7px] border-0 bg-[#ee3347] mt-[11px] text-xs font-black leading-[normal] tracking-[1px] text-white [clip-path:polygon(12px_0,100%_0,calc(100%_-_12px)_100%,0_100%)] [font-family:\'Kaiti_SC\',STKaiti,KaiTi,serif] disabled:cursor-not-allowed disabled:opacity-50';
|
|
35
|
+
|
|
20
36
|
const couponSubtitleIsTime = (subtitle: string) => {
|
|
21
37
|
const plainText = subtitle.replace(/<[^>]+>/g, ' ').replace(/ /gi, ' ');
|
|
22
38
|
return /\d{4}\s*[-/.年]\s*\d{1,2}\s*[-/.月]\s*\d{1,2}|\d{1,2}:\d{2}/.test(plainText);
|
|
@@ -78,19 +94,19 @@ export function PromotionOfferListCard(props: {
|
|
|
78
94
|
const [offer, ...alternatives] = data.items;
|
|
79
95
|
if (!offer) return <Empty text={data.noResultsReason ?? '暂未找到匹配当前场景的优惠'} />;
|
|
80
96
|
return (
|
|
81
|
-
<section className="promotion-card promotion-recommendation" aria-label="更适合你的优惠">
|
|
82
|
-
<header className="promotion-card__header">
|
|
83
|
-
<span className="promotion-card__mark promotion-card__mark--violet"><Sparkle weight="fill" /></span>
|
|
84
|
-
<div><span className="promotion-card__eyebrow">智能匹配</span><h3>更适合你的优惠</h3><p>根据当前可用性与预计节省排序</p></div>
|
|
97
|
+
<section className="promotion-card promotion-recommendation relative w-full overflow-hidden bg-card text-sm leading-[normal] tracking-[0] text-foreground pb-[15px]" aria-label="更适合你的优惠">
|
|
98
|
+
<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]">
|
|
99
|
+
<span className="promotion-card__mark promotion-card__mark--violet grid h-[38px] w-[38px] flex-[0_0_38px] place-items-center rounded-[10px] border border-[rgba(155,104,20,0.22)] bg-[#fff0cb] text-[#9b6814] shadow-[0_5px_14px_rgba(8,119,95,0.08)] [&_svg]:size-5"><Sparkle weight="fill" /></span>
|
|
100
|
+
<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>
|
|
85
101
|
</header>
|
|
86
|
-
<div className="promotion-recommendation__main">
|
|
87
|
-
<ImageWithFallback src={offer.imageUrl} alt={offer.title} className="promotion-recommendation__image" />
|
|
88
|
-
<div
|
|
89
|
-
<em>{offer.benefitText ?? offerTypeLabel(offer.offerType)}</em>
|
|
102
|
+
<div className="promotion-recommendation__main mx-4 grid grid-cols-[70px_minmax(0,1fr)_auto] items-center gap-2.5 rounded-[8px] border border-[rgba(35,104,236,0.16)] bg-[#f5fbf8] p-[9px]">
|
|
103
|
+
<ImageWithFallback src={offer.imageUrl} alt={offer.title} className="promotion-recommendation__image h-[62px] w-[70px] rounded-[7px] object-cover" />
|
|
104
|
+
<div className="grid min-w-0 gap-[3px]"><span className={statusBadgeClass(offer.availabilityStatus, offer.claimable)}>{statusText(offer.availabilityStatus, offer.claimable)}</span><strong className="truncate text-sm leading-[normal]">{offer.title}</strong><small className="truncate text-xs leading-[normal] text-secondary-foreground">{offer.subtitle ?? offer.validityText ?? '当前商场可用'}</small></div>
|
|
105
|
+
<em className="text-lg font-extrabold not-italic leading-[normal] tabular-nums text-[var(--tbox-domain-promotion-accent,#e42f46)]">{offer.benefitText ?? offerTypeLabel(offer.offerType)}</em>
|
|
90
106
|
</div>
|
|
91
|
-
<div className="promotion-recommendation__reason"><Lightbulb weight="duotone" /><span><b>推荐依据</b>{data.summary ?? '综合资格、可用性和优惠力度'}</span></div>
|
|
92
|
-
{alternatives.length > 0 && <div className="promotion-recommendation__alternatives">另有 {alternatives.length} 个候选优惠</div>}
|
|
93
|
-
<ItemActionsRow actions={offer.itemActions ?? []} cardId={cardId} isHistory={isHistory} className="promotion-recommendation__actions" chipClassName=
|
|
107
|
+
<div className="promotion-recommendation__reason 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)]"><Lightbulb weight="duotone" /><span className="grid gap-[1px]"><b>推荐依据</b>{data.summary ?? '综合资格、可用性和优惠力度'}</span></div>
|
|
108
|
+
{alternatives.length > 0 && <div className="promotion-recommendation__alternatives mx-4 mt-2 text-xs leading-[normal] text-secondary-foreground">另有 {alternatives.length} 个候选优惠</div>}
|
|
109
|
+
<ItemActionsRow actions={offer.itemActions ?? []} cardId={cardId} isHistory={isHistory} className="promotion-recommendation__actions" chipClassName={`promotion-button promotion-button--primary ${PROMOTION_BUTTON_PRIMARY_CLASS}`} />
|
|
94
110
|
</section>
|
|
95
111
|
);
|
|
96
112
|
}
|
|
@@ -107,66 +123,66 @@ export function PromotionOfferListCard(props: {
|
|
|
107
123
|
const items = data.mode === 'claimable' ? data.items.filter((item) => item.claimable) : data.items;
|
|
108
124
|
const maxItems = data.maxItems ?? 4;
|
|
109
125
|
return (
|
|
110
|
-
<section className={`promotion-card promotion-list${promotion ? ' promotion-list--promotion' : ''}${coupon ? ' promotion-list--coupon promotion-list--offers' : ''}`} aria-label={title}>
|
|
111
|
-
{promotion && hero && <div className="promotion-list__hero"><ImageWithFallback src={hero.imageUrl} alt={title} className="promotion-list__hero-image" /><div className="promotion-list__glass"><span>刚刚更新</span><strong>{data.items.length} 个活动正在进行</strong></div></div>}
|
|
126
|
+
<section className={`promotion-card promotion-list relative w-full overflow-hidden bg-card text-sm leading-[normal] tracking-[0] text-foreground ${promotion ? ' promotion-list--promotion' : ''}${coupon ? ' promotion-list--coupon promotion-list--offers pb-3' : ''}`} aria-label={title}>
|
|
127
|
+
{promotion && hero && <div className="promotion-list__hero relative h-[92px] overflow-hidden bg-[#eef2f8]"><ImageWithFallback src={hero.imageUrl} alt={title} className="promotion-list__hero-image h-full w-full object-cover" /><div className="promotion-list__glass absolute right-3 bottom-2.5 left-3 grid gap-[1px] rounded-[7px] border border-[rgba(255,255,255,0.68)] bg-[rgba(255,255,255,0.78)] px-2.5 py-2 shadow-[0_8px_20px_rgba(21,45,88,0.15)] backdrop-blur-[6px]"><span className="text-xs font-bold leading-[normal] text-[#128356]">刚刚更新</span><strong className="text-sm leading-[18px]">{data.items.length} 个活动正在进行</strong></div></div>}
|
|
112
128
|
{coupon ? (
|
|
113
|
-
<header className="promotion-activity__header promotion-activity__header--pea promotion-coupon__header">
|
|
114
|
-
<div className="promotion-activity__header-copy">
|
|
115
|
-
<div className="promotion-activity__header-title-row">
|
|
129
|
+
<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">
|
|
130
|
+
<div className="promotion-activity__header-copy relative z-[1] w-[52%] min-w-0">
|
|
131
|
+
<div className="promotion-activity__header-title-row flex items-center gap-2.5 text-[#2f3a22] [&_svg]:size-[15px] [&_svg]:shrink-0 [&_svg]:text-[#4f7b37]">
|
|
116
132
|
<Ticket weight="fill" />
|
|
117
|
-
<h3>{title}</h3>
|
|
133
|
+
<h3 className="text-base font-bold leading-[21px] text-[#2f3a22] [overflow-wrap:anywhere]">{title}</h3>
|
|
118
134
|
</div>
|
|
119
|
-
<p>{eyebrow}</p>
|
|
135
|
+
<p className="mt-1 text-xs leading-4 text-[#626b5c]">{eyebrow}</p>
|
|
120
136
|
</div>
|
|
121
137
|
</header>
|
|
122
138
|
) : (
|
|
123
|
-
<header className="promotion-card__header">
|
|
124
|
-
<span className="promotion-card__mark">{promotion ? <CalendarDots weight="duotone" /> : <Sparkle weight="fill" />}</span>
|
|
125
|
-
<div><span className="promotion-card__eyebrow">{eyebrow}</span><h3>{title}</h3><p>{summary ?? '根据当前场景实时筛选'}</p></div>
|
|
126
|
-
<b className="promotion-card__count">{data.items.length} 个</b>
|
|
139
|
+
<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]">
|
|
140
|
+
<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">{promotion ? <CalendarDots weight="duotone" /> : <Sparkle weight="fill" />}</span>
|
|
141
|
+
<div className="min-w-0 flex-1"><span className="promotion-card__eyebrow mb-0.5 block text-xs font-bold leading-[14px] text-[#2368ec]">{eyebrow}</span><h3 className="text-lg font-bold leading-[22px] text-foreground [overflow-wrap:anywhere] max-[380px]:text-base">{title}</h3><p className="mt-0.5 truncate text-xs leading-4 text-secondary-foreground">{summary ?? '根据当前场景实时筛选'}</p></div>
|
|
142
|
+
<b className="promotion-card__count flex-none rounded-full border border-[rgba(83,91,108,0.13)] bg-[#f0f3f8] px-2 py-1.25 text-xs leading-[normal] text-secondary-foreground max-[380px]:hidden">{data.items.length} 个</b>
|
|
127
143
|
</header>
|
|
128
144
|
)}
|
|
129
145
|
{!items.length ? <Empty text={data.noResultsReason ?? '暂未找到符合条件的优惠'} /> : (
|
|
130
|
-
<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); }}>
|
|
146
|
+
<div ref={listRef} className={coupon ? `promotion-list__items overflow-hidden px-3.5 pb-1 ${expanded ? ' promotion-list__items--expanded transition-none' : ' transition-[max-height] duration-[320ms] ease-[ease]'}` : `promotion-list__items px-4 pb-1 max-[380px]:px-[13px]${expanded ? ' promotion-list__items--expanded' : ''}`} style={{ maxHeight: expanded ? listHeights.expanded || undefined : listHeights.collapsed || undefined }} onTransitionEnd={() => { if (bottomRef.current) scrollCardBottom(bottomRef.current); }}>
|
|
131
147
|
{items.map((item) => coupon ? (
|
|
132
148
|
<article
|
|
133
149
|
key={item.offerRef}
|
|
134
|
-
className="promotion-coupon-row"
|
|
150
|
+
className="promotion-coupon-row relative grid min-h-[77px] w-full cursor-pointer grid-cols-[68px_minmax(0,1fr)_auto] items-center gap-x-[9px] gap-y-0 overflow-hidden border-0 py-2.5 text-left text-inherit focus-visible:rounded-[6px] focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-[#2368ec]"
|
|
135
151
|
role="button"
|
|
136
152
|
tabIndex={0}
|
|
137
153
|
aria-label={`${item.claimActionLabel ?? '领取'}「${item.title}」`}
|
|
138
154
|
onClick={() => setOpenRef(item.offerRef)}
|
|
139
155
|
onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); setOpenRef(item.offerRef); } }}
|
|
140
156
|
>
|
|
141
|
-
<ImageWithFallback src={item.imageUrl} alt={item.title} className="promotion-coupon-row__thumb" />
|
|
142
|
-
<div className="promotion-coupon-row__main">
|
|
143
|
-
<strong className="promotion-coupon-row__title">{item.title}</strong>
|
|
144
|
-
{item.tags.some((tag) => !/^TOP[1-5]$/i.test(tag)) && <span className="promotion-coupon-row__tags">{item.tags.filter((tag) => !/^TOP[1-5]$/i.test(tag)).slice(0, 3).map((tag) => <em key={tag} className={/^(精选|餐饮|购物|生活)$/.test(tag) ? 'promotion-coupon-row__tag--category' : 'promotion-coupon-row__tag--meta'}>{tag}</em>)}</span>}
|
|
157
|
+
<ImageWithFallback src={item.imageUrl} alt={item.title} className="promotion-coupon-row__thumb h-[68px] w-[68px] shrink-0 rounded-[9px] object-cover shadow-[inset_0_0_0_1px_rgba(11,15,23,0.04)] [&:not(.promotion-image--fallback)]:block" />
|
|
158
|
+
<div className="promotion-coupon-row__main relative flex min-w-0 flex-col justify-center gap-1 self-stretch pr-0.5">
|
|
159
|
+
<strong className="promotion-coupon-row__title line-clamp-2 text-sm font-semibold leading-[19px] text-foreground">{item.title}</strong>
|
|
160
|
+
{item.tags.some((tag) => !/^TOP[1-5]$/i.test(tag)) && <span className="promotion-coupon-row__tags mt-0 flex gap-1 overflow-hidden">{item.tags.filter((tag) => !/^TOP[1-5]$/i.test(tag)).slice(0, 3).map((tag) => <em key={tag} className={`${/^(精选|餐饮|购物|生活)$/.test(tag) ? 'promotion-coupon-row__tag--category' : 'promotion-coupon-row__tag--meta'} shrink-0 max-w-[80px] truncate rounded-[3.5px] bg-[#fff4df] px-[5px] py-[1px] text-xs font-normal not-italic leading-[14px] text-[#986415]`}>{tag}</em>)}</span>}
|
|
145
161
|
{item.subtitle && !couponSubtitleIsTime(item.subtitle)
|
|
146
|
-
&& <span className="promotion-coupon-row__sub" dangerouslySetInnerHTML={{ __html: item.subtitle }} />}
|
|
147
|
-
<span className="promotion-coupon-row__price">
|
|
162
|
+
&& <span className="promotion-coupon-row__sub line-clamp-2 text-xs leading-[11.5px] text-[rgba(11,15,23,0.55)]" dangerouslySetInnerHTML={{ __html: item.subtitle }} />}
|
|
163
|
+
<span className="promotion-coupon-row__price mt-[1px] flex min-w-0 items-baseline gap-1">
|
|
148
164
|
{/* 售价缺省时退回 benefitText:老 provider 没有价格字段,不能让这行空着 */}
|
|
149
|
-
<b>{item.priceText ?? item.benefitText ?? offerTypeLabel(item.offerType)}</b>
|
|
150
|
-
{item.discountLabel && <em className="promotion-coupon-row__discount">{item.discountLabel}</em>}
|
|
151
|
-
{item.priceText && item.originalPriceText && <s>{item.originalPriceText}</s>}
|
|
165
|
+
<b className="shrink-0 text-sm font-extrabold leading-[17px] text-[#e8471c]">{item.priceText ?? item.benefitText ?? offerTypeLabel(item.offerType)}</b>
|
|
166
|
+
{item.discountLabel && <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.discountLabel}</em>}
|
|
167
|
+
{item.priceText && item.originalPriceText && <s className="truncate text-xs leading-3 text-[rgba(11,15,23,0.38)]">{item.originalPriceText}</s>}
|
|
152
168
|
</span>
|
|
153
169
|
</div>
|
|
154
170
|
{/* 领/抢是拉起浮层的入口,不是成交按钮:整行已是可交互控件,
|
|
155
171
|
这里只做视觉承诺——真正的领取动作只在浮层里出现一次 */}
|
|
156
|
-
<span className="promotion-item-actions promotion-item-actions--coupon" aria-hidden="true">
|
|
157
|
-
<span className=
|
|
172
|
+
<span className="promotion-item-actions promotion-item-actions--coupon contents shrink-0" aria-hidden="true">
|
|
173
|
+
<span className={`promotion-chip promotion-chip--coupon ${PROMOTION_CHIP_COUPON_CLASS}`}>{item.claimActionLabel ?? '领取'}</span>
|
|
158
174
|
</span>
|
|
159
175
|
</article>
|
|
160
176
|
) : (
|
|
161
|
-
<article key={item.offerRef}>
|
|
162
|
-
<span className="promotion-list__visual"><ImageWithFallback src={item.imageUrl} alt={item.title} className="promotion-list__thumb" /><em>{item.benefitText ?? offerTypeLabel(item.offerType)}</em></span>
|
|
163
|
-
<span className="promotion-list__copy">
|
|
164
|
-
<small>{promotion ? '本周活动' : offerTypeLabel(item.offerType)}</small>
|
|
165
|
-
<strong>{item.title}</strong>
|
|
166
|
-
<span>{item.subtitle ?? item.validityText ?? '当前商场可用'}</span>
|
|
177
|
+
<article key={item.offerRef} className="grid min-h-[66px] w-full grid-cols-[52px_minmax(0,1fr)_auto_12px] items-center gap-[9px] border-t border-border py-2 text-left text-inherit first:border-t-0 max-[380px]:grid-cols-[46px_minmax(0,1fr)_auto_10px] max-[380px]:gap-[7px]">
|
|
178
|
+
<span className="promotion-list__visual relative h-[48px] w-[52px] max-[380px]:w-[46px]"><ImageWithFallback src={item.imageUrl} alt={item.title} className="promotion-list__thumb h-[48px] w-[52px] rounded-[7px] object-cover max-[380px]:w-[46px]" /><em className="absolute right-[3px] bottom-[3px] max-w-[47px] truncate rounded-[4px] border border-[rgba(255,255,255,0.7)] bg-[rgba(255,255,255,0.82)] px-1 py-0.5 text-xs font-extrabold not-italic leading-[normal] text-[var(--tbox-domain-promotion-accent,#e42f46)] backdrop-blur-[3.5px]">{item.benefitText ?? offerTypeLabel(item.offerType)}</em></span>
|
|
179
|
+
<span className="promotion-list__copy grid min-w-0 gap-0.5">
|
|
180
|
+
<small className="text-xs font-bold leading-[normal] text-[#128356]">{promotion ? '本周活动' : offerTypeLabel(item.offerType)}</small>
|
|
181
|
+
<strong className="truncate text-sm leading-[18px]">{item.title}</strong>
|
|
182
|
+
<span className="truncate text-xs leading-[normal] text-secondary-foreground">{item.subtitle ?? item.validityText ?? '当前商场可用'}</span>
|
|
167
183
|
</span>
|
|
168
|
-
<span className={
|
|
169
|
-
<ItemActionsRow actions={item.itemActions ?? []} cardId={cardId} isHistory={isHistory} className="promotion-item-actions" chipClassName=
|
|
184
|
+
<span className={statusBadgeClass(item.availabilityStatus, item.claimable)}>{statusText(item.availabilityStatus, item.claimable)}</span>
|
|
185
|
+
<ItemActionsRow actions={item.itemActions ?? []} cardId={cardId} isHistory={isHistory} className="promotion-item-actions contents" chipClassName={PROMOTION_CHIP_CLASS} />
|
|
170
186
|
</article>
|
|
171
187
|
))}
|
|
172
188
|
</div>
|
|
@@ -174,7 +190,7 @@ export function PromotionOfferListCard(props: {
|
|
|
174
190
|
{items.length > maxItems && (
|
|
175
191
|
<button
|
|
176
192
|
type="button"
|
|
177
|
-
className=
|
|
193
|
+
className={coupon ? `promotion-list__toggle flex min-h-8 w-full cursor-pointer items-center justify-center gap-0.5 mt-0.5 border-0 bg-transparent px-0 py-0 text-xs font-normal leading-[normal] text-[#686d69] [font-family:inherit] hover:brightness-100 focus-visible:rounded-[5px] focus-visible:outline-3 focus-visible:outline-offset-2 focus-visible:outline-[rgba(9,107,250,0.28)] [&_svg]:transition-transform [&_svg]:duration-[160ms] [&_svg]:ease-[ease] [&_svg[data-rotated=true]]:rotate-180` : `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`}
|
|
178
194
|
aria-expanded={expanded}
|
|
179
195
|
onClick={toggleExpanded}
|
|
180
196
|
>
|
|
@@ -183,8 +199,8 @@ export function PromotionOfferListCard(props: {
|
|
|
183
199
|
{coupon && <CaretDown size={17} aria-hidden="true" data-rotated={expanded || undefined} />}
|
|
184
200
|
</button>
|
|
185
201
|
)}
|
|
186
|
-
{items.length > maxItems && <div ref={bottomRef} className="promotion-list__bottom-anchor" aria-hidden="true" />}
|
|
187
|
-
{data.nextCursor && <p className="promotion-list__more">还有更多内容,可继续查询</p>}
|
|
202
|
+
{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" />}
|
|
203
|
+
{data.nextCursor && <p className="promotion-list__more px-4 pt-1 pb-[9px] text-center text-xs leading-[normal] text-secondary-foreground">还有更多内容,可继续查询</p>}
|
|
188
204
|
{openRef && (() => {
|
|
189
205
|
const target = items.find((i) => i.offerRef === openRef);
|
|
190
206
|
if (!target) return null;
|
|
@@ -229,15 +245,15 @@ export function PromotionOfferListCard(props: {
|
|
|
229
245
|
});
|
|
230
246
|
}}
|
|
231
247
|
foot={<>
|
|
232
|
-
<span className="promotion-sheet__foot-price">
|
|
233
|
-
<b>{target.priceText ?? target.benefitText ?? ''}</b>
|
|
234
|
-
{target.priceText && target.originalPriceText && <s>{target.originalPriceText}</s>}
|
|
248
|
+
<span className="promotion-sheet__foot-price flex min-w-0 items-baseline gap-1">
|
|
249
|
+
<b className="text-xl font-extrabold leading-[normal] text-[#e8471c]">{target.priceText ?? target.benefitText ?? ''}</b>
|
|
250
|
+
{target.priceText && target.originalPriceText && <s className="text-xs leading-[normal] text-[rgba(11,15,23,0.4)]">{target.originalPriceText}</s>}
|
|
235
251
|
</span>
|
|
236
252
|
{redirectOnly ? (
|
|
237
253
|
<button
|
|
238
254
|
type="button"
|
|
239
255
|
disabled={!target.purchaseUrl}
|
|
240
|
-
className=
|
|
256
|
+
className={`promotion-chip promotion-chip--coupon promotion-chip--coupon-lg ${PROMOTION_CHIP_COUPON_LG_CLASS}`}
|
|
241
257
|
onClick={() => {
|
|
242
258
|
if (!target.purchaseUrl) return;
|
|
243
259
|
void navigateToAlipayPage(target.purchaseUrl).catch((err: unknown) => {
|
|
@@ -251,7 +267,7 @@ export function PromotionOfferListCard(props: {
|
|
|
251
267
|
// 直接走写动作,不再绕发消息:结果以新卡片回到对话流,当前浮层保持已领取态
|
|
252
268
|
<button
|
|
253
269
|
type="button"
|
|
254
|
-
className=
|
|
270
|
+
className={`promotion-chip promotion-chip--coupon promotion-chip--coupon-lg ${PROMOTION_CHIP_COUPON_LG_CLASS}`}
|
|
255
271
|
onClick={() => {
|
|
256
272
|
setClaimingRef(target.offerRef);
|
|
257
273
|
sendCardAction(cardId, { type: 'moduleAction', actionId: 'promotion.acquire-from-list', contextToken: token }, { offerRef: target.offerRef });
|
|
@@ -267,7 +283,7 @@ export function PromotionOfferListCard(props: {
|
|
|
267
283
|
cardId={cardId}
|
|
268
284
|
isHistory={isHistory}
|
|
269
285
|
className="promotion-item-actions"
|
|
270
|
-
chipClassName=
|
|
286
|
+
chipClassName={`promotion-chip promotion-chip--coupon promotion-chip--coupon-lg ${PROMOTION_CHIP_COUPON_LG_CLASS}`}
|
|
271
287
|
/>
|
|
272
288
|
)}
|
|
273
289
|
</>}
|
|
@@ -281,7 +297,7 @@ export function PromotionOfferListCard(props: {
|
|
|
281
297
|
markSelfRendering(PromotionOfferListCard);
|
|
282
298
|
|
|
283
299
|
function Empty({ text }: { text: string }) {
|
|
284
|
-
return <div className="promotion-card__empty"><Ticket size={28} weight="duotone" /><span>{text}</span></div>;
|
|
300
|
+
return <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>{text}</span></div>;
|
|
285
301
|
}
|
|
286
302
|
|
|
287
303
|
export default PromotionOfferListCard;
|
|
@@ -23,7 +23,7 @@ export function CouponQrCode(props: { value: string; disabled?: boolean }) {
|
|
|
23
23
|
return () => { active = false; };
|
|
24
24
|
}, [disabled, value]);
|
|
25
25
|
|
|
26
|
-
return src ? <img className={`promotion-sheet__qrcode${disabled ? ' promotion-sheet__qrcode--disabled' : ''}`} src={src} alt="券码二维码" /> : null;
|
|
26
|
+
return src ? <img className={`promotion-sheet__qrcode block h-auto w-[min(70%,120px)] aspect-square mx-auto mt-2.5 mb-3 [image-rendering:pixelated] ${disabled ? ' promotion-sheet__qrcode--disabled opacity-85' : ''}`} src={src} alt="券码二维码" /> : null;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export function CouponBarcode(props: { value: string; disabled?: boolean }) {
|
|
@@ -44,5 +44,5 @@ export function CouponBarcode(props: { value: string; disabled?: boolean }) {
|
|
|
44
44
|
ref.current.replaceChildren();
|
|
45
45
|
}
|
|
46
46
|
}, [disabled, value]);
|
|
47
|
-
return <svg ref={ref} className={`promotion-sheet__barcode${disabled ? ' promotion-sheet__barcode--disabled' : ''}`} aria-label="券码条形码" role="img" />;
|
|
47
|
+
return <svg ref={ref} className={`promotion-sheet__barcode block h-auto min-h-[26px] w-[min(70%,160px)] mx-auto mt-3.5 mb-2.5 ${disabled ? ' promotion-sheet__barcode--disabled opacity-85' : ''}`} aria-label="券码条形码" role="img" />;
|
|
48
48
|
}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* 列表这一跳已经下发的字段:**缺的整块不渲染,绝不留空壳,也不编造占位文案**。
|
|
6
6
|
*/
|
|
7
7
|
import { X } from '@phosphor-icons/react';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { useState } from 'react';
|
|
9
|
+
import { Overlay } from '@tbox.cn/app-agent-ui-kit/overlay';
|
|
10
10
|
import { ImageWithFallback } from './ImageWithFallback';
|
|
11
11
|
import { sanitizeActivityHtml } from '../utils/sanitize-activity-html';
|
|
12
12
|
|
|
@@ -39,76 +39,51 @@ export function CouponSheet(props: {
|
|
|
39
39
|
onClose: () => void;
|
|
40
40
|
}) {
|
|
41
41
|
const { title, imageUrl, imageFit = 'contain', subtitle, noticeText, guaranteeText, priceMain, priceOriginal, aside, facts = [], beforeFacts, extra, foot, onClose } = props;
|
|
42
|
+
// 关闭分两段:先让弹层播退出动画(Overlay 的 onExited),再交给父组件卸载。
|
|
42
43
|
const [closing, setClosing] = useState(false);
|
|
43
|
-
const
|
|
44
|
-
const closeTimerRef = useRef<number>();
|
|
45
|
-
const onCloseRef = useRef(onClose);
|
|
46
|
-
onCloseRef.current = onClose;
|
|
44
|
+
const requestClose = () => setClosing(true);
|
|
47
45
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const reducedMotion = window.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches ?? false;
|
|
61
|
-
closeTimerRef.current = window.setTimeout(finishClose, reducedMotion ? 1 : 200);
|
|
62
|
-
}, [finishClose]);
|
|
63
|
-
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') requestClose(); };
|
|
66
|
-
document.addEventListener('keydown', onKey);
|
|
67
|
-
return () => document.removeEventListener('keydown', onKey);
|
|
68
|
-
}, [requestClose]);
|
|
69
|
-
|
|
70
|
-
useEffect(() => () => window.clearTimeout(closeTimerRef.current), []);
|
|
71
|
-
|
|
72
|
-
return createPortal(
|
|
73
|
-
<div
|
|
74
|
-
className={`promotion-sheet${closing ? ' promotion-sheet--closing' : ''}`}
|
|
75
|
-
role="dialog"
|
|
76
|
-
aria-modal="true"
|
|
77
|
-
aria-label={`${title} 详情`}
|
|
78
|
-
onAnimationEnd={(event) => {
|
|
79
|
-
if (closing && event.target === event.currentTarget) finishClose();
|
|
80
|
-
}}
|
|
81
|
-
onMouseDown={(e) => { if (e.target === e.currentTarget) requestClose(); }}
|
|
46
|
+
return (
|
|
47
|
+
<Overlay
|
|
48
|
+
open={!closing}
|
|
49
|
+
onDismiss={requestClose}
|
|
50
|
+
onExited={onClose}
|
|
51
|
+
placement="bottom"
|
|
52
|
+
label={`${title} 详情`}
|
|
53
|
+
maskDismiss="self-pointerdown"
|
|
54
|
+
exitMs={220}
|
|
55
|
+
rootClassName="promotion-sheet group animate-[promotion-sheet-in_180ms_ease-out] group-data-[state=closed]:animate-[promotion-sheet-out_180ms_ease-in_both] motion-reduce:animate-none"
|
|
56
|
+
maskClassName="bg-[rgba(11,15,23,0.42)]"
|
|
57
|
+
panelClassName="promotion-sheet__panel relative flex max-h-[82vh] w-full max-w-[375px] flex-col rounded-t-[18px] bg-card animate-[promotion-sheet-up_220ms_cubic-bezier(0.22,1,0.36,1)] group-data-[state=closed]:animate-[promotion-sheet-down_180ms_ease-in_both] motion-reduce:animate-none"
|
|
82
58
|
>
|
|
83
|
-
|
|
84
|
-
<button type="button" className="promotion-sheet__close" aria-label="关闭详情" onClick={requestClose}>
|
|
59
|
+
<button type="button" className="promotion-sheet__close absolute top-3 right-3 z-[2] grid size-[30px] cursor-pointer place-items-center rounded-full border-0 bg-[rgba(11,15,23,0.42)] text-white [font-family:inherit]" aria-label="关闭详情" onClick={requestClose}>
|
|
85
60
|
<X size={18} weight="bold" aria-hidden="true" />
|
|
86
61
|
</button>
|
|
87
|
-
<div className="promotion-sheet__scroll">
|
|
88
|
-
<ImageWithFallback src={imageUrl} alt={title} className={
|
|
62
|
+
<div className="promotion-sheet__scroll overflow-y-auto pb-1.5 [-webkit-overflow-scrolling:touch]">
|
|
63
|
+
<ImageWithFallback src={imageUrl} alt={title} className={imageFit === 'cover' ? 'promotion-sheet__image promotion-sheet__image--cover block h-[210px] w-full rounded-t-[18px] bg-[#f5f6f8] object-cover' : 'promotion-sheet__image h-[210px] w-full rounded-t-[18px] bg-[#f5f6f8] object-contain'} />
|
|
89
64
|
{/* 价格条压在图下沿:与列表行同一组价格语言,浮层里放大一档 */}
|
|
90
65
|
{(priceMain || aside) && (
|
|
91
|
-
<div className="promotion-sheet__price">
|
|
92
|
-
{priceMain && <b>{priceMain}</b>}
|
|
93
|
-
{priceMain && priceOriginal && <s>{priceOriginal}</s>}
|
|
94
|
-
{aside && <span className="promotion-sheet__stock">{aside}</span>}
|
|
66
|
+
<div className="promotion-sheet__price flex items-baseline gap-2 bg-[linear-gradient(180deg,#fdf1e8_0%,#fbe7d9_100%)] px-4 py-3">
|
|
67
|
+
{priceMain && <b className="text-2xl font-extrabold leading-[27px] text-[#e8471c]">{priceMain}</b>}
|
|
68
|
+
{priceMain && priceOriginal && <s className="text-xs leading-[normal] text-[rgba(11,15,23,0.4)]">{priceOriginal}</s>}
|
|
69
|
+
{aside && <span className="promotion-sheet__stock ml-auto text-xs leading-[normal] text-[rgba(11,15,23,0.55)]">{aside}</span>}
|
|
95
70
|
</div>
|
|
96
71
|
)}
|
|
97
|
-
<h4 className="promotion-sheet__title">{title}</h4>
|
|
98
|
-
{(noticeText || guaranteeText) && <div className="promotion-sheet__notice-strip">
|
|
99
|
-
{noticeText && <span><b>须知</b>{noticeText}</span>}
|
|
100
|
-
{guaranteeText && <span><b>保障</b>{guaranteeText}</span>}
|
|
72
|
+
<h4 className="promotion-sheet__title mx-4 mt-3.5 text-lg font-bold leading-[23px] text-[rgba(11,15,23,0.9)]">{title}</h4>
|
|
73
|
+
{(noticeText || guaranteeText) && <div className="promotion-sheet__notice-strip mx-4 mt-3 grid gap-[3px] rounded-[5px] bg-[#fff8ef] px-[7px] py-1.5 text-sm leading-[19px]">
|
|
74
|
+
{noticeText && <span className="grid grid-cols-[72px_minmax(0,1fr)] gap-1.5"><b className="w-auto text-left text-[#b38a3e]">须知</b>{noticeText}</span>}
|
|
75
|
+
{guaranteeText && <span className="grid grid-cols-[72px_minmax(0,1fr)] gap-1.5"><b className="w-auto text-left text-[#ef7654]">保障</b>{guaranteeText}</span>}
|
|
101
76
|
</div>}
|
|
102
|
-
{subtitle && <p className="promotion-sheet__sub" dangerouslySetInnerHTML={{ __html: subtitle }} />}
|
|
77
|
+
{subtitle && <p className="promotion-sheet__sub mx-4 mt-3 text-sm leading-[19px] text-[rgba(11,15,23,0.55)]" dangerouslySetInnerHTML={{ __html: sanitizeActivityHtml(subtitle) }} />}
|
|
103
78
|
{beforeFacts}
|
|
104
79
|
{facts.length > 0 && (
|
|
105
80
|
<>
|
|
106
|
-
<div className="promotion-sheet__section">使用须知</div>
|
|
107
|
-
<dl className="promotion-sheet__facts">
|
|
81
|
+
<div className="promotion-sheet__section mx-4 mt-[17px] text-sm font-bold leading-5 text-[rgba(11,15,23,0.9)]">使用须知</div>
|
|
82
|
+
<dl className="promotion-sheet__facts mx-4 mt-2 rounded-[10px] bg-[#f7f8fa] px-3 py-[3px]">
|
|
108
83
|
{facts.map((f) => (
|
|
109
|
-
<div key={f.label}>
|
|
110
|
-
<dt>{f.icon}{f.label}</dt>
|
|
111
|
-
<dd dangerouslySetInnerHTML={{ __html: sanitizeActivityHtml(f.value) }} />
|
|
84
|
+
<div key={f.label} className="flex gap-1.5 border-b border-[#ecedf1] py-[11px] last:border-b-0">
|
|
85
|
+
<dt className="flex w-[70px] shrink-0 items-center gap-[3.5px] text-xs leading-[17px] text-[rgba(11,15,23,0.55)]">{f.icon}{f.label}</dt>
|
|
86
|
+
<dd className="text-sm leading-[19px] text-[rgba(11,15,23,0.85)] [overflow-wrap:anywhere]" dangerouslySetInnerHTML={{ __html: sanitizeActivityHtml(f.value) }} />
|
|
112
87
|
</div>
|
|
113
88
|
))}
|
|
114
89
|
</dl>
|
|
@@ -116,10 +91,8 @@ export function CouponSheet(props: {
|
|
|
116
91
|
)}
|
|
117
92
|
{extra}
|
|
118
93
|
</div>
|
|
119
|
-
{foot && <div className="promotion-sheet__foot">{foot}</div>}
|
|
120
|
-
|
|
121
|
-
</div>,
|
|
122
|
-
document.body,
|
|
94
|
+
{foot && <div className="promotion-sheet__foot flex items-center justify-between gap-3 border-t border-[#eef0f3] bg-card px-4 pt-[11px] pb-[calc(11px+env(safe-area-inset-bottom,0px))]">{foot}</div>}
|
|
95
|
+
</Overlay>
|
|
123
96
|
);
|
|
124
97
|
}
|
|
125
98
|
|
|
@@ -17,7 +17,7 @@ export function ImageWithFallback(props: {
|
|
|
17
17
|
if (!src || failed) {
|
|
18
18
|
return (
|
|
19
19
|
<div
|
|
20
|
-
className={`img-fallback promotion-image--fallback ${className ?? ''}`.trim()}
|
|
20
|
+
className={`img-fallback promotion-image--fallback grid place-items-center bg-[#f1f2f4] text-[rgba(11,15,23,0.26)] ${className ?? ''}`.trim()}
|
|
21
21
|
aria-label={alt}
|
|
22
22
|
role="img"
|
|
23
23
|
>
|