pb-sxp-ui 1.20.64 → 1.20.65

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/dist/index.cjs CHANGED
@@ -1733,8 +1733,12 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
1733
1733
  contentFormat = 'image';
1734
1734
  }
1735
1735
  const contentTags = (_p = (_m = (_h = product === null || product === void 0 ? void 0 : product.tags) !== null && _h !== void 0 ? _h : (_l = (_k = (_j = rec === null || rec === void 0 ? void 0 : rec.video) === null || _j === void 0 ? void 0 : _j.bindProducts) === null || _k === void 0 ? void 0 : _k[0]) === null || _l === void 0 ? void 0 : _l.tags) !== null && _m !== void 0 ? _m : (_o = rec === null || rec === void 0 ? void 0 : rec.video) === null || _o === void 0 ? void 0 : _o.tags) !== null && _p !== void 0 ? _p : (_q = rec === null || rec === void 0 ? void 0 : rec.product) === null || _q === void 0 ? void 0 : _q.tags;
1736
+ // 收窄到 ProductInfoType,以访问 SKU 特有字段
1737
+ const productInfo = product;
1738
+ const variantId = productInfo === null || productInfo === void 0 ? void 0 : productInfo.variantId;
1739
+ const variantOption = productInfo === null || productInfo === void 0 ? void 0 : productInfo.variantOption;
1736
1740
  bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
1737
- eventInfo: Object.assign(Object.assign({}, eventInfo), { ctaId: (_r = cta === null || cta === void 0 ? void 0 : cta.itemId) !== null && _r !== void 0 ? _r : '', ctaName: (_s = cta === null || cta === void 0 ? void 0 : cta.title) !== null && _s !== void 0 ? _s : '', contentTags: contentTags ? JSON.stringify(contentTags) : '', position: position + '', contentId: (_u = (_t = rec === null || rec === void 0 ? void 0 : rec.video) === null || _t === void 0 ? void 0 : _t.itemId) !== null && _u !== void 0 ? _u : '', sceneId: (_x = (_w = (_v = rec === null || rec === void 0 ? void 0 : rec.video) === null || _v === void 0 ? void 0 : _v.scene) === null || _w === void 0 ? void 0 : _w.sceneId) !== null && _x !== void 0 ? _x : '', productId: isProd ? product === null || product === void 0 ? void 0 : product.itemId : '', traceInfo: (_13 = (_10 = (_5 = (_1 = (_y = cta === null || cta === void 0 ? void 0 : cta.traceInfo) !== null && _y !== void 0 ? _y : (_0 = (_z = rec === null || rec === void 0 ? void 0 : rec.video) === null || _z === void 0 ? void 0 : _z.bindCta) === null || _0 === void 0 ? void 0 : _0.traceInfo) !== null && _1 !== void 0 ? _1 : (_4 = (_3 = (_2 = rec === null || rec === void 0 ? void 0 : rec.video) === null || _2 === void 0 ? void 0 : _2.bindProduct) === null || _3 === void 0 ? void 0 : _3.bindCta) === null || _4 === void 0 ? void 0 : _4.traceInfo) !== null && _5 !== void 0 ? _5 : (_9 = (_8 = (_7 = (_6 = rec === null || rec === void 0 ? void 0 : rec.video) === null || _6 === void 0 ? void 0 : _6.bindProducts) === null || _7 === void 0 ? void 0 : _7[0]) === null || _8 === void 0 ? void 0 : _8.bindCta) === null || _9 === void 0 ? void 0 : _9.traceInfo) !== null && _10 !== void 0 ? _10 : (_12 = (_11 = rec === null || rec === void 0 ? void 0 : rec.product) === null || _11 === void 0 ? void 0 : _11.bindCta) === null || _12 === void 0 ? void 0 : _12.traceInfo) !== null && _13 !== void 0 ? _13 : '', fromKName, fromKPage: (_14 = location === null || location === void 0 ? void 0 : location.href) !== null && _14 !== void 0 ? _14 : '', contentFormat })
1741
+ eventInfo: Object.assign(Object.assign(Object.assign(Object.assign({}, eventInfo), { ctaId: (_r = cta === null || cta === void 0 ? void 0 : cta.itemId) !== null && _r !== void 0 ? _r : '', ctaName: (_s = cta === null || cta === void 0 ? void 0 : cta.title) !== null && _s !== void 0 ? _s : '', contentTags: contentTags ? JSON.stringify(contentTags) : '', position: position + '', contentId: (_u = (_t = rec === null || rec === void 0 ? void 0 : rec.video) === null || _t === void 0 ? void 0 : _t.itemId) !== null && _u !== void 0 ? _u : '', sceneId: (_x = (_w = (_v = rec === null || rec === void 0 ? void 0 : rec.video) === null || _v === void 0 ? void 0 : _v.scene) === null || _w === void 0 ? void 0 : _w.sceneId) !== null && _x !== void 0 ? _x : '', productId: isProd ? product === null || product === void 0 ? void 0 : product.itemId : '', traceInfo: (_13 = (_10 = (_5 = (_1 = (_y = cta === null || cta === void 0 ? void 0 : cta.traceInfo) !== null && _y !== void 0 ? _y : (_0 = (_z = rec === null || rec === void 0 ? void 0 : rec.video) === null || _z === void 0 ? void 0 : _z.bindCta) === null || _0 === void 0 ? void 0 : _0.traceInfo) !== null && _1 !== void 0 ? _1 : (_4 = (_3 = (_2 = rec === null || rec === void 0 ? void 0 : rec.video) === null || _2 === void 0 ? void 0 : _2.bindProduct) === null || _3 === void 0 ? void 0 : _3.bindCta) === null || _4 === void 0 ? void 0 : _4.traceInfo) !== null && _5 !== void 0 ? _5 : (_9 = (_8 = (_7 = (_6 = rec === null || rec === void 0 ? void 0 : rec.video) === null || _6 === void 0 ? void 0 : _6.bindProducts) === null || _7 === void 0 ? void 0 : _7[0]) === null || _8 === void 0 ? void 0 : _8.bindCta) === null || _9 === void 0 ? void 0 : _9.traceInfo) !== null && _10 !== void 0 ? _10 : (_12 = (_11 = rec === null || rec === void 0 ? void 0 : rec.product) === null || _11 === void 0 ? void 0 : _11.bindCta) === null || _12 === void 0 ? void 0 : _12.traceInfo) !== null && _13 !== void 0 ? _13 : '', fromKName, fromKPage: (_14 = location === null || location === void 0 ? void 0 : location.href) !== null && _14 !== void 0 ? _14 : '', contentFormat }), (variantId && { variantId })), (variantOption && { variantOption }))
1738
1742
  });
