zz-shopify-components 0.36.1-beta.6 → 0.36.1-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.
@@ -314,8 +314,22 @@ class BuyNowBottomBar extends HTMLElement {
314
314
  // 计算折扣
315
315
  const discountEl = this.querySelectorAll('.price-discouter');
316
316
  if (discountEl.length > 0) {
317
- const percent = total_price.times(100).dividedBy(total_before);
318
- const discountPercent = 100 - percent;
317
+ const discountPercent = total_before
318
+ .minus(total_price)
319
+ .times(100)
320
+ .dividedBy(total_before)
321
+ .toNumber();
322
+ const percentRound = this.dataset.percentRound || 'floor';
323
+ let roundedDiscountPercent = discountPercent;
324
+
325
+ if (percentRound === 'round') {
326
+ roundedDiscountPercent = Math.round(discountPercent);
327
+ } else if (percentRound === 'ceil') {
328
+ roundedDiscountPercent = Math.ceil(discountPercent);
329
+ } else {
330
+ roundedDiscountPercent = Math.floor(discountPercent);
331
+ }
332
+
319
333
  const discountValue = total_before.minus(total_price);
320
334
 
321
335
  discountEl.forEach((el) => {
@@ -323,7 +337,7 @@ class BuyNowBottomBar extends HTMLElement {
323
337
  el.classList.remove('tw-hidden');
324
338
  el.textContent =
325
339
  this.dataset.discountType === 'percent'
326
- ? '- ' + Math.round(discountPercent) + '%'
340
+ ? '- ' + roundedDiscountPercent + '%'
327
341
  : 'Save ' + this.currency + discountValue;
328
342
  } else {
329
343
  el.classList.add('tw-hidden');
@@ -170,7 +170,11 @@
170
170
  </svg>
171
171
  </button>
172
172
 
173
- <div class="zz-bottom-popup__body zz-overflow-scrollbar-hidden">
173
+ <div
174
+ {% if block.settings.modal_id != blank %}
175
+ data-track-zz-scroll="{{ block.settings.modal_id }}"
176
+ {% endif %}
177
+ class="zz-bottom-popup__body zz-overflow-scrollbar-hidden">
174
178
  <div class="zz-bottom-popup__inner" id="{{ modal_id }}-title">
175
179
  {% content_for 'blocks' %}
176
180
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zz-shopify-components",
3
- "version": "0.36.1-beta.6",
3
+ "version": "0.36.1-beta.8",
4
4
  "description": "Reusable Shopify components for theme projects",
5
5
  "keywords": [
6
6
  "shopify",
@@ -46,7 +46,7 @@
46
46
  {% if section.settings.is_exposure != false %}
47
47
  data-track-zz-exposure="true"
48
48
  {% endif %}
49
- data-zz-module-name="faq"
49
+ data-zz-module-name="faq-id"
50
50
  class="faq-custom max-lg:tw-px-[20px] lg:tw-mx-auto lg:tw-w-[95.3125vw] xl:tw-w-[1220px] fade-in-box">
51
51
  {% render 'content-h2',
52
52
  title_color: section.settings.title_color,
@@ -0,0 +1,409 @@
1
+ {% schema %}
2
+ {
3
+ "name": "页面内容导航",
4
+ "tag": "section",
5
+ "class": "zz-content-navigation",
6
+ "settings": [
7
+ {
8
+ "type": "image_picker",
9
+ "id": "logo",
10
+ "label": "Logo"
11
+ },
12
+ {
13
+ "type": "text",
14
+ "id": "aftershow",
15
+ "label": "在某个模块后显示",
16
+ "default": "product-buy"
17
+ },
18
+ {
19
+ "type": "color",
20
+ "id": "bg",
21
+ "label": "背景颜色",
22
+ "default": "#000000"
23
+ },
24
+ {
25
+ "type": "select",
26
+ "id": "text_color",
27
+ "options": [
28
+ {
29
+ "value": "dark",
30
+ "label": "深色模式"
31
+ },
32
+ {
33
+ "value": "white",
34
+ "label": "白色模式"
35
+ }
36
+ ],
37
+ "default": "white",
38
+ "label": "文案颜色模式"
39
+ },
40
+ ],
41
+ "blocks": [
42
+ {
43
+ "type": "item",
44
+ "name": "内容导航项",
45
+ "settings": [
46
+ {
47
+ "type": "text",
48
+ "id": "title",
49
+ "label": "标题"
50
+ },
51
+ {
52
+ "type": "text",
53
+ "id": "module_id",
54
+ "label": "模块id"
55
+ }
56
+ ]
57
+ }
58
+ ],
59
+ "presets": [
60
+ {
61
+ "name": "page content navigation"
62
+ }
63
+ ]
64
+ }
65
+ {% endschema %}
66
+ <style>
67
+ #shopify-section-{{ section.id }} {
68
+ position: sticky;
69
+ height: 50px;
70
+ top: 0;
71
+ z-index: 501;
72
+ opacity: 0;
73
+ pointer-events: none;
74
+ transform: translateY(-100%);
75
+ transition: opacity 0.2s ease, transform 0.2s ease;
76
+ }
77
+
78
+ #shopify-section-{{ section.id }}.content-navigation--visible {
79
+ opacity: 1;
80
+ pointer-events: auto;
81
+ transform: translateY(0);
82
+ }
83
+
84
+ #shopify-section-{{ section.id }} .content-navigation-item--active {
85
+ opacity: 1;
86
+ }
87
+
88
+ #shopify-section-{{ section.id }} .nav-swiper-shadow {
89
+ position: relative;
90
+ overflow: hidden;
91
+ }
92
+
93
+ /* 移动端导航箭头位置 */
94
+ #shopify-section-{{ section.id }} .nav-swiper-button-prev,
95
+ #shopify-section-{{ section.id }} .nav-swiper-button-next {
96
+ position: absolute;
97
+ top: 0;
98
+ bottom: 0;
99
+ width: 24px;
100
+ display: flex;
101
+ align-items: center;
102
+ justify-content: center;
103
+ z-index: 40;
104
+ pointer-events: auto;
105
+ }
106
+
107
+ /* 阴影加在左右箭头的伪元素上 */
108
+ #shopify-section-{{ section.id }} .nav-swiper-button-prev::before,
109
+ #shopify-section-{{ section.id }} .nav-swiper-button-next::before {
110
+ content: '';
111
+ position: absolute;
112
+ top: 0;
113
+ bottom: 0;
114
+ width: 40px;
115
+ pointer-events: none;
116
+ z-index: -1;
117
+ }
118
+
119
+ /* 左侧渐变阴影,从左箭头往内容方向淡出 */
120
+ #shopify-section-{{ section.id }} .nav-swiper-button-prev::before {
121
+ left: -4px;
122
+ background: linear-gradient(
123
+ to right,
124
+ {{ section.settings.bg }} 0%,
125
+ rgba(0, 0, 0, 0) 70%
126
+ );
127
+ }
128
+
129
+ /* 右侧渐变阴影,从右箭头往内容方向淡出 */
130
+ #shopify-section-{{ section.id }} .nav-swiper-button-next::before {
131
+ right: -4px;
132
+ background: linear-gradient(
133
+ to left,
134
+ {{ section.settings.bg }} 0%,
135
+ rgba(0, 0, 0, 0) 70%
136
+ );
137
+ }
138
+
139
+
140
+ #shopify-section-{{ section.id }} .nav-swiper-button-prev {
141
+ left: -4px;
142
+ }
143
+
144
+ #shopify-section-{{ section.id }} .nav-swiper-button-next {
145
+ right: -4px;
146
+ }
147
+ {% comment %}
148
+ #shopify-section-{{ section.id }} {
149
+ scroll-behavior: auto ;
150
+ } {% endcomment %}
151
+ </style>
152
+
153
+ <!-- PC端 -->
154
+ <div
155
+ data-track-zz-section="page_content_nav"
156
+ class='content-navigation content-navigation-pc tw-h-[50px] max-lg:tw-hidden'
157
+ style='background-color: {{ section.settings.bg }};'
158
+ >
159
+ <div class=' tw-max-w-[1660px] lg:tw-px-[20px] tw-w-full tw-mx-auto tw-h-full tw-flex tw-items-center tw-justify-between'>
160
+ <div class='content-navigation-logo'>
161
+ {% if section.settings.logo != blank %}
162
+ {{
163
+ section.settings.logo
164
+ | image_url: width: 200
165
+ | image_tag: class: 'tw-w-auto tw-h-[12px]'
166
+ }}
167
+ {% endif %}
168
+ </div>
169
+ <div class='content-navigation-items tw-flex tw-items-center tw-space-x-[20px]'>
170
+ {% for block in section.blocks %}
171
+ <button
172
+ data-module-id='{{ block.settings.module_id }}'
173
+ data-track-zz-element='quick_nav_{{ block.settings.module_id | downcase}}'
174
+ class='content-navigation-item tw-opacity-[0.6] {% if section.settings.text_color == 'white' %} tw-text-white {% else %} tw-text-black {% endif %} tw-text-[14px] tw-font-medium'
175
+ >
176
+ {{ block.settings.title }}
177
+ </button>
178
+ {%- if forloop.last == false -%}
179
+ <div class='tw-w-[1px] tw-h-[16px] tw-bg-[#9E9E9E]'>&nbsp;</div>
180
+ {%- endif -%}
181
+ {% endfor %}
182
+ </div>
183
+ </div>
184
+ </div>
185
+
186
+ <!-- 移动端 -->
187
+ <div
188
+ data-track-zz-section="page_content_nav"
189
+ class='content-navigation content-navigation-mobile lg:tw-hidden tw-px-[20px]'
190
+ style='background-color: {{ section.settings.bg }};'
191
+ >
192
+ <div class='tw-py-[12px]'>
193
+ {% if section.settings.logo != blank %}
194
+ {{
195
+ section.settings.logo
196
+ | image_url: width: 200
197
+ | image_tag: class: 'tw-h-[10px] tw-object-contain tw-w-auto'
198
+ }}
199
+ {% endif %}
200
+ </div>
201
+ <div class='nav-swiper-shadow'>
202
+ <div class=' swiper'>
203
+ <div class='swiper-wrapper tw-px-[20px]'>
204
+ {% for block in section.blocks %}
205
+ <div class='swiper-slide tw-py-[12px] tw-max-w-[30vw]'>
206
+ <button
207
+ data-module-id='{{ block.settings.module_id }}'
208
+ data-track-zz-element='quick_nav_{{ block.settings.module_id | downcase }}'
209
+ class='content-navigation-item tw-opacity-[0.6] tw-w-full tw-text-center {% if section.settings.text_color == 'white' %} tw-text-white {% else %} tw-text-black {% endif %} tw-text-[13px] tw-font-medium'
210
+ >
211
+ {{ block.settings.title }}
212
+ </button>
213
+ </div>
214
+ {% endfor %}
215
+ </div>
216
+
217
+ <div class="nav-swiper-button-prev">
218
+ <svg
219
+ width='24'
220
+ height='24'
221
+ viewBox='0 0 24 24'
222
+ fill='none'
223
+ xmlns='http://www.w3.org/2000/svg'
224
+ >
225
+ {% if section.settings.text_color == 'white' %}
226
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M7 12L14.0711 4.92893L14.0608 7.11487L9.17571 12L14.0711 16.8718L14.0711 19.0711L7 12Z" fill="white"/>
227
+ {% else %}
228
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M7 12L14.0711 4.92893L14.0608 7.11487L9.17571 12L14.0711 16.8718L14.0711 19.0711L7 12Z" fill="black"/>
229
+ {% endif %}
230
+
231
+ </svg>
232
+ </div>
233
+
234
+ <div class="nav-swiper-button-next">
235
+ <svg
236
+ width='24'
237
+ height='24'
238
+ viewBox='0 0 24 24'
239
+ fill='none'
240
+ xmlns='http://www.w3.org/2000/svg'
241
+ >
242
+ {% if section.settings.text_color == 'white' %}
243
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M17 12L9.92893 4.92893L9.93916 7.11487L14.8243 12L9.92893 16.8718L9.92893 19.0711L17 12Z" fill="white"/>
244
+ {% else %}
245
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M17 12L9.92893 4.92893L9.93916 7.11487L14.8243 12L9.92893 16.8718L9.92893 19.0711L17 12Z" fill="black"/>
246
+ {% endif %}
247
+ </svg>
248
+ </div>
249
+ </div>
250
+ </div>
251
+ </div>
252
+
253
+ <script>
254
+ document.addEventListener('DOMContentLoaded', (event) => {
255
+ const isDesktop = window.innerWidth > 1024;
256
+ const currentSection = document.getElementById(
257
+ 'shopify-section-{{ section.id }}'
258
+ );
259
+ let exposure = false;
260
+ // 显示逻辑
261
+ const afterShowModuleName = '{{ section.settings.aftershow | strip | escape }}';
262
+ const isDesignMode =
263
+ typeof Shopify !== 'undefined' && Shopify.designMode === true;
264
+
265
+ if (currentSection) {
266
+ if (!afterShowModuleName || isDesignMode) {
267
+ currentSection.classList.add('content-navigation--visible');
268
+ } else {
269
+ const afterShowTarget = document.querySelector(
270
+ `[data-zz-module-name="${afterShowModuleName}"]`
271
+ );
272
+
273
+ if (afterShowTarget) {
274
+ const afterShowObserver = new IntersectionObserver(
275
+ (entries) => {
276
+ entries.forEach((entry) => {
277
+ const shouldShow = entry.boundingClientRect.bottom <= 0;
278
+ console.log('shouldShow', shouldShow);
279
+ const element = currentSection.querySelector('[data-track-zz-section="page_content_nav"]');
280
+ const hpm = window.zzGetElementHpm ? zzGetElementHpm(element, 'section') : null;
281
+ if (!exposure && shouldShow && hpm) {
282
+ exposure = true; // 只触发一次曝光
283
+ window.zzAnalytics && window.zzAnalytics.trackEvent('exposure', {
284
+ page_element: {
285
+ hpm,
286
+ }
287
+ });
288
+ }
289
+
290
+ currentSection.classList.toggle(
291
+ 'content-navigation--visible',
292
+ shouldShow
293
+ );
294
+ });
295
+ },
296
+ {
297
+ root: null,
298
+ rootMargin: '0px 0px -200px 0px',
299
+ threshold: 0,
300
+ }
301
+ );
302
+
303
+ afterShowObserver.observe(afterShowTarget);
304
+ } else {
305
+ currentSection.classList.add('content-navigation--visible');
306
+ }
307
+ }
308
+ }
309
+
310
+
311
+ const navItems = currentSection.querySelectorAll('.content-navigation-item');
312
+ const sections = [];
313
+ let swiper = null;
314
+ const moduleIdToSlideIndex = {};
315
+
316
+ navItems.forEach((item) => {
317
+ const id = item.getAttribute('data-module-id');
318
+ if (!id) return;
319
+
320
+ const target = document.querySelector(`[data-zz-module-name="${id}"]`);
321
+ if (!target) return;
322
+
323
+ sections.push(target);
324
+
325
+ item.addEventListener('click', (e) => {
326
+ e.preventDefault();
327
+ const headerHeight = isDesktop ? 64 : 82;
328
+ const rect = target.getBoundingClientRect();
329
+ const offsetTop = rect.top + window.pageYOffset - headerHeight;
330
+
331
+ window.scrollTo({ top: offsetTop, behavior: 'smooth' })
332
+ });
333
+ });
334
+
335
+ if (sections.length) {
336
+ const observerOptions = {
337
+ root: null,
338
+ rootMargin: '0px 0px -200px 0px',
339
+ threshold: 0.1,
340
+ };
341
+
342
+ const observer = new IntersectionObserver((entries) => {
343
+ entries.forEach((entry) => {
344
+ if (!entry.isIntersecting) return;
345
+
346
+ const id = entry.target.dataset.zzModuleName;
347
+ navItems.forEach((item) => {
348
+ const isActive = item.getAttribute('data-module-id') === id;
349
+ item.classList.toggle('content-navigation-item--active', isActive);
350
+ });
351
+
352
+ if (swiper && moduleIdToSlideIndex[id] != null) {
353
+ const targetIndex = moduleIdToSlideIndex[id];
354
+ if (swiper.activeIndex !== targetIndex) {
355
+ swiper.slideTo(targetIndex);
356
+ }
357
+ }
358
+ });
359
+ }, observerOptions);
360
+
361
+ sections.forEach((sec) => observer.observe(sec));
362
+ }
363
+
364
+ /* 移动端 */
365
+ const swiperEl = currentSection.querySelector('.swiper');
366
+ const nextBtn = currentSection.querySelector('.nav-swiper-button-next');
367
+ const prevBtn = currentSection.querySelector('.nav-swiper-button-prev');
368
+
369
+ if (swiperEl) {
370
+ swiper = new Swiper(swiperEl, {
371
+ slidesPerView: 3.2,
372
+ spaceBetween: 12,
373
+ centeredSlides: false,
374
+ slidesOffsetAfter: 20,
375
+ navigation: {
376
+ nextEl: nextBtn,
377
+ prevEl: prevBtn,
378
+ },
379
+ clickable: true,
380
+ });
381
+
382
+ const slides = swiperEl.querySelectorAll('.swiper-slide');
383
+ slides.forEach((slide, index) => {
384
+ const btn = slide.querySelector('[data-module-id]');
385
+ if (!btn) return;
386
+ const id = btn.getAttribute('data-module-id');
387
+ if (!id) return;
388
+ moduleIdToSlideIndex[id] = index;
389
+ });
390
+
391
+ const updateNavState = () => {
392
+ const atBeginning = swiper.isBeginning;
393
+ const atEnd = swiper.isEnd;
394
+
395
+ if (prevBtn) {
396
+ prevBtn.style.display = atBeginning ? 'none' : 'flex';
397
+ }
398
+
399
+ if (nextBtn) {
400
+ nextBtn.style.display = atEnd ? 'none' : 'flex';
401
+ }
402
+ };
403
+
404
+ updateNavState();
405
+ swiper.on('slideChange', updateNavState);
406
+ swiper.on('resize', updateNavState);
407
+ }
408
+ });
409
+ </script>
@@ -28,6 +28,17 @@
28
28
  ],
