shoplazza-cli 0.0.1

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 (181) hide show
  1. package/.editorconfig +28 -0
  2. package/.prettierrc +9 -0
  3. package/LICENSE +21 -0
  4. package/README.md +208 -0
  5. package/bin/shoplazza +117 -0
  6. package/fixtures/assets/blog.scss +74 -0
  7. package/fixtures/assets/cart_modal.scss +450 -0
  8. package/fixtures/assets/collection_detail.js +234 -0
  9. package/fixtures/assets/collection_detail.scss +345 -0
  10. package/fixtures/assets/collection_list.scss +11 -0
  11. package/fixtures/assets/collection_slider.scss +169 -0
  12. package/fixtures/assets/feature_columns.scss +26 -0
  13. package/fixtures/assets/feature_product.scss +109 -0
  14. package/fixtures/assets/footer.js +58 -0
  15. package/fixtures/assets/footer.scss +337 -0
  16. package/fixtures/assets/four_images.scss +29 -0
  17. package/fixtures/assets/gallery.scss +55 -0
  18. package/fixtures/assets/header.js +178 -0
  19. package/fixtures/assets/header.scss +929 -0
  20. package/fixtures/assets/image_text.scss +72 -0
  21. package/fixtures/assets/logo_bar.scss +11 -0
  22. package/fixtures/assets/newsletter.scss +90 -0
  23. package/fixtures/assets/not_found.scss +39 -0
  24. package/fixtures/assets/page_detail.scss +16 -0
  25. package/fixtures/assets/pagination.scss +150 -0
  26. package/fixtures/assets/postcss.config.js +6 -0
  27. package/fixtures/assets/product_description.scss +88 -0
  28. package/fixtures/assets/product_detail.js +634 -0
  29. package/fixtures/assets/product_detail.scss +1106 -0
  30. package/fixtures/assets/relative_product.scss +45 -0
  31. package/fixtures/assets/reviews.scss +70 -0
  32. package/fixtures/assets/rich_text.scss +71 -0
  33. package/fixtures/assets/search.js +87 -0
  34. package/fixtures/assets/search.scss +67 -0
  35. package/fixtures/assets/slide.scss +51 -0
  36. package/fixtures/assets/slider.scss +141 -0
  37. package/fixtures/assets/theme.css +976 -0
  38. package/fixtures/assets/theme.scss +1100 -0
  39. package/fixtures/assets/three_images.scss +20 -0
  40. package/fixtures/assets/tools.scss +23 -0
  41. package/fixtures/assets/two_images.scss +24 -0
  42. package/fixtures/assets/video.scss +45 -0
  43. package/fixtures/assets/video_text.scss +63 -0
  44. package/fixtures/config/settings_data.json +107 -0
  45. package/fixtures/config/settings_schema.json +690 -0
  46. package/fixtures/layout/theme.liquid +76 -0
  47. package/fixtures/locales/ar-SA.json +212 -0
  48. package/fixtures/locales/de-DE.json +290 -0
  49. package/fixtures/locales/en-US.json +290 -0
  50. package/fixtures/locales/es-ES.json +290 -0
  51. package/fixtures/locales/fr-FR.json +290 -0
  52. package/fixtures/locales/id-ID.json +212 -0
  53. package/fixtures/locales/it-IT.json +212 -0
  54. package/fixtures/locales/ja-JP.json +289 -0
  55. package/fixtures/locales/ko-KR.json +290 -0
  56. package/fixtures/locales/nl-NL.json +290 -0
  57. package/fixtures/locales/pl-PL.json +290 -0
  58. package/fixtures/locales/pt-PT.json +212 -0
  59. package/fixtures/locales/ru-RU.json +212 -0
  60. package/fixtures/locales/th-TH.json +212 -0
  61. package/fixtures/locales/zh-CN.json +290 -0
  62. package/fixtures/locales/zh-TW.json +290 -0
  63. package/fixtures/sections/apps.liquid +47 -0
  64. package/fixtures/sections/blog.liquid +137 -0
  65. package/fixtures/sections/collection_desc.liquid +34 -0
  66. package/fixtures/sections/collection_detail.liquid +436 -0
  67. package/fixtures/sections/collection_image.liquid +104 -0
  68. package/fixtures/sections/collection_list.liquid +161 -0
  69. package/fixtures/sections/collection_name.liquid +34 -0
  70. package/fixtures/sections/collection_slider.liquid +330 -0
  71. package/fixtures/sections/feature_columns.liquid +275 -0
  72. package/fixtures/sections/feature_product.liquid +227 -0
  73. package/fixtures/sections/footer.liquid +488 -0
  74. package/fixtures/sections/four_images.liquid +160 -0
  75. package/fixtures/sections/gallery.liquid +258 -0
  76. package/fixtures/sections/header.liquid +1157 -0
  77. package/fixtures/sections/html.liquid +40 -0
  78. package/fixtures/sections/image_text.liquid +350 -0
  79. package/fixtures/sections/instagram_plus.liquid +393 -0
  80. package/fixtures/sections/logo_bar.liquid +183 -0
  81. package/fixtures/sections/newsletter.liquid +225 -0
  82. package/fixtures/sections/not_found.liquid +39 -0
  83. package/fixtures/sections/overlay_image.liquid +648 -0
  84. package/fixtures/sections/page_detail.liquid +39 -0
  85. package/fixtures/sections/photo_collection.liquid +433 -0
  86. package/fixtures/sections/product_description.liquid +208 -0
  87. package/fixtures/sections/product_detail.liquid +611 -0
  88. package/fixtures/sections/products.liquid +216 -0
  89. package/fixtures/sections/relative_product.liquid +121 -0
  90. package/fixtures/sections/reviews.liquid +115 -0
  91. package/fixtures/sections/rich_text.liquid +157 -0
  92. package/fixtures/sections/search.liquid +163 -0
  93. package/fixtures/sections/slide.liquid +719 -0
  94. package/fixtures/sections/three_images.liquid +157 -0
  95. package/fixtures/sections/two_images.liquid +125 -0
  96. package/fixtures/sections/video.liquid +95 -0
  97. package/fixtures/sections/video_text.liquid +128 -0
  98. package/fixtures/snippets/bgset.liquid +21 -0
  99. package/fixtures/snippets/card_title.liquid +8 -0
  100. package/fixtures/snippets/cart_modal.liquid +74 -0
  101. package/fixtures/snippets/collection.liquid +77 -0
  102. package/fixtures/snippets/collection_filter_modal.liquid +56 -0
  103. package/fixtures/snippets/default_image_4.liquid +14 -0
  104. package/fixtures/snippets/default_image_6.liquid +18 -0
  105. package/fixtures/snippets/default_image_8.liquid +23 -0
  106. package/fixtures/snippets/four_images_item.liquid +8 -0
  107. package/fixtures/snippets/header_ads.liquid +95 -0
  108. package/fixtures/snippets/hero_image.liquid +94 -0
  109. package/fixtures/snippets/icon_video_play_large.liquid +1 -0
  110. package/fixtures/snippets/icon_video_play_medium.liquid +4 -0
  111. package/fixtures/snippets/icon_video_play_small.liquid +4 -0
  112. package/fixtures/snippets/lazyimg.liquid +22 -0
  113. package/fixtures/snippets/lazyimg_art.liquid +36 -0
  114. package/fixtures/snippets/lazysizes.liquid +41 -0
  115. package/fixtures/snippets/link.liquid +2 -0
  116. package/fixtures/snippets/pagination.liquid +48 -0
  117. package/fixtures/snippets/product.liquid +126 -0
  118. package/fixtures/snippets/product_art_tpl.liquid +152 -0
  119. package/fixtures/snippets/product_info_body.liquid +337 -0
  120. package/fixtures/snippets/product_info_tpl.liquid +423 -0
  121. package/fixtures/snippets/product_label.liquid +46 -0
  122. package/fixtures/snippets/settings.liquid +295 -0
  123. package/fixtures/snippets/social-meta-tags.liquid +106 -0
  124. package/fixtures/snippets/video_html.liquid +11 -0
  125. package/fixtures/snippets/video_source.liquid +98 -0
  126. package/fixtures/snippets/video_thumb_icon.liquid +2 -0
  127. package/fixtures/templates/404.liquid +1 -0
  128. package/fixtures/templates/collection.liquid +92 -0
  129. package/fixtures/templates/index.liquid +206 -0
  130. package/fixtures/templates/page.liquid +1 -0
  131. package/fixtures/templates/product.liquid +99 -0
  132. package/fixtures/templates/search.liquid +1 -0
  133. package/jest.config.js +192 -0
  134. package/lib/__tests__/log.test.js +15 -0
  135. package/lib/__tests__/utils.test.js +69 -0
  136. package/lib/auth/__mocks__/getCode.js +7 -0
  137. package/lib/auth/__mocks__/index.js +0 -0
  138. package/lib/auth/child.js +23 -0
  139. package/lib/auth/getCode.js +35 -0
  140. package/lib/auth/index.js +91 -0
  141. package/lib/commands/__tests__/login.test.js +77 -0
  142. package/lib/commands/__tests__/logout.test.js +29 -0
  143. package/lib/commands/__tests__/store.test.js +44 -0
  144. package/lib/commands/__tests__/switch.test.js +45 -0
  145. package/lib/commands/login.js +99 -0
  146. package/lib/commands/logout.js +14 -0
  147. package/lib/commands/store.js +14 -0
  148. package/lib/commands/switch.js +52 -0
  149. package/lib/commands/theme/__tests__/delete.test.js +49 -0
  150. package/lib/commands/theme/__tests__/init.test.js +21 -0
  151. package/lib/commands/theme/__tests__/list.test.js +80 -0
  152. package/lib/commands/theme/__tests__/package.test.js +17 -0
  153. package/lib/commands/theme/__tests__/publish.test.js +61 -0
  154. package/lib/commands/theme/__tests__/pull.test.js +69 -0
  155. package/lib/commands/theme/__tests__/push.test.js +63 -0
  156. package/lib/commands/theme/__tests__/serve.test.js +107 -0
  157. package/lib/commands/theme/delete.js +64 -0
  158. package/lib/commands/theme/init.js +51 -0
  159. package/lib/commands/theme/list.js +28 -0
  160. package/lib/commands/theme/package.js +37 -0
  161. package/lib/commands/theme/publish.js +56 -0
  162. package/lib/commands/theme/pull.js +62 -0
  163. package/lib/commands/theme/push.js +106 -0
  164. package/lib/commands/theme/serve.js +153 -0
  165. package/lib/commands/theme/share.js +20 -0
  166. package/lib/commands/version.js +6 -0
  167. package/lib/config.js +5 -0
  168. package/lib/db/__mocks__/index.js +9 -0
  169. package/lib/db/__tests__/analytics.test.js +19 -0
  170. package/lib/db/__tests__/user.test.js +20 -0
  171. package/lib/db/analytics.js +48 -0
  172. package/lib/db/index.js +9 -0
  173. package/lib/db/user.js +68 -0
  174. package/lib/log.js +13 -0
  175. package/lib/openAPI/__mocks__/index.js +20 -0
  176. package/lib/openAPI/api.js +76 -0
  177. package/lib/openAPI/index.js +46 -0
  178. package/lib/report.js +37 -0
  179. package/lib/tracing.js +50 -0
  180. package/lib/utils.js +48 -0
  181. package/package.json +54 -0
