zz-shopify-components 0.16.3-beta.7 → 0.16.3-beta.8

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.
@@ -3,19 +3,26 @@ class WorldVideoCommentsDialog extends HTMLElement {
3
3
  swiper = null; // swiper实例
4
4
  mediaId = '';
5
5
  page = 1;
6
-
7
6
  pageSize = 15;
8
7
  hasMore = true;
9
8
 
10
9
  constructor() {
11
10
  super();
12
- this.init();
11
+
13
12
  }
14
13
  connectedCallback() {
14
+ this.shopSelect = this.dataset.shopSelect;
15
15
  this.baseUrl =
16
16
  this.dataset.requestType === 'prod'
17
17
  ? 'https://h130-app-server-us.hoverx1.cn'
18
18
  : 'https://h130-app-server-test-us.hoverx1.cn';
19
+ if (this.shopSelect === 'JP') {
20
+ this.baseUrl =
21
+ this.dataset.requestType === 'prod'
22
+ ? 'https://h130-app-server-jp.hoverx1.cn'
23
+ : 'https://h130-app-server-test-jp.hoverx1.cn';
24
+ }
25
+ this.init();
19
26
  }
20
27
 
21
28
  init() {
@@ -23,6 +23,8 @@ class WorldVideoDialog extends HTMLElement {
23
23
  initData() {
24
24
  this.x1Img = this.dataset.x1Img;
25
25
  this.x1ProImg = this.dataset.x1proImg;
26
+ this.x121Img = this.dataset.x121Img;
27
+ this.x121Links = this.dataset.x121Links;
26
28
  this.x1Links = this.dataset.x1Links;
27
29
  this.x1ProLinks = this.dataset.x1proLinks;
28
30
  }
@@ -88,6 +90,7 @@ class WorldVideoDialog extends HTMLElement {
88
90
  });
89
91
  }
90
92
  updateSlide(data, productType, isInit = false) {
93
+ console.log('updateSlide', data, productType, this.x121Links, this.x121Img);
91
94
  const template = $('#video-swiper-slide').html();
92
95
  if (isInit) {
93
96
  this.destroySwiper();
@@ -119,6 +122,11 @@ class WorldVideoDialog extends HTMLElement {
119
122
  .replace(new RegExp('{product-links}', 'g'), this.x1ProLinks)
120
123
  .replace(new RegExp('{product-icon}', 'g'), this.x1ProImg)
121
124
  .replace(new RegExp('{product-type}', 'g'), '141');
125
+ } else if (productType === 3) {
126
+ replacedTemplate = replacedTemplate
127
+ .replace(new RegExp('{product-links}', 'g'), this.x121Links)
128
+ .replace(new RegExp('{product-icon}', 'g'), this.x121Img)
129
+ .replace(new RegExp('{product-type}', 'g'), '121');
122
130
  }
123
131
  this.swiper.virtual.slides.push(replacedTemplate);
124
132
  });
@@ -152,6 +160,7 @@ class WorldVideoDialog extends HTMLElement {
152
160
  modal.classList.add('show');
153
161
  }, 10);
154
162
  body.classList.add('modal-open');
163
+ window.zzLockBodyScroll && window.zzLockBodyScroll();
155
164
  // 滑到固定位置
