zz-shopify-components 0.3.1-beta.8 → 0.4.0

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.
@@ -0,0 +1,856 @@
1
+ {% comment %}
2
+ 同时支持video和img的swiper
3
+ {% endcomment %}
4
+
5
+ <style>
6
+ #shopify-section-{{section.id}} {
7
+ padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px;
8
+ padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px;
9
+ }
10
+ #shopify-section-{{section.id}} .swiper-banner-video-img p {
11
+ margin: 0;
12
+ }
13
+
14
+
15
+ @media (min-width: 1024px) {
16
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-wrapper {
17
+ width: 100%;
18
+ height: 660px !important;
19
+ }
20
+
21
+ }
22
+ @media (min-width: 1440px) {
23
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-wrapper {
24
+ width: 100%;
25
+ height: 760px !important;
26
+ }
27
+
28
+ }
29
+ @media (min-width: 1536px) {
30
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-wrapper {
31
+ width: 100%;
32
+ height: 860px !important;
33
+ }
34
+
35
+ }
36
+
37
+ #shopify-section-{{section.id}} .swiper-banner-video-img {
38
+ margin-top: -50px;
39
+ width: 100%;
40
+ letter-spacing: 0;
41
+ }
42
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-pagination-bullet {
43
+ position: relative;
44
+ background-color: rgba(255, 255, 255, 0.3);
45
+ width: 48px;
46
+ height: 4px;
47
+ border-radius: 10px;
48
+ opacity: 1;
49
+ }
50
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-pagination-bullet-active {
51
+ width: 120px;
52
+ /* background-color: #fff; */
53
+ }
54
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-button-next {
55
+ right: 20px;
56
+ }
57
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-button-prev {
58
+ left: 20px;
59
+ }
60
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-button-next,
61
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-button-prev {
62
+ position: absolute;
63
+ display: block;
64
+ width: 48px;
65
+ height: 48px;
66
+ text-align: center;
67
+ cursor: pointer;
68
+
69
+ }
70
+
71
+ #shopify-section-{{section.id}} .zz-swiper-banner-img-video {
72
+ width: 100% !important;
73
+ height: 100% !important;
74
+ object-fit: cover !important;
75
+ }
76
+
77
+ #shopify-section-{{section.id}} .swiper-button-next:after,
78
+ #shopify-section-{{section.id}} .swiper-button-prev:after{
79
+ display:none;
80
+ }
81
+
82
+ #shopify-section-{{section.id}} .swiper-horizontal>.swiper-pagination-bullets, .swiper-pagination-bullets.swiper-pagination-horizontal{
83
+ bottom:30px;
84
+ }
85
+
86
+
87
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-pagination-bullets .progress-bar {
88
+ position: absolute;
89
+ top: 0;
90
+ left: 0;
91
+ width: 0;
92
+ height: 4px;
93
+ background: #fff;
94
+ border-radius: 10px;
95
+ }
96
+
97
+
98
+ @media (max-width: 1024px) {
99
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-wrapper {
100
+ width: 100%;
101
+ aspect-ratio: 375 / 576;
102
+ }
103
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-button-next,
104
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-button-prev {
105
+ display: none;
106
+ }
107
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-pagination-bullet {
108
+ width: 24px;
109
+ height: 3px;
110
+ border-radius: 10px;
111
+ }
112
+ #shopify-section-{{section.id}} .swiper-banner-video-img .swiper-pagination-bullet-active {
113
+ width: 48px;
114
+ }
115
+ #shopify-section-{{section.id}} .swiper-horizontal>.swiper-pagination-bullets .progress-bar {
116
+ position: absolute;
117
+ top: 0;
118
+ left: 0;
119
+ width: 0;
120
+ height: 3px;
121
+ background: #fff;
122
+ }
123
+ }
124
+ </style>
125
+ {% schema %}
126
+ {
127
+ "name": "Swiper Banner V3",
128
+ "settings": [
129
+ {
130
+ "type": "range",
131
+ "id": "padding_top",
132
+ "min": 0,
133
+ "max": 100,
134
+ "step": 4,
135
+ "unit": "px",
136
+ "label": "t:sections.all.padding.padding_top",
137
+ "default": 0
138
+ },
139
+ {
140
+ "type": "range",
141
+ "id": "padding_bottom",
142
+ "min": 0,
143
+ "max": 100,
144
+ "step": 4,
145
+ "unit": "px",
146
+ "label": "t:sections.all.padding.padding_bottom",
147
+ "default": 0
148
+ }
149
+ ],
150
+ "blocks": [
151
+ {
152
+ "name": "BannerImg",
153
+ "type": "img",
154
+ "settings": [
155
+ {
156
+ "type": "select",
157
+ "id": "theme",
158
+ "label": "Header 主题变化",
159
+ "info": "当前banner对应的header主题变化",
160
+ "options": [
161
+ {
162
+ "value": "dark",
163
+ "label": "Dark"
164
+ },
165
+ {
166
+ "value": "light",
167
+ "label": "Light"
168
+ }
169
+ ]
170
+ },
171
+ {
172
+ "type": "textarea",
173
+ "id": "linksbanner",
174
+ "label": "Sites Link Map banner",
175
+ "info": "国家对应链接的表,国家即是国家选择器上显示的字段,国家和路由之间用冒号隔开( 冒号后要加空格)。国家之间换行,“default”为其他未写的默认的链接 EG: Canada: https://hoverair.com/ default: https://hoverair.com/ "
176
+ },
177
+ {
178
+ "type": "select",
179
+ "id": "desc_text_type",
180
+ "label": "描述文字类型",
181
+ "options": [
182
+
183
+ {
184
+ "value": "text",
185
+ "label": "文字,需要填写大小标题"
186
+ },
187
+ {
188
+ "value": "image",
189
+ "label": "图片,需要传标题图片"
190
+ },
191
+ ],
192
+ "default": "text"
193
+ },
194
+ {
195
+ "type": "richtext",
196
+ "id": "title",
197
+ "label": "大标题",
198
+ "visible_if": "{{ block.settings.desc_text_type == 'text' }}"
199
+ },
200
+ {
201
+ "type": "richtext",
202
+ "id": "title_mb",
203
+ "label": "大标题 Mobile",
204
+ "visible_if": "{{ block.settings.desc_text_type == 'text' }}"
205
+ },
206
+ {
207
+ "type": "richtext",
208
+ "id": "subtitle",
209
+ "label": "小标题",
210
+ "visible_if": "{{ block.settings.desc_text_type == 'text' }}"
211
+ },
212
+ {
213
+ "type": "richtext",
214
+ "id": "subtitle_mb",
215
+ "label": "小标题 Mobile",
216
+ "visible_if": "{{ block.settings.desc_text_type == 'text' }}"
217
+ },
218
+ {
219
+ "type": "color",
220
+ "id": "color",
221
+ "label": "Text Color",
222
+ "info": "文本颜色",
223
+ "visible_if": "{{ block.settings.desc_text_type == 'text' }}"
224
+ },
225
+ {
226
+ "type": "image_picker",
227
+ "id": "banner_desc",
228
+ "label": "Banner上悬浮标题图",
229
+ "visible_if": "{{ block.settings.desc_text_type == 'image' }}"
230
+ },
231
+ {
232
+ "type": "image_picker",
233
+ "id": "banner_desc_mb",
234
+ "label": "Banner上悬浮标题图 Mobile",
235
+ "visible_if": "{{ block.settings.desc_text_type == 'image' }}"
236
+ },
237
+
238
+ {
239
+ "type": "number",
240
+ "id": "top_mb",
241
+ "default": 90,
242
+ "label": "移动端顶部距离",
243
+ "info": "移动端文案距离顶部距离 单位PX"
244
+ },
245
+ {
246
+ "type": "image_picker",
247
+ "id": "banner",
248
+ "label": "Banner PC"
249
+ },
250
+ {
251
+ "type": "image_picker",
252
+ "id": "banner_mb",
253
+ "label": "Banner Mobile"
254
+ },
255
+ {
256
+ "type": "text",
257
+ "id": "btn_text",
258
+ "label": "按钮文字",
259
+ "default": "learn more"
260
+ },
261
+ {
262
+ "type": "select",
263
+ "id": "function_type",
264
+ "label": "功能类型",
265
+ "options": [
266
+ {
267
+ "value": "link",
268
+ "label": "链接"
269
+ },
270
+ {
271
+ "value": "link_map",
272
+ "label": "多国家映射"
273
+ },
274
+ ],
275
+ "default": "link"
276
+ },
277
+ {
278
+ "type": "textarea",
279
+ "id": "links",
280
+ "label": "Sites Link Map",
281
+ "info": "国家对应链接的表,国家即是国家选择器上显示的字段,国家和路由之间用冒号隔开( 冒号后要加空格)。国家之间换行,“default”为其他未写的默认的链接 EG: Canada: https://hoverair.com/ default: https://hoverair.com/ ",
282
+ "visible_if": "{{ block.settings.function_type == 'link_map' }}"
283
+ },
284
+ {
285
+ "type": "url",
286
+ "id": "link",
287
+ "label": "Normal Button Link",
288
+ "info": "普通按钮跳转地址",
289
+ "visible_if": "{{ block.settings.function_type == 'link' }}"
290
+ },
291
+ {
292
+ "type": "color",
293
+ "id": "btn_border_color",
294
+ "label": "Button Border Color",
295
+ "info": "按钮的边框颜色"
296
+ },
297
+ {
298
+ "type": "color",
299
+ "id": "btn_background_color",
300
+ "label": "Button Background Color",
301
+ "info": "按钮的背景颜色"
302
+ },
303
+ {
304
+ "type": "color",
305
+ "id": "btn_color",
306
+ "label": "Button Text Color",
307
+ "info": "按钮的文本颜色"
308
+ }
309
+ ]
310
+ },
311
+ {
312
+ "name": "BannerVideo",
313
+ "type": "video",
314
+ "settings": [
315
+ {
316
+ "type": "select",
317
+ "id": "theme",
318
+ "label": "Header 主题变化",
319
+ "info": "当前banner对应的header主题变化",
320
+ "options": [
321
+ {
322
+ "value": "dark",
323
+ "label": "Dark"
324
+ },
325
+ {
326
+ "value": "light",
327
+ "label": "Light"
328
+ }
329
+ ]
330
+ },
331
+ {
332
+ "type": "textarea",
333
+ "id": "linksbanner",
334
+ "label": "Sites Link Map banner",
335
+ "info": "国家对应链接的表,国家即是国家选择器上显示的字段,国家和路由之间用冒号隔开( 冒号后要加空格)。国家之间换行,“default”为其他未写的默认的链接 EG: Canada: https://hoverair.com/ default: https://hoverair.com/ "
336
+ },
337
+ {
338
+ "type": "select",
339
+ "id": "desc_text_type",
340
+ "label": "描述文字类型",
341
+ "options": [
342
+
343
+ {
344
+ "value": "text",
345
+ "label": "文字,需要填写大小标题"
346
+ },
347
+ {
348
+ "value": "image",
349
+ "label": "图片,需要传标题图片"
350
+ },
351
+ ],
352
+ "default": "text"
353
+ },
354
+ {
355
+ "type": "richtext",
356
+ "id": "title",
357
+ "label": "大标题",
358
+ "visible_if": "{{ block.settings.desc_text_type == 'text' }}"
359
+ },
360
+ {
361
+ "type": "richtext",
362
+ "id": "title_mb",
363
+ "label": "大标题 Mobile",
364
+ "visible_if": "{{ block.settings.desc_text_type == 'text' }}"
365
+ },
366
+ {
367
+ "type": "richtext",
368
+ "id": "subtitle",
369
+ "label": "小标题",
370
+ "visible_if": "{{ block.settings.desc_text_type == 'text' }}"
371
+ },
372
+ {
373
+ "type": "richtext",
374
+ "id": "subtitle_mb",
375
+ "label": "小标题 Mobile",
376
+ "visible_if": "{{ block.settings.desc_text_type == 'text' }}"
377
+ },
378
+ {
379
+ "type": "color",
380
+ "id": "color",
381
+ "label": "Text Color",
382
+ "info": "文本颜色",
383
+ "visible_if": "{{ block.settings.desc_text_type == 'text' }}"
384
+ },
385
+ {
386
+ "type": "image_picker",
387
+ "id": "banner_desc",
388
+ "label": "Banner上悬浮标题图",
389
+ "visible_if": "{{ block.settings.desc_text_type == 'image' }}"
390
+ },
391
+ {
392
+ "type": "image_picker",
393
+ "id": "banner_desc_mb",
394
+ "label": "Banner上悬浮标题图 Mobile",
395
+ "visible_if": "{{ block.settings.desc_text_type == 'image' }}"
396
+ },
397
+
398
+ {
399
+ "type": "number",
400
+ "id": "top_mb",
401
+ "default": 90,
402
+ "label": "移动端顶部距离",
403
+ "info": "移动端文案距离顶部距离 单位PX"
404
+ },
405
+ {
406
+ "type": "video",
407
+ "id": "video_pc",
408
+ "label": "video_pc",
409
+ "info": "pc端的视频"
410
+ },
411
+ {
412
+ "type": "text",
413
+ "id": "video_pc_url",
414
+ "label": "video_pc_url",
415
+ "info": "pc段的视频链接"
416
+ },
417
+ {
418
+ "type": "image_picker",
419
+ "id": "posterPc",
420
+ "label": "poster Pc"
421
+ },
422
+ {
423
+ "type": "video",
424
+ "id": "video_mobile",
425
+ "label": "video_mobile",
426
+ "info": "mobile端的视频"
427
+ },
428
+ {
429
+ "type": "text",
430
+ "id": "video_mobile_url",
431
+ "label": "video_mobile_url",
432
+ "info": "mobile端的视频链接"
433
+ },
434
+ {
435
+ "type": "image_picker",
436
+ "id": "posterMb",
437
+ "label": "poster Mb"
438
+ },
439
+ {
440
+ "type": "text",
441
+ "id": "btn_text",
442
+ "label": "按钮文字",
443
+ "default": "learn more"
444
+ },
445
+ {
446
+ "type": "select",
447
+ "id": "function_type",
448
+ "label": "功能类型",
449
+ "options": [
450
+ {
451
+ "value": "link",
452
+ "label": "链接"
453
+ },
454
+ {
455
+ "value": "link_map",
456
+ "label": "多国家映射"
457
+ },
458
+ ],
459
+ "default": "link"
460
+ },
461
+ {
462
+ "type": "textarea",
463
+ "id": "links",
464
+ "label": "Sites Link Map",
465
+ "info": "国家对应链接的表,国家即是国家选择器上显示的字段,国家和路由之间用冒号隔开( 冒号后要加空格)。国家之间换行,“default”为其他未写的默认的链接 EG: Canada: https://hoverair.com/ default: https://hoverair.com/ ",
466
+ "visible_if": "{{ block.settings.function_type == 'link_map' }}"
467
+ },
468
+ {
469
+ "type": "url",
470
+ "id": "link",
471
+ "label": "Normal Button Link",
472
+ "info": "普通按钮跳转地址",
473
+ "visible_if": "{{ block.settings.function_type == 'link' }}"
474
+ },
475
+ {
476
+ "type": "color",
477
+ "id": "btn_border_color",
478
+ "label": "Button Border Color",
479
+ "info": "按钮的边框颜色"
480
+ },
481
+ {
482
+ "type": "color",
483
+ "id": "btn_background_color",
484
+ "label": "Button Background Color",
485
+ "info": "按钮的背景颜色"
486
+ },
487
+ {
488
+ "type": "color",
489
+ "id": "btn_color",
490
+ "label": "Button Text Color",
491
+ "info": "按钮的文本颜色"
492
+ }
493
+ ]
494
+ }
495
+ ],
496
+ "presets": [
497
+ {
498
+ "name": "Swiper Banner V3"
499
+ }
500
+ ]
501
+ }
502
+ {% endschema %}
503
+
504
+
505
+ <div class='swiper swiper-banner-video-img'>
506
+ <div class='swiper-wrapper'>
507
+ {% for banner in section.blocks %}
508
+ <div
509
+ class='swiper-slide tw-h-full'
510
+ data-header-theme='{{ banner.settings.theme }}'
511
+ >
512
+ <div
513
+ id='{{ banner.id }}-bannerlink'
514
+ class='swiper-content tw-w-full tw-max-w-screen tw-relative tw-text-left tw-h-full'
515
+ >
516
+ {%- if banner.type == 'img' -%}
517
+ {% render 'zz-img',
518
+ pc_image: banner.settings.banner,
519
+ mb_image: banner.settings.banner_mb,
520
+ image_alt: banner.settings.title | escape,
521
+ class_name: "zz-swiper-banner-img-video",
522
+ %}
523
+
524
+ {%- elsif banner.type == 'video' -%}
525
+ {% if banner.settings.video_pc_url != blank %}
526
+ {% assign pc_video = banner.settings.video_pc_url %}
527
+ {% else %}
528
+ {% assign pc_video = banner.settings.video_pc %}
529
+ {% endif %}
530
+ {% if banner.settings.video_mobile_url != blank %}
531
+ {% assign mb_video = banner.settings.video_mobile_url %}
532
+ {% else %}
533
+ {% assign mb_video = banner.settings.video_mobile %}
534
+ {% endif %}
535
+ {% render 'zz-video',
536
+ pc_video: pc_video,
537
+ pc_poster: banner.settings.posterPc,
538
+ mb_video: mb_video,
539
+ mb_poster: banner.settings.posterMb,
540
+ class: 'zz-swiper-banner-img-video',
541
+ autoplay: true,
542
+ loop: true,
543
+ muted: true
544
+ %}
545
+ {% endif %}
546
+ <div
547
+ class='tw-absolute lg:tw-left-[50%] lg:tw-top-[50%] lg:tw-translate-x-[-50%] lg:tw-translate-y-[-50%] lg:tw-w-[85vw] xl:tw-w-[1220px] tw-z-10 max-lg:tw-h-full max-lg:tw-top-0 max-lg:tw-left-0 max-lg:tw-w-full max-lg:tw-pt-[90px] tw-box-border max-lg:tw-flex max-lg:tw-flex-col max-lg:tw-items-center'
548
+ >
549
+ <div class='swiper-content-text lg:tw-w-[640px]'>
550
+ {%- if banner.settings.desc_text_type == 'text' -%}
551
+ <div
552
+ class='lg:tw-hidden tw-p-0 tw-leading-[58px] tw-text-[48px] tw-font-bold tw-mb-[24px] max-lg:tw-my-[8px] max-lg:tw-text-[24px] max-lg:tw-leading-[1.2] max-lg:tw-text-center'
553
+ style='color: {{ banner.settings.color | default: 'white' }};'
554
+ >
555
+ {{ banner.settings.title_mb }}
556
+ </div>
557
+ <div
558
+ class='max-lg:tw-hidden tw-p-0 tw-leading-[58px] tw-text-[48px] tw-font-bold tw-mb-[24px] max-lg:tw-my-[8px] max-lg:tw-text-[24px] max-lg:tw-leading-[1.2] max-lg:tw-text-center'
559
+ style='color: {{ banner.settings.color | default: 'white' }};'
560
+ >
561
+ {{ banner.settings.title }}
562
+ </div>
563
+ <div
564
+ class='lg:tw-hidden tw-p-0 tw-m-0 tw-leading-[1.5] tw-text-[28px] tw-font-medium max-lg:tw-text-[14px] max-lg:tw-text-center'
565
+ style='color: {{ banner.settings.color | default: 'white' }}'
566
+ >
567
+ {{ banner.settings.subtitle_mb }}
568
+ </div>
569
+ <div
570
+ class='max-lg:tw-hidden tw-p-0 tw-m-0 tw-leading-[1.5] tw-text-[28px] tw-font-medium max-lg:tw-text-[14px] max-lg:tw-text-center'
571
+ style='color: {{ banner.settings.color | default: 'white' }}'
572
+ >
573
+ {{ banner.settings.subtitle }}
574
+ </div>
575
+ {%- elsif banner.settings.desc_text_type == 'image' -%}
576
+ <div
577
+ class="max-lg:tw-hidden tw-w-[640px]">
578
+ {{
579
+ banner.settings.banner_desc
580
+ | image_url: width: 1280
581
+ | image_tag:
582
+ alt: banner.settings.title,
583
+ class: 'tw-w-full tw-h-auto',
584
+ format: 'webp',
585
+ preload: true,
586
+ fetchpriority:"high"
587
+ }}
588
+
589
+ </div>
590
+ <div
591
+ class="lg:tw-hidden tw-max-w-[480px]">
592
+ {{
593
+ banner.settings.banner_desc_mb
594
+ | image_url: width: 670
595
+ | image_tag:
596
+ alt: banner.settings.title,
597
+ class: 'tw-w-full tw-h-auto',
598
+ format: 'webp',
599
+ preload: true,
600
+ fetchpriority:"high"
601
+ }}
602
+ </div>
603
+ {% endif %}
604
+
605
+
606
+ <div
607
+ class='buttons max-lg:tw-absolute max-lg:tw-bottom-[60px] max-lg:tw-left-[0] max-lg:tw-right-[0] lg:tw-mt-[48px]'
608
+ >
609
+ {%- if banner.settings.function_type == 'link' -%}
610
+ <a
611
+ href='{{ banner.settings.link }}'
612
+ class='tw-w-fit tw-block tw-no-underline tw-h-[48px] max-lg:tw-px-[20px] lg:tw-px-[24px] max-lg:tw-h-[36px] tw-leading-[48px] max-lg:tw-leading-[36px] tw-text-center tw-rounded-full tw-text-[16px] max-lg:tw-text-[13px] max-lg:tw-mx-auto tw-cursor-pointer'
613
+ style='color: {{ banner.settings.btn_color | default: 'black' }}; border: 1px solid {{ banner.settings.btn_border_color | default: 'white' }}; background: {{ banner.settings.btn_background_color | default: 'white' }}'
614
+ >
615
+ {{- banner.settings.btn_text -}}
616
+ </a>
617
+
618
+ {%- elsif banner.settings.function_type == 'link_map' -%}
619
+ <div
620
+ id='{{ banner.id }}-site-btn'
621
+ class='tw-w-fit tw-h-[48px] max-lg:tw-px-[20px] lg:tw-px-[24px] max-lg:tw-h-[36px] tw-leading-[48px] max-lg:tw-leading-[36px] tw-text-center tw-rounded-full tw-text-[16px] max-lg:tw-text-[13px] max-lg:tw-mx-auto tw-cursor-pointer'
622
+ style='color: {{ banner.settings.btn_color | default: 'black' }}; border: 1px solid {{ banner.settings.btn_border_color | default: 'white' }}; background: {{ banner.settings.btn_background_color | default: 'white' }}'
623
+ >
624
+ {{- banner.settings.btn_text -}}
625
+ </div>
626
+ {% endif %}
627
+ </div>
628
+ </div>
629
+ </div>
630
+ </div>
631
+ <script>
632
+ document.addEventListener('DOMContentLoaded', (event) => {
633
+ if(document.getElementById('{{ banner.id }}-site-btn')) {
634
+ bindSiteJump(document.getElementById('{{ banner.id }}-site-btn'), {{ banner.settings.links | json }})
635
+ }
636
+ bindSiteJump(document.getElementById('{{ banner.id }}-bannerlink'), {{ banner.settings.linksbanner | json }})
637
+ })
638
+ </script>
639
+ </div>
640
+ {% endfor %}
641
+ </div>
642
+
643
+ <!-- If we need navigation buttons -->
644
+ <div class='swiper-button-prev'>
645
+ {% render 'zz-prev-next-blur-icon', type: 'prev', color_type: 'light' %}
646
+ </div>
647
+ <div class='swiper-button-next'>
648
+ {% render 'zz-prev-next-blur-icon', type: 'next', color_type: 'light' %}
649
+ </div>
650
+
651
+ <!-- Pagination indicator -->
652
+ <div class='swiper-pagination'></div>
653
+ </div>
654
+
655
+ <script src='{{ 'site-jump.js' | asset_url }}' defer='defer'></script>
656
+
657
+ <script>
658
+ document.addEventListener('DOMContentLoaded', (event) => {
659
+ const VIDEO_IMG_SWIPER = new Swiper('#shopify-section-{{section.id}} .swiper-banner-video-img', {
660
+ loop: true,
661
+ spaceBetween: 0,
662
+ navigation: {
663
+ nextEl: '.swiper-button-next',
664
+ prevEl: '.swiper-button-prev',
665
+ enabled: {% if section.blocks.size > 1 %} true {% else %} false {% endif %}
666
+ },
667
+ pagination: {
668
+ el: '.swiper-pagination',
669
+ clickable: true,
670
+ renderBullet: function (index, className) {
671
+ return `
672
+ <span class="${className}">
673
+ <span class="progress-bar"></span>
674
+ </span>`;
675
+ },
676
+ },
677
+ effect: 'slide',
678
+ on: {
679
+ afterInit: function () {
680
+ const section = document.getElementById('shopify-section-{{section.id}}')
681
+ const allvideo =section.querySelectorAll('video')
682
+ allvideo.forEach((item)=>{
683
+ item.addEventListener('ended', () => {
684
+ // 在这里可以放置你希望在视频播放结束后执行的代码
685
+ setTimeout(() => {
686
+ VIDEO_IMG_SWIPER.slideNext();
687
+ }, 500);
688
+ })
689
+ })
690
+ },
691
+ slideChange: function () {
692
+ const theme = this.slides[this.activeIndex].getAttribute('data-header-theme')
693
+ if(theme) {
694
+ document.querySelector('header-control').setBannerTheme(theme)
695
+ }
696
+ }
697
+ }
698
+ });
699
+
700
+ var timerSwiper = null;
701
+ let progressInterval = null
702
+
703
+ function resetProgress() {
704
+ clearInterval(progressInterval)
705
+ document.querySelectorAll(".swiper-banner-video-img .swiper-pagination-bullet").forEach((bullet) => {
706
+ const progressBar = bullet.querySelector(".progress-bar");
707
+ bullet.style.transition = "0.3s";
708
+ progressBar.style.transition = "none";
709
+ progressBar.style.width = "0";
710
+ });
711
+ }
712
+
713
+ // 判断active dom 是img还是video
714
+ function activeType() {
715
+ var judgeDom = document
716
+ .getElementsByClassName('swiper-banner-video-img')[0]
717
+ .getElementsByClassName('swiper-wrapper')[0]
718
+ .getElementsByClassName('swiper-slide-active')[0]
719
+ .getElementsByClassName('zz-swiper-banner-img-video')[0];
720
+ if (judgeDom.tagName.toLowerCase() === 'video') {
721
+ judgeVideoOrImg = 'video';
722
+ return 'video';
723
+ }
724
+ if (judgeDom.tagName.toLowerCase() === 'img') {
725
+ judgeVideoOrImg = 'img';
726
+ return 'img';
727
+ }
728
+ }
729
+
730
+ {% comment %} 获取当前active的dom的type {% endcomment %}
731
+ var judgeVideoOrImg = activeType();
732
+ // debugger
733
+ console.log('judgeVideoOrImg1',judgeVideoOrImg)
734
+
735
+ {% comment %} 当为video的时候 {% endcomment %}
736
+ if(judgeVideoOrImg==='video'){
737
+
738
+ playit();
739
+ }
740
+ {% comment %} 当为img的时候 {% endcomment %}
741
+ if(judgeVideoOrImg==='img'){
742
+ // console.log('wo shi tup ')
743
+ if(timerSwiper){
744
+ // timerSwiper=null
745
+ clearTimeout(timerSwiper);
746
+ }
747
+ updataMediaProgress('img')
748
+ timerSwiper = setTimeout(function() {
749
+ VIDEO_IMG_SWIPER.slideNext();
750
+ }, 5000);
751
+ }
752
+
753
+
754
+ function updataMediaProgress(type, videoDom) {
755
+ const activeBullet = document.querySelector(".swiper-banner-video-img .swiper-pagination-bullet-active");
756
+ const progressBar = activeBullet.querySelector(".progress-bar");
757
+ if (progressBar) {
758
+ let progress = 0
759
+ if(progressInterval) clearInterval(progressInterval)
760
+ progressInterval = setInterval(() => {
761
+ if(progress >= 1) {
762
+ clearInterval(progressInterval)
763
+ progress = 1
764
+ } else {
765
+ if(type === 'img') {
766
+ progress = 100 / 4800 + progress
767
+ } else {
768
+ progress = videoDom.currentTime / videoDom.duration
769
+ }
770
+ }
771
+ progressBar.style.transition = "0.2s";
772
+ progressBar.style.width = `${(progress) * 100}%`;
773
+ }, 100);
774
+ }
775
+ }
776
+
777
+ // function updataVideoProgress(videoDom) {
778
+ // const activeBullet = document.querySelector(".swiper-banner-video-img .swiper-pagination-bullet-active");
779
+ // const progressBar = activeBullet.querySelector(".progress-bar");
780
+ // if (progressBar) {
781
+ // let progress = 0
782
+ // if(progressInterval) clearInterval(progressInterval)
783
+ // progressInterval = setInterval(() => {
784
+ // if(progress >= 1) {
785
+ // clearInterval(progressInterval)
786
+ // progress = 1
787
+ // } else {
788
+ // }
789
+ // progressBar.style.transition = "0.25s";
790
+ // progressBar.style.width = `${(progress) * 100}%`;
791
+ // }, 200);
792
+ // }
793
+ // }
794
+
795
+ {% comment %} 下一个滑块之后判断类型 {% endcomment %}
796
+ VIDEO_IMG_SWIPER.on('slideChangeTransitionEnd ', function () {
797
+ // console.log('slideChangeTransitionEnd');
798
+ judgeVideoOrImg = activeType();
799
+ if(judgeVideoOrImg==='video'){
800
+ playit();
801
+
802
+ }
803
+ if(judgeVideoOrImg==='img'){
804
+ if(timerSwiper){
805
+ // timerSwiper=null
806
+ clearTimeout(timerSwiper);
807
+ }
808
+ timerSwiper = setTimeout(function() {
809
+ VIDEO_IMG_SWIPER.slideNext();
810
+ }, 5000);
811
+ updataMediaProgress('img')
812
+ }
813
+ })
814
+ {% comment %} 暂停所有的video的播放 {% endcomment %}
815
+ VIDEO_IMG_SWIPER.on('slideChange ', function () {
816
+ resetProgress()
817
+ clearTimeout(timerSwiper);
818
+ endallvideo()
819
+ });
820
+
821
+
822
+
823
+
824
+ {% comment %} 监听当前active video完成 {% endcomment %}
825
+ function playit() {
826
+ // debugger
827
+ // 获取当前激活的slide 的index
828
+ let activeIndex = VIDEO_IMG_SWIPER.activeIndex;
829
+ let active_video = Array.from(
830
+ document
831
+ .getElementsByClassName('swiper-banner-video-img')[0]
832
+ .getElementsByClassName('swiper-wrapper')[0]
833
+ .getElementsByClassName('swiper-slide-active')[0]
834
+ .getElementsByTagName('video')
835
+ ).find(video => getComputedStyle(video).display !== 'none');
836
+
837
+ active_video.play()
838
+ updataMediaProgress('video', active_video)
839
+
840
+ }
841
+
842
+ //将所有的video暂停,然后播放下一个
843
+ function endallvideo() {
844
+ let videoALL = document
845
+ .getElementsByClassName('swiper-banner-video-img')[0]
846
+ .getElementsByClassName('swiper-wrapper')[0]
847
+ .getElementsByClassName('swiper-slide');
848
+ for (var i = 0; i < videoALL.length; i++) {
849
+ // console.log('videoALL[i]', videoALL[i]);
850
+ if(videoALL[i].getElementsByTagName('video')[0]){
851
+ videoALL[i].getElementsByTagName('video')[0].currentTime = 0;
852
+ }
853
+ }
854
+ }
855
+ })
856
+ </script>