@@ -0,0 +1,450 @@
1
+ @import './tools.scss';
2
+
3
+ #atc_container .container{
4
+ padding: 15px !important;
5
+ max-width: unset !important;
6
+ }
7
+
8
+ #atc_container .cart__recommended,
9
+ #atc_container .mobile-recommended,
10
+ #atc_container .cart__discount-container,
11
+ #atc_container .cart__compare-at-price,
12
+ #atc_container .cart__remove,
13
+ #atc_container .free-gift .sep-font-angle-down-fill,
14
+ #atc_container .cart__total-price-wrapper .cart__original-price {
15
+ display: none;
16
+ }
17
+
18
+ #atc_container .cart__total-price-wrapper .cart__sub-total {
19
+ font-size: 17px;
20
+ font-weight: 500;
21
+ color: #000000;
22
+ }
23
+
24
+ #atc_container .cart__total-price-wrapper_last {
25
+ margin-bottom: 16px;
26
+ }
27
+
28
+ #atc_container .cart__total-price-wrapper .cart__total-price {
29
+ font-size: 18px;
30
+ font-weight: 500 !important;
31
+ color: #9b3c44;
32
+ line-height: 20px;
33
+ }
34
+
35
+ #atc_container .cart__detail .cart__discount {
36
+ font-size: 14px;
37
+ font-weight: 400;
38
+ line-height: 17px;
39
+ color: #9b3c44;
40
+ margin-top: 2px;
41
+ }
42
+
43
+ #atc_container #cart_form {
44
+ margin-bottom: 17px;
45
+ }
46
+
47
+ #atc_container .currency__cart-tip>div:nth-child(1) {
48
+ padding-left: 32px;
49
+ font-style: italic;
50
+ font-size: 14px;
51
+ color: #999999;
52
+ justify-content: flex-end !important;
53
+ }
54
+
55
+ #atc_container .currency__cart-tip>div:nth-child(2) {
56
+ font-style: italic;
57
+ font-size: 14px;
58
+ color: #999999;
59
+ }
60
+
61
+ #atc_container .currency__cart-tip>div:nth-child(1)>span:nth-child(1) {
62
+ display: none;
63
+ }
64
+
65
+ #atc_container .currency__cart-tip_exchange {
66
+ height: auto;
67
+ background: #f3f3f3;
68
+ font-size: 14px !important;
69
+ font-weight: 400;
70
+ color: #383838 !important;
71
+ line-height: 18px;
72
+ text-align: left !important;
73
+ padding: 10px !important;
74
+ }
75
+
76
+ #atc_container .cart__checkbox {
77
+ border-radius: 50%;
78
+ }
79
+
80
+ #atc_container .cart__checkbox>svg {
81
+ border-radius: 50%;
82
+ }
83
+
84
+ #atc_container .pp_container .paypal-express-button-container {
85
+ margin-top: 16px;
86
+ width: auto;
87
+ }
88
+
89
+ .modal-backdrop.show {
90
+ opacity: .6;
91
+ }
92
+
93
+ #atc-modal {
94
+ z-index: 1051;
95
+ }
96
+
97
+ #atc-modal .modal-body {
98
+ height: 100vh;
99
+ overflow: auto;
100
+ }
101
+
102
+ #atc_container .cart {
103
+ padding-bottom: 0;
104
+ }
105
+
106
+ #atc_container .cart__title {
107
+ font-size: 24px;
108
+ padding: 0;
109
+ padding-bottom: 20px;
110
+ font-weight: 500 !important;
111
+ text-align: left !important;
112
+ letter-spacing: 0;
113
+ color: #000;
114
+ border-bottom: 1px solid #e3e3e3;
115
+ }
116
+
117
+ #atc_container .cart__checkbox {
118
+ margin: auto 15px auto 0 !important;
119
+ }
120
+
121
+ #atc_container .cart__header {
122
+ display: none;
123
+ }
124
+
125
+ #atc_container .cart__item .cart__checkbox {
126
+ margin: 0 15px 0 0;
127
+ }
128
+
129
+
130
+ #atc_container .cart__img {
131
+ background-position-x: center;
132
+ width: 5.625rem;
133
+ height: 6.875rem;
134
+ margin-right: 0;
135
+ }
136
+
137
+ #atc_container .cart__detail {
138
+ flex-direction: column;
139
+ position: relative;
140
+ }
141
+
142
+ #atc_container .cart__detail>div {
143
+ width: auto;
144
+ margin: 0 0px 0 20px;
145
+ }
146
+
147
+ #atc_container .cart__content .product_title {
148
+ -webkit-line-clamp: 2;
149
+ }
150
+
151
+ #atc_container .cart__remove {
152
+ position: absolute;
153
+ right: -17px;
154
+ }
155
+
156
+ #atc_container .cart__total {
157
+ display: none;
158
+ }
159
+
160
+ #atc_container .cart__qty {
161
+ position: absolute;
162
+ bottom: 0;
163
+ left: 20px;
164
+ margin: 14px 0 0 0 !important;
165
+ }
166
+
167
+ #atc_container .cart__content .spec p {
168
+ margin-top: .3125rem;
169
+ margin-bottom: 0;
170
+ }
171
+
172
+ #atc_container .cart__counter,
173
+ #atc_container .cart__qty-input {
174
+ width: 24px;
175
+ height: 24px;
176
+ line-height: 22px;
177
+ font-size: 12px;
178
+ top: 0;
179
+ }
180
+
181
+ #atc_container .cart__price {
182
+ text-align: right;
183
+ }
184
+
185
+ #atc_container .cart__content {
186
+ margin-bottom: 14px !important;
187
+ }
188
+
189
+ #atc_container .cart__checkout_wrapper {
190
+ width: 100%;
191
+ }
192
+
193
+ #atc_container .cart__sub-total {
194
+ color: #000000;
195
+ }
196
+
197
+ /* }
198
+
199
+ @media (max-width: 767.98px) { */
200
+ #atc-modal .modal-dialog {
201
+ box-shadow: 0px 8px 32px 0px rgba(0, 0, 0, 0.12);
202
+ margin: 0;
203
+ }
204
+
205
+ #atc-modal .modal__close.close {
206
+ font-size: 0.75rem;
207
+ top: 0.625rem;
208
+ right: 1rem;
209
+ }
210
+
211
+ /* } */
212
+
213
+ #atc_container .product-atc-title {
214
+ color: #000000;
215
+ font-weight: 700;
216
+ font-size: 16px;
217
+ margin-bottom: 15px;
218
+ }
219
+
220
+ .atc-modal {
221
+ display: flex;
222
+ flex-wrap: nowrap;
223
+ align-items: center;
224
+ overflow: hidden;
225
+ padding-bottom: 20px;
226
+ margin-bottom: 20px;
227
+ border-bottom: 1px solid #E5E5E5;
228
+ }
229
+
230
+ .atc-modal .atc-image {
231
+ width: 100px;
232
+ flex: 0 0 auto;
233
+ padding: 0 0.625rem 0 0;
234
+ }
235
+
236
+ .atc-modal .atc-image img {
237
+ width: 100%;
238
+ }
239
+
240
+ .atc-modal .atc-info {
241
+ text-align: center;
242
+ width: calc(100% - 110px);
243
+ }
244
+
245
+ .atc-modal .atc-info__title {
246
+ font-size: 0.875rem;
247
+ font-weight: bold;
248
+ color: #212121;
249
+ margin-bottom: 0.375rem;
250
+ text-align: left;
251
+ }
252
+
253
+ .atc-modal .atc-info__subtitle {
254
+ font-size: 0.875rem;
255
+ color: #212121;
256
+ margin-bottom: 0.25rem;
257
+ text-align: left;
258
+ }
259
+
260
+ #atc_container .product-atc-btn {
261
+ display: flex;
262
+ align-items: center;
263
+ flex-direction: column;
264
+ }
265
+
266
+ #atc_container .product-atc-btn .atc-btn__link {
267
+ color: #202020;
268
+ font-size: 16px;
269
+ text-decoration: underline;
270
+ }
271
+
272
+ #atc_container .product-atc-btn .atc-btn__button {
273
+ width: 100%;
274
+ height: 3.125rem;
275
+ order: 0;
276
+ margin-bottom: 1.25rem;
277
+ }
278
+
279
+ #atc_container .cart__detail .cart__now-price {
280
+ margin: 0;
281
+ font-size: 18px;
282
+ font-weight: 400;
283
+ color: #9b3c44;
284
+ }
285
+
286
+ #atc-modal .text_toggle {
287
+ -webkit-line-clamp: 2;
288
+ }
289
+
290
+ @media ($pc) {
291
+ #atc-modal .modal-dialog {
292
+ width: 400px;
293
+ margin: 0;
294
+ position: fixed;
295
+ box-shadow: 0px 8px 32px 0px rgba(0, 0, 0, 0.12);
296
+ }
297
+
298
+ #atc_container .cart__checkbox_total {
299
+ display: block !important;
300
+ }
301
+
302
+ #atc_container .cart_modal_icon_hide {
303
+ display: none !important;
304
+ }
305
+
306
+ html[dir='rtl'] #atc_container .cart__img {
307
+ margin: 0 15px 0 20px;
308
+ }
309
+
310
+ html[dir='rtl'] #atc_container .cart__checkbox {
311
+ margin: auto 0 !important;
312
+ }
313
+
314
+ .right {
315
+ right: 0;
316
+ width: 400px;
317
+ left: auto;
318
+ transition: right .15s linear;
319
+ }
320
+
321
+ .right:not(.show) {
322
+ right: 0px;
323
+ left: auto;
324
+ }
325
+
326
+ html[dir='rtl'] .right {
327
+ left: 0;
328
+ width: 400px;
329
+ right: auto;
330
+ transition: left .15s linear;
331
+ }
332
+
333
+ html[dir='rtl'] .right:not(.show) {
334
+ left: 0;
335
+ right: auto;
336
+ }
337
+ }
338
+
339
+ @media ($mobile) {
340
+ .right {
341
+ right: 0;
342
+ width: 325px;
343
+ left: auto;
344
+ transition: right .15s linear;
345
+ }
346
+
347
+ .right:not(.show) {
348
+ right: 0px;
349
+ left: auto;
350
+ }
351
+
352
+ html[dir='rtl'] .right {
353
+ left: 0;
354
+ width: 325px;
355
+ right: auto;
356
+ transition: left .15s linear;
357
+ }
358
+
359
+ html[dir='rtl'] .right:not(.show) {
360
+ left: 0;
361
+ right: auto;
362
+ }
363
+
364
+ html[dir='rtl'] #atc_container .cart__checkbox {
365
+ margin: auto 0px auto 15px !important;
366
+ }
367
+
368
+ #atc-modal .modal-dialog {
369
+ width: 325px;
370
+ margin: 0;
371
+ position: fixed;
372
+ box-shadow: 0px 8px 32px 0px rgba(0, 0, 0, 0.12);
373
+ }
374
+
375
+ #atc_container .cart__title {
376
+ font-size: 18px;
377
+ height: auto;
378
+ line-height: 1;
379
+ }
380
+
381
+ #atc-modal .modal__close.close {
382
+ top: 0;
383
+ }
384
+
385
+ #atc_container .cart__item {
386
+ padding: 1.25rem 0;
387
+ margin: 0;
388
+ }
389
+
390
+ #atc_container .cart__submit {
391
+ padding: 0;
392
+ }
393
+
394
+ #atc_container .cart__detail>div {
395
+ margin: 0 10px 0 10px;
396
+ }
397
+
398
+ #atc_container .cart__qty {
399
+ left: 10px;
400
+ bottom: -15px;
401
+ }
402
+
403
+ #atc_container .cart__detail .cart__price {
404
+ position: absolute;
405
+ bottom: -1rem;
406
+ right: -1rem;
407
+ margin: 0;
408
+ width: 5.625rem;
409
+ text-align: center;
410
+ }
411
+
412
+ #atc_container .cart__detail .cart__now-price {
413
+ line-height: 26px;
414
+ font-size: 15px;
415
+ }
416
+
417
+ #atc_container .cart__detail .cart__discount {
418
+ font-size: 12px;
419
+ }
420
+
421
+ #atc_container .currency__cart-tip_exchange {
422
+ font-size: 12px !important;
423
+ }
424
+
425
+ }
426
+
427
+ .atc-btn__link {
428
+ color: #202020;
429
+ font-size: 16px;
430
+ text-decoration: underline;
431
+ }
432
+
433
+ .modal.fade .modal-dialog {
434
+ transition: none;
435
+ }
436
+
437
+ html[dir='rtl'] #atc_container .currency__cart-tip>div:nth-child(1) {
438
+ justify-content: flex-start !important;
439
+ }
440
+
441
+ .cart_fixed-screen {
442
+ overflow: hidden;
443
+ }
444
+
445
+ @media screen and (max-width: 768px) {#atc-modal{width:100%;right:0;left:0;}}
446
+ @media screen and (min-width: 768px) {#atc-modal{width:100%;right:0;left:0;}}
447
+ #atc-modal .modal-dialog{right:0;}
448
+ #atc-modal div.modal-body { height: 100%; overflow-y: scroll; }
449
+ #atc-modal .modal-dialog { height: 100%; }
450
+ #atc-modal .modal-content { height: 100%; }
@@ -0,0 +1,234 @@
1
+ (function ($) {
2
+ $.collectionDetail = function (params) {
3
+ var collectionId = params.collection_id;
4
+ var $section = $('[data-section-id=' + params.id + ']');
5
+ var $content = $section.find('.collection-product__wrapper');
6
+ var $number = $section.find('.collection__number');
7
+ var isPaginationShow = params.is_pagination_show;
8
+ var limit = params.limit; // 每页数量
9
+ var total = params.pages; //总页数
10
+ var queryParams = $.params();
11
+ var page = parseInt(queryParams.page, 10) || 1, //分页码
12
+ loading = false, // 请求数据标示
13
+ hasMore = true; // 是否还有数据
14
+ var sort = {
15
+ name: 'Recommend',
16
+ value: queryParams.sort_by || 'manual'
17
+ };
18
+ if (params.current_tags) {
19
+ params.current_tags.split(',').map(function (i) {
20
+ // TODO escape css selector
21
+ $("[data-type=tag_filter] :radio[value='" + i.replace(/ /g, "\\ ") + "']").prop("checked", true)
22
+ })
23
+ }
24
+ sort.value && ($(".collection__sort select").val(sort.value));
25
+ queryParams.price && ($("[data-type=price_filter] :radio").each(function (i, r) {
26
+ if (r.value.replace(/[^\d-]/g, "").replace("-", ",") == (queryParams.price || "").replace(/,$/, "")) {
27
+ r.checked = true;
28
+ }
29
+ }));
30
+
31
+
32
+ // 获取数据,拼接html模板
33
+ var getData = function (param, reload, cb) {
34
+ // 显示分页直接跳转页面
35
+ if (isPaginationShow) {
36
+ return location.href = "/collections/" + params.handle + (param.tags ? "/" : "") + (param.tags || "") + "?" + $.toQuery(Object.assign($.params(), param, {
37
+ page: param.page + 1
38
+ }));
39
+ }
40
+ // 请求数据
41
+ $(document).trigger('dj.common.load_more.loading.start', { sectionId: params.id })
42
+ $.get('/api/collections/' + encodeURIComponent(collectionId) + '/products?' + $.toQuery(param), function (res, status) {
43
+ if (res && res.data && status == 'success') {
44
+ var products = res.data.products || [];
45
+ products = products.filter(function (item) {
46
+ return item.published;
47
+ })
48
+ page++;
49
+ hasMore = res.data.has_more == 1 ? true : false;
50
+ var html = '';
51
+ var topProductIds = [];
52
+ $('.top-product').each(function(_, element) {
53
+ topProductIds.push($(element).data('product-id'));
54
+ });
55
+ products = products.filter(function(p) {
56
+ return topProductIds.indexOf(p.id) === -1
57
+ });
58
+ $('.collection-empty-art-tpl').remove();
59
+ if (products.length > 0) {
60
+ html = window.template('collection-art-tpl', {
61
+ products: products,
62
+ filter: params.filter,
63
+ });
64
+ } else if (res.data.count == 0 && !$('.top-product').length) {
65
+ // 总数为0,提示搜索结果空
66
+ html = window.template('collection-empty-art-tpl');
67
+ }
68
+ // 更新商品数量
69
+ $number.html($number.text().replace(/\d+(\.\d+)?/g, res.data.count))
70
+ // 如果reload,清空原来的列表,重置page数值
71
+ reload && $content.find('.common__product-gap:not(.top-product)').remove() && (page = 1);
72
+ $content.append(html);
73
+ }else{
74
+ hasMore = false;
75
+ }
76
+ if (hasMore) {
77
+ $(document).trigger('dj.common.load_more.loading.end', { sectionId: params.id })
78
+ } else {
79
+ $(document).trigger('dj.common.load_more.hide', { sectionId: params.id })
80
+ }
81
+ loading = false;
82
+ })
83
+ }
84
+
85
+ // 监听select排序,请求数据
86
+ $(document).off('dj.common.sort_select.change').on('dj.common.sort_select.change', function (e, data) {
87
+ $('#pagination').off('pagination-change');
88
+ // 初始化组件
89
+ if (isPaginationShow && !$.isMobile()) {
90
+ initPagination(1);
91
+ }
92
+ // 请求数据
93
+ if (data.sectionId == params.id) {
94
+ hasMore = true;
95
+ sort = data;
96
+ getData({
97
+ page: 0,
98
+ sort_by: sort.value,
99
+ limit: limit,
100
+ tags: getTags('tag'),
101
+ price: getTags('price'),
102
+ }, true);
103
+ }
104
+ })
105
+
106
+ var loadMore = function () {
107
+ if (!loading && hasMore) {
108
+ loading = true;
109
+ getData({
110
+ page: page,
111
+ sort_by: sort.value,
112
+ limit: limit,
113
+ tags: getTags('tag'),
114
+ price: getTags('price'),
115
+ }, false);
116
+ }
117
+ }
118
+
119
+ // 不分页,监听滚动,请求数据
120
+ if (!isPaginationShow) {
121
+ $(document).on('scroll', $.debounce(function () {
122
+ // 判断是否到底
123
+ if ($.isToPageEnd(params.id)) {
124
+ loadMore();
125
+ }
126
+ }, 10, 50));
127
+ }
128
+
129
+ // 监听loadmore点击,请求数据
130
+ $(document).on('dj.common.load_more.is_click', function (e, data) {
131
+ if (data.sectionId == params.id) {
132
+ loadMore();
133
+ }
134
+ })
135
+
136
+ // filter(mobile)
137
+ var filter_wrapper = $('.collection-filter__wrapper');
138
+ $(document).on('click', '.collection__filter-by', function () {
139
+ //$('html, body').addClass('collection-filter__scroll');
140
+ filter_wrapper.addClass('collection-filter__wrapper-open');
141
+ })
142
+ var closeFilter = function () {
143
+ //$('html, body').removeClass('collection-filter__scroll');
144
+ filter_wrapper.removeClass('collection-filter__wrapper-open');
145
+ }
146
+ var getPrice = function(str) {
147
+ var price = (str + '').replace(/[\r\n]/g, "").replace(/\ +/g, "");
148
+ price = price.charAt(price.length - 2) == '.' ? price + '0' : price;
149
+ var decimal = false; // 是否需要精度
150
+ // 判断是否需要精度
151
+ if (price.charAt(price.length - 3) == ',' || price.charAt(price.length - 3) == '.') {
152
+ decimal = true;
153
+ price = price.substr(0, price.length - 3) + '*' + price.substr(price.length - 3);
154
+ }
155
+ // 去掉千分位分割
156
+ price = price.replace(/\./g, '').replace(/\,/g, '').replace(/\'/g, '');
157
+ if (decimal) {
158
+ price = price.replace('*', '.');
159
+ }
160
+ // 去掉货币符号
161
+ var res = /\d+(\.\d+)?/g.exec(price.replace(/,/g, ''));
162
+ return res && res[0] ? res[0] : price;
163
+ }
164
+ var getTags = function (type) {
165
+ var tagList = [];
166
+ $('.collection-filter__item[data-type=' + type + '_filter]').each(function (k, v) {
167
+ var val = $(v).find('input:checked').val();
168
+ if (type == 'price' && val) {
169
+ var val_arr = val.split('-');
170
+ if (val_arr.length == 2) {
171
+ val = getPrice(val_arr[0]) + ',' + getPrice(val_arr[1]);
172
+ } else if (val_arr.length == 1) {
173
+ val = getPrice(val_arr[0]) + ',';
174
+ }
175
+ }
176
+ val && tagList.push(val);
177
+ })
178
+ return tagList.join(',')
179
+ }
180
+ $(document).on('click', '.collection-filter__footer-confirm', closeFilter);
181
+ filter_wrapper.click(function (e) {
182
+ if ($(e.target).hasClass('collection-filter__wrapper')) {
183
+ closeFilter();
184
+ }
185
+ });
186
+ // clear all
187
+ $('.collection-filter__wrapper').on('click', '.collection-filter-clear', function () {
188
+ $('.custom-control-input').attr('checked', false);
189
+ getData({
190
+ page: 0,
191
+ sort_by: sort.value,
192
+ limit: limit,
193
+ tags: getTags('tag'),
194
+ price: getTags('price'),
195
+ }, true);
196
+ })
197
+ .on('change', '.custom-control-input', function () {
198
+ getData({
199
+ page: 0,
200
+ sort_by: sort.value,
201
+ limit: limit,
202
+ tags: getTags('tag'),
203
+ price: getTags('price'),
204
+ }, true);
205
+ })
206
+ if (window.SHOP_PARAMS.shop_env == '1') {
207
+ $(window).resize($.throttle(closeFilter, 200, 200));
208
+ }
209
+ //分页
210
+ var initPagination = function (page) {
211
+ $("#pagination").pagination({
212
+ labelPrev: '<' + params.lang.prev,
213
+ labelNext: params.lang.next + '>',
214
+ labelPageSize: params.lang.items_per_page,
215
+ page: page,
216
+ total: total,
217
+ pageSize: limit,
218
+ onChange: function (e, data) {
219
+ getData({
220
+ page: data.page - 1,
221
+ sort_by: sort.value,
222
+ limit: limit,
223
+ tags: getTags('tag'),
224
+ price: getTags('price'),
225
+ }, true);
226
+ }
227
+ });
228
+ }
229
+ initPagination(page);
230
+ $(document).on('dj.editor.update dj.editor.delete dj.editor.sort dj.editor.add', function () {
231
+ $('body').removeClass('overflow-hidden');
232
+ });
233
+ }
234
+ })(window.jQuery);