zz-shopify-components 0.0.27 → 0.0.28-beta.10

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.
Files changed (83) hide show
  1. package/CHANGELOG.md +21 -21
  2. package/README.md +70 -56
  3. package/assets/ScrollTrigger.min.js +11 -11
  4. package/assets/gsap.min.js +11 -11
  5. package/assets/jquery.js +2 -2
  6. package/assets/lazy-video.js +2 -2
  7. package/assets/lazyload.min.js +1 -1
  8. package/assets/lozad.js +10 -10
  9. package/assets/site-jump.js +52 -52
  10. package/assets/site-jumpV2.js +35 -35
  11. package/assets/swiper-bundle.min.css +12 -12
  12. package/assets/swiper-bundle.min.js +13 -13
  13. package/assets/swiper.css +330 -330
  14. package/assets/zz-components.css +322 -322
  15. package/assets/zz-components.js +166 -166
  16. package/assets/zz-fade-in-content.js +169 -169
  17. package/assets/zz-http-request.js +73 -73
  18. package/assets/zz-world-video-comments-dialog.js +240 -240
  19. package/assets/zz-world-video-dialog.js +190 -190
  20. package/assets/zz-world-video-list.js +317 -317
  21. package/assets/zz-world-video.js +270 -270
  22. package/blocks/zz-accessories-item.liquid +188 -188
  23. package/blocks/zz-accessories-swiper.liquid +223 -223
  24. package/blocks/zz-button.liquid +216 -216
  25. package/blocks/zz-content-description-html.liquid +201 -201
  26. package/blocks/zz-content-description.liquid +209 -209
  27. package/blocks/zz-flex-layout-bg-block.liquid +524 -524
  28. package/blocks/zz-flex-layout-block.liquid +549 -549
  29. package/blocks/zz-flex-layout-widget.liquid +321 -321
  30. package/blocks/zz-full-screen-swiper.liquid +443 -443
  31. package/blocks/zz-icon.liquid +46 -46
  32. package/blocks/zz-mail.liquid +135 -135
  33. package/blocks/zz-mb-swiper-pc-flex.liquid +273 -273
  34. package/blocks/zz-price-tag-mini.liquid +106 -106
  35. package/blocks/zz-price-tag.liquid +41 -41
  36. package/blocks/zz-ratio-image.liquid +181 -181
  37. package/blocks/zz-ratio-video.liquid +115 -115
  38. package/blocks/zz-responsive-width-image.liquid +222 -222
  39. package/blocks/zz-responsive-width-video.liquid +166 -166
  40. package/blocks/zz-scroll-animate-bg-text.liquid +268 -268
  41. package/blocks/zz-scroll-cover.liquid +67 -67
  42. package/blocks/zz-tag.liquid +50 -50
  43. package/blocks/zz-text.liquid +227 -227
  44. package/blocks/zz-title.liquid +287 -287
  45. package/blocks/zz-video-button.liquid +84 -84
  46. package/blocks/zz-video-img-item.liquid +203 -203
  47. package/blocks/zz-video-img-list.liquid +166 -166
  48. package/blocks/zz-video-swiper-perview-item.liquid +221 -221
  49. package/blocks/zz-video-swiper-perview.liquid +585 -585
  50. package/blocks/zz-world-video.liquid +639 -639
  51. package/component.config.json +7 -7
  52. package/package.json +1 -1
  53. package/scripts/postinstall-v1.js +39 -39
  54. package/scripts/postinstall-v2.js +47 -47
  55. package/scripts/postinstall-v3.js +51 -51
  56. package/scripts/publish-npm.js +43 -43
  57. package/sections/zz-flex-layout-section.liquid +269 -269
  58. package/sections/zz-navigation-tab-v3.liquid +409 -409
  59. package/sections/zz-navigation-tab.liquid +411 -411
  60. package/sections/zz-shopping-card-list.liquid +399 -399
  61. package/sections/zz-video-collapse-swiper.liquid +522 -522
  62. package/sections/zz-video-tab-swiper.liquid +748 -748
  63. package/snippets/zz-button.liquid +70 -70
  64. package/snippets/zz-content-h3.liquid +15 -15
  65. package/snippets/zz-content-text.liquid +56 -56
  66. package/snippets/zz-h2.liquid +31 -31
  67. package/snippets/zz-h3.liquid +31 -31
  68. package/snippets/zz-h4.liquid +30 -30
  69. package/snippets/zz-h5.liquid +39 -39
  70. package/snippets/zz-h6.liquid +39 -39
  71. package/snippets/zz-icon-next.liquid +17 -17
  72. package/snippets/zz-icon-prev.liquid +17 -17
  73. package/snippets/zz-icon.liquid +74 -74
  74. package/snippets/zz-img-md.liquid +44 -44
  75. package/snippets/zz-img.liquid +44 -44
  76. package/snippets/zz-prev-next-blur-icon.liquid +36 -36
  77. package/snippets/zz-prev-next-btn.liquid +62 -62
  78. package/snippets/zz-price-tag.liquid +22 -22
  79. package/snippets/zz-spoke.liquid +142 -142
  80. package/snippets/zz-tag.liquid +22 -22
  81. package/snippets/zz-video-button.liquid +54 -54
  82. package/snippets/zz-video-md.liquid +117 -117
  83. package/snippets/zz-video.liquid +117 -117