29
29
  "default": "percent"
30
30
  },
31
+ {
32
+ "type": "select",
33
+ "id": "percent_round",
34
+ "label": "购买区折扣百分比取整方式",
35
+ "options": [
36
+ { "value": "floor", "label": "向下取整" },
37
+ { "value": "round", "label": "四舍五入" },
38
+ { "value": "ceil", "label": "向上取整" }
39
+ ],
40
+ "default": "floor"
41
+ },
31
42
  {
32
43
  "type": "select",
33
44
  "id": "bar_discount_type",
@@ -38,6 +49,17 @@
38
49
  ],
39
50
  "default": "percent"
40
51
  },
52
+ {
53
+ "type": "select",
54
+ "id": "bar_percent_round",
55
+ "label": "底部Bar折扣百分比取整方式",
56
+ "options": [
57
+ { "value": "floor", "label": "向下取整" },
58
+ { "value": "round", "label": "四舍五入" },
59
+ { "value": "ceil", "label": "向上取整" }
60
+ ],
61
+ "default": "floor"
62
+ },
41
63
  {
42
64
  "type": "header",
43
65
  "content": "Main Settings"
@@ -229,6 +251,7 @@
229
251
  blocks: section.blocks,
230
252
  show_basic: section.settings.show_basic_price,
231
253
  discount_type: section.settings.discount_type,
254
+ percent_round: section.settings.percent_round,
232
255
  basic_title: section.settings.basic_title
233
256
  %}