1739
1743
  }, [bffEventReport, isFromHashtag]);
1740
1744
  const h5EnterLink = React.useCallback(() => {
@@ -2269,7 +2273,7 @@ function useEventReport() {
2269
2273
  contentFormat = 'image';
2270
2274
  }
2271
2275
  bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
2272
- eventInfo: Object.assign({ eventSubject: 'jumpToWeb', eventDescription: 'User jumped to website', productId: (_v = product === null || product === void 0 ? void 0 : product.itemId) !== null && _v !== void 0 ? _v : '', productName: (_w = product === null || product === void 0 ? void 0 : product.title) !== null && _w !== void 0 ? _w : '', price: (product === null || product === void 0 ? void 0 : product.price) ? (product === null || product === void 0 ? void 0 : product.price) + '' : '0', productCollection: (_x = product === null || product === void 0 ? void 0 : product.collection) !== null && _x !== void 0 ? _x : '', fromKName, fromKPage: location === null || location === void 0 ? void 0 : location.href, contentTags: contentTags ? JSON.stringify(contentTags) : '', position: position + '', contentId: (_z = (_y = data === null || data === void 0 ? void 0 : data.video) === null || _y === void 0 ? void 0 : _y.itemId) !== null && _z !== void 0 ? _z : '', sceneId: (_2 = (_1 = (_0 = data === null || data === void 0 ? void 0 : data.video) === null || _0 === void 0 ? void 0 : _0.scene) === null || _1 === void 0 ? void 0 : _1.sceneId) !== null && _2 !== void 0 ? _2 : '', ctatId: (_3 = cta === null || cta === void 0 ? void 0 : cta.itemId) !== null && _3 !== void 0 ? _3 : '', traceInfo: (_16 = (_13 = (_11 = (_7 = (_4 = traceInfo !== null && traceInfo !== void 0 ? traceInfo : product === null || product === void 0 ? void 0 : product.traceInfo) !== null && _4 !== void 0 ? _4 : (_6 = (_5 = data === null || data === void 0 ? void 0 : data.video) === null || _5 === void 0 ? void 0 : _5.bindProduct) === null || _6 === void 0 ? void 0 : _6.traceInfo) !== null && _7 !== void 0 ? _7 : (_10 = (_9 = (_8 = data === null || data === void 0 ? void 0 : data.video) === null || _8 === void 0 ? void 0 : _8.bindProducts) === null || _9 === void 0 ? void 0 : _9[0]) === null || _10 === void 0 ? void 0 : _10.traceInfo) !== null && _11 !== void 0 ? _11 : (_12 = data === null || data === void 0 ? void 0 : data.product) === null || _12 === void 0 ? void 0 : _12.traceInfo) !== null && _13 !== void 0 ? _13 : (_15 = (_14 = data === null || data === void 0 ? void 0 : data.video) === null || _14 === void 0 ? void 0 : _14.bindCta) === null || _15 === void 0 ? void 0 : _15.traceInfo) !== null && _16 !== void 0 ? _16 : '' }, (contentFormat && { contentFormat }))
2276
+ eventInfo: Object.assign(Object.assign(Object.assign({ eventSubject: 'jumpToWeb', eventDescription: 'User jumped to website', productId: (_v = product === null || product === void 0 ? void 0 : product.itemId) !== null && _v !== void 0 ? _v : '', productName: (_w = product === null || product === void 0 ? void 0 : product.title) !== null && _w !== void 0 ? _w : '', price: (product === null || product === void 0 ? void 0 : product.price) ? (product === null || product === void 0 ? void 0 : product.price) + '' : '0', productCollection: (_x = product === null || product === void 0 ? void 0 : product.collection) !== null && _x !== void 0 ? _x : '', fromKName, fromKPage: location === null || location === void 0 ? void 0 : location.href, contentTags: contentTags ? JSON.stringify(contentTags) : '', position: position + '', contentId: (_z = (_y = data === null || data === void 0 ? void 0 : data.video) === null || _y === void 0 ? void 0 : _y.itemId) !== null && _z !== void 0 ? _z : '', sceneId: (_2 = (_1 = (_0 = data === null || data === void 0 ? void 0 : data.video) === null || _0 === void 0 ? void 0 : _0.scene) === null || _1 === void 0 ? void 0 : _1.sceneId) !== null && _2 !== void 0 ? _2 : '', ctatId: (_3 = cta === null || cta === void 0 ? void 0 : cta.itemId) !== null && _3 !== void 0 ? _3 : '', traceInfo: (_16 = (_13 = (_11 = (_7 = (_4 = traceInfo !== null && traceInfo !== void 0 ? traceInfo : product === null || product === void 0 ? void 0 : product.traceInfo) !== null && _4 !== void 0 ? _4 : (_6 = (_5 = data === null || data === void 0 ? void 0 : data.video) === null || _5 === void 0 ? void 0 : _5.bindProduct) === null || _6 === void 0 ? void 0 : _6.traceInfo) !== null && _7 !== void 0 ? _7 : (_10 = (_9 = (_8 = data === null || data === void 0 ? void 0 : data.video) === null || _8 === void 0 ? void 0 : _8.bindProducts) === null || _9 === void 0 ? void 0 : _9[0]) === null || _10 === void 0 ? void 0 : _10.traceInfo) !== null && _11 !== void 0 ? _11 : (_12 = data === null || data === void 0 ? void 0 : data.product) === null || _12 === void 0 ? void 0 : _12.traceInfo) !== null && _13 !== void 0 ? _13 : (_15 = (_14 = data === null || data === void 0 ? void 0 : data.video) === null || _14 === void 0 ? void 0 : _14.bindCta) === null || _15 === void 0 ? void 0 : _15.traceInfo) !== null && _16 !== void 0 ? _16 : '' }, (contentFormat && { contentFormat })), ((product === null || product === void 0 ? void 0 : product.variantId) && { variantId: product.variantId })), ((product === null || product === void 0 ? void 0 : product.variantOption) && { variantOption: product.variantOption }))
2273
2277
  });
