@tbox.cn/app-module-promotion 0.10.1 → 0.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tbox.cn/app-module-promotion",
3
- "version": "0.10.1",
3
+ "version": "0.10.3",
4
4
  "type": "module",
5
5
  "description": "商圈营销模块:资格校验、推荐降级链、券卡(codegen 源)。",
6
6
  "exports": {
@@ -19,11 +19,11 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "@tbox.cn/app-contracts": "0.12.0",
22
- "@tbox.cn/app-contracts-mall": "0.12.0",
22
+ "@tbox.cn/app-contracts-mall": "0.12.1",
23
23
  "jsbarcode": "^3.12.3",
24
24
  "qrcode": "^1.5.4",
25
- "@tbox.cn/app-agent-sdk-client": "0.1.0",
26
- "@tbox.cn/app-agent-sdk-server": "0.1.0"
25
+ "@tbox.cn/app-agent-sdk-client": "0.1.1",
26
+ "@tbox.cn/app-agent-sdk-server": "0.1.1"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "@phosphor-icons/react": "2.1.10",
@@ -22,6 +22,9 @@ const couponSubtitleIsTime = (subtitle: string) => {
22
22
  return /\d{4}\s*[-/.年]\s*\d{1,2}\s*[-/.月]\s*\d{1,2}|\d{1,2}:\d{2}/.test(plainText);
23
23
  };
24
24
 
25
+ const sheetImageFit = (offer: PromotionOfferListCardData['items'][number]): 'contain' | 'cover' =>
26
+ offer.offerRef === 'demo:coupon:1001' || offer.offerRef === 'demo:groupon:2001' ? 'cover' : 'contain';
27
+
25
28
  export function PromotionOfferListCard(props: {
26
29
  data: PromotionOfferListCardData;
27
30
  cardId?: string;
@@ -203,6 +206,7 @@ export function PromotionOfferListCard(props: {
203
206
  <CouponSheet
204
207
  title={target.title}
205
208
  imageUrl={target.imageUrl}
209
+ imageFit={sheetImageFit(target)}
206
210
  noticeText={target.usageNoticeText}
207
211
  guaranteeText={target.guaranteeText}
208
212
  subtitle={redirectOnly
@@ -19,6 +19,8 @@ export interface SheetFact {
19
19
  export function CouponSheet(props: {
20
20
  title: string;
21
21
  imageUrl?: string;
22
+ /** 团购图有稳定横幅画幅,可裁切铺满;券图默认完整展示。 */
23
+ imageFit?: 'contain' | 'cover';
22
24
  subtitle?: string;
23
25
  noticeText?: string;
24
26
  guaranteeText?: string;
@@ -36,7 +38,7 @@ export function CouponSheet(props: {
36
38
  foot?: React.ReactNode;
37
39
  onClose: () => void;
38
40
  }) {
39
- const { title, imageUrl, subtitle, noticeText, guaranteeText, priceMain, priceOriginal, aside, facts = [], beforeFacts, extra, foot, onClose } = props;
41
+ const { title, imageUrl, imageFit = 'contain', subtitle, noticeText, guaranteeText, priceMain, priceOriginal, aside, facts = [], beforeFacts, extra, foot, onClose } = props;
40
42
  const [closing, setClosing] = useState(false);
41
43
  const closingRef = useRef(false);
42
44
  const closeTimerRef = useRef<number>();
@@ -83,7 +85,7 @@ export function CouponSheet(props: {
83
85
  <X size={18} weight="bold" aria-hidden="true" />
84
86
  </button>
85
87
  <div className="promotion-sheet__scroll">
86
- <ImageWithFallback src={imageUrl} alt={title} className="promotion-sheet__image" />
88
+ <ImageWithFallback src={imageUrl} alt={title} className={`promotion-sheet__image${imageFit === 'cover' ? ' promotion-sheet__image--cover' : ''}`} />
87
89
  {/* 价格条压在图下沿:与列表行同一组价格语言,浮层里放大一档 */}
88
90
  {(priceMain || aside) && (
89
91
  <div className="promotion-sheet__price">
@@ -1969,6 +1969,10 @@
1969
1969
  object-fit: contain;
1970
1970
  background: #f5f6f8;
1971
1971
  }
1972
+ .promotion-sheet__image--cover {
1973
+ display: block;
1974
+ object-fit: cover;
1975
+ }
1972
1976
  .promotion-sheet__price {
1973
1977
  display: flex;
1974
1978
  align-items: baseline;
package/tbox.module.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "id": "module-promotion",
4
- "name": "营销中心",
4
+ "name": "营销活动",
5
5
  "description": "活动、优惠、权益、套餐查询与券领取,最划算计算",
6
- "version": "0.3.0",
6
+ "version": "0.10.1",
7
+ "hidden": true,
7
8
  "kind": "business",
8
9
  "risk": {
9
10
  "level": "low",
@@ -332,6 +332,38 @@ describe('优惠券链路视觉状态语义', () => {
332
332
  expect(host.querySelector('.promotion-coupon-row__sub')?.textContent).toBe('商场会员专享');
333
333
  });
334
334
 
335
+ it('演示团购与指定满减券详情图裁切铺满,其他券图保持完整展示', () => {
336
+ const host = render(<PromotionOfferListCard data={{
337
+ mode: 'claimable',
338
+ presentation: 'coupon',
339
+ items: [
340
+ offer,
341
+ { ...offer, offerRef: 'demo:coupon:1001', title: '满 100 减 20 元券' },
342
+ { ...offer, offerRef: 'demo:groupon:2001', offerType: 'GROUPON', title: '演示双人套餐' },
343
+ { ...offer, offerRef: 'vendor:groupon:1', offerType: 'GROUPON', title: '厂商双人套餐' },
344
+ ],
345
+ } as never} cardId="coupon-list" />);
346
+ const rows = host.querySelectorAll('.promotion-coupon-row');
347
+
348
+ act(() => (rows[0] as HTMLElement).click());
349
+ expect(document.querySelector('.promotion-sheet__image--cover')).toBeNull();
350
+ act(() => (document.querySelector('.promotion-sheet [aria-label="关闭详情"]') as HTMLElement).click());
351
+ act(() => document.querySelector('.promotion-sheet')?.dispatchEvent(new Event('animationend', { bubbles: true })));
352
+
353
+ act(() => (rows[1] as HTMLElement).click());
354
+ expect(document.querySelector('.promotion-sheet__image--cover')).not.toBeNull();
355
+ act(() => (document.querySelector('.promotion-sheet [aria-label="关闭详情"]') as HTMLElement).click());
356
+ act(() => document.querySelector('.promotion-sheet')?.dispatchEvent(new Event('animationend', { bubbles: true })));
357
+
358
+ act(() => (rows[2] as HTMLElement).click());
359
+ expect(document.querySelector('.promotion-sheet__image--cover')).not.toBeNull();
360
+ act(() => (document.querySelector('.promotion-sheet [aria-label="关闭详情"]') as HTMLElement).click());
361
+ act(() => document.querySelector('.promotion-sheet')?.dispatchEvent(new Event('animationend', { bubbles: true })));
362
+
363
+ act(() => (rows[3] as HTMLElement).click());
364
+ expect(document.querySelector('.promotion-sheet__image--cover')).toBeNull();
365
+ });
366
+
335
367
  it('商场券和我的券缺图时共用居中的缩略图兜底', () => {
336
368
  const offerHost = render(<PromotionOfferListCard data={{
337
369
  mode: 'claimable',