234
257
  </div>
@@ -250,6 +273,7 @@
250
273
  btn_out_of_stock: section.settings.bar_btn_out_of_stock,
251
274
  product_title: section.settings.title,
252
275
  discount_type: section.settings.bar_discount_type,
276
+ percent_round: section.settings.bar_percent_round,
253
277
  %}
254
278
 
255
279
 
@@ -49,6 +49,26 @@
49
49
  "label": "白色"
50
50
  }
51
51
  ]
52
+ },
53
+ {
54
+ "type": "checkbox",
55
+ "id": "show_active_underline",
56
+ "label": "是否下划线",
57
+ "default": true,
58
+ "info": "开启时,选中的 Tab 会显示下划线"
59
+ },
60
+ {
61
+ "type": "checkbox",
62
+ "id": "show_divider",
63
+ "label": "是否有中间线",
64
+ "default": false,
65
+ "info": "开启时,Tab 之间显示分隔中间线"
66
+ },
67
+ {
68
+ "type": "checkbox",
69
+ "id": "smooth_scroll",
70
+ "label": "是否平滑滚动",
71
+ "default": false,
52
72
  }
53
73
  ],
54
74
  "blocks": [
@@ -87,15 +107,19 @@
87
107
 
88
108
  {%- assign top_offset = section.settings.top_offset | default: 50 -%}
89
109
  {%- assign text_color_mode = section.settings.text_color_mode | default: 'black' -%}
110
+ {%- assign show_active_underline = section.settings.show_active_underline -%}
111
+ {%- assign show_divider = section.settings.show_divider -%}
90
112
  {%- if text_color_mode == 'white' -%}
91
113
  {%- assign tab_text_color = 'rgba(255,255,255,0.8)' -%}
92
114
  {%- assign tab_active_text_color = '#FFFFFF' -%}
115
+ {%- assign divider_color = 'rgba(255,255,255,0.6)' -%}
93
116
  {%- else -%}
94
117
  {%- assign tab_text_color = 'rgba(45,45,45,0.8)' -%}
95
118
  {%- assign tab_active_text_color = '#2D2D2D' -%}
119
+ {%- assign divider_color = 'rgba(45,45,45,0.6)' -%}
96
120
  {%- endif -%}
97
121
 
98
- <nav class="zz-product-subnav" aria-label="Product sub navigation">
122
+ <nav class="zz-product-subnav{% if show_active_underline %} zz-product-subnav--underline{% endif %}{% if show_divider %} zz-product-subnav--divider{% endif %}" aria-label="Product sub navigation">
99
123
  <div class="zz-product-subnav__wrap">
100
124
  <div class="zz-product-subnav__track" role="tablist">
101
125
  {%- for block in section.blocks -%}
@@ -123,7 +147,7 @@
123
147
  #shopify-section-{{ section.id }} {
124
148
  position: sticky;
125
149
  top: {{ top_offset }}px;
126
- z-index: 30;
150
+ z-index: 501;
127
151
  }