2274
2278
  }, [bffEventReport, popupDetailData, isFromHashtag, eventTimeList]);
2275
2279
  const productView = React.useCallback((data, product, cta, viewTime, position) => {
@@ -2282,23 +2286,7 @@ function useEventReport() {
2282
2286
  fromKName = 'productPage';
2283
2287
  }
2284
2288
  bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
2285
- eventInfo: {
2286
- productId: product === null || product === void 0 ? void 0 : product.itemId,
2287
- productName: product === null || product === void 0 ? void 0 : product.title,
2288
- price: (product === null || product === void 0 ? void 0 : product.price) ? (product === null || product === void 0 ? void 0 : product.price) + '' : '0',
2289
- productCollection: product === null || product === void 0 ? void 0 : product.collection,
2290
- fromKName,
2291
- fromKPage: location === null || location === void 0 ? void 0 : location.href,
2292
- contentTags: JSON.stringify(product === null || product === void 0 ? void 0 : product.tags),
2293
- position: (position !== null && position !== void 0 ? position : 0) + '',
2294
- contentId: (_d = data === null || data === void 0 ? void 0 : data.video) === null || _d === void 0 ? void 0 : _d.itemId,
2295
- sceneId: (_g = (_f = (_e = data === null || data === void 0 ? void 0 : data.video) === null || _e === void 0 ? void 0 : _e.scene) === null || _f === void 0 ? void 0 : _f.sceneId) !== null && _g !== void 0 ? _g : '',
2296
- ctatId: cta === null || cta === void 0 ? void 0 : cta.itemId,
2297
- traceInfo: (_s = (_q = (_l = (_h = product === null || product === void 0 ? void 0 : product.traceInfo) !== null && _h !== void 0 ? _h : (_k = (_j = data === null || data === void 0 ? void 0 : data.video) === null || _j === void 0 ? void 0 : _j.bindProduct) === null || _k === void 0 ? void 0 : _k.traceInfo) !== null && _l !== void 0 ? _l : (_p = (_o = (_m = data === null || data === void 0 ? void 0 : data.video) === null || _m === void 0 ? void 0 : _m.bindProducts) === null || _o === void 0 ? void 0 : _o[0]) === null || _p === void 0 ? void 0 : _p.traceInfo) !== null && _q !== void 0 ? _q : (_r = data === null || data === void 0 ? void 0 : data.product) === null || _r === void 0 ? void 0 : _r.traceInfo) !== null && _s !== void 0 ? _s : '',
2298
- timeOnSite: Math.floor((new Date() - viewTime) / 1000) + '',
2299
- eventSubject: 'productView',
2300
- eventDescription: 'User browsed the product'
2301
- }
2289
+ eventInfo: Object.assign(Object.assign({ productId: product === null || product === void 0 ? void 0 : product.itemId, productName: product === null || product === void 0 ? void 0 : product.title, price: (product === null || product === void 0 ? void 0 : product.price) ? (product === null || product === void 0 ? void 0 : product.price) + '' : '0', productCollection: product === null || product === void 0 ? void 0 : product.collection, fromKName, fromKPage: location === null || location === void 0 ? void 0 : location.href, contentTags: JSON.stringify(product === null || product === void 0 ? void 0 : product.tags), position: (position !== null && position !== void 0 ? position : 0) + '', contentId: (_d = data === null || data === void 0 ? void 0 : data.video) === null || _d === void 0 ? void 0 : _d.itemId, sceneId: (_g = (_f = (_e = data === null || data === void 0 ? void 0 : data.video) === null || _e === void 0 ? void 0 : _e.scene) === null || _f === void 0 ? void 0 : _f.sceneId) !== null && _g !== void 0 ? _g : '', ctatId: cta === null || cta === void 0 ? void 0 : cta.itemId, traceInfo: (_s = (_q = (_l = (_h = product === null || product === void 0 ? void 0 : product.traceInfo) !== null && _h !== void 0 ? _h : (_k = (_j = data === null || data === void 0 ? void 0 : data.video) === null || _j === void 0 ? void 0 : _j.bindProduct) === null || _k === void 0 ? void 0 : _k.traceInfo) !== null && _l !== void 0 ? _l : (_p = (_o = (_m = data === null || data === void 0 ? void 0 : data.video) === null || _m === void 0 ? void 0 : _m.bindProducts) === null || _o === void 0 ? void 0 : _o[0]) === null || _p === void 0 ? void 0 : _p.traceInfo) !== null && _q !== void 0 ? _q : (_r = data === null || data === void 0 ? void 0 : data.product) === null || _r === void 0 ? void 0 : _r.traceInfo) !== null && _s !== void 0 ? _s : '', timeOnSite: Math.floor((new Date() - viewTime) / 1000) + '', eventSubject: 'productView', eventDescription: 'User browsed the product' }, ((product === null || product === void 0 ? void 0 : product.variantId) && { variantId: product.variantId })), ((product === null || product === void 0 ? void 0 : product.variantOption) && { variantOption: product.variantOption }))
2302
2290
  });
