pb-sxp-ui 1.20.18 → 1.20.20
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 +737 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +291 -0
- package/dist/index.js +737 -26
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +44 -5
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +44 -5
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +737 -26
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +44 -5
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/SxpPageRender/index.d.ts +2 -0
- package/es/core/context/SxpDataSourceProvider.d.ts +1 -1
- package/es/materials/sxp/popup/AddToCart/index.d.ts +33 -0
- package/es/materials/sxp/popup/AddToCart/index.js +279 -0
- package/es/materials/sxp/popup/AddToCart/interactionRender.d.ts +3 -0
- package/es/materials/sxp/popup/AddToCart/interactionRender.js +11 -0
- package/es/materials/sxp/popup/AddToCart/material.d.ts +2 -0
- package/es/materials/sxp/popup/AddToCart/material.js +75 -0
- package/es/materials/sxp/popup/AddToCart/settingRender.d.ts +160 -0
- package/es/materials/sxp/popup/AddToCart/settingRender.js +277 -0
- package/es/materials/sxp/popup/CommodityDetail/index.d.ts +2 -0
- package/es/materials/sxp/popup/CommodityDetail/index.js +30 -2
- package/es/materials/sxp/popup/CommodityDetail/settingRender.d.ts +13 -0
- package/es/materials/sxp/popup/CommodityDetail/settingRender.js +16 -0
- package/es/materials/sxp/popup/index.d.ts +1 -0
- package/es/materials/sxp/popup/index.js +1 -0
- package/lib/core/components/SxpPageRender/index.d.ts +2 -0
- package/lib/core/context/SxpDataSourceProvider.d.ts +1 -1
- package/lib/materials/sxp/popup/AddToCart/index.d.ts +33 -0
- package/lib/materials/sxp/popup/AddToCart/index.js +281 -0
- package/lib/materials/sxp/popup/AddToCart/interactionRender.d.ts +3 -0
- package/lib/materials/sxp/popup/AddToCart/interactionRender.js +14 -0
- package/lib/materials/sxp/popup/AddToCart/material.d.ts +2 -0
- package/lib/materials/sxp/popup/AddToCart/material.js +79 -0
- package/lib/materials/sxp/popup/AddToCart/settingRender.d.ts +160 -0
- package/lib/materials/sxp/popup/AddToCart/settingRender.js +279 -0
- package/lib/materials/sxp/popup/CommodityDetail/index.d.ts +2 -0
- package/lib/materials/sxp/popup/CommodityDetail/index.js +30 -2
- package/lib/materials/sxp/popup/CommodityDetail/settingRender.d.ts +13 -0
- package/lib/materials/sxp/popup/CommodityDetail/settingRender.js +16 -0
- package/lib/materials/sxp/popup/index.d.ts +1 -0
- package/lib/materials/sxp/popup/index.js +1 -0
- package/package.json +1 -1
package/dist/pb-ui.js
CHANGED
|
@@ -2781,7 +2781,7 @@
|
|
|
2781
2781
|
StructurePage: StructurePage
|
|
2782
2782
|
});
|
|
2783
2783
|
|
|
2784
|
-
var interactionRender$
|
|
2784
|
+
var interactionRender$i = [
|
|
2785
2785
|
{
|
|
2786
2786
|
title: '点击事件',
|
|
2787
2787
|
child: [
|
|
@@ -2801,7 +2801,7 @@
|
|
|
2801
2801
|
* @FilePath: \pb-sxp-ui\src\materials\sxp\popup\AppointForm\settingRender.tsx
|
|
2802
2802
|
*
|
|
2803
2803
|
*/
|
|
2804
|
-
var settingRender$
|
|
2804
|
+
var settingRender$g = [
|
|
2805
2805
|
{
|
|
2806
2806
|
title: '弹窗背景',
|
|
2807
2807
|
child: [
|
|
@@ -3238,9 +3238,9 @@
|
|
|
3238
3238
|
category: 'popup',
|
|
3239
3239
|
type: 'AppointForm',
|
|
3240
3240
|
related: {
|
|
3241
|
-
settingRender: settingRender$
|
|
3241
|
+
settingRender: settingRender$g,
|
|
3242
3242
|
bindableProps: [],
|
|
3243
|
-
interactionRender: interactionRender$
|
|
3243
|
+
interactionRender: interactionRender$i
|
|
3244
3244
|
},
|
|
3245
3245
|
defaulSetting: {
|
|
3246
3246
|
name: '表单',
|
|
@@ -3263,7 +3263,7 @@
|
|
|
3263
3263
|
sort: 2
|
|
3264
3264
|
});
|
|
3265
3265
|
|
|
3266
|
-
var settingRender$
|
|
3266
|
+
var settingRender$f = [
|
|
3267
3267
|
{
|
|
3268
3268
|
title: '弹窗背景',
|
|
3269
3269
|
child: [
|
|
@@ -3661,6 +3661,22 @@
|
|
|
3661
3661
|
name: ['props', 'enableFixedCloseButton']
|
|
3662
3662
|
}
|
|
3663
3663
|
]
|
|
3664
|
+
},
|
|
3665
|
+
{
|
|
3666
|
+
title: '加购功能',
|
|
3667
|
+
child: [
|
|
3668
|
+
{
|
|
3669
|
+
label: '启用加购弹窗',
|
|
3670
|
+
type: 'Switch',
|
|
3671
|
+
name: ['props', 'enableAddToCart']
|
|
3672
|
+
},
|
|
3673
|
+
{
|
|
3674
|
+
label: '加购弹窗ID',
|
|
3675
|
+
type: 'Input',
|
|
3676
|
+
name: ['props', 'addToCartPopupId'],
|
|
3677
|
+
placeholder: '请输入加购弹窗的ID'
|
|
3678
|
+
}
|
|
3679
|
+
]
|
|
3664
3680
|
}
|
|
3665
3681
|
];
|
|
3666
3682
|
|
|
@@ -3680,7 +3696,7 @@
|
|
|
3680
3696
|
* @FilePath: \pb-sxp-ui\src\materials\sxp\cta\AniLink\interactionRender.tsx
|
|
3681
3697
|
*
|
|
3682
3698
|
*/
|
|
3683
|
-
var interactionRender$
|
|
3699
|
+
var interactionRender$h = [
|
|
3684
3700
|
{
|
|
3685
3701
|
title: '滑动事件',
|
|
3686
3702
|
child: [
|
|
@@ -11658,8 +11674,8 @@
|
|
|
11658
11674
|
|
|
11659
11675
|
const CommodityDetail$1 = (_a) => {
|
|
11660
11676
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
11661
|
-
var { content, style, bgImg, onClick, schema, isDefault, bottom_image, tipText, isPost, viewTime, rec, swiper, commodityStyles, buttonStyle, index, commodityGroup, popupBg, iframeIcon, commodityImgRatio, isTel, iframeBgColor, isActive = true } = _a, props = __rest(_a, ["content", "style", "bgImg", "onClick", "schema", "isDefault", "bottom_image", "tipText", "isPost", "viewTime", "rec", "swiper", "commodityStyles", "buttonStyle", "index", "commodityGroup", "popupBg", "iframeIcon", "commodityImgRatio", "isTel", "iframeBgColor", "isActive"]);
|
|
11662
|
-
const { sxpParameter, popupDetailData, isPreview, bffFbReport, popupCurTimeRef, checkCommodityIndexRef, globalConfig, ctaEvent } = useSxpDataSource();
|
|
11677
|
+
var { content, style, bgImg, onClick, schema, isDefault, bottom_image, tipText, isPost, viewTime, rec, swiper, commodityStyles, buttonStyle, index, commodityGroup, popupBg, iframeIcon, commodityImgRatio, isTel, iframeBgColor, isActive = true, enableAddToCart = false, addToCartPopupId = '' } = _a, props = __rest(_a, ["content", "style", "bgImg", "onClick", "schema", "isDefault", "bottom_image", "tipText", "isPost", "viewTime", "rec", "swiper", "commodityStyles", "buttonStyle", "index", "commodityGroup", "popupBg", "iframeIcon", "commodityImgRatio", "isTel", "iframeBgColor", "isActive", "enableAddToCart", "addToCartPopupId"]);
|
|
11678
|
+
const { sxpParameter, popupDetailData, isPreview, bffFbReport, popupCurTimeRef, checkCommodityIndexRef, globalConfig, ctaEvent, setPopupDetailData } = useSxpDataSource();
|
|
11663
11679
|
const { jumpToWeb, productView } = useEventReport();
|
|
11664
11680
|
const curTimeRef = React.useRef(null);
|
|
11665
11681
|
const [showModal, setShowModal] = React.useState(false);
|
|
@@ -11680,6 +11696,32 @@
|
|
|
11680
11696
|
cta = p === null || p === void 0 ? void 0 : p.bindCta;
|
|
11681
11697
|
}
|
|
11682
11698
|
const handleLink = (e) => {
|
|
11699
|
+
// 如果启用了加购功能且配置了加购弹窗ID,则打开加购弹窗
|
|
11700
|
+
if (enableAddToCart && addToCartPopupId) {
|
|
11701
|
+
// 设置弹窗数据
|
|
11702
|
+
setPopupDetailData === null || setPopupDetailData === void 0 ? void 0 : setPopupDetailData(Object.assign(Object.assign({}, data), { index: position }));
|
|
11703
|
+
// 上报点击事件
|
|
11704
|
+
bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
|
|
11705
|
+
eventName: 'ClickCTA',
|
|
11706
|
+
product: product ? [product] : undefined,
|
|
11707
|
+
contentType: 'product',
|
|
11708
|
+
data,
|
|
11709
|
+
position,
|
|
11710
|
+
cta_text: cta === null || cta === void 0 ? void 0 : cta.enTitle,
|
|
11711
|
+
cta_action_type: 'open_internal_popup',
|
|
11712
|
+
target_content_id: product === null || product === void 0 ? void 0 : product.itemId
|
|
11713
|
+
});
|
|
11714
|
+
console.log('[CommodityDetail] 打开加购弹窗:', addToCartPopupId);
|
|
11715
|
+
// 打开加购弹窗
|
|
11716
|
+
if (typeof window !== 'undefined' && window.sxpPopup) {
|
|
11717
|
+
window.sxpPopup(addToCartPopupId);
|
|
11718
|
+
}
|
|
11719
|
+
else {
|
|
11720
|
+
console.warn('[CommodityDetail] sxpPopup 方法不存在');
|
|
11721
|
+
}
|
|
11722
|
+
return;
|
|
11723
|
+
}
|
|
11724
|
+
// 默认行为:跳转到商品链接
|
|
11683
11725
|
if (product === null || product === void 0 ? void 0 : product.link) {
|
|
11684
11726
|
jumpToWeb(e, data, product, cta, position);
|
|
11685
11727
|
if (!isPost) {
|
|
@@ -11704,6 +11746,14 @@
|
|
|
11704
11746
|
}
|
|
11705
11747
|
window.location.href = window.getJointUtmLink(product.link);
|
|
11706
11748
|
}
|
|
11749
|
+
else {
|
|
11750
|
+
// 如果没有配置链接也没有启用加购功能,给出提示
|
|
11751
|
+
console.warn('[CommodityDetail] 商品未配置跳转链接,且未启用加购功能', {
|
|
11752
|
+
productId: product === null || product === void 0 ? void 0 : product.itemId,
|
|
11753
|
+
enableAddToCart,
|
|
11754
|
+
addToCartPopupId
|
|
11755
|
+
});
|
|
11756
|
+
}
|
|
11707
11757
|
};
|
|
11708
11758
|
React.useEffect(() => {
|
|
11709
11759
|
var _a, _b;
|
|
@@ -11951,8 +12001,8 @@
|
|
|
11951
12001
|
category: 'popup',
|
|
11952
12002
|
type: 'CommodityDetail',
|
|
11953
12003
|
related: {
|
|
11954
|
-
settingRender: settingRender$
|
|
11955
|
-
interactionRender: interactionRender$
|
|
12004
|
+
settingRender: settingRender$f,
|
|
12005
|
+
interactionRender: interactionRender$h
|
|
11956
12006
|
},
|
|
11957
12007
|
defaulSetting: {
|
|
11958
12008
|
props: {
|
|
@@ -12007,7 +12057,7 @@
|
|
|
12007
12057
|
sort: 1
|
|
12008
12058
|
});
|
|
12009
12059
|
|
|
12010
|
-
var interactionRender$
|
|
12060
|
+
var interactionRender$g = [
|
|
12011
12061
|
{
|
|
12012
12062
|
title: '点击事件',
|
|
12013
12063
|
child: [
|
|
@@ -12027,7 +12077,7 @@
|
|
|
12027
12077
|
* @FilePath: \pb-sxp-ui\src\materials\sxp\popup\Prompt\settingRender.tsx
|
|
12028
12078
|
*
|
|
12029
12079
|
*/
|
|
12030
|
-
var settingRender$
|
|
12080
|
+
var settingRender$e = [
|
|
12031
12081
|
{
|
|
12032
12082
|
title: '弹窗背景',
|
|
12033
12083
|
child: [
|
|
@@ -12207,9 +12257,9 @@
|
|
|
12207
12257
|
category: 'popup',
|
|
12208
12258
|
type: 'Prompt',
|
|
12209
12259
|
related: {
|
|
12210
|
-
settingRender: settingRender$
|
|
12260
|
+
settingRender: settingRender$e,
|
|
12211
12261
|
bindableProps: [],
|
|
12212
|
-
interactionRender: interactionRender$
|
|
12262
|
+
interactionRender: interactionRender$g
|
|
12213
12263
|
},
|
|
12214
12264
|
defaulSetting: {
|
|
12215
12265
|
props: {
|
|
@@ -12232,7 +12282,7 @@
|
|
|
12232
12282
|
* @FilePath: \pb-sxp-ui\src\materials\sxp\popup\CommodityDetailDiroNew\settingRender.tsx
|
|
12233
12283
|
*
|
|
12234
12284
|
*/
|
|
12235
|
-
var settingRender$
|
|
12285
|
+
var settingRender$d = [
|
|
12236
12286
|
{
|
|
12237
12287
|
title: '弹窗背景',
|
|
12238
12288
|
child: [
|
|
@@ -12965,7 +13015,7 @@ Made in Italy` })));
|
|
|
12965
13015
|
* @FilePath: \pb-sxp-ui\src\materials\sxp\cta\AniLink\interactionRender.tsx
|
|
12966
13016
|
*
|
|
12967
13017
|
*/
|
|
12968
|
-
var interactionRender$
|
|
13018
|
+
var interactionRender$f = [
|
|
12969
13019
|
{
|
|
12970
13020
|
title: '滑动事件',
|
|
12971
13021
|
child: [
|
|
@@ -12992,8 +13042,8 @@ Made in Italy` })));
|
|
|
12992
13042
|
category: 'popup',
|
|
12993
13043
|
type: 'CommodityDetailDiroNew',
|
|
12994
13044
|
related: {
|
|
12995
|
-
settingRender: settingRender$
|
|
12996
|
-
interactionRender: interactionRender$
|
|
13045
|
+
settingRender: settingRender$d,
|
|
13046
|
+
interactionRender: interactionRender$f
|
|
12997
13047
|
},
|
|
12998
13048
|
defaulSetting: {
|
|
12999
13049
|
props: {
|
|
@@ -13057,7 +13107,7 @@ Made in Italy` })));
|
|
|
13057
13107
|
* @FilePath: \pb-sxp-ui\src\materials\sxp\popup\CommodityList\settingRender.tsx
|
|
13058
13108
|
*
|
|
13059
13109
|
*/
|
|
13060
|
-
var settingRender$
|
|
13110
|
+
var settingRender$c = [
|
|
13061
13111
|
{
|
|
13062
13112
|
title: '弹窗背景',
|
|
13063
13113
|
child: [
|
|
@@ -13482,7 +13532,7 @@ Made in Italy` })));
|
|
|
13482
13532
|
* @FilePath: \pb-sxp-ui\src\materials\sxp\cta\AniLink\interactionRender.tsx
|
|
13483
13533
|
*
|
|
13484
13534
|
*/
|
|
13485
|
-
var interactionRender$
|
|
13535
|
+
var interactionRender$e = [
|
|
13486
13536
|
{
|
|
13487
13537
|
title: '点击事件',
|
|
13488
13538
|
child: [
|
|
@@ -13509,8 +13559,8 @@ Made in Italy` })));
|
|
|
13509
13559
|
category: 'popup',
|
|
13510
13560
|
type: 'CommodityList',
|
|
13511
13561
|
related: {
|
|
13512
|
-
settingRender: settingRender$
|
|
13513
|
-
interactionRender: interactionRender$
|
|
13562
|
+
settingRender: settingRender$c,
|
|
13563
|
+
interactionRender: interactionRender$e
|
|
13514
13564
|
},
|
|
13515
13565
|
defaulSetting: {
|
|
13516
13566
|
props: {
|
|
@@ -13558,7 +13608,7 @@ Made in Italy` })));
|
|
|
13558
13608
|
* @FilePath: \pb-sxp-ui\src\materials\sxp\popup\Iframe\settingRender.tsx
|
|
13559
13609
|
*
|
|
13560
13610
|
*/
|
|
13561
|
-
var settingRender$
|
|
13611
|
+
var settingRender$b = [
|
|
13562
13612
|
{
|
|
13563
13613
|
title: '背景样式',
|
|
13564
13614
|
child: [
|
|
@@ -13592,7 +13642,7 @@ Made in Italy` })));
|
|
|
13592
13642
|
category: 'popup',
|
|
13593
13643
|
type: 'Iframe',
|
|
13594
13644
|
related: {
|
|
13595
|
-
settingRender: settingRender$
|
|
13645
|
+
settingRender: settingRender$b,
|
|
13596
13646
|
bindableProps: []
|
|
13597
13647
|
},
|
|
13598
13648
|
defaulSetting: {
|
|
@@ -13612,7 +13662,7 @@ Made in Italy` })));
|
|
|
13612
13662
|
* @FilePath: \pb-sxp-ui\src\materials\sxp\popup\ConsentDetail\settingRender.tsx
|
|
13613
13663
|
*
|
|
13614
13664
|
*/
|
|
13615
|
-
var settingRender$
|
|
13665
|
+
var settingRender$a = [
|
|
13616
13666
|
{
|
|
13617
13667
|
title: '弹窗文本',
|
|
13618
13668
|
child: [
|
|
@@ -13641,7 +13691,7 @@ Made in Italy` })));
|
|
|
13641
13691
|
category: 'popup',
|
|
13642
13692
|
type: 'ConsentDetail',
|
|
13643
13693
|
related: {
|
|
13644
|
-
settingRender: settingRender$
|
|
13694
|
+
settingRender: settingRender$a,
|
|
13645
13695
|
bindableProps: []
|
|
13646
13696
|
},
|
|
13647
13697
|
defaulSetting: {
|
|
@@ -13653,6 +13703,666 @@ Made in Italy` })));
|
|
|
13653
13703
|
sort: 7
|
|
13654
13704
|
});
|
|
13655
13705
|
|
|
13706
|
+
var settingRender$9 = [
|
|
13707
|
+
{
|
|
13708
|
+
title: 'Shopify配置',
|
|
13709
|
+
child: [
|
|
13710
|
+
{
|
|
13711
|
+
type: 'Input',
|
|
13712
|
+
label: 'Shopify域名',
|
|
13713
|
+
name: ['props', 'shopifyDomain'],
|
|
13714
|
+
placeholder: 'your-store.myshopify.com'
|
|
13715
|
+
},
|
|
13716
|
+
{
|
|
13717
|
+
type: 'Input',
|
|
13718
|
+
label: 'Storefront Token',
|
|
13719
|
+
name: ['props', 'storefrontAccessToken'],
|
|
13720
|
+
placeholder: 'Storefront Access Token'
|
|
13721
|
+
}
|
|
13722
|
+
]
|
|
13723
|
+
},
|
|
13724
|
+
{
|
|
13725
|
+
title: '弹窗背景',
|
|
13726
|
+
child: [
|
|
13727
|
+
{
|
|
13728
|
+
type: 'Number',
|
|
13729
|
+
label: '左右边距',
|
|
13730
|
+
name: ['props', 'popupBg', 'horizontalMargin']
|
|
13731
|
+
},
|
|
13732
|
+
{
|
|
13733
|
+
type: 'Number',
|
|
13734
|
+
label: '下边距',
|
|
13735
|
+
name: ['props', 'popupBg', 'bottomMargin']
|
|
13736
|
+
}
|
|
13737
|
+
]
|
|
13738
|
+
},
|
|
13739
|
+
{
|
|
13740
|
+
title: '商品信息样式',
|
|
13741
|
+
child: [
|
|
13742
|
+
{
|
|
13743
|
+
name: ['props', 'variantStyles'],
|
|
13744
|
+
type: 'SelectLinkage',
|
|
13745
|
+
child: [
|
|
13746
|
+
{
|
|
13747
|
+
label: '字段',
|
|
13748
|
+
type: 'Select',
|
|
13749
|
+
options: [
|
|
13750
|
+
{
|
|
13751
|
+
label: '商品标题',
|
|
13752
|
+
value: 'title'
|
|
13753
|
+
},
|
|
13754
|
+
{
|
|
13755
|
+
label: '价格',
|
|
13756
|
+
value: 'price'
|
|
13757
|
+
},
|
|
13758
|
+
{
|
|
13759
|
+
label: '规格选项',
|
|
13760
|
+
value: 'option'
|
|
13761
|
+
},
|
|
13762
|
+
{
|
|
13763
|
+
label: '已选规格',
|
|
13764
|
+
value: 'selectedOption'
|
|
13765
|
+
}
|
|
13766
|
+
],
|
|
13767
|
+
name: ['props', 'variantStyles', 'field'],
|
|
13768
|
+
initialValue: 'title'
|
|
13769
|
+
},
|
|
13770
|
+
{
|
|
13771
|
+
type: 'Group',
|
|
13772
|
+
child: [
|
|
13773
|
+
{
|
|
13774
|
+
label: '上边距',
|
|
13775
|
+
type: 'Number',
|
|
13776
|
+
addonAfter: 'px',
|
|
13777
|
+
name: ['marginTop']
|
|
13778
|
+
},
|
|
13779
|
+
{
|
|
13780
|
+
label: '下边距',
|
|
13781
|
+
type: 'Number',
|
|
13782
|
+
addonAfter: 'px',
|
|
13783
|
+
name: ['marginBottom']
|
|
13784
|
+
}
|
|
13785
|
+
]
|
|
13786
|
+
},
|
|
13787
|
+
{
|
|
13788
|
+
type: 'Group',
|
|
13789
|
+
label: '字体',
|
|
13790
|
+
child: [
|
|
13791
|
+
{
|
|
13792
|
+
type: 'Select',
|
|
13793
|
+
name: ['fontFamily-cn'],
|
|
13794
|
+
bottomText: '中文字体'
|
|
13795
|
+
},
|
|
13796
|
+
{
|
|
13797
|
+
type: 'Select',
|
|
13798
|
+
name: ['fontFamily-en'],
|
|
13799
|
+
bottomText: '英文/其他字体'
|
|
13800
|
+
}
|
|
13801
|
+
]
|
|
13802
|
+
},
|
|
13803
|
+
{
|
|
13804
|
+
type: 'Group',
|
|
13805
|
+
label: '',
|
|
13806
|
+
child: [
|
|
13807
|
+
{
|
|
13808
|
+
type: 'Color',
|
|
13809
|
+
name: ['color']
|
|
13810
|
+
},
|
|
13811
|
+
{
|
|
13812
|
+
type: 'Number',
|
|
13813
|
+
addonAfter: 'px',
|
|
13814
|
+
name: ['fontSize']
|
|
13815
|
+
}
|
|
13816
|
+
]
|
|
13817
|
+
},
|
|
13818
|
+
{
|
|
13819
|
+
label: '样式',
|
|
13820
|
+
type: 'TextStyle'
|
|
13821
|
+
},
|
|
13822
|
+
{
|
|
13823
|
+
label: '对齐',
|
|
13824
|
+
type: 'TextAlign'
|
|
13825
|
+
},
|
|
13826
|
+
{
|
|
13827
|
+
label: '间距',
|
|
13828
|
+
type: 'TextSpace'
|
|
13829
|
+
}
|
|
13830
|
+
]
|
|
13831
|
+
}
|
|
13832
|
+
]
|
|
13833
|
+
},
|
|
13834
|
+
{
|
|
13835
|
+
title: '加购按钮样式',
|
|
13836
|
+
child: [
|
|
13837
|
+
{
|
|
13838
|
+
label: '英文大小写',
|
|
13839
|
+
type: 'Select',
|
|
13840
|
+
name: ['props', 'buttonStyle', 'textTransform'],
|
|
13841
|
+
options: [
|
|
13842
|
+
{
|
|
13843
|
+
label: '默认',
|
|
13844
|
+
value: 'unset'
|
|
13845
|
+
},
|
|
13846
|
+
{
|
|
13847
|
+
label: '小写',
|
|
13848
|
+
value: 'lowercase'
|
|
13849
|
+
},
|
|
13850
|
+
{
|
|
13851
|
+
label: '大写',
|
|
13852
|
+
value: 'uppercase'
|
|
13853
|
+
}
|
|
13854
|
+
]
|
|
13855
|
+
},
|
|
13856
|
+
{
|
|
13857
|
+
type: 'Color',
|
|
13858
|
+
label: '背景色',
|
|
13859
|
+
name: ['props', 'buttonStyle', 'backgroundColor'],
|
|
13860
|
+
initialValue: '#000'
|
|
13861
|
+
},
|
|
13862
|
+
{
|
|
13863
|
+
type: 'Group',
|
|
13864
|
+
label: '尺寸',
|
|
13865
|
+
child: [
|
|
13866
|
+
{
|
|
13867
|
+
type: 'Number',
|
|
13868
|
+
name: ['props', 'buttonStyle', 'height'],
|
|
13869
|
+
addonAfter: 'H'
|
|
13870
|
+
}
|
|
13871
|
+
]
|
|
13872
|
+
},
|
|
13873
|
+
{
|
|
13874
|
+
type: 'Group',
|
|
13875
|
+
label: '圆角',
|
|
13876
|
+
child: [
|
|
13877
|
+
{
|
|
13878
|
+
type: 'Slider',
|
|
13879
|
+
name: ['props', 'buttonStyle', 'borderRadius'],
|
|
13880
|
+
max: 100
|
|
13881
|
+
},
|
|
13882
|
+
{
|
|
13883
|
+
type: 'Number',
|
|
13884
|
+
name: ['props', 'buttonStyle', 'borderRadius'],
|
|
13885
|
+
addonAfter: 'px',
|
|
13886
|
+
max: 100
|
|
13887
|
+
}
|
|
13888
|
+
]
|
|
13889
|
+
},
|
|
13890
|
+
{
|
|
13891
|
+
type: 'TextMargin',
|
|
13892
|
+
name: ['props', 'buttonStyle']
|
|
13893
|
+
},
|
|
13894
|
+
{
|
|
13895
|
+
type: 'Group',
|
|
13896
|
+
label: '字体',
|
|
13897
|
+
child: [
|
|
13898
|
+
{
|
|
13899
|
+
type: 'Select',
|
|
13900
|
+
name: ['props', 'buttonStyle', 'fontFamily-cn'],
|
|
13901
|
+
bottomText: '中文字体'
|
|
13902
|
+
},
|
|
13903
|
+
{
|
|
13904
|
+
type: 'Select',
|
|
13905
|
+
name: ['props', 'buttonStyle', 'fontFamily-en'],
|
|
13906
|
+
bottomText: '英文/其他字体'
|
|
13907
|
+
}
|
|
13908
|
+
]
|
|
13909
|
+
},
|
|
13910
|
+
{
|
|
13911
|
+
type: 'Group',
|
|
13912
|
+
label: '',
|
|
13913
|
+
child: [
|
|
13914
|
+
{
|
|
13915
|
+
type: 'Color',
|
|
13916
|
+
name: ['props', 'buttonStyle', 'color'],
|
|
13917
|
+
initialValue: '#fff'
|
|
13918
|
+
},
|
|
13919
|
+
{
|
|
13920
|
+
type: 'Number',
|
|
13921
|
+
name: ['props', 'buttonStyle', 'fontSize'],
|
|
13922
|
+
addonAfter: 'px'
|
|
13923
|
+
}
|
|
13924
|
+
]
|
|
13925
|
+
},
|
|
13926
|
+
{
|
|
13927
|
+
type: 'TextStyle',
|
|
13928
|
+
name: ['props', 'buttonStyle']
|
|
13929
|
+
},
|
|
13930
|
+
{
|
|
13931
|
+
type: 'TextAlign',
|
|
13932
|
+
name: ['props', 'buttonStyle']
|
|
13933
|
+
},
|
|
13934
|
+
{
|
|
13935
|
+
label: '间距',
|
|
13936
|
+
type: 'TextSpace',
|
|
13937
|
+
name: ['props', 'buttonStyle']
|
|
13938
|
+
}
|
|
13939
|
+
]
|
|
13940
|
+
},
|
|
13941
|
+
{
|
|
13942
|
+
title: '文案配置',
|
|
13943
|
+
child: [
|
|
13944
|
+
{
|
|
13945
|
+
type: 'Input',
|
|
13946
|
+
label: '加购按钮文案',
|
|
13947
|
+
name: ['props', 'texts', 'addToCart'],
|
|
13948
|
+
placeholder: 'Add to Cart'
|
|
13949
|
+
},
|
|
13950
|
+
{
|
|
13951
|
+
type: 'Input',
|
|
13952
|
+
label: '选择规格提示',
|
|
13953
|
+
name: ['props', 'texts', 'selectOptions'],
|
|
13954
|
+
placeholder: 'Please select options'
|
|
13955
|
+
},
|
|
13956
|
+
{
|
|
13957
|
+
type: 'Input',
|
|
13958
|
+
label: '加载文案',
|
|
13959
|
+
name: ['props', 'texts', 'loading'],
|
|
13960
|
+
placeholder: 'Loading...'
|
|
13961
|
+
},
|
|
13962
|
+
{
|
|
13963
|
+
type: 'Input',
|
|
13964
|
+
label: '错误文案',
|
|
13965
|
+
name: ['props', 'texts', 'error'],
|
|
13966
|
+
placeholder: 'Failed to load product'
|
|
13967
|
+
}
|
|
13968
|
+
]
|
|
13969
|
+
},
|
|
13970
|
+
{
|
|
13971
|
+
title: '数量选择器',
|
|
13972
|
+
child: [
|
|
13973
|
+
{
|
|
13974
|
+
type: 'Number',
|
|
13975
|
+
label: '按钮间距',
|
|
13976
|
+
name: ['props', 'quantityStyle', 'gap'],
|
|
13977
|
+
addonAfter: 'px',
|
|
13978
|
+
initialValue: 12
|
|
13979
|
+
}
|
|
13980
|
+
]
|
|
13981
|
+
}
|
|
13982
|
+
];
|
|
13983
|
+
|
|
13984
|
+
/*
|
|
13985
|
+
* @Author: tao
|
|
13986
|
+
* @Date: 2026-01-12
|
|
13987
|
+
* @Description: Add to Cart 交互配置
|
|
13988
|
+
*/
|
|
13989
|
+
var interactionRender$d = () => {
|
|
13990
|
+
return (React.createElement("div", { style: { padding: '20px', color: '#666' } },
|
|
13991
|
+
React.createElement("p", null, "\u52A0\u8D2D\u5546\u54C1\u5F39\u7A97\u4EA4\u4E92\u8BF4\u660E\uFF1A"),
|
|
13992
|
+
React.createElement("ul", { style: { paddingLeft: '20px', lineHeight: '1.8' } },
|
|
13993
|
+
React.createElement("li", null, "\u70B9\u51FB\u5546\u54C1\u8BE6\u60C5\u5F39\u7A97\u7684\"Shop Now\"\u6309\u94AE\u540E\u81EA\u52A8\u5C55\u793A"),
|
|
13994
|
+
React.createElement("li", null, "\u901A\u8FC7Shopify Storefront API\u83B7\u53D6\u5546\u54C1\u89C4\u683C\u548C\u5E93\u5B58\u4FE1\u606F"),
|
|
13995
|
+
React.createElement("li", null, "\u7528\u6237\u9009\u62E9\u89C4\u683C\u540E\u5B9E\u65F6\u663E\u793A\u5BF9\u5E94SKU\u7684\u4EF7\u683C\u548C\u5E93\u5B58"),
|
|
13996
|
+
React.createElement("li", null, "\u70B9\u51FB\"Add to Cart\"\u6309\u94AE\u540E\u8DF3\u8F6C\u81F3Shopify\u8D2D\u7269\u8F66\u9875\u9762"),
|
|
13997
|
+
React.createElement("li", null, "\u65E0\u5E93\u5B58\u6216\u4E0D\u53EF\u552E\u5356\u7684\u89C4\u683C\u81EA\u52A8\u7F6E\u7070\u4E0D\u53EF\u9009"))));
|
|
13998
|
+
};
|
|
13999
|
+
|
|
14000
|
+
const AddToCartPopup$1 = (_a) => {
|
|
14001
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
14002
|
+
var { style, isActive = true, index, shopifyDomain = '', storefrontAccessToken = '', variantStyles = {}, buttonStyle = {}, quantityStyle = {}, texts = {}, popupBg = {} } = _a, props = __rest(_a, ["style", "isActive", "index", "shopifyDomain", "storefrontAccessToken", "variantStyles", "buttonStyle", "quantityStyle", "texts", "popupBg"]);
|
|
14003
|
+
const { sxpParameter, popupDetailData, isPreview, bffFbReport, globalConfig } = useSxpDataSource();
|
|
14004
|
+
useEventReport();
|
|
14005
|
+
const curTimeRef = React.useRef(null);
|
|
14006
|
+
const [productData, setProductData] = React.useState(null);
|
|
14007
|
+
const [selectedOptions, setSelectedOptions] = React.useState({});
|
|
14008
|
+
const [selectedVariant, setSelectedVariant] = React.useState(null);
|
|
14009
|
+
const [quantity, setQuantity] = React.useState(1);
|
|
14010
|
+
const [loading, setLoading] = React.useState(true);
|
|
14011
|
+
const [error, setError] = React.useState(null);
|
|
14012
|
+
// 获取当前弹窗商品数据(自动从 popupDetailData 获取)
|
|
14013
|
+
const data = popupDetailData;
|
|
14014
|
+
const product = (_c = (_b = data === null || data === void 0 ? void 0 : data.video) === null || _b === void 0 ? void 0 : _b.bindProduct) !== null && _c !== void 0 ? _c : (_e = (_d = data === null || data === void 0 ? void 0 : data.video) === null || _d === void 0 ? void 0 : _d.bindProducts) === null || _e === void 0 ? void 0 : _e[0];
|
|
14015
|
+
product === null || product === void 0 ? void 0 : product.bindCta;
|
|
14016
|
+
const position = (_g = (_f = popupDetailData === null || popupDetailData === void 0 ? void 0 : popupDetailData.index) !== null && _f !== void 0 ? _f : index) !== null && _g !== void 0 ? _g : 0;
|
|
14017
|
+
// Shopify配置 - 优先级:props > globalConfig > 默认值
|
|
14018
|
+
const finalShopifyDomain = shopifyDomain || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.shopifyDomain) || 'dev-store-749237498237498636.myshopify.com';
|
|
14019
|
+
const finalStorefrontToken = storefrontAccessToken || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.storefrontAccessToken) || '77d894c490f79430ce7bd0a7efdff6b7';
|
|
14020
|
+
// 自动从商品数据获取 Shopify Product ID
|
|
14021
|
+
const productId = (product === null || product === void 0 ? void 0 : product.itemId) || '';
|
|
14022
|
+
// 文案
|
|
14023
|
+
const finalTexts = {
|
|
14024
|
+
addToCart: texts.addToCart || 'Add to Cart',
|
|
14025
|
+
selectOptions: texts.selectOptions || 'Please select options',
|
|
14026
|
+
loading: texts.loading || 'Loading...',
|
|
14027
|
+
error: texts.error || 'Failed to load product',
|
|
14028
|
+
color: texts.color || 'Color',
|
|
14029
|
+
size: texts.size || 'Size',
|
|
14030
|
+
material: texts.material || 'Material',
|
|
14031
|
+
style: texts.style || 'Style'
|
|
14032
|
+
};
|
|
14033
|
+
// 查询Shopify商品数据
|
|
14034
|
+
const fetchProductData = React.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
14035
|
+
var _m;
|
|
14036
|
+
if (!productId || !finalShopifyDomain || !finalStorefrontToken) {
|
|
14037
|
+
console.log('[AddToCartPopup] 缺少必要配置:', {
|
|
14038
|
+
productId,
|
|
14039
|
+
shopifyDomain: finalShopifyDomain,
|
|
14040
|
+
hasToken: !!finalStorefrontToken
|
|
14041
|
+
});
|
|
14042
|
+
setLoading(false);
|
|
14043
|
+
return;
|
|
14044
|
+
}
|
|
14045
|
+
console.log('[AddToCartPopup] 开始加载商品数据:', {
|
|
14046
|
+
productId,
|
|
14047
|
+
shopifyDomain: finalShopifyDomain
|
|
14048
|
+
});
|
|
14049
|
+
setLoading(true);
|
|
14050
|
+
setError(null);
|
|
14051
|
+
try {
|
|
14052
|
+
const query = `
|
|
14053
|
+
query getProduct($id: ID!) {
|
|
14054
|
+
product(id: $id) {
|
|
14055
|
+
id
|
|
14056
|
+
title
|
|
14057
|
+
images(first: 10) {
|
|
14058
|
+
edges {
|
|
14059
|
+
node {
|
|
14060
|
+
url
|
|
14061
|
+
}
|
|
14062
|
+
}
|
|
14063
|
+
}
|
|
14064
|
+
options {
|
|
14065
|
+
name
|
|
14066
|
+
values
|
|
14067
|
+
}
|
|
14068
|
+
variants(first: 100) {
|
|
14069
|
+
edges {
|
|
14070
|
+
node {
|
|
14071
|
+
id
|
|
14072
|
+
title
|
|
14073
|
+
availableForSale
|
|
14074
|
+
quantityAvailable
|
|
14075
|
+
price {
|
|
14076
|
+
amount
|
|
14077
|
+
currencyCode
|
|
14078
|
+
}
|
|
14079
|
+
image {
|
|
14080
|
+
url
|
|
14081
|
+
}
|
|
14082
|
+
selectedOptions {
|
|
14083
|
+
name
|
|
14084
|
+
value
|
|
14085
|
+
}
|
|
14086
|
+
}
|
|
14087
|
+
}
|
|
14088
|
+
}
|
|
14089
|
+
}
|
|
14090
|
+
}
|
|
14091
|
+
`;
|
|
14092
|
+
// 确保 Product ID 格式正确
|
|
14093
|
+
const formattedProductId = productId.startsWith('gid://')
|
|
14094
|
+
? productId
|
|
14095
|
+
: `gid://shopify/Product/${productId}`;
|
|
14096
|
+
console.log('[AddToCartPopup] 使用的 Product ID:', formattedProductId);
|
|
14097
|
+
const response = yield fetch(`https://${finalShopifyDomain}/api/2024-01/graphql.json`, {
|
|
14098
|
+
method: 'POST',
|
|
14099
|
+
headers: {
|
|
14100
|
+
'Content-Type': 'application/json',
|
|
14101
|
+
'X-Shopify-Storefront-Access-Token': finalStorefrontToken
|
|
14102
|
+
},
|
|
14103
|
+
body: JSON.stringify({
|
|
14104
|
+
query,
|
|
14105
|
+
variables: { id: formattedProductId }
|
|
14106
|
+
})
|
|
14107
|
+
});
|
|
14108
|
+
if (!response.ok) {
|
|
14109
|
+
throw new Error(`HTTP ${response.status}`);
|
|
14110
|
+
}
|
|
14111
|
+
const result = yield response.json();
|
|
14112
|
+
if (result.errors) {
|
|
14113
|
+
console.error('[AddToCartPopup] GraphQL 错误:', result.errors);
|
|
14114
|
+
throw new Error(result.errors[0].message);
|
|
14115
|
+
}
|
|
14116
|
+
if (!((_m = result.data) === null || _m === void 0 ? void 0 : _m.product)) {
|
|
14117
|
+
console.error('[AddToCartPopup] 未找到商品');
|
|
14118
|
+
throw new Error('Product not found');
|
|
14119
|
+
}
|
|
14120
|
+
console.log('[AddToCartPopup] 商品数据加载成功:', result.data.product.title);
|
|
14121
|
+
setProductData(result.data.product);
|
|
14122
|
+
}
|
|
14123
|
+
catch (err) {
|
|
14124
|
+
const errorMessage = err instanceof Error ? err.message : finalTexts.error;
|
|
14125
|
+
setError(errorMessage);
|
|
14126
|
+
console.error('[AddToCartPopup] 加载失败:', err);
|
|
14127
|
+
}
|
|
14128
|
+
finally {
|
|
14129
|
+
setLoading(false);
|
|
14130
|
+
}
|
|
14131
|
+
}), [productId, finalShopifyDomain, finalStorefrontToken, finalTexts.error]);
|
|
14132
|
+
React.useEffect(() => {
|
|
14133
|
+
if (isActive) {
|
|
14134
|
+
fetchProductData();
|
|
14135
|
+
}
|
|
14136
|
+
}, [isActive, fetchProductData]);
|
|
14137
|
+
// 根据选中的规格匹配variant
|
|
14138
|
+
React.useEffect(() => {
|
|
14139
|
+
if (!productData)
|
|
14140
|
+
return;
|
|
14141
|
+
const variants = productData.variants.edges.map(edge => edge.node);
|
|
14142
|
+
const optionsCount = productData.options.length;
|
|
14143
|
+
const selectedCount = Object.keys(selectedOptions).length;
|
|
14144
|
+
if (selectedCount === 0 || selectedCount < optionsCount) {
|
|
14145
|
+
setSelectedVariant(null);
|
|
14146
|
+
return;
|
|
14147
|
+
}
|
|
14148
|
+
const matchedVariant = variants.find(variant => {
|
|
14149
|
+
return variant.selectedOptions.every(option => selectedOptions[option.name] === option.value);
|
|
14150
|
+
});
|
|
14151
|
+
setSelectedVariant(matchedVariant || null);
|
|
14152
|
+
setQuantity(1);
|
|
14153
|
+
}, [selectedOptions, productData]);
|
|
14154
|
+
// 处理规格选择
|
|
14155
|
+
const handleOptionSelect = React.useCallback((optionName, value) => {
|
|
14156
|
+
setSelectedOptions(prev => {
|
|
14157
|
+
const newOptions = Object.assign({}, prev);
|
|
14158
|
+
if (newOptions[optionName] === value) {
|
|
14159
|
+
delete newOptions[optionName];
|
|
14160
|
+
}
|
|
14161
|
+
else {
|
|
14162
|
+
newOptions[optionName] = value;
|
|
14163
|
+
}
|
|
14164
|
+
return newOptions;
|
|
14165
|
+
});
|
|
14166
|
+
}, []);
|
|
14167
|
+
// 处理数量变化
|
|
14168
|
+
const handleQuantityChange = React.useCallback((delta) => {
|
|
14169
|
+
setQuantity(prev => {
|
|
14170
|
+
var _a;
|
|
14171
|
+
const newQuantity = prev + delta;
|
|
14172
|
+
const maxQuantity = (_a = selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.quantityAvailable) !== null && _a !== void 0 ? _a : 999;
|
|
14173
|
+
return Math.max(1, Math.min(newQuantity, maxQuantity));
|
|
14174
|
+
});
|
|
14175
|
+
}, [selectedVariant]);
|
|
14176
|
+
// 检查某个规格值是否可用
|
|
14177
|
+
const isOptionValueAvailable = React.useCallback((optionName, value) => {
|
|
14178
|
+
if (!productData)
|
|
14179
|
+
return false;
|
|
14180
|
+
const variants = productData.variants.edges.map(edge => edge.node);
|
|
14181
|
+
const tempOptions = Object.assign(Object.assign({}, selectedOptions), { [optionName]: value });
|
|
14182
|
+
return variants.some(variant => {
|
|
14183
|
+
const matches = variant.selectedOptions.every(option => !tempOptions[option.name] || tempOptions[option.name] === option.value);
|
|
14184
|
+
const hasStock = variant.quantityAvailable === null || variant.quantityAvailable > 0;
|
|
14185
|
+
return matches && variant.availableForSale && hasStock;
|
|
14186
|
+
});
|
|
14187
|
+
}, [productData, selectedOptions]);
|
|
14188
|
+
// 处理加购
|
|
14189
|
+
const handleAddToCart = React.useCallback(() => {
|
|
14190
|
+
var _a;
|
|
14191
|
+
if (!selectedVariant || quantity === 0)
|
|
14192
|
+
return;
|
|
14193
|
+
const variantId = selectedVariant.id.split('/').pop();
|
|
14194
|
+
const cartUrl = `https://${finalShopifyDomain}/cart/add?id=${variantId}&quantity=${quantity}`;
|
|
14195
|
+
console.log('[AddToCartPopup] 加购:', {
|
|
14196
|
+
variantId,
|
|
14197
|
+
quantity,
|
|
14198
|
+
cartUrl
|
|
14199
|
+
});
|
|
14200
|
+
// 上报事件
|
|
14201
|
+
bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
|
|
14202
|
+
eventName: 'AddToCart',
|
|
14203
|
+
product: product ? [product] : undefined,
|
|
14204
|
+
contentType: 'product',
|
|
14205
|
+
data,
|
|
14206
|
+
position,
|
|
14207
|
+
content_id: (_a = product === null || product === void 0 ? void 0 : product.itemId) !== null && _a !== void 0 ? _a : '',
|
|
14208
|
+
value: parseFloat(selectedVariant.price.amount) * quantity,
|
|
14209
|
+
currency: selectedVariant.price.currencyCode,
|
|
14210
|
+
contents: [{
|
|
14211
|
+
id: variantId,
|
|
14212
|
+
quantity
|
|
14213
|
+
}]
|
|
14214
|
+
});
|
|
14215
|
+
// 跳转到Shopify购物车页面
|
|
14216
|
+
window.location.href = cartUrl;
|
|
14217
|
+
}, [selectedVariant, quantity, finalShopifyDomain, bffFbReport, product, data, position]);
|
|
14218
|
+
// 计算总价
|
|
14219
|
+
const totalPrice = React.useMemo(() => {
|
|
14220
|
+
if (!selectedVariant)
|
|
14221
|
+
return null;
|
|
14222
|
+
const price = parseFloat(selectedVariant.price.amount);
|
|
14223
|
+
const total = price * quantity;
|
|
14224
|
+
return total.toFixed(2);
|
|
14225
|
+
}, [selectedVariant, quantity]);
|
|
14226
|
+
// 初始化时间
|
|
14227
|
+
React.useEffect(() => {
|
|
14228
|
+
const initTime = () => {
|
|
14229
|
+
curTimeRef.current = new Date();
|
|
14230
|
+
};
|
|
14231
|
+
initTime();
|
|
14232
|
+
window.addEventListener('pageshow', initTime);
|
|
14233
|
+
return () => {
|
|
14234
|
+
window.removeEventListener('pageshow', initTime);
|
|
14235
|
+
};
|
|
14236
|
+
}, []);
|
|
14237
|
+
// 加载中
|
|
14238
|
+
if (loading) {
|
|
14239
|
+
return (React.createElement("div", { className: "add-to-cart-popup-loading", style: style },
|
|
14240
|
+
React.createElement("div", null, finalTexts.loading)));
|
|
14241
|
+
}
|
|
14242
|
+
// 错误状态
|
|
14243
|
+
if (error || !productData) {
|
|
14244
|
+
return (React.createElement("div", { className: "add-to-cart-popup-error", style: style },
|
|
14245
|
+
React.createElement("div", null,
|
|
14246
|
+
finalTexts.error,
|
|
14247
|
+
": ",
|
|
14248
|
+
error || 'Product not found')));
|
|
14249
|
+
}
|
|
14250
|
+
const mainImage = ((_h = selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.image) === null || _h === void 0 ? void 0 : _h.url) || ((_j = productData.images.edges[0]) === null || _j === void 0 ? void 0 : _j.node.url) || ((_k = product === null || product === void 0 ? void 0 : product.homePage) === null || _k === void 0 ? void 0 : _k[0]) || '';
|
|
14251
|
+
const hasAllOptionsSelected = productData.options.length === Object.keys(selectedOptions).length;
|
|
14252
|
+
const isAddToCartDisabled = !selectedVariant || quantity === 0;
|
|
14253
|
+
return (React.createElement("div", Object.assign({ className: "add-to-cart-popup-container", style: style }, props),
|
|
14254
|
+
React.createElement("div", { className: "variant-detail-section" },
|
|
14255
|
+
React.createElement("div", { className: "variant-image-wrapper" },
|
|
14256
|
+
React.createElement("img", { src: mainImage, alt: productData.title, className: "variant-image" })),
|
|
14257
|
+
React.createElement("div", { className: "variant-info-wrapper" },
|
|
14258
|
+
React.createElement("h2", { className: "product-title-text", style: variantStyles.title, dangerouslySetInnerHTML: {
|
|
14259
|
+
__html: setFontForText(productData.title, variantStyles.title)
|
|
14260
|
+
} }),
|
|
14261
|
+
selectedVariant && (React.createElement(React.Fragment, null,
|
|
14262
|
+
React.createElement("div", { className: "selected-options-tags" }, selectedVariant.selectedOptions.map(option => (React.createElement("span", { key: option.name, className: "option-tag", style: variantStyles.selectedOption },
|
|
14263
|
+
option.name,
|
|
14264
|
+
": ",
|
|
14265
|
+
option.value)))),
|
|
14266
|
+
React.createElement("div", { className: "price-display" },
|
|
14267
|
+
React.createElement("span", { className: "price-value", style: variantStyles.price, dangerouslySetInnerHTML: {
|
|
14268
|
+
__html: setFontForText(`${selectedVariant.price.currencyCode} $${totalPrice}`, variantStyles.price)
|
|
14269
|
+
} })),
|
|
14270
|
+
React.createElement("div", { className: "quantity-selector-wrapper", style: quantityStyle },
|
|
14271
|
+
React.createElement("button", { className: "quantity-btn quantity-decrease", onClick: () => handleQuantityChange(-1), disabled: quantity <= 1, "aria-label": "Decrease quantity" }, "-"),
|
|
14272
|
+
React.createElement("input", { type: "number", value: quantity, readOnly: true, className: "quantity-input-field", "aria-label": "Quantity" }),
|
|
14273
|
+
React.createElement("button", { className: "quantity-btn quantity-increase", onClick: () => handleQuantityChange(1), disabled: quantity >= ((_l = selectedVariant.quantityAvailable) !== null && _l !== void 0 ? _l : 999), "aria-label": "Increase quantity" }, "+")))),
|
|
14274
|
+
!hasAllOptionsSelected && (React.createElement("div", { className: "no-selection-hint", style: variantStyles.option }, finalTexts.selectOptions)))),
|
|
14275
|
+
React.createElement("div", { className: "variant-options-section" }, productData.options.map(option => (React.createElement("div", { key: option.name, className: "option-group-wrapper" },
|
|
14276
|
+
React.createElement("h3", { className: "option-group-name", style: variantStyles.option, dangerouslySetInnerHTML: {
|
|
14277
|
+
__html: setFontForText(option.name, variantStyles.option)
|
|
14278
|
+
} }),
|
|
14279
|
+
React.createElement("div", { className: "option-values-grid" }, option.values.map(value => {
|
|
14280
|
+
const isSelected = selectedOptions[option.name] === value;
|
|
14281
|
+
const isAvailable = isOptionValueAvailable(option.name, value);
|
|
14282
|
+
return (React.createElement("button", { key: value, className: `option-value-button ${isSelected ? 'selected' : ''} ${!isAvailable ? 'disabled' : ''}`, onClick: () => isAvailable && handleOptionSelect(option.name, value), disabled: !isAvailable, "aria-label": `${option.name}: ${value}`, "aria-pressed": isSelected }, value));
|
|
14283
|
+
})))))),
|
|
14284
|
+
React.createElement("button", { className: `add-to-cart-button ${isAddToCartDisabled ? 'disabled' : ''}`, style: buttonStyle, onClick: handleAddToCart, disabled: isAddToCartDisabled, "aria-label": finalTexts.addToCart },
|
|
14285
|
+
React.createElement("span", { dangerouslySetInnerHTML: {
|
|
14286
|
+
__html: setFontForText(finalTexts.addToCart, buttonStyle)
|
|
14287
|
+
} }))));
|
|
14288
|
+
};
|
|
14289
|
+
|
|
14290
|
+
/*
|
|
14291
|
+
* @Author: tao
|
|
14292
|
+
* @Date: 2026-01-12
|
|
14293
|
+
* @Description: Add to Cart 弹窗组件物料配置
|
|
14294
|
+
*/
|
|
14295
|
+
const AddToCartPopup = createMaterial(AddToCartPopup$1, {
|
|
14296
|
+
displayName: '加购商品',
|
|
14297
|
+
icon: '',
|
|
14298
|
+
category: 'popup',
|
|
14299
|
+
type: 'AddToCartPopup',
|
|
14300
|
+
related: {
|
|
14301
|
+
settingRender: settingRender$9,
|
|
14302
|
+
interactionRender: interactionRender$d
|
|
14303
|
+
},
|
|
14304
|
+
defaulSetting: {
|
|
14305
|
+
props: {
|
|
14306
|
+
shopifyDomain: '',
|
|
14307
|
+
storefrontAccessToken: '',
|
|
14308
|
+
variantStyles: {
|
|
14309
|
+
title: {
|
|
14310
|
+
color: '#000',
|
|
14311
|
+
fontSize: 20,
|
|
14312
|
+
fontWeight: 600,
|
|
14313
|
+
marginBottom: 12
|
|
14314
|
+
},
|
|
14315
|
+
price: {
|
|
14316
|
+
color: '#000',
|
|
14317
|
+
fontSize: 24,
|
|
14318
|
+
fontWeight: 700,
|
|
14319
|
+
marginBottom: 16
|
|
14320
|
+
},
|
|
14321
|
+
option: {
|
|
14322
|
+
color: '#111',
|
|
14323
|
+
fontSize: 16,
|
|
14324
|
+
fontWeight: 600,
|
|
14325
|
+
marginBottom: 12
|
|
14326
|
+
},
|
|
14327
|
+
selectedOption: {
|
|
14328
|
+
fontSize: 14,
|
|
14329
|
+
color: '#374151'
|
|
14330
|
+
}
|
|
14331
|
+
},
|
|
14332
|
+
buttonStyle: {
|
|
14333
|
+
backgroundColor: '#000',
|
|
14334
|
+
color: '#fff',
|
|
14335
|
+
fontSize: 16,
|
|
14336
|
+
height: 52,
|
|
14337
|
+
fontWeight: 600,
|
|
14338
|
+
textAlign: 'center',
|
|
14339
|
+
textTransform: 'uppercase'
|
|
14340
|
+
},
|
|
14341
|
+
quantityStyle: {
|
|
14342
|
+
gap: 12
|
|
14343
|
+
},
|
|
14344
|
+
texts: {
|
|
14345
|
+
addToCart: 'Add to Cart',
|
|
14346
|
+
selectOptions: 'Please select options',
|
|
14347
|
+
loading: 'Loading...',
|
|
14348
|
+
error: 'Failed to load product',
|
|
14349
|
+
color: 'Color',
|
|
14350
|
+
size: 'Size',
|
|
14351
|
+
material: 'Material',
|
|
14352
|
+
style: 'Style'
|
|
14353
|
+
},
|
|
14354
|
+
popupBg: {
|
|
14355
|
+
horizontalMargin: 0,
|
|
14356
|
+
bottomMargin: 0
|
|
14357
|
+
}
|
|
14358
|
+
},
|
|
14359
|
+
style: {}
|
|
14360
|
+
},
|
|
14361
|
+
w: 100,
|
|
14362
|
+
h: 40,
|
|
14363
|
+
sort: 7
|
|
14364
|
+
});
|
|
14365
|
+
|
|
13656
14366
|
/*
|
|
13657
14367
|
* @Author: binruan@chatlabs.com
|
|
13658
14368
|
* @Date: 2024-03-26 16:50:25
|
|
@@ -19144,6 +19854,7 @@ Made in Italy` })));
|
|
|
19144
19854
|
|
|
19145
19855
|
var _materials_ = /*#__PURE__*/Object.freeze({
|
|
19146
19856
|
__proto__: null,
|
|
19857
|
+
AddToCartPopup: AddToCartPopup,
|
|
19147
19858
|
AniLink: AniLink,
|
|
19148
19859
|
AniLinkPopup: AniLinkPopup,
|
|
19149
19860
|
Appoint: Appoint,
|