128
152
 
129
153
  #shopify-section-{{ section.id }} .zz-product-subnav {
@@ -178,7 +202,7 @@
178
202
  white-space: nowrap;
179
203
  }
180
204
 
181
- #shopify-section-{{ section.id }} .zz-product-subnav__tab.is-active {
205
+ #shopify-section-{{ section.id }} .zz-product-subnav--underline .zz-product-subnav__tab.is-active {
182
206
  border-bottom-color: {{ tab_active_text_color }};
183
207
  }
184
208
 
@@ -187,6 +211,21 @@
187
211
  color: {{ tab_active_text_color }};
188
212
  }
189
213
 
214
+ #shopify-section-{{ section.id }} .zz-product-subnav--divider .zz-product-subnav__tab {
215
+ position: relative;
216
+ }
217
+
218
+ #shopify-section-{{ section.id }} .zz-product-subnav--divider .zz-product-subnav__tab:not(:first-child)::before {
219
+ content: "";
220
+ position: absolute;
221
+ top: 50%;
222
+ left: -30px;
223
+ transform: translateY(-50%);
224
+ width: 1px;
225
+ height: 13px;
226
+ background: {{ divider_color }};
227
+ }
228
+
190
229
  @media (max-width: 1023px) {
191
230
  #shopify-section-{{ section.id }} .zz-product-subnav__wrap {
192
231
  padding: 0 20px;
@@ -204,7 +243,16 @@
204
243
  #shopify-section-{{ section.id }} .zz-product-subnav__tabText {
205
244
  font-size: 14px;
206
245
  }