2303
2291
  }, [bffEventReport, popupDetailData]);
2304
2292
  const backMainFeed = React.useCallback((lastFeed, selectTag, themeTag, hashTag) => {
@@ -11382,7 +11370,7 @@ const CommodityDetail$1 = (_a) => {
11382
11370
  return;
11383
11371
  }
11384
11372
  }
11385
- // 默认行为:跳转到商品链接
11373
+ // 默认行为:跳转到商品链接(外链跳转)
11386
11374
  if (product === null || product === void 0 ? void 0 : product.link) {
11387
11375
  jumpToWeb(e, data, product, cta, position);
11388
11376
  if (!isPost) {
@@ -11404,8 +11392,10 @@ const CommodityDetail$1 = (_a) => {
11404
11392
  target_content_id: product === null || product === void 0 ? void 0 : product.itemId,
11405
11393
  target_url: product.link
11406
11394
  });
11407
- // feed 流 post 跳转外链时也需要上报 productView
11408
- productView(data, product, cta, viewTime || curTimeRef.current, position);
11395
+ // feed 流 post 跳转外链时上报 productView(Shopify 加购模式不上报)
11396
+ if (!enableAddToCart) {
11397
+ productView(data, product, cta, viewTime || curTimeRef.current, position);
11398
+ }
11409
11399
  }
11410
11400
  window.location.href = window.getJointUtmLink(product.link);
11411
11401
  }
