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

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,190 +1,190 @@
1
- class WorldVideoDialog extends HTMLElement {
2
- isInitOpen = true;
3
- swiper = null; // swiper实例
4
-
5
- constructor() {
6
- super();
7
- this.init();
8
- }
9
-
10
- init() {
11
- this.initData();
12
- document.addEventListener('DOMContentLoaded', () => {
13
- this.initEvent();
14
- });
15
- }
16
-
17
- initEvent() {
18
- const closeBtn = this.querySelector('.close-modal-btn');
19
- closeBtn.addEventListener('click', () => {
20
- this.closeModal();
21
- });
22
- }
23
- initData() {
24
- this.x1Img = this.dataset.x1Img;
25
- this.x1ProImg = this.dataset.x1proImg;
26
- this.x1Links = this.dataset.x1Links;
27
- this.x1ProLinks = this.dataset.x1proLinks;
28
- }
29
-
30
- // 初始化
31
- initSwiper() {
32
- const swiperContainer = this.querySelector('.video-page-swiper');
33
- if (swiperContainer) {
34
- const isDesktop = window.innerWidth >= 1024;
35
- this.swiper = new Swiper(swiperContainer, {
36
- direction: isDesktop ? 'horizontal' : 'vertical',
37
- navigation: {
38
- nextEl: '.swiper-button-next',
39
- prevEl: '.swiper-button-prev',
40
- },
41
- virtual: {
42
- slides: [],
43
- },
44
- slidesPerView: 1,
45
- spaceBetween: 0,
46
- allowTouchMove: isDesktop ? false : true, // 禁用Swiper的触摸/拖动
47
- preventInteractionOnTransition: false,
48
- touchStartPreventDefault: false,
49
- touchMoveStopPropagation: false,
50
- on: {
51
- slideChangeTransitionEnd: () => {
52
- this.handleVideoOnSlideChange();
53
- },
54
- slideChange: () => {
55
- const currentIndex = this.swiper.activeIndex;
56
- if (currentIndex === this.swiper.virtual.slides.length - 1) {
57
- // 滑到最后一条,加载下一页数据
58
- const wordList = document.querySelector('world-video-list');
59
- if (wordList) {
60
- wordList.loadNextPage();
61
- }
62
- }
63
- },
64
- },
65
- });
66
- this.isInitOpen = true;
67
- }
68
- }
69
-
70
- handleVideoOnSlideChange() {
71
- // 暂停所有视频
72
- this.parseVideo();
73
- // 播放当前 active slide 中的视频
74
- const activeSlide = this.querySelector('.swiper-slide-active');
75
- const video = activeSlide.querySelector('.word-slide-lazy-video');
76
- if (video) {
77
- video.play().catch((err) => {
78
- console.error('视频播放失败', err);
79
- video.pause();
80
- });
81
- }
82
- }
83
- parseVideo() {
84
- // 暂停所有视频
85
- const allVideos = this.querySelectorAll('.word-slide-lazy-video');
86
- allVideos.forEach((video) => {
87
- video.pause();
88
- });
89
- }
90
- updateSlide(data, productType, isInit = false) {
91
- const template = $('#video-swiper-slide').html();
92
- if (isInit) {
93
- this.destroySwiper();
94
- this.initSwiper();
95
- }
96
- data.forEach((item) => {
97
- let replacedTemplate = template
98
- .replace(new RegExp('{video-url}', 'g'), item.videoUrl)
99
- .replace(new RegExp('{poster-url}', 'g'), item.pictureUrl)
100
- .replace(
101
- new RegExp('{avatar}', 'g'),
102
- item.userInfo && item.userInfo.avatar
103
- )
104
- .replace(
105
- new RegExp('{nickname}', 'g'),
106
- item.userInfo && item.userInfo.nickname
107
- )
108
- .replace(new RegExp('{content}', 'g'), item.content)
109
- .replace(new RegExp('{likeCount}', 'g'), item.likeCount)
110
- .replace(new RegExp('{commentCount}', 'g'), item.commentCount)
111
- .replace(new RegExp('{mediaId}', 'g'), item.id);
112
- if (productType === 1) {
113
- replacedTemplate = replacedTemplate
114
- .replace(new RegExp('{product-links}', 'g'), this.x1Links)
115
- .replace(new RegExp('{product-icon}', 'g'), this.x1Img)
116
- .replace(new RegExp('{product-type}', 'g'), '130');
117
- } else if (productType === 4) {
118
- replacedTemplate = replacedTemplate
119
- .replace(new RegExp('{product-links}', 'g'), this.x1ProLinks)
120
- .replace(new RegExp('{product-icon}', 'g'), this.x1ProImg)
121
- .replace(new RegExp('{product-type}', 'g'), '141');
122
- }
123
- this.swiper.virtual.slides.push(replacedTemplate);
124
- });
125
- this.swiper.virtual.update();
126
- }
127
- // 销毁
128
- destroySwiper() {
129
- if (this.swiper) {
130
- // 完全销毁swiper,包括所有事件监听器和DOM元素
131
- const swiperWrapper = this.querySelector('.swiper-wrapper');
132
- if (!swiperWrapper) return;
133
- // 找到swiper-wrapper 清空
134
- swiperWrapper.innerHTML = '';
135
- this.swiper.destroy(true, true);
136
- this.swiper = null;
137
- }
138
- }
139
- // 虚拟列表播放视频
140
- playVideo() {
141
- setTimeout(() => {
142
- this.handleVideoOnSlideChange();
143
- }, 200);
144
- }
145
- showModal(videoIndex) {
146
- const modal = this.querySelector('#world-video-modal');
147
- const mask = this.querySelector('#world-video-modalMask');
148
- const body = document.body;
149
- modal.style.display = 'block';
150
- mask.style.display = 'block';
151
- setTimeout(() => {
152
- modal.classList.add('show');
153
- }, 10);
154
- body.classList.add('modal-open');
155
- // 滑到固定位置
156
- if (this.isInitOpen) {
157
- // 是否是初始化后第一次打开
158
- videoIndex && this.swiper.slideTo(videoIndex);
159
- } else {
160
- this.swiper.slideTo(videoIndex);
161
- }
162
- this.isInitOpen = false;
163
- this.playVideo();
164
- dataLayer.push({
165
- event: 'world_video_dialog_open',
166
- timestamp: new Date().toISOString(),
167
- });
168
- }
169
- closeModal() {
170
- const modal = this.querySelector('#world-video-modal');
171
- const mask = this.querySelector('#world-video-modalMask');
172
- const body = document.body;
173
- modal.classList.remove('show');
174
- setTimeout(() => {
175
- modal.style.display = 'none';
176
- mask.style.display = 'none';
177
- this.parseVideo();
178
- }, 200);
179
- body.classList.remove('modal-open');
180
- }
181
-
182
- closeTouchMove() {
183
- this.swiper.allowTouchMove = false;
184
- }
185
- openTouchMove() {
186
- this.swiper.allowTouchMove = true;
187
- }
188
- }
189
-
190
- customElements.define('world-video-dialog', WorldVideoDialog);
1
+ class WorldVideoDialog extends HTMLElement {
2
+ isInitOpen = true;
3
+ swiper = null; // swiper实例
4
+
5
+ constructor() {
6
+ super();
7
+ this.init();
8
+ }
9
+
10
+ init() {
11
+ this.initData();
12
+ document.addEventListener('DOMContentLoaded', () => {
13
+ this.initEvent();
14
+ });
15
+ }
16
+
17
+ initEvent() {
18
+ const closeBtn = this.querySelector('.close-modal-btn');
19
+ closeBtn.addEventListener('click', () => {
20
+ this.closeModal();
21
+ });
22
+ }
23
+ initData() {
24
+ this.x1Img = this.dataset.x1Img;
25
+ this.x1ProImg = this.dataset.x1proImg;
26
+ this.x1Links = this.dataset.x1Links;
27
+ this.x1ProLinks = this.dataset.x1proLinks;
28
+ }
29
+
30
+ // 初始化
31
+ initSwiper() {
32
+ const swiperContainer = this.querySelector('.video-page-swiper');
33
+ if (swiperContainer) {
34
+ const isDesktop = window.innerWidth >= 1024;
35
+ this.swiper = new Swiper(swiperContainer, {
36
+ direction: isDesktop ? 'horizontal' : 'vertical',
37
+ navigation: {
38
+ nextEl: '.swiper-button-next',
39
+ prevEl: '.swiper-button-prev',
40
+ },
41
+ virtual: {
42
+ slides: [],
43
+ },
44
+ slidesPerView: 1,
45
+ spaceBetween: 0,
46
+ allowTouchMove: isDesktop ? false : true, // 禁用Swiper的触摸/拖动
47
+ preventInteractionOnTransition: false,
48
+ touchStartPreventDefault: false,
49
+ touchMoveStopPropagation: false,
50
+ on: {
51
+ slideChangeTransitionEnd: () => {
52
+ this.handleVideoOnSlideChange();
53
+ },
54
+ slideChange: () => {
55
+ const currentIndex = this.swiper.activeIndex;
56
+ if (currentIndex === this.swiper.virtual.slides.length - 1) {
57
+ // 滑到最后一条,加载下一页数据
58
+ const wordList = document.querySelector('world-video-list');
59
+ if (wordList) {
60
+ wordList.loadNextPage();
61
+ }
62
+ }
63
+ },
64
+ },
65
+ });
66
+ this.isInitOpen = true;
67
+ }
68
+ }
69
+
70
+ handleVideoOnSlideChange() {
71
+ // 暂停所有视频
72
+ this.parseVideo();
73
+ // 播放当前 active slide 中的视频
74
+ const activeSlide = this.querySelector('.swiper-slide-active');
75
+ const video = activeSlide.querySelector('.word-slide-lazy-video');
76
+ if (video) {
77
+ video.play().catch((err) => {
78
+ console.error('视频播放失败', err);
79
+ video.pause();
80
+ });
81
+ }
82
+ }
83
+ parseVideo() {
84
+ // 暂停所有视频
85
+ const allVideos = this.querySelectorAll('.word-slide-lazy-video');
86
+ allVideos.forEach((video) => {
87
+ video.pause();
88
+ });
89
+ }
90
+ updateSlide(data, productType, isInit = false) {
91
+ const template = $('#video-swiper-slide').html();
92
+ if (isInit) {
93
+ this.destroySwiper();
94
+ this.initSwiper();
95
+ }
96
+ data.forEach((item) => {
97
+ let replacedTemplate = template
98
+ .replace(new RegExp('{video-url}', 'g'), item.videoUrl)
99
+ .replace(new RegExp('{poster-url}', 'g'), item.pictureUrl)
100
+ .replace(
101
+ new RegExp('{avatar}', 'g'),
102
+ item.userInfo && item.userInfo.avatar
103
+ )
104
+ .replace(
105
+ new RegExp('{nickname}', 'g'),
106
+ item.userInfo && item.userInfo.nickname
107
+ )
108
+ .replace(new RegExp('{content}', 'g'), item.content)
109
+ .replace(new RegExp('{likeCount}', 'g'), item.likeCount)
110
+ .replace(new RegExp('{commentCount}', 'g'), item.commentCount)
111
+ .replace(new RegExp('{mediaId}', 'g'), item.id);
112
+ if (productType === 1) {
113
+ replacedTemplate = replacedTemplate
114
+ .replace(new RegExp('{product-links}', 'g'), this.x1Links)
115
+ .replace(new RegExp('{product-icon}', 'g'), this.x1Img)
116
+ .replace(new RegExp('{product-type}', 'g'), '130');
117
+ } else if (productType === 4) {
118
+ replacedTemplate = replacedTemplate
119
+ .replace(new RegExp('{product-links}', 'g'), this.x1ProLinks)
120
+ .replace(new RegExp('{product-icon}', 'g'), this.x1ProImg)
121
+ .replace(new RegExp('{product-type}', 'g'), '141');
122
+ }
123
+ this.swiper.virtual.slides.push(replacedTemplate);
124
+ });
125
+ this.swiper.virtual.update();
126
+ }
127
+ // 销毁
128
+ destroySwiper() {
129
+ if (this.swiper) {
130
+ // 完全销毁swiper,包括所有事件监听器和DOM元素
131
+ const swiperWrapper = this.querySelector('.swiper-wrapper');
132
+ if (!swiperWrapper) return;
133
+ // 找到swiper-wrapper 清空
134
+ swiperWrapper.innerHTML = '';
135
+ this.swiper.destroy(true, true);
136
+ this.swiper = null;
137
+ }
138
+ }
139
+ // 虚拟列表播放视频
140
+ playVideo() {
141
+ setTimeout(() => {
142
+ this.handleVideoOnSlideChange();
143
+ }, 200);
144
+ }
145
+ showModal(videoIndex) {
146
+ const modal = this.querySelector('#world-video-modal');
147
+ const mask = this.querySelector('#world-video-modalMask');
148
+ const body = document.body;
149
+ modal.style.display = 'block';
150
+ mask.style.display = 'block';
151
+ setTimeout(() => {
152
+ modal.classList.add('show');
153
+ }, 10);
154
+ body.classList.add('modal-open');
155
+ // 滑到固定位置
156
+ if (this.isInitOpen) {
157
+ // 是否是初始化后第一次打开
158
+ videoIndex && this.swiper.slideTo(videoIndex);
159
+ } else {
160
+ this.swiper.slideTo(videoIndex);
161
+ }
162
+ this.isInitOpen = false;
163
+ this.playVideo();
164
+ dataLayer.push({
165
+ event: 'world_video_dialog_open',
166
+ timestamp: new Date().toISOString(),
167
+ });
168
+ }
169
+ closeModal() {
170
+ const modal = this.querySelector('#world-video-modal');
171
+ const mask = this.querySelector('#world-video-modalMask');
172
+ const body = document.body;
173
+ modal.classList.remove('show');
174
+ setTimeout(() => {
175
+ modal.style.display = 'none';
176
+ mask.style.display = 'none';
177
+ this.parseVideo();
178
+ }, 200);
179
+ body.classList.remove('modal-open');
180
+ }
181
+
182
+ closeTouchMove() {
183
+ this.swiper.allowTouchMove = false;
184
+ }
185
+ openTouchMove() {
186
+ this.swiper.allowTouchMove = true;
187
+ }
188
+ }
189
+
190
+ customElements.define('world-video-dialog', WorldVideoDialog);