246
+
247
+ #shopify-section-{{ section.id }} .zz-product-subnav--divider .zz-product-subnav__tab:not(:first-child)::before {
248
+ left: -12px;
249
+ }
207
250
  }
251
+ {% if section.settings.smooth_scroll == false %}
252
+ html {
253
+ scroll-behavior: auto;
254
+ }
255
+ {% endif %}
208
256
  </style>
209
257
 
210
258
  <script>
@@ -270,7 +318,11 @@
270
318
  if (!target) return;
271
319
  const rect = target.getBoundingClientRect();
272
320
  const offsetTop = rect.top + window.scrollY - getScrollOffset();
273
- window.scrollTo({ top: offsetTop, behavior: 'smooth' });
321
+ {% if section.settings.smooth_scroll == false %}
322
+ window.scrollTo(0, offsetTop);
323
+ {% else %}
324
+ window.scrollTo({ top: offsetTop, behavior: 'smooth' });
325
+ {% endif %}
274
326
  }
275
327
 
276
328
  // Click to scroll
@@ -361,6 +413,10 @@
361
413
  }
362
414
 
363
415
  function tryStartSpyWithWait() {
416
+ if (window.USER_AGENT && window.USER_AGENT.isApp) {
417
+ // top 设置成 top_offset-50px
418
+ sectionEl.style.top = '0px';
419
+ }
364
420
  if (startSpy()) return;
365
421
 
366
422
  // Targets not in DOM yet: wait for insertion
@@ -47,17 +47,25 @@
47
47
  product.settings.image
48
48
  | image_url: width: 400
49
49
  | image_tag:
50
- class: 'product-image tw-w-[128px] lg:tw-w-[168px] tw-object-contain tw-object-center tw-aspect-[168/132]',
50
+ class: 'product-image tw-w-[128px] lg:tw-w-[168px] xl:tw-w-[200px] tw-object-contain tw-object-center tw-aspect-[200/134]',
51
51
  loading: 'lazy',
52
52
  alt: product.settings.heading
53
53
  }}