@@ -11457,8 +11447,10 @@ const CommodityDetail$1 = (_a) => {
11457
11447
  content_id: (_a = product === null || product === void 0 ? void 0 : product.itemId) !== null && _a !== void 0 ? _a : ''
11458
11448
  });
11459
11449
  };
11460
- SXP_EVENT_BUS.on(SXP_EVENT_TYPE.PAGE_DID_SHOW, () => onShow());
11461
- SXP_EVENT_BUS.on(SXP_EVENT_TYPE.PAGE_DID_HIDE, () => onHide());
11450
+ const handleShow = () => onShow();
11451
+ const handleHide = () => onHide();
11452
+ SXP_EVENT_BUS.on(SXP_EVENT_TYPE.PAGE_DID_SHOW, handleShow);
11453
+ SXP_EVENT_BUS.on(SXP_EVENT_TYPE.PAGE_DID_HIDE, handleHide);
11462
11454
  return () => {
11463
11455
  var _a;
11464
11456
  bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
@@ -11471,8 +11463,8 @@ const CommodityDetail$1 = (_a) => {
11471
11463
  contentType: 'product',
11472
11464
  view_time: new Date() - curTimeRef.current
11473
11465
  });
11474
- SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_SHOW);
11475
- SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_HIDE);
11466
+ SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_SHOW, handleShow);
11467
+ SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_HIDE, handleHide);
11476
11468
  };
11477
11469
  }, [isActive, isPost, bffFbReport, data, product, position, curTimeRef]);