@@ -1,270 +1,270 @@
1
- class WorldVideo extends HTMLElement {
2
- constructor() {
3
- super();
4
- this.init();
5
- }
6
-
7
- init() {
8
- this.initSiteJump();
9
- // 初始化详情按钮
10
- this.initCommentsAction();
11
- this.initVideoAction();
12
- this.initCloseModal();
13
- }
14
-
15
- initSiteJump() {
16
- const productLinks = decodeURIComponent(this.dataset.productLinks).replace(
17
- /\+/g,
18
- ' '
19
- );
20
-
21
- // 去掉productLinks 里面 + 号
22
- this.querySelectorAll('.world-video-learn-more').forEach((item) => {
23
- item.addEventListener('click', (event) => {
24
- const productType =
25
- event.currentTarget.getAttribute('data-product-type');
26
- dataLayer.push({
27
- event: 'world_video_learn_more',
28
- timestamp: new Date().toISOString(),
29
- productType: productType,
30
- });
31
- });
32
- bindSiteJump(item, productLinks);
33
- });
34
- }
35
- initVideoAction() {
36
- const video = this.querySelector('.video-player');
37
- const videoPlayBtn = this.querySelector('.video-play-btn');
38
- const playPauseBtn = this.querySelector('.play-pause');
39
- const progressBar = this.querySelector('.progress-bar');
40
- const progressContainer = this.querySelector('.progress-container');
41
- const controlsContainer = this.querySelector('.controls-container');
42
- const volumeBtn = this.querySelector('.volume-btn');
43
- const mbVolumeBtn = this.querySelector('.mb-word-video-volume-btn');
44
- const currentTimeDisplay = this.querySelector('.current-time');
45
- const totalTimeDisplay = this.querySelector('.total-time');
46
- const overlay = this.querySelector('.overlay');
47
- this.video = video;
48
- if (window.innerWidth > 1024) {
49
- // 播放/暂停
50
- playPauseBtn.addEventListener('click', () => {
51
- if (video.paused) {
52
- video.play();
53
- } else {
54
- video.pause();
55
- }
56
- });
57
- } else {
58
- overlay.addEventListener('click', () => {
59
- if (video.paused) {
60
- video.play();
61
- } else {
62
- video.pause();
63
- }
64
- });
65
- videoPlayBtn.addEventListener('click', () => {
66
- video.play();
67
- videoPlayBtn.style.display = 'none';
68
- });
69
- }
70
-
71
- // 进度条拖动功能
72
- let isDragging = false;
73
- // 更新进度条
74
- video.addEventListener('timeupdate', () => {
75
- if (isDragging) return;
76
- const progress = (video.currentTime / video.duration) * 100;
77
- progressBar.style.width = `${progress}%`;
78
- currentTimeDisplay.textContent = formatTime(video.currentTime);
79
- });
80
-
81
- // 更新视频时间的函数
82
- function updateVideoTime(e) {
83
- const rect = progressContainer.getBoundingClientRect();
84
- const clientX = e.clientX || (e.touches && e.touches[0].clientX);
85
- const pos = Math.max(0, Math.min(1, (clientX - rect.left) / rect.width));
86
- video.currentTime = pos * video.duration;
87
- progressBar.style.width = `${pos * 100}%`;
88
- }
89
-
90
- // 鼠标事件
91
- progressContainer.addEventListener('mousedown', (e) => {
92
- e.stopPropagation();
93
- isDragging = true;
94
- progressContainer.classList.add('dragging');
95
- overlay.classList.add('hidden');
96
- updateVideoTime(e);
97
- });
98
-
99
- progressContainer.addEventListener('mousemove', (e) => {
100
- // 阻止冒泡
101
- e.stopPropagation();
102
- if (!isDragging) return;
103
- updateVideoTime(e);
104
- });
105
-
106
- document.addEventListener('mouseup', () => {
107
- progressContainer.classList.remove('dragging');
108
- setTimeout(() => {
109
- overlay.classList.remove('hidden');
110
- isDragging = false;
111
- }, 500);
112
- });
113
-
114
- // 触摸事件
115
- progressContainer.addEventListener('touchstart', (e) => {
116
- isDragging = true;
117
- progressContainer.classList.add('dragging');
118
- overlay.classList.add('hidden');
119
- updateVideoTime(e);
120
- });
121
-
122
- document.addEventListener('touchmove', (e) => {
123
- if (!isDragging) return;
124
- e.preventDefault();
125
- updateVideoTime(e);
126
- });
127
-
128
- document.addEventListener('touchend', () => {
129
- progressContainer.classList.remove('dragging');
130
- setTimeout(() => {
131
- overlay.classList.remove('hidden');
132
- isDragging = false;
133
- }, 500);
134
- });
135
-
136
- volumeBtn.addEventListener('click', (e) => {
137
- e.stopPropagation();
138
- if (video.muted === false) {
139
- video.muted = true;
140
- } else {
141
- video.muted = false;
142
- }
143
- updateVolumeIcon();
144
- });
145
-
146
- mbVolumeBtn.addEventListener('click', (e) => {
147
- e.stopPropagation();
148
- if (video.muted === false) {
149
- video.muted = true;
150
- } else {
151
- video.muted = false;
152
- }
153
-
154
- updateVolumeIcon();
155
- });
156
- function updateVolumeIcon() {
157
- let volumeIcon = '';
158
- if (video.muted) {
159
- volumeIcon = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
160
- <path d="M12.7271 6.92578C13.7191 7.58537 14.3729 8.71327 14.3729 9.99388C14.3729 11.2745 13.7191 12.4024 12.7271 13.062" stroke="white" stroke-width="1.15381" stroke-linecap="round"/>
161
- <path d="M14.7729 4.91113C16.4168 6.00409 17.5001 7.87303 17.5001 9.99501C17.5001 12.117 16.4168 13.9859 14.7729 15.0789" stroke="white" stroke-width="1.15381" stroke-linecap="round"/>
162
- <path d="M3.50098 3.79785L15.8753 16.1722" stroke="white" stroke-width="1.25" stroke-linecap="round"/>
163
- <path d="M10 12.5468V16.4891C9.9997 17.1018 9.25411 17.4031 8.82812 16.9628L5.22754 13.2372H1.93164C1.5553 13.2371 1.25022 12.9319 1.25 12.5555V7.43153C1.25 7.05503 1.55517 6.74997 1.93164 6.74988H4.20312L10 12.5468ZM8.82812 3.0243C9.25423 2.58404 10 2.88606 10 3.49891V10.4257L5.76562 6.19129L8.82812 3.0243Z" fill="white"/>
164
- </svg>
165
- `;
166
- } else {
167
- volumeIcon = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
168
- <path d="M1.25 7.43155C1.25 7.05501 1.55525 6.74976 1.9318 6.74976H5.2272L8.82779 3.02494C9.25384 2.58419 9.9998 2.8858 9.9998 3.49881V16.4891C9.9998 17.1021 9.25375 17.4037 8.82773 16.9629L5.2272 13.2373H1.9318C1.55525 13.2373 1.25 12.932 1.25 12.5555V7.43155Z" fill="white"/>
169
- <path d="M12.7271 6.92578C13.7191 7.58537 14.3729 8.71327 14.3729 9.99388C14.3729 11.2745 13.7191 12.4024 12.7271 13.062" stroke="white" stroke-width="1.15381" stroke-linecap="round"/>
170
- <path d="M14.7729 4.91016C16.4168 6.00311 17.5001 7.87205 17.5001 9.99403C17.5001 12.116 16.4168 13.9849 14.7729 15.0779" stroke="white" stroke-width="1.15381" stroke-linecap="round"/>
171
- </svg>
172
- `;
173
- }
174
- mbVolumeBtn.innerHTML = volumeIcon;
175
- volumeBtn.innerHTML = volumeIcon;
176
- }
177
-
178
- // 格式化时间
179
- function formatTime(seconds) {
180
- const minutes = Math.floor(seconds / 60);
181
- seconds = Math.floor(seconds % 60);
182
- return `${minutes}:${seconds.toString().padStart(2, '0')}`;
183
- }
184
-
185
- // 设置总时长
186
- video.addEventListener('loadedmetadata', () => {
187
- totalTimeDisplay.textContent = formatTime(video.duration);
188
- updateVolumeIcon();
189
- });
190
- video.addEventListener('loadeddata', () => {
191
- if (video.duration) {
192
- totalTimeDisplay.textContent = formatTime(video.duration);
193
- }
194
- });
195
- // 播放时添加样式
196
- video.addEventListener('play', () => {
197
- videoPlayBtn.style.display = 'none';
198
- playPauseBtn.innerHTML = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
199
- <rect x="6.6001" y="5.09961" width="3.6" height="13.8" rx="0.9" fill="white"/>
200
- <rect x="13.7998" y="5.09961" width="3.6" height="13.8" rx="0.9" fill="white"/>
201
- </svg>`;
202
- });
203
-
204
- // 暂停时添加样式
205
- video.addEventListener('pause', () => {
206
- if (window.innerWidth < 1024) {
207
- videoPlayBtn.style.display = 'block';
208
- }
209
- playPauseBtn.innerHTML = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
210
- <path fill-rule="evenodd" clip-rule="evenodd" d="M19.2216 10.4612C20.3819 11.159 20.3819 12.841 19.2216 13.5388L10.2294 18.9463C9.03257 19.666 7.50836 18.804 7.50836 17.4075L7.50836 6.59251C7.50836 5.19597 9.03257 4.33398 10.2294 5.05368L19.2216 10.4612Z" fill="white"/>
211
- </svg>`;
212
- });
213
-
214
- // 添加视频错误处理
215
- video.addEventListener('error', (e) => {
216
- console.error('视频加载错误:', e);
217
- if (window.innerWidth < 1024) {
218
- videoPlayBtn.style.display = 'block';
219
- }
220
- playPauseBtn.innerHTML = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
221
- <path fill-rule="evenodd" clip-rule="evenodd" d="M19.2216 10.4612C20.3819 11.159 20.3819 12.841 19.2216 13.5388L10.2294 18.9463C9.03257 19.666 7.50836 18.804 7.50836 17.4075L7.50836 6.59251C7.50836 5.19597 9.03257 4.33398 10.2294 5.05368L19.2216 10.4612Z" fill="white"/>
222
- </svg>`;
223
- });
224
-
225
- // 确保视频加载完成后设置总时长
226
- if (video.readyState >= 2) {
227
- totalTimeDisplay.textContent = formatTime(video.duration);
228
- }
229
- }
230
- initCloseModal() {
231
- const closeBtn = this.querySelector('.mb-close-modal-btn');
232
- closeBtn.addEventListener('click', () => {
233
- document.querySelector('world-video-dialog').closeModal();
234
- });
235
- }
236
-
237
- initCommentsAction() {
238
- const commentBtns = this.querySelectorAll('.video-comments-btn');
239
- if (commentBtns) {
240
- commentBtns.forEach((item) => {
241
- item.addEventListener('click', (event) => {
242
- event.stopPropagation();
243
- const id = event.currentTarget.getAttribute('data-id');
244
-
245
- const dialog = this.querySelector('world-video-comments-dialog');
246
- if (dialog) {
247
- dialog.showModal(id);
248
- }
249
- dataLayer.push({
250
- event: 'world-video-comments',
251
- timestamp: new Date().toISOString(),
252
- });
253
- });
254
- });
255
- }
256
- const likeBtns = this.querySelectorAll('.video-like-btn');
257
- if (likeBtns) {
258
- likeBtns.forEach((item) => {
259
- item.addEventListener('click', (event) => {
260
- event.stopPropagation();
261
- dataLayer.push({
262
- event: 'world-video-like',
263
- timestamp: new Date().toISOString(),
264
- });
265
- });
266
- });
267
- }
268
- }
269
- }
270
- customElements.define('world-video', WorldVideo);
1
+ class WorldVideo extends HTMLElement {
2
+ constructor() {
3
+ super();
4
+ this.init();
5
+ }
6
+
7
+ init() {
8
+ this.initSiteJump();
9
+ // 初始化详情按钮
10
+ this.initCommentsAction();
11
+ this.initVideoAction();
12
+ this.initCloseModal();
13
+ }
14
+
15
+ initSiteJump() {
16
+ const productLinks = decodeURIComponent(this.dataset.productLinks).replace(
17
+ /\+/g,
18
+ ' '
19
+ );
20
+
21
+ // 去掉productLinks 里面 + 号
22
+ this.querySelectorAll('.world-video-learn-more').forEach((item) => {
23
+ item.addEventListener('click', (event) => {
24
+ const productType =
25
+ event.currentTarget.getAttribute('data-product-type');
26
+ dataLayer.push({
27
+ event: 'world_video_learn_more',
28
+ timestamp: new Date().toISOString(),
29
+ productType: productType,
30
+ });
31
+ });
32
+ bindSiteJump(item, productLinks);
33
+ });
34
+ }
35
+ initVideoAction() {
36
+ const video = this.querySelector('.video-player');
37
+ const videoPlayBtn = this.querySelector('.video-play-btn');
38
+ const playPauseBtn = this.querySelector('.play-pause');
39
+ const progressBar = this.querySelector('.progress-bar');
40
+ const progressContainer = this.querySelector('.progress-container');
41
+ const controlsContainer = this.querySelector('.controls-container');
42
+ const volumeBtn = this.querySelector('.volume-btn');
43
+ const mbVolumeBtn = this.querySelector('.mb-word-video-volume-btn');
44
+ const currentTimeDisplay = this.querySelector('.current-time');
45
+ const totalTimeDisplay = this.querySelector('.total-time');
46
+ const overlay = this.querySelector('.overlay');
47
+ this.video = video;
48
+ if (window.innerWidth > 1024) {
49
+ // 播放/暂停
50
+ playPauseBtn.addEventListener('click', () => {
51
+ if (video.paused) {
52
+ video.play();
53
+ } else {
54
+ video.pause();
55
+ }
56
+ });
57
+ } else {
58
+ overlay.addEventListener('click', () => {
59
+ if (video.paused) {
60
+ video.play();
61
+ } else {
62
+ video.pause();
63
+ }
64
+ });
65
+ videoPlayBtn.addEventListener('click', () => {
66
+ video.play();
67
+ videoPlayBtn.style.display = 'none';
68
+ });
69
+ }
70
+
71
+ // 进度条拖动功能
72
+ let isDragging = false;
73
+ // 更新进度条
74
+ video.addEventListener('timeupdate', () => {
75
+ if (isDragging) return;
76
+ const progress = (video.currentTime / video.duration) * 100;
77
+ progressBar.style.width = `${progress}%`;
78
+ currentTimeDisplay.textContent = formatTime(video.currentTime);
79
+ });
80
+
81
+ // 更新视频时间的函数
82
+ function updateVideoTime(e) {
83
+ const rect = progressContainer.getBoundingClientRect();
84
+ const clientX = e.clientX || (e.touches && e.touches[0].clientX);
85
+ const pos = Math.max(0, Math.min(1, (clientX - rect.left) / rect.width));
86
+ video.currentTime = pos * video.duration;
87
+ progressBar.style.width = `${pos * 100}%`;
88
+ }
89
+
90
+ // 鼠标事件
91
+ progressContainer.addEventListener('mousedown', (e) => {
92
+ e.stopPropagation();
93
+ isDragging = true;
94
+ progressContainer.classList.add('dragging');
95
+ overlay.classList.add('hidden');
96
+ updateVideoTime(e);
97
+ });
98
+
99
+ progressContainer.addEventListener('mousemove', (e) => {
100
+ // 阻止冒泡
101
+ e.stopPropagation();
102
+ if (!isDragging) return;
103
+ updateVideoTime(e);
104
+ });
105
+
106
+ document.addEventListener('mouseup', () => {
107
+ progressContainer.classList.remove('dragging');
108
+ setTimeout(() => {
109
+ overlay.classList.remove('hidden');
110
+ isDragging = false;
111
+ }, 500);
112
+ });
113
+
114
+ // 触摸事件
115
+ progressContainer.addEventListener('touchstart', (e) => {
116
+ isDragging = true;
117
+ progressContainer.classList.add('dragging');
118
+ overlay.classList.add('hidden');
119
+ updateVideoTime(e);
120
+ });
121
+
122
+ document.addEventListener('touchmove', (e) => {
123
+ if (!isDragging) return;
124
+ e.preventDefault();
125
+ updateVideoTime(e);
126
+ });
127
+
128
+ document.addEventListener('touchend', () => {
129
+ progressContainer.classList.remove('dragging');
130
+ setTimeout(() => {
131
+ overlay.classList.remove('hidden');
132
+ isDragging = false;
133
+ }, 500);
134
+ });
135
+
136
+ volumeBtn.addEventListener('click', (e) => {
137
+ e.stopPropagation();
138
+ if (video.muted === false) {
139
+ video.muted = true;
140
+ } else {
141
+ video.muted = false;
142
+ }
143
+ updateVolumeIcon();
144
+ });
145
+
146
+ mbVolumeBtn.addEventListener('click', (e) => {
147
+ e.stopPropagation();
148
+ if (video.muted === false) {
149
+ video.muted = true;
150
+ } else {
151
+ video.muted = false;
152
+ }
153
+
154
+ updateVolumeIcon();
155
+ });
156
+ function updateVolumeIcon() {
157
+ let volumeIcon = '';
158
+ if (video.muted) {
159
+ volumeIcon = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
160
+ <path d="M12.7271 6.92578C13.7191 7.58537 14.3729 8.71327 14.3729 9.99388C14.3729 11.2745 13.7191 12.4024 12.7271 13.062" stroke="white" stroke-width="1.15381" stroke-linecap="round"/>
161
+ <path d="M14.7729 4.91113C16.4168 6.00409 17.5001 7.87303 17.5001 9.99501C17.5001 12.117 16.4168 13.9859 14.7729 15.0789" stroke="white" stroke-width="1.15381" stroke-linecap="round"/>
162
+ <path d="M3.50098 3.79785L15.8753 16.1722" stroke="white" stroke-width="1.25" stroke-linecap="round"/>
163
+ <path d="M10 12.5468V16.4891C9.9997 17.1018 9.25411 17.4031 8.82812 16.9628L5.22754 13.2372H1.93164C1.5553 13.2371 1.25022 12.9319 1.25 12.5555V7.43153C1.25 7.05503 1.55517 6.74997 1.93164 6.74988H4.20312L10 12.5468ZM8.82812 3.0243C9.25423 2.58404 10 2.88606 10 3.49891V10.4257L5.76562 6.19129L8.82812 3.0243Z" fill="white"/>
164
+ </svg>
165
+ `;
166
+ } else {
167
+ volumeIcon = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
168
+ <path d="M1.25 7.43155C1.25 7.05501 1.55525 6.74976 1.9318 6.74976H5.2272L8.82779 3.02494C9.25384 2.58419 9.9998 2.8858 9.9998 3.49881V16.4891C9.9998 17.1021 9.25375 17.4037 8.82773 16.9629L5.2272 13.2373H1.9318C1.55525 13.2373 1.25 12.932 1.25 12.5555V7.43155Z" fill="white"/>
169
+ <path d="M12.7271 6.92578C13.7191 7.58537 14.3729 8.71327 14.3729 9.99388C14.3729 11.2745 13.7191 12.4024 12.7271 13.062" stroke="white" stroke-width="1.15381" stroke-linecap="round"/>
170
+ <path d="M14.7729 4.91016C16.4168 6.00311 17.5001 7.87205 17.5001 9.99403C17.5001 12.116 16.4168 13.9849 14.7729 15.0779" stroke="white" stroke-width="1.15381" stroke-linecap="round"/>
171
+ </svg>
172
+ `;
173
+ }
174
+ mbVolumeBtn.innerHTML = volumeIcon;
175
+ volumeBtn.innerHTML = volumeIcon;
176
+ }
177
+
178
+ // 格式化时间
179
+ function formatTime(seconds) {
180
+ const minutes = Math.floor(seconds / 60);
181
+ seconds = Math.floor(seconds % 60);
182
+ return `${minutes}:${seconds.toString().padStart(2, '0')}`;
183
+ }
184
+
185
+ // 设置总时长
186
+ video.addEventListener('loadedmetadata', () => {
187
+ totalTimeDisplay.textContent = formatTime(video.duration);
188
+ updateVolumeIcon();
189
+ });
190
+ video.addEventListener('loadeddata', () => {
191
+ if (video.duration) {
192
+ totalTimeDisplay.textContent = formatTime(video.duration);
193
+ }
194
+ });
195
+ // 播放时添加样式
196
+ video.addEventListener('play', () => {
197
+ videoPlayBtn.style.display = 'none';
198
+ playPauseBtn.innerHTML = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
199
+ <rect x="6.6001" y="5.09961" width="3.6" height="13.8" rx="0.9" fill="white"/>
200
+ <rect x="13.7998" y="5.09961" width="3.6" height="13.8" rx="0.9" fill="white"/>
201
+ </svg>`;
202
+ });
203
+
204
+ // 暂停时添加样式
205
+ video.addEventListener('pause', () => {
206
+ if (window.innerWidth < 1024) {
207
+ videoPlayBtn.style.display = 'block';
208
+ }
209
+ playPauseBtn.innerHTML = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
210
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M19.2216 10.4612C20.3819 11.159 20.3819 12.841 19.2216 13.5388L10.2294 18.9463C9.03257 19.666 7.50836 18.804 7.50836 17.4075L7.50836 6.59251C7.50836 5.19597 9.03257 4.33398 10.2294 5.05368L19.2216 10.4612Z" fill="white"/>
211
+ </svg>`;
212
+ });
213
+
214
+ // 添加视频错误处理
215
+ video.addEventListener('error', (e) => {
216
+ console.error('视频加载错误:', e);
217
+ if (window.innerWidth < 1024) {
218
+ videoPlayBtn.style.display = 'block';
219
+ }
220
+ playPauseBtn.innerHTML = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
221
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M19.2216 10.4612C20.3819 11.159 20.3819 12.841 19.2216 13.5388L10.2294 18.9463C9.03257 19.666 7.50836 18.804 7.50836 17.4075L7.50836 6.59251C7.50836 5.19597 9.03257 4.33398 10.2294 5.05368L19.2216 10.4612Z" fill="white"/>
222
+ </svg>`;
223
+ });
224
+
225
+ // 确保视频加载完成后设置总时长
226
+ if (video.readyState >= 2) {
227
+ totalTimeDisplay.textContent = formatTime(video.duration);
228
+ }
229
+ }
230
+ initCloseModal() {
231
+ const closeBtn = this.querySelector('.mb-close-modal-btn');
232
+ closeBtn.addEventListener('click', () => {
233
+ document.querySelector('world-video-dialog').closeModal();
234
+ });
235
+ }
236
+
237
+ initCommentsAction() {
238
+ const commentBtns = this.querySelectorAll('.video-comments-btn');
239
+ if (commentBtns) {
240
+ commentBtns.forEach((item) => {
241
+ item.addEventListener('click', (event) => {
242
+ event.stopPropagation();
243
+ const id = event.currentTarget.getAttribute('data-id');
244
+
245
+ const dialog = this.querySelector('world-video-comments-dialog');
246
+ if (dialog) {
247
+ dialog.showModal(id);
248
+ }
249
+ dataLayer.push({
250
+ event: 'world-video-comments',
251
+ timestamp: new Date().toISOString(),
252
+ });
253
+ });
254
+ });
255
+ }
256
+ const likeBtns = this.querySelectorAll('.video-like-btn');
257
+ if (likeBtns) {
258
+ likeBtns.forEach((item) => {
259
+ item.addEventListener('click', (event) => {
260
+ event.stopPropagation();
261
+ dataLayer.push({
262
+ event: 'world-video-like',
263
+ timestamp: new Date().toISOString(),
264
+ });
265
+ });
266
+ });
267
+ }
268
+ }
269
+ }
270
+ customElements.define('world-video', WorldVideo);