54
54
  {%- endif -%}
55
- <div class="tw-break-words tw-font-bold tw-leading-[1.5] tw-mt-[10px] lg:tw-mt-[18px] tw-text-[#2d2d2d] lg:tw-text-[28px] max-lg:tw-text-[1.8rem]">{{ product.settings.heading | escape }}</div>
55
+ <div class="tw-break-words tw-font-bold tw-leading-[1.5] lg:tw-mt-[18px] tw-text-[#2d2d2d] lg:tw-text-[28px] max-lg:tw-text-[1.8rem]">{{ product.settings.heading | escape }}</div>
56
56
 
57
57
  {%- if product.settings.description != blank -%}
58
- <div class="tw-break-words tw-text-[1.2rem] lg:tw-text-[14px] tw-font-bold tw-leading-[1.5] tw-text-[#2d2d2d]">{{ product.settings.description | escape | newline_to_br }}</div>
58
+ <div class="product-image-desc tw-break-words tw-text-[1.2rem] lg:tw-text-[14px] tw-font-bold tw-leading-[1.5] tw-text-[#2d2d2d]">{{ product.settings.description | escape | newline_to_br }}</div>
59
59
  {%- endif -%}
60
- <div class="tw-align-middle tw-text-center tw-text-[1.4rem] lg:tw-text-[20px] tw-leading-[1.5] tw-tracking-[0px] tw-text-[#2D2D2DCC]">{{ section.settings.price_prefix }} {{ variant.price | money_without_trailing_zeros }}</div>
60
+ <div class="tw-align-middle tw-text-center tw-text-[1.4rem] lg:tw-text-[20px] tw-leading-[1.5] tw-tracking-[0px] tw-text-[#2D2D2DCC]">
61
+ {%- if section.settings.from_type == 'prefix' -%}
62
+ {{ section.settings.price_prefix }}&nbsp;
63
+ {%- endif -%}
64
+ {{ variant.price | money_without_trailing_zeros }}
65
+ {% if section.settings.from_type == 'suffix' %}
66
+ &nbsp;{{ section.settings.price_prefix }}
67
+ {% endif %}
68
+ </div>
61
69
  </div>