11478
11470
  React.useEffect(() => {
@@ -12350,7 +12342,7 @@ var settingRender$d = [
12350
12342
  }
12351
12343
  ];
12352
12344
 
12353
- const AddToCartPopup$1 = ({ isActive = true }) => {
12345
+ const AddToCartPopup$1 = ({ isActive = true, defaultVariantId }) => {
12354
12346
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
12355
12347
  const { popupDetailData, globalConfig, bffFbReport, bffEventReport, popupCurTimeRef, shopifyConfig: contextShopifyConfig } = useSxpDataSource();
12356
12348
  const [productData, setProductData] = React.useState(null);
@@ -12474,6 +12466,23 @@ const AddToCartPopup$1 = ({ isActive = true }) => {
12474
12466
  fetchProductData();
12475
12467
  }
12476
12468
  }, [isActive, fetchProductData]);
12469
+ // 当 productData 加载完成后,若有 defaultVariantId 则自动预选对应规格
12470
+ React.useEffect(() => {
12471
+ if (!productData || !defaultVariantId)
12472
+ return;
12473
+ const normalizedDefault = defaultVariantId.startsWith('gid://')
12474
+ ? defaultVariantId
12475
+ : `gid://shopify/ProductVariant/${defaultVariantId}`;
12476
+ const variants = productData.variants.edges.map(edge => edge.node);
12477
+ const targetVariant = variants.find(v => v.id === normalizedDefault);
12478
+ if (!targetVariant)
12479
+ return;
12480
+ const defaultOptions = {};
12481
+ targetVariant.selectedOptions.forEach(opt => {
12482
+ defaultOptions[opt.name] = opt.value;
12483
+ });
12484
+ setSelectedOptions(defaultOptions);
12485
+ }, [productData, defaultVariantId]);
12477
12486
  // 根据选中的规格匹配 variant
12478
12487
  React.useEffect(() => {
12479
12488
  if (!productData)
@@ -12740,6 +12749,7 @@ const CommodityDetailDiroNew$1 = (_a) => {
12740
12749
  const curTimeRef = React.useRef(null);
12741
12750
  const [show3DModal, setShow3DModal] = React.useState(false);
12742
12751
  const [showAddToCart, setShowAddToCart] = React.useState(false);
12752
+ const [addToCartVariantId, setAddToCartVariantId] = React.useState(undefined);
12743
12753
  const [checkCommodityIndex, setCheckCommodityIndex] = React.useState((_b = popupDetailData === null || popupDetailData === void 0 ? void 0 : popupDetailData.multiCheckIndex) !== null && _b !== void 0 ? _b : 0);
12744
12754
  const swiperRef = React.useRef();
12745
12755
  const [swiperActiveIndex, setSwiperActiveIndex] = React.useState(0);
@@ -12755,16 +12765,33 @@ const CommodityDetailDiroNew$1 = (_a) => {
12755
12765
  product = p;
12756
12766
  cta = p === null || p === void 0 ? void 0 : p.bindCta;
12757
12767
  }
12768
+ // 是否为 SKU 层绑定(variantId 和 variantOption 同时存在时)
12769
+ const isSkuLevel = !!(product === null || product === void 0 ? void 0 : product.variantId) && !!(product === null || product === void 0 ? void 0 : product.variantOption);
12770
+ const handleOpenAddToCart = (variantId) => {
12771
+ ctaEvent === null || ctaEvent === void 0 ? void 0 : ctaEvent({ eventSubject: 'clickCta', eventDescription: 'User clicked the CTA' }, data, product, position);
12772
+ bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
12773
+ eventName: 'ClickCTA',
12774
+ product: product ? [product] : undefined,
12775
+ contentType: 'product',
12776
+ data,
12777
+ position,
12778
+ cta_text: cta === null || cta === void 0 ? void 0 : cta.enTitle,
12779
+ cta_action_type: 'open_internal_popup',
12780
+ target_content_id: product === null || product === void 0 ? void 0 : product.itemId,
12781
+ target_url: product === null || product === void 0 ? void 0 : product.link
12782
+ });
12783
+ if (!isPost) {
12784
+ productView(data, product, cta, viewTime || curTimeRef.current, position);
12785
+ }
12786
+ ctaEvent === null || ctaEvent === void 0 ? void 0 : ctaEvent({ eventSubject: 'clickShopifyPopup', eventDescription: 'User clicked to open Shopify popup' }, data, product, position);
12787
+ setPopupDetailData === null || setPopupDetailData === void 0 ? void 0 : setPopupDetailData(Object.assign(Object.assign({}, data), { video: Object.assign(Object.assign({}, data === null || data === void 0 ? void 0 : data.video), { bindProduct: product }), index: position }));
12788
+ setAddToCartVariantId(variantId);
12789
+ setShowAddToCart(true);
12790
+ };
12758
12791
  const handleLink = (e) => {
12759
12792
  e.preventDefault();
12760
- // 问题3:只有 Shopify 商品(有 shopifyId)才打开加购弹窗
12761
12793
  if (!(product === null || product === void 0 ? void 0 : product.shopifyId)) {
12762
- console.warn('[CommodityDetailDiroNew] Shopify 商品,跳转到外链');
12763
- // 上报点击事件
12764
- ctaEvent === null || ctaEvent === void 0 ? void 0 : ctaEvent({
12765
- eventSubject: 'clickCta',
12766
- eventDescription: 'User clicked the CTA'
12767
- }, data, product, position);
12794
+ ctaEvent === null || ctaEvent === void 0 ? void 0 : ctaEvent({ eventSubject: 'clickCta', eventDescription: 'User clicked the CTA' }, data, product, position);
12768
12795
  bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
12769
12796
  eventName: 'ClickCTA',
12770
12797
  product: product ? [product] : undefined,
@@ -12776,42 +12803,21 @@ const CommodityDetailDiroNew$1 = (_a) => {
12776
12803
  target_content_id: product === null || product === void 0 ? void 0 : product.itemId,
12777
12804
  target_url: product === null || product === void 0 ? void 0 : product.link
12778
12805
  });
12779
- // 跳转外链时无论 isPost 是否为 true 都需要上报 productView
12780
12806
  productView(data, product, cta, viewTime || curTimeRef.current, position);
12781
- // 跳转到商品链接
12782
12807
  if (product === null || product === void 0 ? void 0 : product.link) {
12783
12808
  window.location.href = window.getJointUtmLink(product.link);
12784
12809
  }
12785
12810
  return;
12786
12811
  }
12787
- // Shopify 商品:上报点击事件
12788
- ctaEvent === null || ctaEvent === void 0 ? void 0 : ctaEvent({
12789
- eventSubject: 'clickCta',
12790
- eventDescription: 'User clicked the CTA'
12791
- }, data, product, position);
12792
- bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
12793
- eventName: 'ClickCTA',
12794
- product: product ? [product] : undefined,
12795
- contentType: 'product',
12796
- data,
12797
- position,
12798
- cta_text: cta === null || cta === void 0 ? void 0 : cta.enTitle,
12799
- cta_action_type: 'open_internal_popup',
12800
- target_content_id: product === null || product === void 0 ? void 0 : product.itemId,
12801
- target_url: product === null || product === void 0 ? void 0 : product.link
12802
- });
12803
- // 打开加购弹窗时无论 isPost 是否为 true 都需要上报 productView
12804
- productView(data, product, cta, viewTime || curTimeRef.current, position);
12805
- // 上报 clickShopifyPopup 事件(打开购物车弹窗时上报,无论是 feed 流 post 还是商品详情弹窗内)
12806
- ctaEvent === null || ctaEvent === void 0 ? void 0 : ctaEvent({
12807
- eventSubject: 'clickShopifyPopup',
12808
- eventDescription: 'User clicked to open Shopify popup'
12809
- }, data, product, position);
12810
- // 更新 popupDetailData,确保 AddToCart 组件能获取到商品数据
12811
- setPopupDetailData === null || setPopupDetailData === void 0 ? void 0 : setPopupDetailData(Object.assign(Object.assign({}, data), { video: Object.assign(Object.assign({}, data === null || data === void 0 ? void 0 : data.video), { bindProduct: product }), index: position }));
12812
- // 打开 AddToCart 弹窗
12813
- setShowAddToCart(true);
12812
+ // SKU 层绑定:直接传入 variantId 预选该 SKU
12813
+ handleOpenAddToCart(isSkuLevel ? product === null || product === void 0 ? void 0 : product.variantId : undefined);
12814
12814
  };
