pb-sxp-ui 1.0.41 → 1.0.43
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 +218 -497
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -6
- package/dist/index.js +218 -496
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +3 -4
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +3 -4
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +222 -500
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +3 -4
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/SxpPageRender/VideoWidget/index.d.ts +1 -0
- package/es/core/components/SxpPageRender/VideoWidget/index.js +119 -88
- package/es/core/components/SxpPageRender/WaterFall/index.js +1 -1
- package/es/core/components/SxpPageRender/index.js +58 -11
- package/es/core/context/SxpDataSourceProvider.d.ts +2 -0
- package/es/core/context/SxpDataSourceProvider.js +5 -2
- package/es/core/hooks/useEventReport.js +4 -4
- package/es/index.d.ts +0 -1
- package/es/index.js +0 -1
- package/es/materials/sxp/popup/CommodityDetail/index.js +6 -6
- package/es/materials/sxp/popup/CommodityDetailDiroNew/index.js +9 -9
- package/lib/core/components/SxpPageRender/VideoWidget/index.d.ts +1 -0
- package/lib/core/components/SxpPageRender/VideoWidget/index.js +119 -88
- package/lib/core/components/SxpPageRender/WaterFall/index.js +1 -1
- package/lib/core/components/SxpPageRender/index.js +58 -11
- package/lib/core/context/SxpDataSourceProvider.d.ts +2 -0
- package/lib/core/context/SxpDataSourceProvider.js +5 -2
- package/lib/core/hooks/useEventReport.js +4 -4
- package/lib/index.d.ts +0 -1
- package/lib/index.js +1 -3
- package/lib/materials/sxp/popup/CommodityDetail/index.js +6 -6
- package/lib/materials/sxp/popup/CommodityDetailDiroNew/index.js +9 -9
- package/package.json +1 -2
- package/es/core/components/DiyPortalPreview/PictureGroup.d.ts +0 -13
- package/es/core/components/DiyPortalPreview/PictureGroup.js +0 -11
- package/es/core/components/DiyPortalPreview/VideoWidget.d.ts +0 -15
- package/es/core/components/DiyPortalPreview/VideoWidget.js +0 -236
- package/es/core/components/DiyPortalPreview/index.d.ts +0 -6
- package/es/core/components/DiyPortalPreview/index.js +0 -112
- package/lib/core/components/DiyPortalPreview/PictureGroup.d.ts +0 -13
- package/lib/core/components/DiyPortalPreview/PictureGroup.js +0 -14
- package/lib/core/components/DiyPortalPreview/VideoWidget.d.ts +0 -15
- package/lib/core/components/DiyPortalPreview/VideoWidget.js +0 -239
- package/lib/core/components/DiyPortalPreview/index.d.ts +0 -6
- package/lib/core/components/DiyPortalPreview/index.js +0 -115
@@ -4,9 +4,8 @@ import { useIconLink } from '../useIconLink';
|
|
4
4
|
import FormatImage from '../FormatImage';
|
5
5
|
import { useSxpDataSource } from '../../../../core/hooks';
|
6
6
|
import SXP_EVENT_BUS, { SXP_EVENT_TYPE } from '../../../../core/utils/event';
|
7
|
-
const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig }) => {
|
7
|
+
const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, videoRef }) => {
|
8
8
|
const [isPauseVideo, setIsPauseVideo] = useState(false);
|
9
|
-
const videoRef = useRef(null);
|
10
9
|
const { bffEventReport, sxpParameter, waterFallData, openHashtag } = useSxpDataSource();
|
11
10
|
const videoStartTime = useRef(0);
|
12
11
|
const [isLoadFinish, setIsLoadFinish] = useState(false);
|
@@ -14,99 +13,118 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
14
13
|
const { isActive } = useSwiperSlide();
|
15
14
|
const canvasRef = useRef(null);
|
16
15
|
const [firstFrameSrc, setFirstFrameSrc] = useState('');
|
16
|
+
const videoId = `pb-cache-video-${index}`;
|
17
|
+
const videoEleRef = useRef(null);
|
17
18
|
useEffect(() => {
|
18
|
-
if (!videoRef
|
19
|
+
if (!videoRef)
|
19
20
|
return;
|
20
|
-
videoRef
|
21
|
-
}, [muted]);
|
22
|
-
const
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.muted(muted);
|
22
|
+
}, [muted, videoRef]);
|
23
|
+
const handleEnded = useCallback(() => {
|
24
|
+
if (!videoRef)
|
25
|
+
return;
|
26
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.play();
|
27
|
+
}, [videoRef]);
|
26
28
|
const PAUSE_ICON = useIconLink('/pb_static/06f28a2025c74c1cb49be6767316d827.png');
|
27
29
|
const handlePlaying = useCallback(() => {
|
28
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j
|
30
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
31
|
+
if (!videoRef)
|
32
|
+
return;
|
29
33
|
setIsPauseVideo(false);
|
30
34
|
const item = data[index];
|
31
|
-
if (item && (
|
32
|
-
videoStartTime.current = (
|
33
|
-
const videoDuration = ((
|
34
|
-
const videoCurrentTime = ((
|
35
|
+
if (item && (videoRef === null || videoRef === void 0 ? void 0 : videoRef.duration())) {
|
36
|
+
videoStartTime.current = (videoRef === null || videoRef === void 0 ? void 0 : videoRef.currentTime()) || 0;
|
37
|
+
const videoDuration = ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.duration()) !== null && _a !== void 0 ? _a : 0).toFixed(2);
|
38
|
+
const videoCurrentTime = ((_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.currentTime()) !== null && _b !== void 0 ? _b : 0).toFixed(2);
|
35
39
|
const playType = isFirstPlay ? '0' : '1';
|
36
40
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
37
41
|
eventInfo: {
|
38
42
|
eventSubject: 'playVideo',
|
39
43
|
eventDescription: 'User played the video',
|
40
|
-
contentId: (
|
41
|
-
contentName: (
|
44
|
+
contentId: (_d = (_c = item.video) === null || _c === void 0 ? void 0 : _c.itemId) !== null && _d !== void 0 ? _d : '',
|
45
|
+
contentName: (_f = (_e = item.video) === null || _e === void 0 ? void 0 : _e.title) !== null && _f !== void 0 ? _f : '',
|
42
46
|
playType,
|
43
47
|
startTime: videoCurrentTime,
|
44
48
|
videoDuration,
|
45
|
-
contentTags: JSON.stringify((
|
49
|
+
contentTags: JSON.stringify((_h = (_g = item.video) === null || _g === void 0 ? void 0 : _g.tags) !== null && _h !== void 0 ? _h : []),
|
46
50
|
position: index + '',
|
47
51
|
contentFormat: 'video',
|
48
|
-
traceInfo: (
|
52
|
+
traceInfo: (_j = item.video) === null || _j === void 0 ? void 0 : _j.traceInfo
|
49
53
|
}
|
50
54
|
});
|
51
55
|
setIsFirstPlay(false);
|
52
56
|
}
|
53
|
-
}, [bffEventReport, data, index, isFirstPlay]);
|
54
|
-
const
|
57
|
+
}, [bffEventReport, data, index, isFirstPlay, videoRef]);
|
58
|
+
const handleLoadedmetadata = useCallback(() => {
|
59
|
+
if (!videoRef)
|
60
|
+
return;
|
61
|
+
if (activeIndex !== index) {
|
62
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.play();
|
63
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.pause();
|
64
|
+
}
|
65
|
+
setIsLoadFinish(true);
|
66
|
+
}, [activeIndex, index, videoRef]);
|
67
|
+
const handleCanplay = useCallback(() => {
|
55
68
|
setIsLoadFinish(true);
|
56
69
|
}, []);
|
57
70
|
const handleClickVideo = useCallback((type) => () => {
|
58
|
-
|
71
|
+
if (!videoRef)
|
72
|
+
return;
|
59
73
|
if (!isLoadFinish)
|
60
74
|
return;
|
61
|
-
const isPause =
|
75
|
+
const isPause = videoRef === null || videoRef === void 0 ? void 0 : videoRef.paused();
|
62
76
|
switch (type) {
|
63
77
|
case 'start':
|
64
78
|
if (!isPause)
|
65
79
|
return;
|
66
|
-
|
80
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.play();
|
67
81
|
setIsPauseVideo(false);
|
68
82
|
break;
|
69
83
|
case 'pause':
|
70
84
|
if (isPause)
|
71
85
|
return;
|
72
|
-
|
86
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.pause();
|
73
87
|
setIsPauseVideo(true);
|
74
88
|
break;
|
75
89
|
default:
|
76
90
|
if (isPause) {
|
77
|
-
|
91
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.play();
|
78
92
|
}
|
79
93
|
else {
|
80
|
-
|
94
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.pause();
|
81
95
|
}
|
82
96
|
setIsPauseVideo(!isPause);
|
83
97
|
break;
|
84
98
|
}
|
85
|
-
}, [isLoadFinish]);
|
86
|
-
const
|
87
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j
|
99
|
+
}, [isLoadFinish, videoRef]);
|
100
|
+
const handlePause = useCallback(() => {
|
101
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
102
|
+
if (!videoRef)
|
103
|
+
return;
|
104
|
+
if (activeIndex !== index)
|
105
|
+
return;
|
88
106
|
const item = data[index];
|
89
|
-
const videoDuration = ((
|
90
|
-
const videoCurrentTime = ((
|
91
|
-
if (
|
92
|
-
const playDuration = ((
|
107
|
+
const videoDuration = ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.duration()) !== null && _a !== void 0 ? _a : 0).toFixed(2);
|
108
|
+
const videoCurrentTime = ((_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.currentTime()) !== null && _b !== void 0 ? _b : 0).toFixed(2);
|
109
|
+
if (videoRef === null || videoRef === void 0 ? void 0 : videoRef.duration()) {
|
110
|
+
const playDuration = ((videoRef === null || videoRef === void 0 ? void 0 : videoRef.currentTime()) - videoStartTime.current).toFixed(2);
|
93
111
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
94
112
|
eventInfo: {
|
95
113
|
eventSubject: 'playOverVideo',
|
96
114
|
eventDescription: 'User finished playing the video',
|
97
|
-
contentId: (
|
98
|
-
contentName: (
|
115
|
+
contentId: (_d = (_c = item.video) === null || _c === void 0 ? void 0 : _c.itemId) !== null && _d !== void 0 ? _d : '',
|
116
|
+
contentName: (_f = (_e = item.video) === null || _e === void 0 ? void 0 : _e.title) !== null && _f !== void 0 ? _f : '',
|
99
117
|
endTime: videoCurrentTime,
|
100
118
|
videoDuration,
|
101
119
|
playDuration,
|
102
|
-
contentTags: JSON.stringify((
|
120
|
+
contentTags: JSON.stringify((_h = (_g = item.video) === null || _g === void 0 ? void 0 : _g.tags) !== null && _h !== void 0 ? _h : []),
|
103
121
|
position: index + '',
|
104
122
|
contentFormat: 'video',
|
105
|
-
traceInfo: (
|
123
|
+
traceInfo: (_j = item.video) === null || _j === void 0 ? void 0 : _j.traceInfo
|
106
124
|
}
|
107
125
|
});
|
108
126
|
}
|
109
|
-
}, [data, index, bffEventReport]);
|
127
|
+
}, [data, index, bffEventReport, videoRef]);
|
110
128
|
const blur = useMemo(() => {
|
111
129
|
return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2';
|
112
130
|
}, [videoPostConfig]);
|
@@ -121,64 +139,79 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
121
139
|
return ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.cover) || firstFrameSrc;
|
122
140
|
}, [firstFrameSrc, rec]);
|
123
141
|
const handLoadeddata = useCallback(() => {
|
124
|
-
|
142
|
+
var _a;
|
143
|
+
if (!videoRef)
|
125
144
|
return;
|
126
|
-
const
|
127
|
-
|
128
|
-
|
129
|
-
const
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
145
|
+
const videoDomRef = document.getElementById(`${videoId}_html5_api`);
|
146
|
+
if (((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.cover) || !canvasRef || !videoDomRef || !canvasRef.current)
|
147
|
+
return;
|
148
|
+
const setFrameImg = () => {
|
149
|
+
const video = videoDomRef;
|
150
|
+
const canvas = canvasRef === null || canvasRef === void 0 ? void 0 : canvasRef.current;
|
151
|
+
const ctx = canvas.getContext('2d');
|
152
|
+
const targetWidth = window === null || window === void 0 ? void 0 : window.innerWidth;
|
153
|
+
const targetHeight = window === null || window === void 0 ? void 0 : window.innerHeight;
|
154
|
+
canvas.height = targetHeight;
|
155
|
+
canvas.width = targetWidth;
|
156
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
157
|
+
setFirstFrameSrc(canvas.toDataURL());
|
158
|
+
};
|
159
|
+
setFrameImg();
|
160
|
+
setTimeout(() => {
|
161
|
+
setFrameImg();
|
162
|
+
}, 500);
|
163
|
+
}, [videoRef]);
|
136
164
|
useEffect(() => {
|
137
|
-
|
138
|
-
|
165
|
+
if (!isActive || !videoRef)
|
166
|
+
return;
|
167
|
+
const videoSrc = rec.video.url;
|
168
|
+
if (!videoSrc)
|
139
169
|
return;
|
140
170
|
setIsPauseVideo(false);
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
171
|
+
const videoPlayerWrapperNode = document.querySelector(`#${videoId}`);
|
172
|
+
const dom = document.querySelector('#player-container-id');
|
173
|
+
const dom2 = document.querySelector('#player-container-id-copy');
|
174
|
+
if (!dom && !dom2)
|
175
|
+
return;
|
176
|
+
videoPlayerWrapperNode === null || videoPlayerWrapperNode === void 0 ? void 0 : videoPlayerWrapperNode.appendChild(dom || dom2);
|
177
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.src(videoSrc);
|
178
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.on('loadedmetadata', handleLoadedmetadata);
|
179
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.on('loadeddata', handLoadeddata);
|
180
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.on('canplay', handleCanplay);
|
181
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.on('playing', handlePlaying);
|
182
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.on('pause', handlePause);
|
183
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.on('ended', handleEnded);
|
151
184
|
return () => {
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
185
|
+
dom2 === null || dom2 === void 0 ? void 0 : dom2.appendChild(dom);
|
186
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.off('loadedmetadata', handleLoadedmetadata);
|
187
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.off('loadeddata', handLoadeddata);
|
188
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.off('canplay', handleCanplay);
|
189
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.off('playing', handlePlaying);
|
190
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.off('pause', handlePause);
|
191
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.off('ended', handleEnded);
|
157
192
|
};
|
158
|
-
}, [
|
193
|
+
}, [isActive, videoId, rec, videoRef]);
|
159
194
|
useEffect(() => {
|
160
|
-
|
161
|
-
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || !isLoadFinish)
|
195
|
+
if (!videoRef || !isLoadFinish)
|
162
196
|
return;
|
163
197
|
if (isActive) {
|
164
|
-
videoRef.
|
198
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.play();
|
165
199
|
}
|
166
200
|
else {
|
167
|
-
|
201
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.pause();
|
168
202
|
}
|
169
|
-
}, [isActive, isLoadFinish]);
|
203
|
+
}, [isActive, isLoadFinish, videoRef]);
|
170
204
|
useEffect(() => {
|
171
|
-
|
172
|
-
if (!isActive || !(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
205
|
+
if (!isActive || !videoRef)
|
173
206
|
return;
|
174
|
-
const isPause =
|
207
|
+
const isPause = videoRef === null || videoRef === void 0 ? void 0 : videoRef.paused();
|
175
208
|
if (!isPause && openHashtag) {
|
176
|
-
|
209
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.pause();
|
177
210
|
}
|
178
211
|
else if (!openHashtag) {
|
179
|
-
|
212
|
+
videoRef === null || videoRef === void 0 ? void 0 : videoRef.play();
|
180
213
|
}
|
181
|
-
}, [openHashtag, isActive]);
|
214
|
+
}, [openHashtag, isActive, videoRef]);
|
182
215
|
useEffect(() => {
|
183
216
|
if (!isActive)
|
184
217
|
return;
|
@@ -198,9 +231,11 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
198
231
|
return (React.createElement("img", { style: { position: 'absolute', left: 0, top: 0, width: '100%', height: '100%', objectFit: 'cover' }, src: sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image }));
|
199
232
|
}, [isLoadFinish, sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image]);
|
200
233
|
useEffect(() => {
|
234
|
+
if (!videoRef)
|
235
|
+
return;
|
201
236
|
const handleBeforeUnload = () => {
|
202
|
-
var _a
|
203
|
-
if (activeIndex === index && ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.url) &&
|
237
|
+
var _a;
|
238
|
+
if (activeIndex === index && ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.url) && videoRef && !isPauseVideo) {
|
204
239
|
handleClickVideo('pause')();
|
205
240
|
}
|
206
241
|
};
|
@@ -238,19 +273,15 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
238
273
|
right: 0
|
239
274
|
} },
|
240
275
|
React.createElement("div", { style: { position: 'relative', width: '100%', height: '100%' } },
|
241
|
-
React.createElement("
|
242
|
-
width: '100%',
|
243
|
-
height: '100%',
|
244
|
-
objectFit: 'contain'
|
245
|
-
} }),
|
276
|
+
React.createElement("div", { className: 'n-full-screen', ref: videoEleRef, id: videoId, style: { width: '100%', height: '100%' } }),
|
246
277
|
React.createElement("img", { hidden: !isPauseVideo, className: 'clc-pb-video-pause', src: PAUSE_ICON }))),
|
247
|
-
renderPoster)) : (React.createElement("div", { className: 'video-container', key: rec.video.itemId,
|
278
|
+
renderPoster)) : (React.createElement("div", { className: 'video-container', key: rec.video.itemId, style: {
|
248
279
|
position: 'relative',
|
249
280
|
width: '100%',
|
250
281
|
height,
|
251
282
|
overflow: 'hidden'
|
252
|
-
} },
|
253
|
-
React.createElement("
|
283
|
+
}, onClick: handleClickVideo() },
|
284
|
+
React.createElement("div", { className: 'n-full-screen', ref: videoEleRef, id: videoId, style: { width: '100%', height: '100%' } }),
|
254
285
|
renderPoster,
|
255
286
|
React.createElement("img", { hidden: !isPauseVideo, className: 'clc-pb-video-pause', src: PAUSE_ICON })))));
|
256
287
|
};
|
@@ -63,7 +63,7 @@ const WaterFall = (props) => {
|
|
63
63
|
}
|
64
64
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
65
65
|
eventInfo: {
|
66
|
-
|
66
|
+
relatedContentId: (_d = rec === null || rec === void 0 ? void 0 : rec.video) === null || _d === void 0 ? void 0 : _d.itemId,
|
67
67
|
position: cacheActiveIndex + '',
|
68
68
|
contentTags: JSON.stringify((_e = rec === null || rec === void 0 ? void 0 : rec.video) === null || _e === void 0 ? void 0 : _e.tags),
|
69
69
|
traceInfo: (_f = rec === null || rec === void 0 ? void 0 : rec.video) === null || _f === void 0 ? void 0 : _f.traceInfo,
|
@@ -33,6 +33,8 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
33
33
|
const [isLoadMore, setIsLoadMore] = useState(false);
|
34
34
|
const [isShowMore, setIsShowMore] = useState(false);
|
35
35
|
const { loadVideos, bffEventReport, loading, setPopupDetailData, ctaEvent, swiperRef, waterFallData, setOpenHashtag, appDomain, openHashtag, loadingImage, isFromHashtag, popupDetailData } = useSxpDataSource();
|
36
|
+
const [videoRef, setVideoRef] = useState(null);
|
37
|
+
const playerRef = useRef();
|
36
38
|
const { productView } = useEventReport();
|
37
39
|
const isShowFingerTip = useMemo(() => {
|
38
40
|
return data.length > 0 && !loading && getFeUserId();
|
@@ -68,6 +70,25 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
68
70
|
viewTime.current = new Date();
|
69
71
|
refreshFeSessionId();
|
70
72
|
};
|
73
|
+
const firstRef = useRef();
|
74
|
+
useEffect(() => {
|
75
|
+
if (!firstRef.current && !videoRef) {
|
76
|
+
firstRef.current = true;
|
77
|
+
const player = TCPlayer('player-container-id', {
|
78
|
+
licenseUrl: 'https://license.vod2.myqcloud.com/license/v2/1325816236_1/v_cube.license',
|
79
|
+
controls: false,
|
80
|
+
autoplay: false,
|
81
|
+
loop: false,
|
82
|
+
muted: true,
|
83
|
+
preload: 'auto',
|
84
|
+
posterImage: false,
|
85
|
+
bigPlayButton: true
|
86
|
+
});
|
87
|
+
player === null || player === void 0 ? void 0 : player.ready(() => {
|
88
|
+
setVideoRef(player);
|
89
|
+
});
|
90
|
+
}
|
91
|
+
}, [videoRef]);
|
71
92
|
useEffect(() => {
|
72
93
|
if (!isInit)
|
73
94
|
handleH5EnterLink();
|
@@ -120,12 +141,12 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
120
141
|
sessionDuration: Math.floor((new Date() - curTime.current) / 1000) + '',
|
121
142
|
eventSubject: 'sessionCompleted',
|
122
143
|
eventDescription: 'Session completed',
|
123
|
-
|
124
|
-
|
144
|
+
relatedContentId: (_l = item === null || item === void 0 ? void 0 : item.video) === null || _l === void 0 ? void 0 : _l.itemId,
|
145
|
+
relatedProductId: (_m = item === null || item === void 0 ? void 0 : item.product) === null || _m === void 0 ? void 0 : _m.itemId,
|
125
146
|
position: activeIndex + '',
|
126
147
|
fromKName,
|
127
148
|
fromKPage: location === null || location === void 0 ? void 0 : location.href,
|
128
|
-
|
149
|
+
relatedCtatId: (_q = (_p = (_o = item.video) === null || _o === void 0 ? void 0 : _o.bindCta) === null || _p === void 0 ? void 0 : _p.itemId) !== null && _q !== void 0 ? _q : ''
|
129
150
|
}
|
130
151
|
});
|
131
152
|
}
|
@@ -153,7 +174,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
153
174
|
const renderContent = useCallback((rec, index) => {
|
154
175
|
var _a, _b, _c, _d;
|
155
176
|
if ((_a = rec.video) === null || _a === void 0 ? void 0 : _a.url) {
|
156
|
-
return (React.createElement(VideoWidget, { rec: rec, index: index, muted: isMuted, data: data, height: height, activeIndex: activeIndex, videoPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.videoPost }));
|
177
|
+
return (React.createElement(VideoWidget, { rec: rec, index: index, muted: isMuted, data: data, height: height, activeIndex: activeIndex, videoPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.videoPost, videoRef: videoRef }));
|
157
178
|
}
|
158
179
|
if ((_b = rec.video) === null || _b === void 0 ? void 0 : _b.imgUrls) {
|
159
180
|
return (React.createElement(PictureGroup, { key: rec.video.itemId, imgUrls: rec.video.imgUrls, width: containerWidth, height: height, rec: rec, index: index, onReportViewImageEnd: handleReportViewImageEnd, onViewImageStartEvent: handleViewImageStartEvent, imgUrlsPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.imgUrlsPost }));
|
@@ -168,7 +189,19 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
168
189
|
});
|
169
190
|
}
|
170
191
|
return null;
|
171
|
-
}, [
|
192
|
+
}, [
|
193
|
+
containerWidth,
|
194
|
+
data,
|
195
|
+
height,
|
196
|
+
isMuted,
|
197
|
+
activeIndex,
|
198
|
+
globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost,
|
199
|
+
viewTime,
|
200
|
+
tipText,
|
201
|
+
resolver,
|
202
|
+
schema,
|
203
|
+
videoRef
|
204
|
+
]);
|
172
205
|
const onExpandableChange = useCallback((v) => {
|
173
206
|
setIsShowMore(v);
|
174
207
|
}, []);
|
@@ -258,8 +291,8 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
258
291
|
eventInfo: {
|
259
292
|
eventSubject: 'scrollDown',
|
260
293
|
eventDescription: 'User scroll down',
|
261
|
-
|
262
|
-
|
294
|
+
relatedContentId: (_b = (_a = item.video) === null || _a === void 0 ? void 0 : _a.itemId) !== null && _b !== void 0 ? _b : '',
|
295
|
+
relatedProductId: (_d = (_c = item.product) === null || _c === void 0 ? void 0 : _c.itemId) !== null && _d !== void 0 ? _d : '',
|
263
296
|
requestId: null
|
264
297
|
}
|
265
298
|
});
|
@@ -270,8 +303,8 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
270
303
|
eventInfo: {
|
271
304
|
eventSubject: 'scrollUp',
|
272
305
|
eventDescription: 'User scroll up',
|
273
|
-
|
274
|
-
|
306
|
+
relatedContentId: (_f = (_e = item.video) === null || _e === void 0 ? void 0 : _e.itemId) !== null && _f !== void 0 ? _f : '',
|
307
|
+
relatedProductId: (_h = (_g = item.product) === null || _g === void 0 ? void 0 : _g.itemId) !== null && _h !== void 0 ? _h : '',
|
275
308
|
requestId: null
|
276
309
|
}
|
277
310
|
});
|
@@ -349,7 +382,12 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
349
382
|
} })),
|
350
383
|
renderLogo,
|
351
384
|
isShowFingerTip ? React.createElement(FingerSwipeTip, { imageUrl: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.swipeTipIcon }) : null,
|
352
|
-
React.createElement(Swiper, { ref: swiperRef,
|
385
|
+
React.createElement(Swiper, { ref: swiperRef, onSlideChange: () => {
|
386
|
+
swiperRef.current.swiper.allowTouchMove = false;
|
387
|
+
setTimeout(() => {
|
388
|
+
swiperRef.current.swiper.allowTouchMove = true;
|
389
|
+
}, 500);
|
390
|
+
}, onActiveIndexChange: (swiper) => {
|
353
391
|
setActiveIndex(swiper.activeIndex);
|
354
392
|
if (openHashtag)
|
355
393
|
return;
|
@@ -373,6 +411,15 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
373
411
|
zIndex: 999
|
374
412
|
}, defaultValue: isMuted, activeIcon: (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.unMuteIcon) ? globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.unMuteIcon : mutedIcon, unactiveIcon: (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIcon) ? globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIcon : unmutedIcon, onChange: setIsMuted }),
|
375
413
|
renderView),
|
376
|
-
React.createElement(WaterFall, Object.assign({}, (_g = (_f = (_e = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.hashTag) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.item) === null || _g === void 0 ? void 0 : _g.props))
|
414
|
+
React.createElement(WaterFall, Object.assign({}, (_g = (_f = (_e = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.hashTag) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.item) === null || _g === void 0 ? void 0 : _g.props)),
|
415
|
+
React.createElement("div", { style: { position: 'absolute', zIndex: -100 } },
|
416
|
+
React.createElement("video", { ref: playerRef, id: 'player-container-id', playsInline: true, crossOrigin: 'anonymous', style: {
|
417
|
+
backgroundColor: 'transparent',
|
418
|
+
width: '100%',
|
419
|
+
height: '100%',
|
420
|
+
objectFit: 'cover',
|
421
|
+
pointerEvents: 'none'
|
422
|
+
} }),
|
423
|
+
React.createElement("div", { id: 'player-container-id-copy' }))));
|
377
424
|
};
|
378
425
|
export default SxpPageRender;
|
@@ -60,6 +60,8 @@ export interface ISxpDataSourceContext {
|
|
60
60
|
hashTagSize?: number;
|
61
61
|
loadingImage?: string;
|
62
62
|
isOpenHashTag?: boolean;
|
63
|
+
videoRef?: any;
|
64
|
+
setVideoRef?: React.Dispatch<React.SetStateAction<any>>;
|
63
65
|
}
|
64
66
|
export declare const SxpDataSourceContext: React.Context<ISxpDataSourceContext>;
|
65
67
|
export interface SxpDataSourceProviderProps {
|
@@ -24,6 +24,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
24
24
|
const [cacheRtcList, setCacheRtcList] = useState([]);
|
25
25
|
const [cacheActiveIndex, setCacheActiveIndex] = useState(0);
|
26
26
|
const [isFromHashtag, setIsFromHashtag] = useState(false);
|
27
|
+
const [videoRef, setVideoRef] = useState(null);
|
27
28
|
useEffect(() => {
|
28
29
|
setOpenHashtag(isOpenHashTag);
|
29
30
|
}, [isOpenHashTag]);
|
@@ -141,7 +142,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
141
142
|
fromKName = 'imagePage';
|
142
143
|
}
|
143
144
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
144
|
-
eventInfo: Object.assign(Object.assign({}, eventInfo), { ctaId: (_h = cta === null || cta === void 0 ? void 0 : cta.itemId) !== null && _h !== void 0 ? _h : '', ctaName: (_j = cta === null || cta === void 0 ? void 0 : cta.title) !== null && _j !== void 0 ? _j : '', contentTags: JSON.stringify(cta === null || cta === void 0 ? void 0 : cta.tags), position: position + '',
|
145
|
+
eventInfo: Object.assign(Object.assign({}, eventInfo), { ctaId: (_h = cta === null || cta === void 0 ? void 0 : cta.itemId) !== null && _h !== void 0 ? _h : '', ctaName: (_j = cta === null || cta === void 0 ? void 0 : cta.title) !== null && _j !== void 0 ? _j : '', contentTags: JSON.stringify(cta === null || cta === void 0 ? void 0 : cta.tags), position: position + '', relatedContentId: (_l = (_k = rec === null || rec === void 0 ? void 0 : rec.video) === null || _k === void 0 ? void 0 : _k.itemId) !== null && _l !== void 0 ? _l : '', relatedProductId: isProd ? product === null || product === void 0 ? void 0 : product.itemId : '', traceInfo: (_m = cta === null || cta === void 0 ? void 0 : cta.traceInfo) !== null && _m !== void 0 ? _m : '', fromKName })
|
145
146
|
});
|
146
147
|
}, [bffEventReport, isFromHashtag]);
|
147
148
|
useEffect(() => {
|
@@ -202,7 +203,9 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
202
203
|
appDomain,
|
203
204
|
hashTagSize,
|
204
205
|
loadingImage: loadingImage !== null && loadingImage !== void 0 ? loadingImage : defaultLoadingImage,
|
205
|
-
isOpenHashTag
|
206
|
+
isOpenHashTag,
|
207
|
+
videoRef,
|
208
|
+
setVideoRef
|
206
209
|
} }, render({ rtcList, mutateLike: bffMutateLike, mutateUnlike: bffMutateUnlike, submitForm: bffSubmitForm })));
|
207
210
|
};
|
208
211
|
export default memo(SxpDataSourceProvider);
|
@@ -32,8 +32,8 @@ export function useEventReport() {
|
|
32
32
|
fromKPage: location === null || location === void 0 ? void 0 : location.href,
|
33
33
|
contentTags: (product === null || product === void 0 ? void 0 : product.tags) ? JSON.stringify(product === null || product === void 0 ? void 0 : product.tags) : '',
|
34
34
|
position: position + '',
|
35
|
-
|
36
|
-
|
35
|
+
relatedContentId: (_m = (_l = data === null || data === void 0 ? void 0 : data.video) === null || _l === void 0 ? void 0 : _l.itemId) !== null && _m !== void 0 ? _m : '',
|
36
|
+
relatedCtatId: (_o = cta === null || cta === void 0 ? void 0 : cta.itemId) !== null && _o !== void 0 ? _o : '',
|
37
37
|
traceInfo: (_p = product === null || product === void 0 ? void 0 : product.traceInfo) !== null && _p !== void 0 ? _p : ''
|
38
38
|
}
|
39
39
|
});
|
@@ -57,8 +57,8 @@ export function useEventReport() {
|
|
57
57
|
fromKPage: location === null || location === void 0 ? void 0 : location.href,
|
58
58
|
contentTags: JSON.stringify(product === null || product === void 0 ? void 0 : product.tags),
|
59
59
|
position: position + '',
|
60
|
-
|
61
|
-
|
60
|
+
relatedContentId: (_d = data === null || data === void 0 ? void 0 : data.video) === null || _d === void 0 ? void 0 : _d.itemId,
|
61
|
+
relatedCtatId: cta === null || cta === void 0 ? void 0 : cta.itemId,
|
62
62
|
traceInfo: product === null || product === void 0 ? void 0 : product.traceInfo,
|
63
63
|
timeOnSite: Math.floor((new Date() - viewTime) / 1000) + '',
|
64
64
|
eventSubject: 'productView',
|
package/es/index.d.ts
CHANGED
@@ -2,7 +2,6 @@ import { Pagebuilder } from './core/Pagebuilder';
|
|
2
2
|
export * as core from './core';
|
3
3
|
export * as materials from './materials';
|
4
4
|
export { default as SxpPageRender } from './core/components/SxpPageRender';
|
5
|
-
export { default as DiyPortalPreview } from './core/components/DiyPortalPreview';
|
6
5
|
export { default as Modal } from './core/components/SxpPageRender/Modal';
|
7
6
|
export { default as SxpDataSourceProvider } from './core/context/SxpDataSourceProvider';
|
8
7
|
export { default as SxpPageCore } from './core/components/SxpPageCore';
|
package/es/index.js
CHANGED
@@ -4,7 +4,6 @@ export { core_1 as core };
|
|
4
4
|
import * as materials_1 from './materials';
|
5
5
|
export { materials_1 as materials };
|
6
6
|
export { default as SxpPageRender } from './core/components/SxpPageRender';
|
7
|
-
export { default as DiyPortalPreview } from './core/components/DiyPortalPreview';
|
8
7
|
export { default as Modal } from './core/components/SxpPageRender/Modal';
|
9
8
|
export { default as SxpDataSourceProvider } from './core/context/SxpDataSourceProvider';
|
10
9
|
export { default as SxpPageCore } from './core/components/SxpPageCore';
|
@@ -10,7 +10,7 @@ import Modal from '../../../../core/components/SxpPageRender/Modal';
|
|
10
10
|
import ExpandableText from '../../../../core/components/SxpPageRender/ExpandableText';
|
11
11
|
import FormatImage from '../../../../core/components/SxpPageRender/FormatImage';
|
12
12
|
const CommodityDetail = (_a) => {
|
13
|
-
var _b, _c, _d, _e, _f, _g, _h, _j
|
13
|
+
var _b, _c, _d, _e, _f, _g, _h, _j;
|
14
14
|
var { content, style, bgImg, onClick, schema, isDefault, bottom_image, tipText, isPost, viewTime, rec, swiper, commodityStyles, buttonStyle, index } = _a, props = __rest(_a, ["content", "style", "bgImg", "onClick", "schema", "isDefault", "bottom_image", "tipText", "isPost", "viewTime", "rec", "swiper", "commodityStyles", "buttonStyle", "index"]);
|
15
15
|
const { sxpParameter } = useSxpDataSource();
|
16
16
|
const { popupDetailData, bffEventReport, isPreview, waterFallData } = useSxpDataSource();
|
@@ -51,7 +51,7 @@ const CommodityDetail = (_a) => {
|
|
51
51
|
return '$7,000';
|
52
52
|
}
|
53
53
|
}, [product === null || product === void 0 ? void 0 : product.price, product === null || product === void 0 ? void 0 : product.currency]);
|
54
|
-
const width = isPreview ? 375 :
|
54
|
+
const width = isPreview ? 375 : window.innerWidth;
|
55
55
|
const renderContent = ({ isPost }) => {
|
56
56
|
var _a, _b, _c;
|
57
57
|
return (React.createElement("div", null,
|
@@ -71,7 +71,7 @@ const CommodityDetail = (_a) => {
|
|
71
71
|
};
|
72
72
|
return (React.createElement("div", { className: 'pb-commondity' },
|
73
73
|
React.createElement("div", Object.assign({ className: css(Object.assign({}, style)) }, props),
|
74
|
-
product && ((
|
74
|
+
product && ((_f = product === null || product === void 0 ? void 0 : product.homePage) === null || _f === void 0 ? void 0 : _f.length) > 0 && (React.createElement(Swiper, { height: width, modules: [Pagination, Autoplay], pagination: {
|
75
75
|
clickable: true,
|
76
76
|
bulletActiveClass: 'swipe-item-active-bullet',
|
77
77
|
clickableClass: (swiper === null || swiper === void 0 ? void 0 : swiper.dotsAlign) === 'left'
|
@@ -79,7 +79,7 @@ const CommodityDetail = (_a) => {
|
|
79
79
|
: 'commondityDetail-swiper-clickable-center'
|
80
80
|
}, loop: true, autoplay: {
|
81
81
|
delay: (swiper === null || swiper === void 0 ? void 0 : swiper.delay) * 1000
|
82
|
-
} }, (
|
82
|
+
} }, (_g = product === null || product === void 0 ? void 0 : product.homePage) === null || _g === void 0 ? void 0 : _g.map((src) => {
|
83
83
|
return (React.createElement(SwiperSlide, { key: src },
|
84
84
|
React.createElement("div", { style: {
|
85
85
|
overflow: 'hidden',
|
@@ -88,7 +88,7 @@ const CommodityDetail = (_a) => {
|
|
88
88
|
} },
|
89
89
|
React.createElement(FormatImage, { style: { height: '100%', width: '100%', objectFit: 'cover', display: 'block' }, src: src }))));
|
90
90
|
}))),
|
91
|
-
!((
|
91
|
+
!((_h = product === null || product === void 0 ? void 0 : product.homePage) === null || _h === void 0 ? void 0 : _h.length) && (React.createElement("div", { className: css({
|
92
92
|
position: 'relative',
|
93
93
|
height: 0,
|
94
94
|
width: '100%',
|
@@ -101,7 +101,7 @@ const CommodityDetail = (_a) => {
|
|
101
101
|
top: 0,
|
102
102
|
objectFit: 'cover',
|
103
103
|
width: '100%'
|
104
|
-
}), src: (
|
104
|
+
}), src: (_j = sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.bottom_image) !== null && _j !== void 0 ? _j : bottom_image, alt: '' }))),
|
105
105
|
React.createElement("div", { className: 'pb-commondity-content' }, renderContent({ isPost }))),
|
106
106
|
renderBtn(),
|
107
107
|
React.createElement(Modal, { visible: showModal, onClose: () => setShowModal(false) },
|