62
70
  {%- endfor -%}
63
71
  </div>
@@ -78,6 +86,8 @@
78
86
  {%- assign cell_value = spec.settings.x1_promax_value -%}
79
87
  {%- when 'AQUA' -%}
80
88
  {%- assign cell_value = spec.settings.aqua_value -%}
89
+ {%- when 'X1 Smart' -%}
90
+ {%- assign cell_value = spec.settings.x1_smart_value -%}
81
91
  {%- else -%}
82
92
  {%- assign cell_value = '' -%}
83
93
  {%- endcase -%}
@@ -181,10 +191,10 @@
181
191
  var isVisible = false;
182
192
  var ticking = false;
183
193
 
184
- {%- comment -%} Height of the visible content-nagivation bar (mobile vs pc) {%- endcomment -%}
194
+ {%- comment -%} Height of the visible content-navigation bar (mobile vs pc) {%- endcomment -%}
185
195
  function getNavHeight() {
186
- var pc = document.querySelector('.content-nagivation-pc');
187
- var mobile = document.querySelector('.content-nagivation-mobile');
196
+ var pc = document.querySelector('.content-navigation-pc');
197
+ var mobile = document.querySelector('.content-navigation-mobile');
188
198
  {%- comment -%} the hidden one (wrong breakpoint) reports offsetHeight 0 {%- endcomment -%}
189
199
  var pcH = pc ? pc.offsetHeight : 0;
190
200
  var mobileH = mobile ? mobile.offsetHeight : 0;
@@ -288,11 +298,27 @@
288
298
  "id": "title",
289
299
  "label": "Section title",
290
300
  "default": "Specs"
301
+ },
302
+ {
303
+ "type": "select",
304
+ "id": "from_type",
305
+ "label": "文案颜色模式",
306
+ "default": "prefix",
307
+ "options": [
308
+ {
309
+ "value": "prefix",
310
+ "label": "前缀"
311
+ },
312
+ {
313
+ "value": "suffix",
314
+ "label": "后缀"
315
+ }
316
+ ]
291
317
  },
292
318
  {
293
319
  "type": "text",
294
320
  "id": "price_prefix",
295
- "label": "Price prefix",
321
+ "label": "Price prefix suffix",
296
322
  "default": "from"
297
323
  }
298
324
  ],
@@ -309,7 +335,8 @@
309
335
  { "value": "X1", "label": "X1" },
310
336
  { "value": "X1 PRO", "label": "X1 PRO" },
311
337
  { "value": "X1 PROMAX", "label": "X1 PROMAX" },
312
- { "value": "AQUA", "label": "AQUA" }
338
+ { "value": "AQUA", "label": "AQUA" },
339
+ { "value": "X1 Smart", "label": "X1 Smart" }
313
340
  ],
314
341
  "default": "X1"
315
342
  },
@@ -366,6 +393,11 @@
366
393
  "type": "textarea",
367
394
  "id": "aqua_value",
368
395
  "label": "AQUA value"
396
+ },
397
+ {
398
+ "type": "textarea",
399
+ "id": "x1_smart_value",
400
+ "label": "X1 Smart value"
369
401
  }
370
402
  ]
371
403
  }
@@ -18,6 +18,7 @@
18
18
  data-currency='{{ cart.currency.symbol }}'
19
19
  data-btn-text='{{ btn }}'
20
20
  data-discount-type='{{ discount_type }}'
21
+ data-percent-round='{{ percent_round | default: "floor" }}'
21
22
  data-btn-out-of-stock-text='{{ btn_out_of_stock }}'
22
23
  data-care-guide='{{ care_guide_type }}'
23
24
  data-is-edu-product='{{ is_edu_product }}'