12815
+ // popup 模式下,若为 SKU 层绑定,直接自动打开加购弹窗
12816
+ React.useEffect(() => {
12817
+ if (!isActive || isPost || !isSkuLevel)
12818
+ return;
12819
+ handleOpenAddToCart(product === null || product === void 0 ? void 0 : product.variantId);
12820
+ }, [isActive, isPost, isSkuLevel]);
12815
12821
  React.useEffect(() => {
12816
12822
  var _a, _b;
12817
12823
  if (!isActive)
@@ -12851,8 +12857,10 @@ const CommodityDetailDiroNew$1 = (_a) => {
12851
12857
  content_id: (_a = product === null || product === void 0 ? void 0 : product.itemId) !== null && _a !== void 0 ? _a : ''
12852
12858
  });
12853
12859
  };
12854
- SXP_EVENT_BUS.on(SXP_EVENT_TYPE.PAGE_DID_SHOW, () => onShow());
12855
- SXP_EVENT_BUS.on(SXP_EVENT_TYPE.PAGE_DID_HIDE, () => onHide());
12860
+ const handleShow = () => onShow();
12861
+ const handleHide = () => onHide();
12862
+ SXP_EVENT_BUS.on(SXP_EVENT_TYPE.PAGE_DID_SHOW, handleShow);
12863
+ SXP_EVENT_BUS.on(SXP_EVENT_TYPE.PAGE_DID_HIDE, handleHide);
12856
12864
  return () => {
12857
12865
  var _a;
12858
12866
  bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
@@ -12865,8 +12873,8 @@ const CommodityDetailDiroNew$1 = (_a) => {
12865
12873
  contentType: 'product',
12866
12874
  view_time: new Date() - curTimeRef.current
12867
12875
  });