156
165
  if (this.isInitOpen) {
157
166
  // 是否是初始化后第一次打开
@@ -161,15 +170,15 @@ class WorldVideoDialog extends HTMLElement {
161
170
  }
162
171
  this.isInitOpen = false;
163
172
  this.playVideo();
164
- dataLayer.push({
165
- event: 'world_video_dialog_open',
166
- timestamp: new Date().toISOString(),
173
+ window.zzAnalytics && window.zzAnalytics.trackEvent('world_video_dialog_open', {
174
+ timestamp: new Date().toISOString(),
167
175
  });
168
176
  }
169
177
  closeModal() {
170
178
  const modal = this.querySelector('#world-video-modal');
171
179
  const mask = this.querySelector('#world-video-modalMask');
172
180
  const body = document.body;
181
+ window.zzUnlockBodyScroll && window.zzUnlockBodyScroll();
173
182
  modal.classList.remove('show');
174
183
  setTimeout(() => {
175
184
  modal.style.display = 'none';
@@ -8,14 +8,21 @@ class WorldVideoList extends HTMLElement {
8
8
  pageSize = 8;
9
9
  constructor() {
10
10
  super();
11
- this.init();
11
+
12
12
  }
13
13
  connectedCallback() {
14
+ this.shopSelect = this.dataset.shopSelect;
14
15
  this.baseUrl =
15
16
  this.dataset.requestType === 'prod'
16
17
  ? 'https://h130-app-server-us.hoverx1.cn'
17
18
  : 'https://h130-app-server-test-us.hoverx1.cn';
18
- this.shopSelect = this.dataset.shopSelect;
19
+ if (this.shopSelect === 'JP') {
20
+ this.baseUrl =
21
+ this.dataset.requestType === 'prod'
22
+ ? 'https://h130-app-server-jp.hoverx1.cn'
23
+ : 'https://h130-app-server-test-jp.hoverx1.cn';
24
+ }
25
+ this.init();
19
26
  }
20
27
 
21
28
  init() {
@@ -40,6 +47,8 @@ class WorldVideoList extends HTMLElement {
40
47
  try {
41
48
  this.x1Img = this.dataset.x1Img;
42
49
  this.x1ProImg = this.dataset.x1proImg;
50
+ this.x121Img = this.dataset.x121Img;
51
+ this.x121Links = this.dataset.x121Links;
43
52
  this.x1Links = this.dataset.x1Links;
44
53
  this.x1ProLinks = this.dataset.x1proLinks;
45
54
  } catch (error) {
@@ -56,10 +65,10 @@ class WorldVideoList extends HTMLElement {
56
65
  videoPageRightArrow.addEventListener('click', () => {
57
66
  videoPageList.scrollBy({ left: 400, behavior: 'smooth' });
58
67
  swiperIndex++;
59
- dataLayer.push({
60
- event: 'world_video_scroll',
68
+ window.zzAnalytics && window.zzAnalytics.trackEvent('world_video_scroll', {
61
69
  timestamp: new Date().toISOString(),
62
70
  });
71
+
63
72
  if (swiperIndex > 0) {
64
73
  videoPageLeftArrow.classList.remove('tw-hidden');
65
74
  }
@@ -98,7 +107,11 @@ class WorldVideoList extends HTMLElement {
98
107
  btnPro.classList.remove('tw-bg-black', 'tw-text-white');
99
108
  // 这里可以加你切换到 X1 的逻辑
100
109
  if (this.productType !== 1) {
101
- this.productType = 1;
110
+ if (this.shopSelect === 'JP') {
111
+ this.productType = 3;
112
+ } else {
113
+ this.productType = 1;
114
+ }
102
115
  this.page = 1;
103
116
  this.loadMoreData();
104
117
  }
@@ -112,8 +125,7 @@ class WorldVideoList extends HTMLElement {
112
125
  if (entry.isIntersecting) {
113
126
  // 进入视窗:开始计时
114
127
  startTime = Date.now();
115
- dataLayer.push({
116
- event: 'world_video_show',
128
+ window.zzAnalytics && window.zzAnalytics.trackEvent('world_video_show', {
117
129
  timestamp: new Date().toISOString(),
118
130
  });
119
131
  } else {
@@ -123,8 +135,7 @@ class WorldVideoList extends HTMLElement {
123
135
  startTime = 0;
124
136
  // 大于2秒 上报
125
137
  if (duration > 2000) {
126
- dataLayer.push({
127
- event: 'world_video_show_time',
138
+ window.zzAnalytics && window.zzAnalytics.trackEvent('world_video_show_time', {
128
139
  timestamp: new Date().toISOString(),
129
140
  duration: duration,
130
141
  });
@@ -145,8 +156,7 @@ class WorldVideoList extends HTMLElement {
145
156
  entries.forEach((entry) => {
146
157
  if (entry.isIntersecting) {
147
158
  this.loadNextPage();
148
- dataLayer.push({
149
- event: 'world_video_scroll',
159
+ window.zzAnalytics && window.zzAnalytics.trackEvent('world_video_scroll', {
150
160
  timestamp: new Date().toISOString(),
151
161
  });
152
162
  }
@@ -317,6 +327,10 @@ class WorldVideoList extends HTMLElement {
317
327
  replacedTemplate = replacedTemplate
318
328
  .replace(new RegExp('{product-links}', 'g'), this.x1ProLinks)
319
329
  .replace(new RegExp('{product-icon}', 'g'), this.x1ProImg);
330
+ } else if (this.productType === 3) {
331
+ replacedTemplate = replacedTemplate
332
+ .replace(new RegExp('{product-links}', 'g'), this.x121Links)
333
+ .replace(new RegExp('{product-icon}', 'g'), this.x121Img);
320
334
  }
321
335
  $('#video-swiper-wrapper').append(replacedTemplate);
322
336
  });
@@ -23,8 +23,7 @@ class WorldVideo extends HTMLElement {
23
23
  item.addEventListener('click', (event) => {
24
24
  const productType =
25
25
  event.currentTarget.getAttribute('data-product-type');
26
- dataLayer.push({
27
- event: 'world_video_learn_more',
26
+ window.zzAnalytics && window.zzAnalytics.trackEvent('world_video_learn_more', {
28
27
  timestamp: new Date().toISOString(),
29
28
  productType: productType,
30
29
  });
@@ -246,8 +245,7 @@ class WorldVideo extends HTMLElement {
246
245
  if (dialog) {
247
246
  dialog.showModal(id);
248
247
  }
249
- dataLayer.push({
250
- event: 'world-video-comments',
248
+ window.zzAnalytics && window.zzAnalytics.trackEvent('world-video-comments', {
251
249
  timestamp: new Date().toISOString(),
252
250
  });
253
251
  });
@@ -258,8 +256,7 @@ class WorldVideo extends HTMLElement {
258
256
  likeBtns.forEach((item) => {
259
257
  item.addEventListener('click', (event) => {
260
258
  event.stopPropagation();
261
- dataLayer.push({
262
- event: 'world-video-like',
259
+ window.zzAnalytics && window.zzAnalytics.trackEvent('world-video-like', {
263
260
  timestamp: new Date().toISOString(),
264
261
  });
265
262
  });
@@ -227,8 +227,7 @@
227
227
  const btn = document.getElementsByClassName('{{ btn_class }}')
228
228
  if(btn && btn[0]) {
229
229
  btn[0].addEventListener('click', (event) => {
230
- dataLayer.push({
231
- event: "{{ block.settings.click_event_class_name }}",
230
+ window.zzAnalytics && window.zzAnalytics.trackEvent("{{ block.settings.click_event_class_name }}", {
232
231
  timestamp: new Date().toISOString(),
233
232
  });
234
233
  });
@@ -209,8 +209,7 @@
209
209
  const btn = document.getElementsByClassName('{{ btn_class }}')
210
210
  if(btn && btn[0]) {
211
211
  btn[0].addEventListener('click', (event) => {
212
- dataLayer.push({
213
- event: "{{ block.settings.click_event_class_name }}",
212
+ window.zzAnalytics && window.zzAnalytics.trackEvent("{{ block.settings.click_event_class_name }}", {
214
213
  timestamp: new Date().toISOString(),
215
214
  });
216
215
  });
@@ -389,8 +389,8 @@
389
389
  } else {
390
390
  zzShowToast('Please fill in all required fields!');
391
391
  }
392
- dataLayer.push({
393
- event: "edu_page_form_submit",
392
+
393
+ window.zzAnalytics && window.zzAnalytics.trackEvent('edu_page_form_submit', {
394
394
  timestamp: new Date().toISOString(),
395
395
  });
396
396
  });
@@ -409,8 +409,7 @@
409
409
  input.addEventListener('input', function() {
410
410
  if(!hasInput) {
411
411
  hasInput = true
412
- dataLayer.push({
413
- event: "edu_page_form_input",
412
+ window.zzAnalytics && window.zzAnalytics.trackEvent('edu_page_form_input', {
414
413
  timestamp: new Date().toISOString(),
415
414
  });
416
415
  return;
@@ -46,20 +46,36 @@
46
46
  {
47
47
  "type": "image_picker",
48
48
  "id": "img_130_icon",
49
- "label": "130 产品icon"
49
+ "label": "130 产品icon",
50
+ "visible_if": "{{ block.settings.shop_select != 'JP' }}"
50
51
  },
51
- {
52
- "type": "textarea",
53
- "id": "links_130",
54
- "label": "Sites Link 130",
55
- "info": "国家对应链接的表,国家即是国家选择器上显示的字段,国家和路由之间用冒号隔开( 冒号后要加空格)。国家之间换行,“default”为其他未写的默认的链接 EG: Canada: https://hoverair.com/ default: https://hoverair.com/ "
52
+ {
53
+ "type": "image_picker",
54
+ "id": "img_121_icon",
55
+ "label": "121 产品icon",
56
+ "visible_if": "{{ block.settings.shop_select == 'JP' }}"
56
57
  },
58
+
57
59
  {
58
60
  "type": "textarea",
59
61
  "id": "links_141",
60
62
  "label": "Sites Link 141",
61
63
  "info": "国家对应链接的表,国家即是国家选择器上显示的字段,国家和路由之间用冒号隔开( 冒号后要加空格)。国家之间换行,“default”为其他未写的默认的链接 EG: Canada: https://hoverair.com/ default: https://hoverair.com/ "
62
- }
64
+ },
65
+ {
66
+ "type": "textarea",
67
+ "id": "links_130",
68
+ "label": "Sites Link 130",
69
+ "info": "国家对应链接的表,国家即是国家选择器上显示的字段,国家和路由之间用冒号隔开( 冒号后要加空格)。国家之间换行,“default”为其他未写的默认的链接 EG: Canada: https://hoverair.com/ default: https://hoverair.com/ ",
70
+ "visible_if": "{{ block.settings.shop_select != 'JP' }}"
71
+ },
72
+ {
73
+ "type": "textarea",
74
+ "id": "links_121",
75
+ "label": "Sites Link 121",
76
+ "info": "国家对应链接的表,国家即是国家选择器上显示的字段,国家和路由之间用冒号隔开( 冒号后要加空格)。国家之间换行,“default”为其他未写的默认的链接 EG: Canada: https://hoverair.com/ default: https://hoverair.com/ ",
77
+ "visible_if": "{{ block.settings.shop_select == 'JP' }}"
78
+ },
63
79
  ],
64
80
  "presets": [
65
81
  {
@@ -74,6 +90,8 @@
74
90
  data-x1-img='{{block.settings.img_130_icon | image_url}}'
75
91
  data-x1pro-links='{{block.settings.links_141 | url_encode }}'
76
92
  data-x1-links='{{block.settings.links_130 | url_encode }}'
93
+ data-x121-links='{{block.settings.links_121 | url_encode }}'
94
+ data-x121-img='{{block.settings.img_121_icon | image_url}}'
77
95
  data-request-type='{{ block.settings.request_type }}'
78
96
  data-shop-select='{{ block.settings.shop_select }}'
79
97
  >
@@ -91,7 +109,11 @@
91
109
  class='tw-flex-1 tw-border-none tw-h-full tw-rounded-[21px] tw-text-[13px] lg:tw-text-[16px] tw-bg-transparent tw-text-black tw-transition-colors'
92
110
  style='font-size: 16px;'
93
111
  >
94
- X1
112
+ {% if block.settings.shop_select == 'JP' %}
113
+ X1 Smart
114
+ {% else %}
115
+ X1
116
+ {% endif %}
95
117
  </button>
96
118
  </div>
97
119
  </div>
@@ -137,6 +159,8 @@
137
159
  data-x1-img='{{block.settings.img_130_icon | image_url}}'
138
160
  data-x1pro-links='{{block.settings.links_141 | url_encode }}'
139
161
  data-x1-links='{{block.settings.links_130 | url_encode }}'
162
+ data-x121-img='{{block.settings.img_121_icon | image_url}}'
163
+ data-x121-links='{{block.settings.links_121 | url_encode }}'
140
164
  data-request-type='{{ block.settings.request_type }}'
141
165
  >
142
166
  <!-- 蒙层 -->
@@ -461,7 +485,7 @@
461
485
  </svg>
462
486
  </div>
463
487
 
464
- <world-video-comments-dialog data-request-type='{{ block.settings.request_type }}'>
488
+ <world-video-comments-dialog data-request-type='{{ block.settings.request_type }}' data-shop-select='{{ block.settings.shop_select }}'>
465
489
  <div
466
490
  class='world-video-comments-mask lg:tw-hidden tw-z-[1007] tw-bg-black/60 tw-fixed tw-inset-0 tw-z-[1000]'
467
491
  ></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zz-shopify-components",
3
- "version": "0.16.3-beta.7",
3
+ "version": "0.16.3-beta.8",
4
4
  "description": "Reusable Shopify components for theme projects",
5
5
  "keywords": [
6
6
  "shopify",
@@ -208,8 +208,7 @@
208
208
  const offsetTop = target.offsetTop - headerHeight;
209
209
  scrollPaginationToCenter();
210
210
  window.scrollTo(0, offsetTop);
211
- dataLayer.push({
212
- event: "141_productpage_click_header_tab_item",
211
+ window.zzAnalytics && window.zzAnalytics.trackEvent('141_productpage_click_header_tab_item', {
213
212
  timestamp: new Date().toISOString(),
214
213
  header_module_name: id,
215
214
  });
@@ -314,8 +313,7 @@
314
313
  const btns = document.querySelectorAll('.{{ btn_class }}');
315
314
  btns.forEach(btn => {
316
315
  btn.addEventListener('click', (event) => {
317
- dataLayer.push({
318
- event: "{{ section.settings.buy_now_click_event_class_name }}",
316
+ window.zzAnalytics && window.zzAnalytics.trackEvent("{{ section.settings.buy_now_click_event_class_name }}", {
319
317
  timestamp: new Date().toISOString(),
320
318
  });
321
319
  });
@@ -212,16 +212,10 @@
212
212
  }
213
213
  scrollPaginationToCenter();
214
214
  window.scrollTo(0, offsetTop);
215
- dataLayer.push({
216
- event: "141_productpage_click_header_tab_item",
215
+ window.zzAnalytics && window.zzAnalytics.trackEvent("141_productpage_click_header_tab_item", {
217
216
  timestamp: new Date().toISOString(),
218
217
  header_module_name: id,
219
218
  });
220
- console.log('tag-data', {
221
- event: "141_productpage_click_header_tab_item",
222
- timestamp: new Date().toISOString(),
223
- header_module_name: id,
224
- })
225
219
 
226
220
  });
227
221
  });
@@ -326,8 +320,7 @@
326
320
  const btns = document.querySelectorAll('.{{ btn_class }}');
327
321
  btns.forEach(btn => {
328
322
  btn.addEventListener('click', (event) => {
329
- dataLayer.push({
330
- event: "{{ section.settings.buy_now_click_event_class_name }}",
323
+ window.zzAnalytics && window.zzAnalytics.trackEvent("{{ section.settings.buy_now_click_event_class_name }}", {
331
324
  timestamp: new Date().toISOString(),
332
325
  });
333
326
  });
@@ -720,17 +720,10 @@
720
720
  item.addEventListener('click', (event) => {
721
721
 
722
722
  event.stopPropagation();
723
- console.log('banner.settings.banner_name', {
724
- event: "banner_click",
725
- timestamp: new Date().toISOString(),
723
+ window.zzAnalytics && window.zzAnalytics.trackEvent("banner_click", {
726
724
  event_type_attribute: "{{ banner.settings.banner_name }}",
727
725
  section_name: "swiper_banner_v3",
728
- })
729
- dataLayer.push({
730
- event: "banner_click",
731
726
  timestamp: new Date().toISOString(),
732
- event_type_attribute: "{{ banner.settings.banner_name }}",
733
- section_name: "swiper_banner_v3",
734
727
  });
735
728
  });
736
729
  });
@@ -953,8 +946,7 @@
953
946
  if (entry.isIntersecting) {
954
947
  const bannerName = entry.target.dataset.bannerName;
955
948
  console.log('banner_show', bannerName);
956
- dataLayer.push({
957
- event: "banner_show",
949
+ window.zzAnalytics && window.zzAnalytics.trackEvent("banner_show", {
958
950
  timestamp: new Date().toISOString(),
959
951
  event_type_attribute: bannerName,
960
952
  section_name: "swiper_banner_v3",