pb-sxp-ui 1.7.2 → 1.7.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/dist/index.cjs +107 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +107 -48
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +3 -3
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +3 -3
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +107 -48
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +3 -3
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/SxpPageRender/PictureGroup/Picture.d.ts +1 -1
- package/es/core/components/SxpPageRender/PictureGroup/index.d.ts +4 -1
- package/es/core/components/SxpPageRender/PictureGroup/index.js +24 -4
- package/es/core/components/SxpPageRender/RenderCard.js +6 -1
- package/es/core/components/SxpPageRender/VideoWidget/index.js +14 -7
- package/es/core/components/SxpPageRender/WaterFall/List.js +3 -2
- package/es/core/components/SxpPageRender/WaterFall/WaterfallList.js +3 -2
- package/es/core/components/SxpPageRender/index.d.ts +1 -0
- package/es/core/components/SxpPageRender/index.js +12 -10
- package/es/core/utils/materials.d.ts +7 -1
- package/es/core/utils/materials.js +5 -2
- package/es/core/utils/tool.d.ts +2 -1
- package/es/core/utils/tool.js +11 -1
- package/es/materials/sxp/cta/AniLink/settingRender.d.ts +11 -0
- package/es/materials/sxp/cta/AniLink/settingRender.js +6 -0
- package/es/materials/sxp/cta/AniLinkPopup/settingRender.d.ts +1 -1
- package/es/materials/sxp/cta/AniLinkPopup/settingRender.js +6 -0
- package/es/materials/sxp/popup/CommodityDetail/index.js +3 -2
- package/es/materials/sxp/popup/CommodityDetailDiroNew/index.js +3 -2
- package/es/materials/sxp/popup/CommodityList/index.js +5 -4
- package/es/materials/sxp/template/components/settingRender.d.ts +1 -1
- package/es/materials/sxp/template/components/settingRender.js +6 -0
- package/lib/core/components/SxpPageRender/PictureGroup/Picture.d.ts +1 -1
- package/lib/core/components/SxpPageRender/PictureGroup/index.d.ts +4 -1
- package/lib/core/components/SxpPageRender/PictureGroup/index.js +23 -4
- package/lib/core/components/SxpPageRender/RenderCard.js +6 -1
- package/lib/core/components/SxpPageRender/VideoWidget/index.js +13 -7
- package/lib/core/components/SxpPageRender/WaterFall/List.js +3 -2
- package/lib/core/components/SxpPageRender/WaterFall/WaterfallList.js +3 -2
- package/lib/core/components/SxpPageRender/index.d.ts +1 -0
- package/lib/core/components/SxpPageRender/index.js +12 -10
- package/lib/core/utils/materials.d.ts +7 -1
- package/lib/core/utils/materials.js +5 -2
- package/lib/core/utils/tool.d.ts +2 -1
- package/lib/core/utils/tool.js +12 -1
- package/lib/materials/sxp/cta/AniLink/settingRender.d.ts +11 -0
- package/lib/materials/sxp/cta/AniLink/settingRender.js +6 -0
- package/lib/materials/sxp/cta/AniLinkPopup/settingRender.d.ts +1 -1
- package/lib/materials/sxp/cta/AniLinkPopup/settingRender.js +6 -0
- package/lib/materials/sxp/popup/CommodityDetail/index.js +3 -2
- package/lib/materials/sxp/popup/CommodityDetailDiroNew/index.js +3 -2
- package/lib/materials/sxp/popup/CommodityList/index.js +5 -4
- package/lib/materials/sxp/template/components/settingRender.d.ts +1 -1
- package/lib/materials/sxp/template/components/settingRender.js +6 -0
- package/package.json +1 -1
@@ -4,7 +4,7 @@ interface IPictureProps {
|
|
4
4
|
src: string;
|
5
5
|
height?: number;
|
6
6
|
imgUrlsPostConfig?: postConfigType;
|
7
|
-
onShowFirstImage?: () => void;
|
7
|
+
onShowFirstImage?: (e: any) => void;
|
8
8
|
}
|
9
9
|
declare const Picture: (props: IPictureProps) => React.JSX.Element;
|
10
10
|
export default Picture;
|
@@ -8,7 +8,10 @@ interface IPictureGroupProps {
|
|
8
8
|
rec: RecItemType;
|
9
9
|
index: number;
|
10
10
|
onReportViewImageEnd: (rec: RecItemType) => void;
|
11
|
-
onViewImageStartEvent: (index: number
|
11
|
+
onViewImageStartEvent: (index: number, imgInfo?: {
|
12
|
+
contentSize: string;
|
13
|
+
loadTime: string;
|
14
|
+
}) => void;
|
12
15
|
imgUrlsPostConfig?: postConfigType;
|
13
16
|
}
|
14
17
|
declare const _default: React.NamedExoticComponent<IPictureGroupProps>;
|
@@ -1,15 +1,20 @@
|
|
1
|
+
import { __awaiter } from "tslib";
|
1
2
|
import React, { memo, useCallback, useEffect, useRef, useState } from 'react';
|
2
3
|
import { Autoplay, Pagination } from 'swiper/modules';
|
3
4
|
import { Swiper, SwiperSlide, useSwiperSlide } from 'swiper/react';
|
4
5
|
import Picture from './Picture';
|
5
6
|
import { useSxpDataSource } from '../../../../core/hooks';
|
6
7
|
import { css } from '@emotion/css';
|
8
|
+
import SXP_EVENT_BUS, { SXP_EVENT_TYPE } from '../../../../core/utils/event';
|
9
|
+
import { getResFileSizeFromSrc } from '../../../../core/utils/tool';
|
7
10
|
const PictureGroup = ({ imgUrls, width, height, rec, index, onReportViewImageEnd, onViewImageStartEvent, imgUrlsPostConfig }) => {
|
8
11
|
var _a, _b;
|
9
12
|
const ref = useRef();
|
10
13
|
const { isActive } = useSwiperSlide();
|
11
14
|
const { sxpParameter, openHashtag } = useSxpDataSource();
|
12
15
|
const [isLoad, setIsLoad] = useState(false);
|
16
|
+
const [imgInfo, setImgInfo] = useState();
|
17
|
+
const initTime = new Date();
|
13
18
|
useEffect(() => {
|
14
19
|
if (isLoad && isActive) {
|
15
20
|
(ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.swiper.autoplay.start();
|
@@ -17,18 +22,33 @@ const PictureGroup = ({ imgUrls, width, height, rec, index, onReportViewImageEnd
|
|
17
22
|
onReportViewImageEnd(rec);
|
18
23
|
}
|
19
24
|
else {
|
20
|
-
onViewImageStartEvent(index);
|
25
|
+
onViewImageStartEvent(index, imgInfo);
|
21
26
|
}
|
22
27
|
}
|
23
28
|
else {
|
24
29
|
(ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.swiper.autoplay.stop();
|
25
30
|
}
|
26
|
-
}, [rec, isActive, onReportViewImageEnd, openHashtag, index, onViewImageStartEvent, isLoad]);
|
27
|
-
const showFirstImageFn = useCallback(() => {
|
31
|
+
}, [rec, isActive, onReportViewImageEnd, openHashtag, index, onViewImageStartEvent, isLoad, imgInfo]);
|
32
|
+
const showFirstImageFn = useCallback((e) => __awaiter(void 0, void 0, void 0, function* () {
|
28
33
|
if (!isLoad) {
|
34
|
+
const contentSize = yield getResFileSizeFromSrc(e.src);
|
35
|
+
setImgInfo({
|
36
|
+
contentSize,
|
37
|
+
loadTime: (new Date() - initTime).toFixed(2) + ''
|
38
|
+
});
|
29
39
|
setIsLoad(true);
|
30
40
|
}
|
31
|
-
}, [isLoad]);
|
41
|
+
}), [isLoad]);
|
42
|
+
useEffect(() => {
|
43
|
+
const onShow = () => onViewImageStartEvent(index, imgInfo);
|
44
|
+
const onHide = () => onReportViewImageEnd(rec);
|
45
|
+
SXP_EVENT_BUS.on(SXP_EVENT_TYPE.PAGE_DID_SHOW, onShow);
|
46
|
+
SXP_EVENT_BUS.on(SXP_EVENT_TYPE.PAGE_DID_HIDE, onHide);
|
47
|
+
return () => {
|
48
|
+
SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_SHOW, onShow);
|
49
|
+
SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_HIDE, onHide);
|
50
|
+
};
|
51
|
+
}, [imgInfo]);
|
32
52
|
return (React.createElement(Swiper, { ref: ref, defaultValue: 0, direction: 'horizontal', modules: [Pagination, Autoplay], pagination: {
|
33
53
|
clickable: true,
|
34
54
|
bulletActiveClass: 'swipe-item-active-bullet',
|
@@ -49,7 +49,12 @@ const RenderCard = ({ rec, index, tempMap, resolver, includesCtaType, isActive }
|
|
49
49
|
const Component = withBindDataSource(t);
|
50
50
|
const defaulSetting = (_z = t === null || t === void 0 ? void 0 : t.extend) === null || _z === void 0 ? void 0 : _z.defaulSetting;
|
51
51
|
const isExternalLink = ((_2 = (_1 = (_0 = value === null || value === void 0 ? void 0 : value.item) === null || _0 === void 0 ? void 0 : _0.event) === null || _1 === void 0 ? void 0 : _1.onClick) === null || _2 === void 0 ? void 0 : _2.linkType) === 'externalLink';
|
52
|
-
|
52
|
+
let style = (_3 = value === null || value === void 0 ? void 0 : value.item) === null || _3 === void 0 ? void 0 : _3.style;
|
53
|
+
if (style.hasOwnProperty('backdropFilter')) {
|
54
|
+
let sbf = style['backdropFilter'];
|
55
|
+
style['backdropFilter'] = `blur(${sbf !== null && sbf !== void 0 ? sbf : 0}px)`;
|
56
|
+
}
|
57
|
+
return (React.createElement(Component, Object.assign({ style: Object.assign(Object.assign(Object.assign({}, defaulSetting === null || defaulSetting === void 0 ? void 0 : defaulSetting.style), style), { zIndex: 50, marginLeft: '20px', boxSizing: 'border-box', transform: 'translate3d(0px, 0px, 0px)' }), textStyle: Object.assign(Object.assign({}, defaulSetting === null || defaulSetting === void 0 ? void 0 : defaulSetting.textStyle), (_4 = value === null || value === void 0 ? void 0 : value.item) === null || _4 === void 0 ? void 0 : _4.textStyle), bindDatas: (_6 = (_5 = value === null || value === void 0 ? void 0 : value.item) === null || _5 === void 0 ? void 0 : _5.bindDatas) !== null && _6 !== void 0 ? _6 : [] }, defaulSetting === null || defaulSetting === void 0 ? void 0 : defaulSetting.props, (_7 = value === null || value === void 0 ? void 0 : value.item) === null || _7 === void 0 ? void 0 : _7.props, { event: ((_8 = value === null || value === void 0 ? void 0 : value.item) === null || _8 === void 0 ? void 0 : _8.event) || {}, schema: schema, id: value === null || value === void 0 ? void 0 : value.id, key: value === null || value === void 0 ? void 0 : value.id, recData: rec, isExternalLink: isExternalLink, index: index, isActive: isActive })));
|
53
58
|
}
|
54
59
|
else {
|
55
60
|
return null;
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { __awaiter } from "tslib";
|
1
2
|
import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
2
3
|
import { useSwiperSlide } from 'swiper/react';
|
3
4
|
import { useIconLink } from '../useIconLink';
|
@@ -6,6 +7,7 @@ import { useSxpDataSource } from '../../../../core/hooks';
|
|
6
7
|
import SXP_EVENT_BUS, { SXP_EVENT_TYPE } from '../../../../core/utils/event';
|
7
8
|
import loading_gif from './loading.gif';
|
8
9
|
import { mountVideoPlayerAtNode } from './VideoPlayer';
|
10
|
+
import { getResFileSizeFromSrc } from '../../../../core/utils/tool';
|
9
11
|
const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, videoPlayIcon }) => {
|
10
12
|
const [isPauseVideo, setIsPauseVideo] = useState(false);
|
11
13
|
const { bffEventReport, sxpParameter, waterFallData, openHashtag, bffFbReport } = useSxpDataSource();
|
@@ -20,6 +22,7 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
20
22
|
const videoId = `pb-cache-video-${index}`;
|
21
23
|
const videoEleRef = useRef(null);
|
22
24
|
const hlsRef = useRef(null);
|
25
|
+
const initTimeRef = useRef();
|
23
26
|
const blur = useMemo(() => {
|
24
27
|
return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2';
|
25
28
|
}, [videoPostConfig]);
|
@@ -65,8 +68,8 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
65
68
|
setWaiting(false);
|
66
69
|
setIsLoadFinish(true);
|
67
70
|
}, []);
|
68
|
-
const handleStartPlay = useCallback(() => {
|
69
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
71
|
+
const handleStartPlay = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
72
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
70
73
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
71
74
|
return;
|
72
75
|
setIsPauseVideo(false);
|
@@ -76,24 +79,27 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
76
79
|
const videoDuration = ((_d = (_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.duration) !== null && _d !== void 0 ? _d : 0).toFixed(2);
|
77
80
|
const videoCurrentTime = ((_f = (_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.currentTime) !== null && _f !== void 0 ? _f : 0).toFixed(2);
|
78
81
|
const playType = isFirstPlay ? '0' : '1';
|
82
|
+
const contentSize = yield getResFileSizeFromSrc((_g = item === null || item === void 0 ? void 0 : item.video) === null || _g === void 0 ? void 0 : _g.url);
|
79
83
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
80
84
|
eventInfo: {
|
81
85
|
eventSubject: 'playVideo',
|
82
86
|
eventDescription: 'User played the video',
|
83
|
-
contentId: (
|
84
|
-
contentName: (
|
87
|
+
contentId: (_j = (_h = item === null || item === void 0 ? void 0 : item.video) === null || _h === void 0 ? void 0 : _h.itemId) !== null && _j !== void 0 ? _j : '',
|
88
|
+
contentName: (_l = (_k = item === null || item === void 0 ? void 0 : item.video) === null || _k === void 0 ? void 0 : _k.title) !== null && _l !== void 0 ? _l : '',
|
85
89
|
playType,
|
86
90
|
startTime: videoCurrentTime,
|
87
91
|
videoDuration,
|
88
|
-
contentTags: JSON.stringify((
|
92
|
+
contentTags: JSON.stringify((_o = (_m = item === null || item === void 0 ? void 0 : item.video) === null || _m === void 0 ? void 0 : _m.tags) !== null && _o !== void 0 ? _o : []),
|
89
93
|
position: index + '',
|
90
94
|
contentFormat: 'video',
|
91
|
-
traceInfo: (
|
95
|
+
traceInfo: (_p = item === null || item === void 0 ? void 0 : item.video) === null || _p === void 0 ? void 0 : _p.traceInfo,
|
96
|
+
contentSize,
|
97
|
+
loadTime: (new Date() - (initTimeRef === null || initTimeRef === void 0 ? void 0 : initTimeRef.current)).toFixed(2) + ''
|
92
98
|
}
|
93
99
|
});
|
94
100
|
setIsFirstPlay(false);
|
95
101
|
}
|
96
|
-
}, [bffEventReport, data, index, isFirstPlay, videoRef === null || videoRef === void 0 ? void 0 : videoRef.current]);
|
102
|
+
}), [bffEventReport, data, index, isFirstPlay, videoRef === null || videoRef === void 0 ? void 0 : videoRef.current]);
|
97
103
|
const handLoadeddata = useCallback(() => {
|
98
104
|
var _a;
|
99
105
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || firstFrameSrc || !blur)
|
@@ -197,6 +203,7 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
197
203
|
videoRef.current = mountVideoPlayerAtNode === null || mountVideoPlayerAtNode === void 0 ? void 0 : mountVideoPlayerAtNode(videoPlayerWrapperNode);
|
198
204
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
199
205
|
return;
|
206
|
+
initTimeRef.current = new Date();
|
200
207
|
const Hls = window === null || window === void 0 ? void 0 : window.Hls;
|
201
208
|
let hls = hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current;
|
202
209
|
if (videoSrc.includes('.m3u8') && Hls && Hls.isSupported()) {
|
@@ -41,7 +41,8 @@ const WaterfallFlowItem = (props) => {
|
|
41
41
|
product: rec === null || rec === void 0 ? void 0 : rec.product,
|
42
42
|
enableFormattedPrice: (_a = textStyles === null || textStyles === void 0 ? void 0 : textStyles.price) === null || _a === void 0 ? void 0 : _a.enableFormattedPrice,
|
43
43
|
globalConfig,
|
44
|
-
isHiddenDef: true
|
44
|
+
isHiddenDef: true,
|
45
|
+
style: textStyles === null || textStyles === void 0 ? void 0 : textStyles.price
|
45
46
|
});
|
46
47
|
useEffect(() => {
|
47
48
|
const observer = new IntersectionObserver((entries) => {
|
@@ -113,7 +114,7 @@ const WaterfallFlowItem = (props) => {
|
|
113
114
|
__html: setFontForText(title, textStyles === null || textStyles === void 0 ? void 0 : textStyles.title)
|
114
115
|
} }),
|
115
116
|
React.createElement("div", { className: 'list-content-listItem-info-price', style: textStyles === null || textStyles === void 0 ? void 0 : textStyles.price, hidden: !priceText, dangerouslySetInnerHTML: {
|
116
|
-
__html:
|
117
|
+
__html: priceText !== null && priceText !== void 0 ? priceText : ''
|
117
118
|
} }))));
|
118
119
|
};
|
119
120
|
export default function WaterfallList(_a) {
|
@@ -64,7 +64,8 @@ const WaterfallFlowItem = (props) => {
|
|
64
64
|
product: rec === null || rec === void 0 ? void 0 : rec.product,
|
65
65
|
enableFormattedPrice: (_a = textStyles === null || textStyles === void 0 ? void 0 : textStyles.price) === null || _a === void 0 ? void 0 : _a.enableFormattedPrice,
|
66
66
|
globalConfig,
|
67
|
-
isHiddenDef: true
|
67
|
+
isHiddenDef: true,
|
68
|
+
style: textStyles === null || textStyles === void 0 ? void 0 : textStyles.price
|
68
69
|
});
|
69
70
|
useEffect(() => {
|
70
71
|
if (imgDom.current === null || src === '') {
|
@@ -105,7 +106,7 @@ const WaterfallFlowItem = (props) => {
|
|
105
106
|
__html: setFontForText(title, textStyles === null || textStyles === void 0 ? void 0 : textStyles.title)
|
106
107
|
} }),
|
107
108
|
React.createElement("div", { className: 'waterFallList-content-listItem-info-price', hidden: !priceText, style: textStyles.price, dangerouslySetInnerHTML: {
|
108
|
-
__html:
|
109
|
+
__html: priceText !== null && priceText !== void 0 ? priceText : ''
|
109
110
|
} }))));
|
110
111
|
};
|
111
112
|
export default function WaterfallList(_a) {
|
@@ -86,7 +86,6 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
86
86
|
if (document.visibilityState === 'hidden') {
|
87
87
|
if (repCond) {
|
88
88
|
SXP_EVENT_BUS.emit(SXP_EVENT_TYPE.PAGE_DID_HIDE, item);
|
89
|
-
handleReportViewImageEnd(item);
|
90
89
|
handleReportProductView(item);
|
91
90
|
}
|
92
91
|
let fromKName = '';
|
@@ -130,7 +129,6 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
130
129
|
}
|
131
130
|
handleH5EnterLink();
|
132
131
|
if (repCond) {
|
133
|
-
handleViewImageStartEvent(activeIndex);
|
134
132
|
SXP_EVENT_BUS.emit(SXP_EVENT_TYPE.PAGE_DID_SHOW, item);
|
135
133
|
backMainFeed('external', selectTag);
|
136
134
|
}
|
@@ -359,7 +357,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
359
357
|
}
|
360
358
|
};
|
361
359
|
const handleScrollEvent = (swiper) => {
|
362
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
360
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
363
361
|
const item = data[swiper.previousIndex];
|
364
362
|
if (!item)
|
365
363
|
return;
|
@@ -380,7 +378,8 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
380
378
|
productId: (_g = (_f = item === null || item === void 0 ? void 0 : item.product) === null || _f === void 0 ? void 0 : _f.itemId) !== null && _g !== void 0 ? _g : '',
|
381
379
|
requestId: null,
|
382
380
|
traceInfo: (_j = (_h = item === null || item === void 0 ? void 0 : item.video) === null || _h === void 0 ? void 0 : _h.traceInfo) !== null && _j !== void 0 ? _j : '',
|
383
|
-
contentFormat
|
381
|
+
contentFormat,
|
382
|
+
position: ((_k = swiper.previousIndex) !== null && _k !== void 0 ? _k : 0) + ''
|
384
383
|
}
|
385
384
|
});
|
386
385
|
handleReportViewImageEnd(item);
|
@@ -391,11 +390,12 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
391
390
|
eventInfo: {
|
392
391
|
eventSubject: 'scrollUp',
|
393
392
|
eventDescription: 'User scroll up',
|
394
|
-
contentId: (
|
395
|
-
productId: (
|
393
|
+
contentId: (_m = (_l = item === null || item === void 0 ? void 0 : item.video) === null || _l === void 0 ? void 0 : _l.itemId) !== null && _m !== void 0 ? _m : '',
|
394
|
+
productId: (_p = (_o = item.product) === null || _o === void 0 ? void 0 : _o.itemId) !== null && _p !== void 0 ? _p : '',
|
396
395
|
requestId: null,
|
397
|
-
traceInfo: (
|
398
|
-
contentFormat
|
396
|
+
traceInfo: (_r = (_q = item === null || item === void 0 ? void 0 : item.video) === null || _q === void 0 ? void 0 : _q.traceInfo) !== null && _r !== void 0 ? _r : '',
|
397
|
+
contentFormat,
|
398
|
+
position: ((_s = swiper.previousIndex) !== null && _s !== void 0 ? _s : 0) + ''
|
399
399
|
}
|
400
400
|
});
|
401
401
|
handleReportViewImageEnd(item);
|
@@ -418,7 +418,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
418
418
|
viewTime.current = new Date();
|
419
419
|
}
|
420
420
|
}, [openHashtag, data, activeIndex]);
|
421
|
-
const handleViewImageStartEvent = (activeIndex) => {
|
421
|
+
const handleViewImageStartEvent = (activeIndex, imgInfo) => {
|
422
422
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
423
423
|
const item = data[activeIndex];
|
424
424
|
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)) {
|
@@ -434,7 +434,9 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
434
434
|
contentTags: JSON.stringify((_f = item === null || item === void 0 ? void 0 : item.video.tags) !== null && _f !== void 0 ? _f : []),
|
435
435
|
position: activeIndex + '',
|
436
436
|
contentFormat: 'image',
|
437
|
-
traceInfo: item === null || item === void 0 ? void 0 : item.video.traceInfo
|
437
|
+
traceInfo: item === null || item === void 0 ? void 0 : item.video.traceInfo,
|
438
|
+
contentSize: imgInfo === null || imgInfo === void 0 ? void 0 : imgInfo.contentSize,
|
439
|
+
loadTime: imgInfo === null || imgInfo === void 0 ? void 0 : imgInfo.loadTime
|
438
440
|
}
|
439
441
|
});
|
440
442
|
bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
|
@@ -11,9 +11,15 @@ export declare const getBgStyleByImg: (data: any) => "" | {
|
|
11
11
|
backgroundRepeat: string;
|
12
12
|
backgroundSize: string;
|
13
13
|
};
|
14
|
-
|
14
|
+
interface IfontType {
|
15
|
+
'fontFamily-cn': string;
|
16
|
+
'fontFamily-en': string;
|
17
|
+
}
|
18
|
+
export declare const getPriceText: ({ product, enableFormattedPrice, globalConfig, isHiddenDef, style }: {
|
15
19
|
product: ProductInfoType | undefined | null;
|
16
20
|
enableFormattedPrice: boolean | undefined;
|
17
21
|
globalConfig: ISxpPageRenderProps['globalConfig'];
|
18
22
|
isHiddenDef?: boolean;
|
23
|
+
style?: IfontType | any;
|
19
24
|
}) => string | null;
|
25
|
+
export {};
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { setFontForText } from './tool';
|
1
2
|
export const getMediaValueByMode = (obj) => {
|
2
3
|
var _a;
|
3
4
|
if (!obj || typeof obj !== 'object') {
|
@@ -29,8 +30,8 @@ export const getBgStyleByImg = (data) => {
|
|
29
30
|
const imgSrc = typeof bgImg === 'string' ? bgImg : getMediaValueByMode(bgImg);
|
30
31
|
return getBgStyle(imgSrc);
|
31
32
|
};
|
32
|
-
export const getPriceText = ({ product, enableFormattedPrice, globalConfig, isHiddenDef }) => {
|
33
|
-
var _a, _b, _c, _d, _e;
|
33
|
+
export const getPriceText = ({ product, enableFormattedPrice, globalConfig, isHiddenDef, style }) => {
|
34
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
34
35
|
if ((!(product === null || product === void 0 ? void 0 : product.currency) || !(product === null || product === void 0 ? void 0 : product.price)) && isHiddenDef)
|
35
36
|
return null;
|
36
37
|
let price = (product === null || product === void 0 ? void 0 : product.currency) && (product === null || product === void 0 ? void 0 : product.price) ? product === null || product === void 0 ? void 0 : product.price : 7000;
|
@@ -77,6 +78,8 @@ export const getPriceText = ({ product, enableFormattedPrice, globalConfig, isHi
|
|
77
78
|
}
|
78
79
|
});
|
79
80
|
}
|
81
|
+
currency = `<span style="font-family:${(_h = (_g = (_f = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.priceSymbol) === null || _f === void 0 ? void 0 : _f.fontFamily) !== null && _g !== void 0 ? _g : style === null || style === void 0 ? void 0 : style['fontFamily-en']) !== null && _h !== void 0 ? _h : 'inherit'}">${currency}</span>`;
|
82
|
+
text = setFontForText(text, style);
|
80
83
|
if ((priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.currencyPosition) && (priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.currencyPosition) !== 'none') {
|
81
84
|
text = (priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.currencyPosition) === 'left' ? currency + text : text + currency;
|
82
85
|
}
|
package/es/core/utils/tool.d.ts
CHANGED
@@ -11,4 +11,5 @@ declare function getBrowserInfo(): string | null;
|
|
11
11
|
declare function getSystem(): string | null;
|
12
12
|
declare function getDevice(): string | null;
|
13
13
|
declare function getCookie(val: string): string;
|
14
|
-
|
14
|
+
declare const getResFileSizeFromSrc: (imageSrc?: string) => "" | Promise<string>;
|
15
|
+
export { uuid, getIndexByblockType, getBrowserInfo, getDevice, getSystem, getCookie, getResFileSizeFromSrc };
|
package/es/core/utils/tool.js
CHANGED
@@ -156,4 +156,14 @@ function getCookie(val) {
|
|
156
156
|
});
|
157
157
|
return value !== null && value !== void 0 ? value : '';
|
158
158
|
}
|
159
|
-
|
159
|
+
const getResFileSizeFromSrc = (imageSrc) => {
|
160
|
+
if (!imageSrc)
|
161
|
+
return '';
|
162
|
+
return fetch(imageSrc)
|
163
|
+
.then((response) => response.blob())
|
164
|
+
.then((blob) => {
|
165
|
+
const fileSizeInMB = blob.size / (1024 * 1024);
|
166
|
+
return fileSizeInMB.toFixed(2) + '';
|
167
|
+
});
|
168
|
+
};
|
169
|
+
export { uuid, getIndexByblockType, getBrowserInfo, getDevice, getSystem, getCookie, getResFileSizeFromSrc };
|
@@ -9,6 +9,7 @@ declare const _default: ({
|
|
9
9
|
addonAfter: string;
|
10
10
|
}[];
|
11
11
|
name?: undefined;
|
12
|
+
addonAfter?: undefined;
|
12
13
|
direction?: undefined;
|
13
14
|
} | {
|
14
15
|
type: string;
|
@@ -25,12 +26,21 @@ declare const _default: ({
|
|
25
26
|
max: number;
|
26
27
|
})[];
|
27
28
|
name?: undefined;
|
29
|
+
addonAfter?: undefined;
|
28
30
|
direction?: undefined;
|
29
31
|
} | {
|
30
32
|
type: string;
|
31
33
|
label: string;
|
32
34
|
name: string[];
|
33
35
|
child?: undefined;
|
36
|
+
addonAfter?: undefined;
|
37
|
+
direction?: undefined;
|
38
|
+
} | {
|
39
|
+
type: string;
|
40
|
+
label: string;
|
41
|
+
name: string[];
|
42
|
+
addonAfter: string;
|
43
|
+
child?: undefined;
|
34
44
|
direction?: undefined;
|
35
45
|
} | {
|
36
46
|
type: string;
|
@@ -38,6 +48,7 @@ declare const _default: ({
|
|
38
48
|
label: string;
|
39
49
|
direction: string;
|
40
50
|
child?: undefined;
|
51
|
+
addonAfter?: undefined;
|
41
52
|
})[];
|
42
53
|
} | {
|
43
54
|
title: string;
|
@@ -68,7 +68,8 @@ const CommodityDetail = (_a) => {
|
|
68
68
|
const priceText = getPriceText({
|
69
69
|
product: product,
|
70
70
|
enableFormattedPrice: (_t = commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.price) === null || _t === void 0 ? void 0 : _t.enableFormattedPrice,
|
71
|
-
globalConfig
|
71
|
+
globalConfig,
|
72
|
+
style: commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.price
|
72
73
|
});
|
73
74
|
const width = (isPreview ? 375 : (_u = style === null || style === void 0 ? void 0 : style.width) !== null && _u !== void 0 ? _u : window.innerWidth) - ((_v = popupBg === null || popupBg === void 0 ? void 0 : popupBg.horizontalMargin) !== null && _v !== void 0 ? _v : 0) * 2;
|
74
75
|
const height = commodityImgRatio ? width * (commodityImgRatio.h / commodityImgRatio.w) : width;
|
@@ -82,7 +83,7 @@ const CommodityDetail = (_a) => {
|
|
82
83
|
__html: setFontForText((_b = product === null || product === void 0 ? void 0 : product.title) !== null && _b !== void 0 ? _b : 'Pendant in Yellow Gold with Diamonds, Medium', commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.title)
|
83
84
|
} }),
|
84
85
|
React.createElement("div", { className: 'pb-commondity-content-price', style: getStyle(commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.price), hidden: !!product && !(product === null || product === void 0 ? void 0 : product.price), dangerouslySetInnerHTML: {
|
85
|
-
__html:
|
86
|
+
__html: priceText !== null && priceText !== void 0 ? priceText : ''
|
86
87
|
} }),
|
87
88
|
React.createElement("div", { hidden: !!product && !(product === null || product === void 0 ? void 0 : product.taxInfo), style: getStyle(commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.taxInfo), dangerouslySetInnerHTML: {
|
88
89
|
__html: setFontForText((_c = product === null || product === void 0 ? void 0 : product.taxInfo) !== null && _c !== void 0 ? _c : '税费', commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.taxInfo)
|
@@ -74,7 +74,8 @@ const CommodityDetailDiroNew = (_a) => {
|
|
74
74
|
const priceText = getPriceText({
|
75
75
|
product,
|
76
76
|
enableFormattedPrice: (_t = commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.price) === null || _t === void 0 ? void 0 : _t.enableFormattedPrice,
|
77
|
-
globalConfig
|
77
|
+
globalConfig,
|
78
|
+
style: commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.price
|
78
79
|
});
|
79
80
|
const width = (isPreview ? 375 : (_u = style === null || style === void 0 ? void 0 : style.width) !== null && _u !== void 0 ? _u : window.innerWidth) - ((_v = popupBg === null || popupBg === void 0 ? void 0 : popupBg.horizontalMargin) !== null && _v !== void 0 ? _v : 0) * 2;
|
80
81
|
const height = commodityImgRatio ? width * (commodityImgRatio.h / commodityImgRatio.w) : width;
|
@@ -188,7 +189,7 @@ Made in Italy` })));
|
|
188
189
|
} })),
|
189
190
|
React.createElement("div", { className: 'pb-commondityDiroNew-content-top-right' },
|
190
191
|
React.createElement("div", { className: 'pb-commondityDiroNew-content-top-right-price', hidden: !!product && !(product === null || product === void 0 ? void 0 : product.price), style: getStyle(commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.price), dangerouslySetInnerHTML: {
|
191
|
-
__html:
|
192
|
+
__html: priceText !== null && priceText !== void 0 ? priceText : ''
|
192
193
|
} }),
|
193
194
|
React.createElement("div", { className: 'pb-commondityDiroNew-content-top-right-price', hidden: !!product && !(product === null || product === void 0 ? void 0 : product.taxInfo), style: getStyle(commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.taxInfo), dangerouslySetInnerHTML: {
|
194
195
|
__html: setFontForText((_2 = product === null || product === void 0 ? void 0 : product.taxInfo) !== null && _2 !== void 0 ? _2 : '税费', commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.taxInfo)
|
@@ -22,7 +22,8 @@ const CommodityList = (_a) => {
|
|
22
22
|
return getPriceText({
|
23
23
|
product,
|
24
24
|
enableFormattedPrice: (_a = commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.price) === null || _a === void 0 ? void 0 : _a.enableFormattedPrice,
|
25
|
-
globalConfig
|
25
|
+
globalConfig,
|
26
|
+
style: commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.price
|
26
27
|
});
|
27
28
|
}, [(_d = commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.price) === null || _d === void 0 ? void 0 : _d.enableFormattedPrice, globalConfig]);
|
28
29
|
const handleClick = throttle((item, multiCheckIndex) => {
|
@@ -47,7 +48,7 @@ const CommodityList = (_a) => {
|
|
47
48
|
});
|
48
49
|
}, []);
|
49
50
|
return (React.createElement("div", { className: css(Object.assign(Object.assign({}, style), { display: 'flex', flexDirection: 'column', gap: '10px', padding: '0 20px', marginTop: '50px', boxSizing: 'border-box' })) }, product === null || product === void 0 ? void 0 : product.map((item, index) => {
|
50
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
51
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
51
52
|
return (React.createElement(React.Fragment, null, recData && !(item === null || item === void 0 ? void 0 : item.bindCta) ? null : (React.createElement("div", Object.assign({ key: index }, props, { className: css({
|
52
53
|
display: 'flex'
|
53
54
|
}), onClick: () => handleClick(item, index) }),
|
@@ -74,10 +75,10 @@ const CommodityList = (_a) => {
|
|
74
75
|
}) },
|
75
76
|
React.createElement("div", null,
|
76
77
|
React.createElement("div", { style: commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.price, hidden: !!item && !(item === null || item === void 0 ? void 0 : item.price), dangerouslySetInnerHTML: {
|
77
|
-
__html:
|
78
|
+
__html: (_j = priceText(item)) !== null && _j !== void 0 ? _j : ''
|
78
79
|
} })),
|
79
80
|
React.createElement("div", { className: 'one-line-ellipsis', style: Object.assign(Object.assign({}, buttonStyle), { padding: '0 15px' }), dangerouslySetInnerHTML: {
|
80
|
-
__html: setFontForText((
|
81
|
+
__html: setFontForText((_l = (_k = item === null || item === void 0 ? void 0 : item.bindCta) === null || _k === void 0 ? void 0 : _k.enTitle) !== null && _l !== void 0 ? _l : 'Shop Now', buttonStyle)
|
81
82
|
} })))))));
|
82
83
|
})));
|
83
84
|
};
|
@@ -4,7 +4,7 @@ interface IPictureProps {
|
|
4
4
|
src: string;
|
5
5
|
height?: number;
|
6
6
|
imgUrlsPostConfig?: postConfigType;
|
7
|
-
onShowFirstImage?: () => void;
|
7
|
+
onShowFirstImage?: (e: any) => void;
|
8
8
|
}
|
9
9
|
declare const Picture: (props: IPictureProps) => React.JSX.Element;
|
10
10
|
export default Picture;
|
@@ -8,7 +8,10 @@ interface IPictureGroupProps {
|
|
8
8
|
rec: RecItemType;
|
9
9
|
index: number;
|
10
10
|
onReportViewImageEnd: (rec: RecItemType) => void;
|
11
|
-
onViewImageStartEvent: (index: number
|
11
|
+
onViewImageStartEvent: (index: number, imgInfo?: {
|
12
|
+
contentSize: string;
|
13
|
+
loadTime: string;
|
14
|
+
}) => void;
|
12
15
|
imgUrlsPostConfig?: postConfigType;
|
13
16
|
}
|
14
17
|
declare const _default: React.NamedExoticComponent<IPictureGroupProps>;
|
@@ -7,12 +7,16 @@ const react_2 = require("swiper/react");
|
|
7
7
|
const Picture_1 = tslib_1.__importDefault(require("./Picture"));
|
8
8
|
const hooks_1 = require("../../../../core/hooks");
|
9
9
|
const css_1 = require("@emotion/css");
|
10
|
+
const event_1 = tslib_1.__importStar(require("../../../../core/utils/event"));
|
11
|
+
const tool_1 = require("../../../../core/utils/tool");
|
10
12
|
const PictureGroup = ({ imgUrls, width, height, rec, index, onReportViewImageEnd, onViewImageStartEvent, imgUrlsPostConfig }) => {
|
11
13
|
var _a, _b;
|
12
14
|
const ref = (0, react_1.useRef)();
|
13
15
|
const { isActive } = (0, react_2.useSwiperSlide)();
|
14
16
|
const { sxpParameter, openHashtag } = (0, hooks_1.useSxpDataSource)();
|
15
17
|
const [isLoad, setIsLoad] = (0, react_1.useState)(false);
|
18
|
+
const [imgInfo, setImgInfo] = (0, react_1.useState)();
|
19
|
+
const initTime = new Date();
|
16
20
|
(0, react_1.useEffect)(() => {
|
17
21
|
if (isLoad && isActive) {
|
18
22
|
(ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.swiper.autoplay.start();
|
@@ -20,18 +24,33 @@ const PictureGroup = ({ imgUrls, width, height, rec, index, onReportViewImageEnd
|
|
20
24
|
onReportViewImageEnd(rec);
|
21
25
|
}
|
22
26
|
else {
|
23
|
-
onViewImageStartEvent(index);
|
27
|
+
onViewImageStartEvent(index, imgInfo);
|
24
28
|
}
|
25
29
|
}
|
26
30
|
else {
|
27
31
|
(ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.swiper.autoplay.stop();
|
28
32
|
}
|
29
|
-
}, [rec, isActive, onReportViewImageEnd, openHashtag, index, onViewImageStartEvent, isLoad]);
|
30
|
-
const showFirstImageFn = (0, react_1.useCallback)(() => {
|
33
|
+
}, [rec, isActive, onReportViewImageEnd, openHashtag, index, onViewImageStartEvent, isLoad, imgInfo]);
|
34
|
+
const showFirstImageFn = (0, react_1.useCallback)((e) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
31
35
|
if (!isLoad) {
|
36
|
+
const contentSize = yield (0, tool_1.getResFileSizeFromSrc)(e.src);
|
37
|
+
setImgInfo({
|
38
|
+
contentSize,
|
39
|
+
loadTime: (new Date() - initTime).toFixed(2) + ''
|
40
|
+
});
|
32
41
|
setIsLoad(true);
|
33
42
|
}
|
34
|
-
}, [isLoad]);
|
43
|
+
}), [isLoad]);
|
44
|
+
(0, react_1.useEffect)(() => {
|
45
|
+
const onShow = () => onViewImageStartEvent(index, imgInfo);
|
46
|
+
const onHide = () => onReportViewImageEnd(rec);
|
47
|
+
event_1.default.on(event_1.SXP_EVENT_TYPE.PAGE_DID_SHOW, onShow);
|
48
|
+
event_1.default.on(event_1.SXP_EVENT_TYPE.PAGE_DID_HIDE, onHide);
|
49
|
+
return () => {
|
50
|
+
event_1.default.off(event_1.SXP_EVENT_TYPE.PAGE_DID_SHOW, onShow);
|
51
|
+
event_1.default.off(event_1.SXP_EVENT_TYPE.PAGE_DID_HIDE, onHide);
|
52
|
+
};
|
53
|
+
}, [imgInfo]);
|
35
54
|
return (react_1.default.createElement(react_2.Swiper, { ref: ref, defaultValue: 0, direction: 'horizontal', modules: [modules_1.Pagination, modules_1.Autoplay], pagination: {
|
36
55
|
clickable: true,
|
37
56
|
bulletActiveClass: 'swipe-item-active-bullet',
|