12868
- SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_SHOW);
12869
- SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_HIDE);
12876
+ SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_SHOW, handleShow);
12877
+ SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_HIDE, handleHide);
12870
12878
  };
12871
12879
  }, [isActive, isPost, bffFbReport, data, product, position, curTimeRef]);
12872
12880
  React.useEffect(() => {
@@ -13090,7 +13098,7 @@ Made in Italy` })));
13090
13098
  border: 'none'
13091
13099
  } }))),
13092
13100
  showAddToCart && (React.createElement(Modal$1, { visible: showAddToCart, padding: 0, isFullScreen: false, onClose: () => setShowAddToCart(false) },
13093
- React.createElement(AddToCartPopup$1, { isActive: true })))));
13101
+ React.createElement(AddToCartPopup$1, { isActive: true, defaultVariantId: addToCartVariantId })))));
13094
13102
  };
13095
13103
  var CommodityDetailDiroNewComponent = React.memo(CommodityDetailDiroNew$1);
13096
13104
 
@@ -24676,9 +24684,13 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight, containerWidt
24676
24684
  viewTime.current = new Date();
24677
24685
  };
24678
24686
  const handleReportProductView = (item, position) => {
24679
- var _a, _b, _c;
24687
+ var _a, _b, _c, _d;
24680
24688
  if (!((_a = item === null || item === void 0 ? void 0 : item.video) === null || _a === void 0 ? void 0 : _a.url) && !((_b = item === null || item === void 0 ? void 0 : item.video) === null || _b === void 0 ? void 0 : _b.imgUrls) && (item === null || item === void 0 ? void 0 : item.product)) {
24681
- productView(item, item.product, (_c = item === null || item === void 0 ? void 0 : item.product) === null || _c === void 0 ? void 0 : _c.bindCta, viewTime.current, position !== null && position !== void 0 ? position : activeIndex);
24689
+ // Shopify 加购模式下,点击 Shop Now 打开购物车不上报 productView,只有跳外链才上报
24690
+ const isEnableAddToCart = (_c = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) === null || _c === void 0 ? void 0 : _c.some((v) => { var _a, _b; return (_b = (_a = v === null || v === void 0 ? void 0 : v.item) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.enableAddToCart; });
24691
+ if (isEnableAddToCart)
24692
+ return;
24693
+ productView(item, item.product, (_d = item === null || item === void 0 ? void 0 : item.product) === null || _d === void 0 ? void 0 : _d.bindCta, viewTime.current, position !== null && position !== void 0 ? position : activeIndex);
24682
24694
  }
24683
24695
  };
24684
24696
  React.useEffect(() => {