@@ -50,7 +51,8 @@
50
51
  {% render 'zz-price-discouter',
51
52
  before: product.selected_or_first_available_variant.compare_at_price,
52
53
  after: product.selected_or_first_available_variant.price,
53
- discount_type: discount_type
54
+ discount_type: discount_type,
55
+ percent_round: percent_round
54
56
  %}
55
57
  </div>
56
58
  <div class='bar-title-desc max-md:tw-mb-[12px]'>
@@ -98,7 +100,8 @@
98
100
  {% render 'zz-price-discouter',
99
101
  before: product.selected_or_first_available_variant.compare_at_price,
100
102
  after: product.selected_or_first_available_variant.price,
101
- discount_type: discount_type
103
+ discount_type: discount_type,
104
+ percent_round: percent_round
102
105
  %}
103
106
  </div>
104
107
  {% if has_installment %}
@@ -1,7 +1,18 @@
1
+ {% comment %}
2
+ percent_round: floor (default) | round | ceil — 对折扣百分比 (before-after)/before*100 取整
3
+ {% endcomment %}
1
4
  {% assign discount_value = before | minus: after %}
2
5
  {% assign discount_value = discount_value | money_without_trailing_zeros %}
3
- {%- assign percent = after | times: 100.0 | divided_by: before | round -%}
4
- {%- assign percent = 100 | minus: percent -%}
6
+ {% assign percent_round = percent_round | default: 'floor' %}
7
+ {% assign percent = before | minus: after | times: 100.0 | divided_by: before %}
8
+ {% case percent_round %}
9
+ {% when 'round' %}
10
+ {% assign percent = percent | round %}
11
+ {% when 'ceil' %}
12
+ {% assign percent = percent | ceil %}
13
+ {% else %}
14
+ {% assign percent = percent | floor %}
15
+ {% endcase %}
5
16
  <span
6
17
  class='discount_percentage tw-whitespace-nowrap {% if before == blank or before <= after %} tw-hidden {% endif %} price-discouter lg:tw-px-[8px] tw-px-[4px] tw-inline-flex tw-justify-center tw-leading-[19px] tw-items-center tw-h-[19px] tw-text-[10px] tw-rounded-lg tw-text-white tw-bg-[#FC6C0F]'
7
18
  >
@@ -37,7 +37,8 @@
37
37
  option_type: option_type,
38
38
  show_basic: show_basic,
39
39
  basic_title: basic_title,
40
- discount_type: discount_type
40
+ discount_type: discount_type,
41
+ percent_round: percent_round
41
42
  %}
42
43
  </div>
43
44
  {% else %}
@@ -72,13 +72,21 @@
72
72
  opacity 0.25s ease,
73
73
  transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
74
74
  }
75
- .product-swiper-container:hover .product-swiper-list-thumbs {
76
- opacity: 1;
77
- transform: translateY(0) scale(1);
75
+ /* 触屏上 :hover 会粘滞,会导致滑动后分页点被隐藏,故只对鼠标设备生效 */
76
+ @media (hover: hover) and (pointer: fine) {
77
+ .product-swiper-container:hover .product-swiper-list-thumbs {
78
+ opacity: 1;
79
+ transform: translateY(0) scale(1);
80
+ }
81
+ .product-swiper-container:hover .swiper-pagination {
82
+ display: none;
83
+ transition: none;
84
+ }
78
85
  }
79
- .product-swiper-container:hover .swiper-pagination {
80
- display: none;
81
- transition: none;
86
+ @media (hover: none) {
87
+ .product-swiper-list-thumbs {
88
+ pointer-events: none;
89
+ }
82
90
  }
83
91
 
84
92
  .product-swiper-list-thumbs .swiper-slide {
@@ -94,7 +94,8 @@
94
94
  {% render 'zz-price-discouter',
95
95
  before: variant_for_value.compare_at_price,
96
96
  after: variant_for_value.price,
97
- discount_type: section.settings.discount_type
97
+ discount_type: section.settings.discount_type,
98
+ percent_round: section.settings.percent_round
98
99
  %}
99
100
  {% endif %}
100
101
  </div>
@@ -110,7 +110,8 @@
110
110
  {% render 'zz-price-discouter',
111
111
  before: variant_for_value.compare_at_price,
112
112
  after: variant_for_value.price,
113
- discount_type: discount_type
113
+ discount_type: discount_type,
114
+ percent_round: percent_round
114
115
  %}
115
116
  {% endif %}
116
117
  </div>
@@ -110,7 +110,8 @@
110
110
  {% render 'zz-price-discouter',
111
111
  before: variant_for_value.compare_at_price,
112
112
  after: variant_for_value.price,
113
- discount_type: discount_type
113
+ discount_type: discount_type,
114
+ percent_round: percent_round
114
115
  %}
115
116
  {% endif %}
116
117
  </div>