ts-glitter 14.2.5 → 14.2.7

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 (54) hide show
  1. package/hwq81jngms.json +1 -0
  2. package/lhygmbqjwr.json +1 -0
  3. package/lowcode/Entry.js +1 -1
  4. package/lowcode/Entry.ts +1 -1
  5. package/lowcode/cms-plugin/filter-options.js +1 -3
  6. package/lowcode/cms-plugin/filter-options.ts +1 -3
  7. package/lowcode/cms-plugin/module/product-excel.js +537 -0
  8. package/lowcode/cms-plugin/module/product-excel.ts +652 -0
  9. package/lowcode/cms-plugin/shopping-allowance-manager.js +12 -5
  10. package/lowcode/cms-plugin/shopping-allowance-manager.ts +12 -5
  11. package/lowcode/cms-plugin/shopping-finance-setting.js +0 -7
  12. package/lowcode/cms-plugin/shopping-finance-setting.ts +8 -8
  13. package/lowcode/cms-plugin/shopping-invoice-manager.js +5 -1
  14. package/lowcode/cms-plugin/shopping-invoice-manager.ts +5 -2
  15. package/lowcode/cms-plugin/shopping-order-manager.js +8 -0
  16. package/lowcode/cms-plugin/shopping-order-manager.ts +8 -0
  17. package/lowcode/cms-plugin/shopping-product-setting.js +61 -638
  18. package/lowcode/cms-plugin/shopping-product-setting.ts +67 -790
  19. package/lowcode/jspage/main.ts +0 -1
  20. package/lowcode/public-components/checkout/index.js +62 -21
  21. package/lowcode/public-components/checkout/index.ts +64 -21
  22. package/lowcode/public-components/checkout/index_.js +1724 -412
  23. package/lowcode/public-components/checkout/index_.ts +2032 -704
  24. package/lowcode/public-components/product/pd-class.js +51 -1
  25. package/lowcode/public-components/product/pd-class.ts +55 -2
  26. package/lowcode/public-components/product/product-detail.js +1 -1
  27. package/lowcode/public-components/product/product-detail.ts +7 -3
  28. package/lowcode/public-components/product/product-list.js +55 -0
  29. package/lowcode/public-components/product/product-list.ts +62 -1
  30. package/lowcode/public-components/public/ad.js +14 -0
  31. package/lowcode/public-components/public/ad.ts +15 -0
  32. package/nmj1s3fc0x.json +1 -0
  33. package/package.json +7 -4
  34. package/src/api-public/controllers/shop.js +16 -0
  35. package/src/api-public/controllers/shop.js.map +1 -1
  36. package/src/api-public/controllers/shop.ts +27 -3
  37. package/src/api-public/services/EcInvoice.js +18 -12
  38. package/src/api-public/services/EcInvoice.js.map +1 -1
  39. package/src/api-public/services/EcInvoice.ts +19 -14
  40. package/src/api-public/services/financial-service.d.ts +49 -1
  41. package/src/api-public/services/financial-service.js +226 -1
  42. package/src/api-public/services/financial-service.js.map +1 -1
  43. package/src/api-public/services/financial-service.ts +282 -1
  44. package/src/api-public/services/shopping.d.ts +2 -2
  45. package/src/api-public/services/shopping.js +9 -9
  46. package/src/api-public/services/shopping.js.map +1 -1
  47. package/src/api-public/services/shopping.ts +28 -28
  48. package/src/helper/glitter-util.d.ts +0 -1
  49. package/src/helper/glitter-util.js.map +1 -5
  50. package/src/index.js +108 -89
  51. package/src/index.js.map +1 -1
  52. package/src/index.ts +424 -397
  53. package/y7x8oegu36.json +1 -0
  54. package/zgp27fxdah.json +1 -0
@@ -12,8 +12,11 @@ import { GlobalUser } from '../../glitter-base/global/global-user.js';
12
12
  import { CheckInput } from '../../modules/checkInput.js';
13
13
  import { Tool } from '../../modules/tool.js';
14
14
  import { ApiCart } from '../../glitter-base/route/api-cart.js';
15
- import { ApiDelivery } from "../../glitter-base/route/delivery.js";
16
- import { ShareDialog } from "../../glitterBundle/dialog/ShareDialog.js";
15
+ import { ApiDelivery } from '../../glitter-base/route/delivery.js';
16
+ import { ApiUser } from '../../glitter-base/route/user.js';
17
+ import { FormWidget } from '../../official_view_component/official/form.js';
18
+ import { ShareDialog } from '../../glitterBundle/dialog/ShareDialog.js';
19
+ import { Ad } from '../public/ad.js';
17
20
  const html = String.raw;
18
21
  const css = String.raw;
19
22
  export class CheckoutIndex {
@@ -31,38 +34,55 @@ export class CheckoutIndex {
31
34
  customer_info: {},
32
35
  lineItems: [
33
36
  {
34
- spec: ['黑色', '小號'],
35
- id: 710,
37
+ spec: ['黃色', 'L'],
38
+ id: 715,
36
39
  count: 1,
37
- preview_image: 'https://d3jnmi1tfjgtti.cloudfront.net/file/122538856/DALL·E2024-11-0514.20.13-AsophisticatedWindermerecoffeetablewithamodernyetclassicdesign.Thetablefeaturesasolidwoodconstructionwithasmooth,polishedsurfa.webp',
38
- title: '溫德米爾 茶几',
39
- sale_price: 1800,
40
- collection: ['折扣專區'],
40
+ preview_image: 'https://d3jnmi1tfjgtti.cloudfront.net/file/122538856/size1440_s*px$_sfs0s0s4s5s7sds6_AI助手.png',
41
+ title: 'Adidas衣服',
42
+ sale_price: 1000,
43
+ collection: [],
41
44
  sku: '',
42
45
  shipment_obj: {
43
46
  type: 'weight',
44
47
  value: 1,
45
48
  },
46
- discount_price: 0,
49
+ discount_price: 188,
47
50
  rebate: 0,
48
51
  },
49
52
  ],
50
- total: 1800,
51
- email: 'daniel.lin@ncdesign.info',
53
+ total: 812,
54
+ email: 'sam38124@gmail.com',
52
55
  user_info: {
53
- shipment: '',
56
+ shipment: 'sescsbsfs4s2s4sf',
57
+ invoice_type: 'me',
58
+ send_type: 'email',
59
+ custom_form_delivery: {
60
+ '1732152125723': 'A司機',
61
+ },
62
+ name: '王建智',
63
+ phone: '0978028730',
64
+ email: 'sam38124@gmail.com',
65
+ note: 'kldskds',
54
66
  },
55
67
  shipment_fee: 0,
56
68
  rebate: 0,
57
69
  use_rebate: 0,
58
- orderID: '1732015169389',
59
- shipment_support: ['OKMARTC2C', 'shop', 'FAMIC2C', 'UNIMARTC2C'],
70
+ orderID: '1732683468622',
71
+ shipment_support: ['OKMARTC2C', 'shop', 'FAMIC2C', 'UNIMARTC2C', 'sescsbsfs4s2s4sf', 'normal', 'HILIFEC2C'],
60
72
  shipment_info: '<p style=\'box-sizing: border-box; margin: 0px; text-align: left; font-size: 14px; font-weight: 700; letter-spacing: 1.2px; color: rgb(254, 85, 65); font-family: "Open Sans", sans-serif; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;\' id="isPasted">感謝您在 SHOPNEX 購買商品,商品的包裝與配送</p><p style=\'box-sizing: border-box; margin: 0px; text-align: left; font-size: 14px; font-weight: 700; letter-spacing: 1.2px; color: rgb(254, 85, 65); font-family: "Open Sans", sans-serif; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;\'>預計花費約 3 到 6 週,煩請耐心等候!</p><p style=\'box-sizing: border-box; margin: 0px; text-align: left; font-size: 14px; font-weight: 700; letter-spacing: 1.2px; color: rgb(254, 85, 65); font-family: "Open Sans", sans-serif; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;\'>若約定配送日當天未能聯繫到你,因而無法完成配送</p><p style=\'box-sizing: border-box; margin: 0px; text-align: left; font-size: 14px; font-weight: 700; letter-spacing: 1.2px; color: rgb(254, 85, 65); font-family: "Open Sans", sans-serif; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;\'>商家會約定再次配送的時間,您將支付額外的運費。</p>',
61
73
  shipment_selector: [
74
+ {
75
+ name: '一般宅配',
76
+ value: 'normal',
77
+ },
62
78
  {
63
79
  name: '全家店到店',
64
80
  value: 'FAMIC2C',
65
81
  },
82
+ {
83
+ name: '萊爾富店到店',
84
+ value: 'HILIFEC2C',
85
+ },
66
86
  {
67
87
  name: 'OK超商店到店',
68
88
  value: 'OKMARTC2C',
@@ -75,20 +95,193 @@ export class CheckoutIndex {
75
95
  name: '實體門市取貨',
76
96
  value: 'shop',
77
97
  },
98
+ {
99
+ form: [
100
+ {
101
+ col: '12',
102
+ key: '1732152125723',
103
+ page: 'form-select',
104
+ type: 'form_plugin_v2',
105
+ group: '',
106
+ title: '物流司機',
107
+ col_sm: '12',
108
+ toggle: true,
109
+ appName: 'cms_system',
110
+ require: 'true',
111
+ readonly: 'write',
112
+ formFormat: '{}',
113
+ moduleName: '下拉選單',
114
+ style_data: {
115
+ input: {
116
+ list: [],
117
+ class: '',
118
+ style: '',
119
+ version: 'v2',
120
+ },
121
+ label: {
122
+ list: [],
123
+ class: 'form-label fs-base ',
124
+ style: '',
125
+ version: 'v2',
126
+ },
127
+ container: {
128
+ list: [],
129
+ class: '',
130
+ style: '',
131
+ version: 'v2',
132
+ },
133
+ },
134
+ form_config: {
135
+ type: 'name',
136
+ title: '',
137
+ option: [
138
+ {
139
+ name: 'A司機',
140
+ index: 0,
141
+ value: 'A司機',
142
+ },
143
+ {
144
+ name: 'B司機',
145
+ index: 0,
146
+ value: 'B司機',
147
+ },
148
+ {
149
+ name: 'C司機',
150
+ index: 0,
151
+ value: 'C司機',
152
+ },
153
+ ],
154
+ input_style: {},
155
+ title_style: {},
156
+ place_holder: '',
157
+ },
158
+ },
159
+ ],
160
+ name: '小榮物流',
161
+ value: 'sescsbsfs4s2s4sf',
162
+ },
78
163
  ],
79
164
  use_wallet: 0,
80
- user_email: 'daniel.lin@ncdesign.info',
165
+ user_email: 'sam38124@gmail.com',
81
166
  useRebateInfo: {
82
167
  point: 0,
83
168
  },
84
169
  orderSource: '',
85
170
  code_array: [],
86
171
  give_away: [],
87
- user_rebate_sum: 0,
88
- voucherList: [],
89
- discount: 0,
172
+ user_rebate_sum: 39807,
173
+ code: 'J3IXLO',
174
+ voucherList: [
175
+ {
176
+ id: 677,
177
+ for: 'all',
178
+ code: 'J3IXLO',
179
+ rule: 'min_count',
180
+ type: 'voucher',
181
+ title: '示範優惠券1011',
182
+ value: '100',
183
+ device: ['normal', 'pos'],
184
+ forKey: [],
185
+ method: 'fixed',
186
+ status: 1,
187
+ target: 'all',
188
+ userID: 122538856,
189
+ endDate: '2024-11-28',
190
+ endTime: '00:13',
191
+ overlay: false,
192
+ trigger: 'code',
193
+ counting: 'single',
194
+ ruleValue: 0,
195
+ startDate: '2024-10-11',
196
+ startTime: '17:00',
197
+ reBackType: 'discount',
198
+ targetList: ['neverBuying'],
199
+ end_ISO_Date: '2024-11-27T16:13:00.000Z',
200
+ macroLimited: 0,
201
+ microLimited: 0,
202
+ rebateEndDay: '30',
203
+ conditionType: 'order',
204
+ start_ISO_Date: '2024-10-11T09:00:00.000Z',
205
+ bind: [
206
+ {
207
+ spec: ['黃色', 'L'],
208
+ id: 715,
209
+ count: 1,
210
+ preview_image: 'https://d3jnmi1tfjgtti.cloudfront.net/file/122538856/size1440_s*px$_sfs0s0s4s5s7sds6_AI助手.png',
211
+ title: 'Adidas衣服',
212
+ sale_price: 1000,
213
+ collection: [],
214
+ sku: '',
215
+ shipment_obj: {
216
+ type: 'weight',
217
+ value: 1,
218
+ },
219
+ discount_price: 188,
220
+ rebate: 0,
221
+ },
222
+ ],
223
+ times: 1,
224
+ bind_subtotal: 1000,
225
+ discount_total: 100,
226
+ rebate_total: 0,
227
+ },
228
+ {
229
+ id: 718,
230
+ for: 'all',
231
+ code: '',
232
+ rule: 'min_price',
233
+ type: 'voucher',
234
+ title: '示範優惠券1121全館',
235
+ value: '88',
236
+ device: ['normal'],
237
+ forKey: [],
238
+ method: 'fixed',
239
+ status: 1,
240
+ target: 'all',
241
+ userID: 122538856,
242
+ endDate: '2024-11-28',
243
+ endTime: '02:00',
244
+ overlay: true,
245
+ trigger: 'auto',
246
+ counting: 'single',
247
+ ruleValue: 100,
248
+ startDate: '2024-11-21',
249
+ startTime: '02:00',
250
+ reBackType: 'discount',
251
+ targetList: [],
252
+ end_ISO_Date: '2024-11-27T18:00:00.000Z',
253
+ macroLimited: 0,
254
+ microLimited: 0,
255
+ rebateEndDay: '30',
256
+ conditionType: 'order',
257
+ start_ISO_Date: '2024-11-20T18:00:00.000Z',
258
+ bind: [
259
+ {
260
+ spec: ['黃色', 'L'],
261
+ id: 715,
262
+ count: 1,
263
+ preview_image: 'https://d3jnmi1tfjgtti.cloudfront.net/file/122538856/size1440_s*px$_sfs0s0s4s5s7sds6_AI助手.png',
264
+ title: 'Adidas衣服',
265
+ sale_price: 1000,
266
+ collection: [],
267
+ sku: '',
268
+ shipment_obj: {
269
+ type: 'weight',
270
+ value: 1,
271
+ },
272
+ discount_price: 188,
273
+ rebate: 0,
274
+ },
275
+ ],
276
+ times: 1,
277
+ bind_subtotal: 1000,
278
+ discount_total: 88,
279
+ rebate_total: 0,
280
+ },
281
+ ],
282
+ discount: 188,
90
283
  payment_setting: {
91
- TYPE: 'newWebPay',
284
+ TYPE: 'ecPay',
92
285
  },
93
286
  off_line_support: {
94
287
  atm: true,
@@ -125,17 +318,14 @@ export class CheckoutIndex {
125
318
  visible: ((_l = obj === null || obj === void 0 ? void 0 : obj.text) === null || _l === void 0 ? void 0 : _l.visible) === false ? false : true,
126
319
  fontSize: (_o = (_m = obj === null || obj === void 0 ? void 0 : obj.text) === null || _m === void 0 ? void 0 : _m.fontSize) !== null && _o !== void 0 ? _o : 16,
127
320
  };
128
- return html `
129
- <div class="d-flex align-items-center justify-content-center flex-column w-100 mx-auto ${container.class}"
130
- style="${container.style}">
131
- <div
132
- class="spinner-border ${circleAttr.visible ? '' : 'd-none'}"
133
- style="font-size: ${circleAttr.borderSize}px; width: ${circleAttr.width}px; height: ${circleAttr.width}px;"
134
- role="status"
135
- ></div>
136
- <span class="mt-3 ${textAttr.visible ? '' : 'd-none'}"
137
- style="font-size: ${textAttr.fontSize}px;">${textAttr.value}</span>
138
- </div>`;
321
+ return html ` <div class="d-flex align-items-center justify-content-center flex-column w-100 mx-auto ${container.class}" style="${container.style}">
322
+ <div
323
+ class="spinner-border ${circleAttr.visible ? '' : 'd-none'}"
324
+ style="font-size: ${circleAttr.borderSize}px; width: ${circleAttr.width}px; height: ${circleAttr.width}px;"
325
+ role="status"
326
+ ></div>
327
+ <span class="mt-3 ${textAttr.visible ? '' : 'd-none'}" style="font-size: ${textAttr.fontSize}px;">${textAttr.value}</span>
328
+ </div>`;
139
329
  }
140
330
  function isImageUrlValid(url) {
141
331
  return new Promise((resolve) => {
@@ -227,10 +417,9 @@ export class CheckoutIndex {
227
417
  return `${classPrefix}-${text}`;
228
418
  }
229
419
  function addItemBadge() {
230
- return html `
231
- <div class="${gClass('add-item-badge')}">
232
- <div class="${gClass('add-item-text')}">加購品</div>
233
- </div>`;
420
+ return html ` <div class="${gClass('add-item-badge')}">
421
+ <div class="${gClass('add-item-text')}">加購品</div>
422
+ </div>`;
234
423
  }
235
424
  function addStyle() {
236
425
  gvc.addStyle(css `
@@ -308,7 +497,7 @@ export class CheckoutIndex {
308
497
  border: 0;
309
498
  border-radius: 0.375rem;
310
499
  height: 40px;
311
- background: #DDDDDD;
500
+ background: #dddddd;
312
501
  padding: 0 24px;
313
502
  margin: 18px 0;
314
503
  }
@@ -347,15 +536,21 @@ export class CheckoutIndex {
347
536
  }
348
537
 
349
538
  .${classPrefix}-group-input {
350
- border:none;
351
- background:none;
352
- text-align: start;
353
- color: #393939;
354
- font-size: 16px;
355
- font-weight: 400;
539
+ border: none;
540
+ background: none;
541
+ text-align: start;
542
+ color: #393939;
543
+ font-size: 16px;
544
+ font-weight: 400;
356
545
  word-wrap: break-word;
357
546
  padding-left: 12px;
358
547
  }
548
+ .${classPrefix}-first-td {
549
+ display: flex;
550
+ align-items: center;
551
+ justify-content: center;
552
+ width: 30%;
553
+ }
359
554
 
360
555
  .${classPrefix}-group-input:focus {
361
556
  outline: 0;
@@ -434,11 +629,127 @@ export class CheckoutIndex {
434
629
  word-wrap: break-word;
435
630
  }
436
631
  `);
632
+ gvc.addStyle(css `
633
+ @media (max-width: 768px) {
634
+ .${classPrefix}-container {
635
+ max-width: 100% !important;
636
+ margin: 2.5rem auto !important;
637
+ }
638
+ .${classPrefix}-td {
639
+ display: flex;
640
+ align-items: center;
641
+ justify-content: start;
642
+ width: 100%;
643
+ }
644
+ .${classPrefix}-price-container {
645
+ display: flex;
646
+ flex-direction: column;
647
+ width: 100% !important;
648
+ align-items: center;
649
+ padding: 0;
650
+ gap: 12px;
651
+ margin: 24px 0;
652
+ }
653
+ }
654
+ `);
437
655
  }
438
656
  function refreshCartData() {
439
- loadings.page = true;
440
- gvc.notifyDataChange(ids.page);
657
+ const dialog = new ShareDialog(gvc.glitter);
658
+ dialog.dataLoading({ visible: true });
659
+ const beta = true;
660
+ if (!beta) {
661
+ new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
662
+ new Promise((resolve, reject) => {
663
+ setTimeout(() => {
664
+ resolve(ApiCart.cart);
665
+ });
666
+ }).then((res) => __awaiter(this, void 0, void 0, function* () {
667
+ var _a;
668
+ const cartData = {
669
+ line_items: [],
670
+ total: 0,
671
+ user_info: {
672
+ shipment: localStorage.getItem('shipment-select'),
673
+ },
674
+ };
675
+ if (res.line_items) {
676
+ res.user_info = {
677
+ shipment: localStorage.getItem('shipment-select'),
678
+ };
679
+ const cart = res;
680
+ ApiShop.getCheckout(cart).then((res) => {
681
+ if (res.result) {
682
+ resolve(res.response.data);
683
+ }
684
+ else {
685
+ resolve([]);
686
+ }
687
+ });
688
+ }
689
+ else {
690
+ for (const b of Object.keys(res)) {
691
+ cartData.line_items.push({
692
+ id: b.split('-')[0],
693
+ count: res[b],
694
+ spec: b.split('-').filter((dd, index) => {
695
+ return index !== 0;
696
+ }),
697
+ });
698
+ }
699
+ const voucher = ApiCart.cart.code;
700
+ const rebate = ApiCart.cart.use_rebate || 0;
701
+ const distributionCode = (_a = localStorage.getItem('distributionCode')) !== null && _a !== void 0 ? _a : '';
702
+ ApiShop.getCheckout({
703
+ line_items: cartData.line_items.map((dd) => {
704
+ return {
705
+ id: dd.id,
706
+ spec: dd.spec,
707
+ count: dd.count,
708
+ };
709
+ }),
710
+ code: voucher,
711
+ use_rebate: GlobalUser.token && rebate ? rebate : undefined,
712
+ distribution_code: distributionCode,
713
+ user_info: {
714
+ shipment: localStorage.getItem('shipment-select'),
715
+ },
716
+ }).then((res) => {
717
+ if (res.result) {
718
+ resolve(res.response.data);
719
+ }
720
+ else {
721
+ resolve([]);
722
+ }
723
+ });
724
+ }
725
+ }));
726
+ })).then((data) => {
727
+ vm.cartData = data;
728
+ gvc.addMtScript([
729
+ {
730
+ src: `https://unpkg.com/@lottiefiles/lottie-player@latest/dist/lottie-player.js`,
731
+ },
732
+ ], () => {
733
+ loadings.page = false;
734
+ dialog.dataLoading({ visible: false });
735
+ gvc.notifyDataChange(['js-cart-count', ids.page]);
736
+ }, () => { });
737
+ });
738
+ }
739
+ else {
740
+ gvc.addMtScript([
741
+ {
742
+ src: `https://unpkg.com/@lottiefiles/lottie-player@latest/dist/lottie-player.js`,
743
+ },
744
+ ], () => {
745
+ loadings.page = false;
746
+ dialog.dataLoading({ visible: false });
747
+ gvc.notifyDataChange(ids.page);
748
+ }, () => { });
749
+ }
750
+ gvc.glitter.recreateView('.js-cart-count');
441
751
  }
752
+ refreshCartData();
442
753
  return gvc.bindView((() => {
443
754
  return {
444
755
  bind: ids.page,
@@ -451,131 +762,186 @@ export class CheckoutIndex {
451
762
  addStyle();
452
763
  if (vm.cartData.lineItems.length === 0) {
453
764
  return html `
454
- <div class="container ${gClass(['container', 'null-container'])}">
455
- <div class="${gClass('header')}">購物明細</div>
456
- <lottie-player
765
+ <div class="container ${gClass(['container', 'null-container'])}">
766
+ <div class="${gClass('header')}">購物明細</div>
767
+ <lottie-player
457
768
  style="max-width: 100%; width: 300px; height: 300px;"
458
769
  src="https://lottie.host/38ba8340-3414-41b8-b068-bba18d240bb3/h7e1Q29IQJ.json"
459
770
  speed="1"
460
771
  loop=""
461
772
  autoplay=""
462
773
  background="transparent"
463
- ></lottie-player>
464
- <div class="mt-3">購物車是空的,趕快前往挑選您心儀的商品</div>
465
- </div> `;
774
+ ></lottie-player>
775
+ <div class="mt-3 fw-bold">購物車是空的,趕快前往挑選您心儀的商品</div>
776
+ </div>
777
+ `;
466
778
  }
467
- return html `
468
- <div class="container ${gClass('container')}">
779
+ return html ` <div class="container ${gClass('container')}">
469
780
  <div class="${gClass('header')}">購物明細</div>
470
781
  ${gvc.bindView((() => {
471
782
  return {
472
783
  bind: ids.cart,
473
784
  view: () => {
474
- var _a;
475
- return html `
476
- <section>
477
- <div class="${gClass('banner-bgr')}">
478
- <span class="${gClass('banner-text')}">購物車</span>
479
- </div>
480
- <div class="d-flex align-items-center p-3 border-bottom">
481
- <div class="${gClass('first-td')}">商品名稱</div>
482
- <div class="${gClass('td')}">規格</div>
483
- <div class="${gClass('td')}">單價</div>
484
- <div class="${gClass('td')}">數量</div>
485
- <div class="${gClass('td')}">小計</div>
486
- </div>
487
- ${gvc.bindView({
785
+ return html ` <section>
786
+ <div class="${gClass('banner-bgr')}">
787
+ <span class="${gClass('banner-text')}">購物車</span>
788
+ </div>
789
+ <div class="d-none d-sm-flex align-items-center p-3 border-bottom">
790
+ <div class="${gClass('first-td')} justify-content-start">商品名稱</div>
791
+ <div class="${gClass('td')}">規格</div>
792
+ <div class="${gClass('td')}">單價</div>
793
+ <div class="${gClass('td')}">數量</div>
794
+ <div class="${gClass('td')}">小計</div>
795
+ </div>
796
+ ${gvc.bindView({
488
797
  bind: glitter.getUUID(),
489
798
  view: () => {
490
799
  return vm.cartData.lineItems
491
- .map((item) => {
800
+ .map((item, index) => {
801
+ function financial(x) {
802
+ const parsed = Number.parseFloat(`${x}`);
803
+ if (Number.isInteger(parsed)) {
804
+ return parsed.toLocaleString();
805
+ }
806
+ const decimalPart = parsed.toString().split('.')[1];
807
+ if (decimalPart && decimalPart.length > 1) {
808
+ return parsed.toLocaleString(undefined, {
809
+ minimumFractionDigits: 1,
810
+ maximumFractionDigits: 1,
811
+ });
812
+ }
813
+ else {
814
+ return parsed.toLocaleString(undefined, {
815
+ minimumFractionDigits: 1,
816
+ maximumFractionDigits: 3,
817
+ });
818
+ }
819
+ }
492
820
  return html `
493
- <div class="d-flex align-items-center p-3 border-bottom"
494
- style="gap: 10px; position: relative;">
495
- <div class="${gClass('first-td')} justify-content-start">
496
- ${validImageBox({
497
- gvc,
498
- image: noImageURL,
499
- width: 100,
500
- })}
501
- <span class="ms-2">${item.title}${item.is_add_on_items ? addItemBadge() : ''}</span>
821
+ <div class="d-flex flex-column border-bottom p-lg-3 px-1 py-3 gap-3">
822
+ <div class="d-flex w-100 position-relative" style="gap:20px;">
823
+ <div class="${gClass('first-td')} justify-content-start d-sm-none">
824
+ <div
825
+ style="width: 88px;height: 88px;border-radius: 20px;background: 50%/cover url('${item.preview_image}')"
826
+ ></div>
827
+ <span class="ms-2 d-none">${item.title}${item.is_add_on_items ? addItemBadge() : ''}</span>
828
+ </div>
829
+ <div class="d-flex flex-sm-row flex-column w-100 position-relative" style="gap: 10px; position: relative;">
830
+ <div class="${gClass('first-td')} justify-content-start d-none d-sm-flex">
831
+ <div
832
+ style="width: 88px;height: 88px;border-radius: 20px;background: 50%/cover url('${item.preview_image}')"
833
+ ></div>
834
+ <span class="ms-2 ">${item.title}${item.is_add_on_items ? addItemBadge() : ''}</span>
502
835
  </div>
503
- <div class="${gClass('td')}">
504
- ${item.spec ? item.spec.join(' / ') : ''}
505
- </div>
506
- <div class="${gClass('td')}">
507
- <div>
836
+ <div class="${gClass('td')}">${item.spec ? item.spec.join(' / ') : ''}</div>
837
+ <div class="${gClass('td')} d-flex flex-column align-items-start align-items-sm-center" style="gap:10px;">
838
+ <div class="">
508
839
  ${(() => {
509
- function financial(x) {
510
- const parsed = Number.parseFloat(`${x}`);
511
- if (Number.isInteger(parsed)) {
512
- return parsed.toLocaleString();
513
- }
514
- const decimalPart = parsed.toString().split('.')[1];
515
- if (decimalPart && decimalPart.length > 1) {
516
- return parsed.toLocaleString(undefined, {
517
- minimumFractionDigits: 1,
518
- maximumFractionDigits: 1
519
- });
520
- }
521
- else {
522
- return parsed.toLocaleString(undefined, {
523
- minimumFractionDigits: 1,
524
- maximumFractionDigits: 3
525
- });
526
- }
527
- }
528
- return `NT.${financial(subData.sale_price - subData.discount_price)}`;
840
+ return `NT.${parseInt(item.sale_price, 10).toLocaleString()}`;
529
841
  })()}
530
842
  </div>
531
- <div>原價: NT.
532
- ${item.sale_price.toLocaleString()}
533
- </div>
534
843
  </div>
535
844
  <div class="${gClass('td')}">
536
845
  <select
537
- class="${gClass('select')}"
538
- style="width: 100px;"
539
- onchange="${gvc.event((e) => {
540
- item.count = parseInt(e.value, 10);
541
- gvc.notifyDataChange(ids.cart);
846
+ class="${gClass('select')}"
847
+ style="width: 100px;"
848
+ onchange="${gvc.event((e) => {
849
+ ApiCart.setCart((cartItem) => {
850
+ cartItem.line_items.find((dd) => {
851
+ return dd.id === item.id && item.spec.join('') === dd.spec.join('');
852
+ }).count = parseInt(e.value, 10);
853
+ refreshCartData();
854
+ });
542
855
  })}"
543
856
  >
544
- ${[...new Array(50)].map((_, index) => {
545
- return html `
546
- <option value="${index + 1}">
547
- ${index + 1}
548
- </option>`;
857
+ ${[...new Array(99)].map((_, index) => {
858
+ return html ` <option value="${index + 1}" ${index + 1 === item.count ? `selected` : ``}>
859
+ ${index + 1}
860
+ </option>`;
549
861
  })}
550
862
  </select>
551
863
  </div>
552
- <div class="${gClass('td')}">
553
- <span>合計 NT. ${(item.sale_price * item.count).toLocaleString()}</span>
554
- <div style="position: absolute; right: 5px; transform: translateY(-50%); top: 50%;">
555
- <i class="fa-solid fa-xmark-large"
556
- style="cursor: pointer;"></i>
864
+ <div class="d-block d-md-none" style="position: absolute; right: 0px; top:0px;">
865
+ <i
866
+ class="fa-solid fa-xmark-large"
867
+ style="cursor: pointer;"
868
+ onclick="${gvc.event(() => {
869
+ ApiCart.setCart((cartItem) => {
870
+ cartItem.line_items = cartItem.line_items.filter((dd) => {
871
+ return !(dd.id === item.id && item.spec.join('') === dd.spec.join(''));
872
+ });
873
+ refreshCartData();
874
+ });
875
+ })}"
876
+ ></i>
877
+ </div>
878
+ <span class="d-block d-md-none" style="position: absolute;bottom:0px;right:0px;"
879
+ >合計 NT.
880
+ ${(item.discount_price
881
+ ? (item.sale_price - item.discount_price) * item.count
882
+ : item.sale_price * item.count).toLocaleString()}</span
883
+ >
884
+ <div class="${gClass('td')} d-none d-md-flex" style="bottom:0px;right:10px;">
885
+ <span class="d-none d-md-block">合計 NT. ${(item.sale_price * item.count).toLocaleString()}</span>
886
+ <div
887
+ class="d-none d-md-block"
888
+ style="position: absolute; right: -10px; transform: translateY(-50%); top: 50%;"
889
+ >
890
+ <i
891
+ class="fa-solid fa-xmark-large"
892
+ style="cursor: pointer;"
893
+ onclick="${gvc.event(() => {
894
+ ApiCart.setCart((cartItem) => {
895
+ cartItem.line_items = cartItem.line_items.filter((dd) => {
896
+ return !(dd.id === item.id && item.spec.join('') === dd.spec.join(''));
897
+ });
898
+ refreshCartData();
899
+ });
900
+ })}"
901
+ ></i>
557
902
  </div>
558
903
  </div>
559
- </div>`;
904
+ </div>
905
+ </div>
906
+ <div>
907
+ ${vm.cartData.voucherList
908
+ .filter((dd) => {
909
+ return dd.bind.find((d2) => {
910
+ return d2.id === item.id;
911
+ });
912
+ })
913
+ .map((dd) => {
914
+ return `<div class="fs-6 w-100 " ><i class="fa-solid fa-tickets-perforated me-2"></i>${dd.title}</div>`;
915
+ })
916
+ .join('<div class="my-1"></div>')}
917
+ </div>
918
+ </div>
919
+ `;
560
920
  })
561
921
  .join('');
562
922
  },
563
923
  })}
564
- </section>
565
- <section class="d-flex">
566
- <div class="flex-fill"></div>
567
- <div class="${gClass('price-container')}">
568
- <div class="${gClass(['price-row', 'text-2'])}">
569
- <div>小計總額(合計)</div>
570
- <div>NT. ${(vm.cartData.total + vm.cartData.discount - vm.cartData.shipment_fee + vm.cartData.use_rebate).toLocaleString()}</div>
571
- </div>
572
- <div class="${gClass(['price-row', 'text-2'])}">
573
- <div>運費</div>
574
- <div>NT. ${vm.cartData.shipment_fee.toLocaleString()}</div>
575
- </div>
576
- <div class="${gClass(['price-row', 'text-2'])}">
577
- <div>優惠代碼</div>
578
- <div style="cursor: pointer; color: #3564c0;" onclick="${gvc.event(() => {
924
+ </section>
925
+ <section class="d-flex">
926
+ <div class="flex-fill"></div>
927
+ <div class="${gClass('price-container')}">
928
+ <div class="${gClass(['price-row', 'text-2'])}">
929
+ <div>商品總計</div>
930
+ <div>NT. ${(vm.cartData.total + vm.cartData.discount - vm.cartData.shipment_fee + vm.cartData.use_rebate).toLocaleString()}</div>
931
+ </div>
932
+ <div class="${gClass(['price-row', 'text-2'])}">
933
+ <div>運費</div>
934
+ <div>NT. ${vm.cartData.shipment_fee.toLocaleString()}</div>
935
+ </div>
936
+ <div class="${gClass(['price-row', 'text-2'])}">
937
+ <div>優惠券折抵</div>
938
+ <div>- NT. ${vm.cartData.discount.toLocaleString()}</div>
939
+ </div>
940
+ <div class="${gClass(['price-row', 'text-2'])}">
941
+ <div>優惠代碼</div>
942
+ <div
943
+ style="cursor: pointer; color: #3564c0;"
944
+ onclick="${gvc.event(() => {
579
945
  this.viewDialog({
580
946
  gvc: gvc,
581
947
  title: '可使用的優惠券',
@@ -595,18 +961,6 @@ export class CheckoutIndex {
595
961
  return html `<div style="height: 400px">${spinner()}</div>`;
596
962
  }
597
963
  else {
598
- if (vmi.dataList.length === 0) {
599
- return html `<div class="d-flex align-items-center justify-content-center flex-column w-100 mx-auto">
600
- <lottie-player
601
- style="max-width: 100%;width: 300px;"
602
- src="https://assets10.lottiefiles.com/packages/lf20_rc6CDU.json"
603
- speed="1"
604
- loop="true"
605
- background="transparent"
606
- ></lottie-player>
607
- <span class="mb-5 fs-5">目前沒有任何優惠券呦</span>
608
- </div>`;
609
- }
610
964
  const header = [
611
965
  {
612
966
  title: '優惠券名稱',
@@ -626,28 +980,31 @@ export class CheckoutIndex {
626
980
  item.title,
627
981
  item.code,
628
982
  (() => {
629
- const endText = item.end_ISO_Date ? glitter.ut.dateFormat(new Date(item.end_ISO_Date), 'yyyy/MM/dd') : '無使用期限';
983
+ const endText = item.end_ISO_Date
984
+ ? glitter.ut.dateFormat(new Date(item.end_ISO_Date), 'yyyy/MM/dd')
985
+ : '無使用期限';
630
986
  return `${glitter.ut.dateFormat(new Date(item.start_ISO_Date), 'yyyy/MM/dd')} ~ ${endText}`;
631
987
  })(),
632
- item.usePass ? html `<button
633
- class="${gClass('button-bgr')} my-2"
634
- style="max-width: 150px;"
635
- onclick="${gvc.event(() => {
636
- vm.cartData.code = item.code;
637
- refreshCartData();
638
- gvc.closeDialog();
639
- })}"
640
- >
641
- <span
642
- class="${gClass('button-text')}">選擇使用</span>
643
- </button>` :
644
- html `<button
645
- class="${gClass('button-bgr-disable')} my-2"
646
- style="max-width: 150px; cursor: not-allowed"
647
- >
648
- <span
649
- class="${gClass('button-text')}">未達使用標準</span>
650
- </button>`,
988
+ item.usePass
989
+ ? html `<button
990
+ class="${gClass('button-bgr')} my-2"
991
+ style="max-width: 150px;"
992
+ onclick="${gvc.event(() => {
993
+ ApiCart.setCart((cartItem) => {
994
+ cartItem.code = item.code;
995
+ refreshCartData();
996
+ gvc.closeDialog();
997
+ });
998
+ })}"
999
+ >
1000
+ <span class="${gClass('button-text')}">選擇使用</span>
1001
+ </button>`
1002
+ : html `<button
1003
+ class="${gClass('button-bgr-disable')} my-2"
1004
+ style="max-width: 150px; cursor: not-allowed"
1005
+ >
1006
+ <span class="${gClass('button-text')}">未達使用標準</span>
1007
+ </button>`,
651
1008
  ];
652
1009
  }
653
1010
  const dialog = new ShareDialog(gvc.glitter);
@@ -658,14 +1015,20 @@ export class CheckoutIndex {
658
1015
  dialog.dataLoading({ visible: true });
659
1016
  ApiShop.getCheckout(cloneCart).then((r) => {
660
1017
  dialog.dataLoading({ visible: false });
661
- if (r.result && r.response.data && r.response.data.voucherList.length > 0) {
662
- vm.cartData.code = code;
663
- refreshCartData();
664
- gvc.closeDialog();
1018
+ if (r.result &&
1019
+ r.response.data &&
1020
+ r.response.data.voucherList.some((dd) => {
1021
+ return dd.code === code;
1022
+ })) {
1023
+ ApiCart.setCart((cartItem) => {
1024
+ cartItem.code = code;
1025
+ refreshCartData();
1026
+ gvc.closeDialog();
1027
+ });
665
1028
  }
666
1029
  else {
667
1030
  dialog.errorMessage({
668
- text: '此代碼無法使用'
1031
+ text: '此代碼無法使用',
669
1032
  });
670
1033
  }
671
1034
  });
@@ -673,62 +1036,85 @@ export class CheckoutIndex {
673
1036
  if (isWebsite) {
674
1037
  const flexList = [1.2, 1, 1.5, 1.5];
675
1038
  return html `
676
- <div>
677
- <div class="d-flex align-items-center mb-2">
678
- <label class="${gClass('label')} mb-0" style="min-width: 80px;">輸入代碼</label>
679
- <input class="${gClass('input')}" type="text" onchange="${gvc.event((e) => {
1039
+ <div>
1040
+ <div class="d-flex align-items-center mb-2">
1041
+ <label class="${gClass('label')} mb-0" style="min-width: 80px;">輸入代碼</label>
1042
+ <input
1043
+ class="${gClass('input')}"
1044
+ type="text"
1045
+ onchange="${gvc.event((e) => {
680
1046
  checkCodeValue(e.value);
681
- })}"/>
682
- </div>
683
- </div>
684
- <div class="w-100 d-sm-flex py-4 um-th-bar">
685
- ${header
1047
+ })}"
1048
+ />
1049
+ </div>
1050
+ </div>
1051
+ <div class="w-100 d-sm-flex py-4 um-th-bar">
1052
+ ${header
686
1053
  .map((item, index) => {
687
- return html `<div class="um-th" style="flex: ${flexList[index]};">${item.title}</div>`;
1054
+ return html `<div class="um-th" style="flex: ${flexList[index]};">
1055
+ ${item.title}
1056
+ </div>`;
688
1057
  })
689
1058
  .join('')}
690
- </div>
691
- ${vmi.dataList
1059
+ </div>
1060
+ ${vmi.dataList
692
1061
  .map((item, t1) => {
693
1062
  const fText = formatText(item.content);
694
1063
  return html `<div class="w-100 d-sm-flex py-1 align-items-center">
695
- ${fText
1064
+ ${fText
696
1065
  .map((dd, t2) => {
697
- return html `<div class="um-td ${t2 === fText.length - 1 ? 'text-center' : ''}" style="flex: ${flexList[t2]}">${dd}</div>`;
1066
+ return html `<div
1067
+ class="um-td ${t2 === fText.length - 1 ? 'text-center' : ''}"
1068
+ style="flex: ${flexList[t2]}"
1069
+ >
1070
+ ${dd}
1071
+ </div>`;
698
1072
  })
699
1073
  .join('')}
700
- </div>`;
1074
+ </div>`;
701
1075
  })
702
1076
  .join('')}
703
- `;
1077
+ `;
704
1078
  }
705
- return html `<div>
706
- <div class="d-flex">
707
- <label class="${gClass('label')}">輸入代碼</label>
708
- <input class="${gClass('input')}" type="text" />
709
- <button class="${gClass('button-bgr')}" onclick="${gvc.event((e) => {
1079
+ return html ` <div>
1080
+ <div class="d-flex flex-column flex-sm-row align-items-center ">
1081
+ <div class="d-flex align-items-center">
1082
+ <input
1083
+ class="${gClass('input')}"
1084
+ type="text"
1085
+ style="border-top-right-radius: 0;border-bottom-right-radius: 0px;"
1086
+ placeholder="請輸入優惠代碼"
1087
+ />
1088
+ <button
1089
+ class="${gClass('button-bgr')}"
1090
+ style="width:100px;border-top-left-radius: 0;border-bottom-left-radius: 0px;"
1091
+ onclick="${gvc.event((e) => {
710
1092
  checkCodeValue(e.value);
711
- })}">
712
- <span class="${gClass('button-text')}">確認</span>
713
- </button>
714
- </div>
715
- <div class="w-100 d-sm-none mb-3 s162413">
716
- ${vmi.dataList
1093
+ })}"
1094
+ >
1095
+ <span class="${gClass('button-text')}" style="">確認</span>
1096
+ </button>
1097
+ </div>
1098
+ </div>
1099
+ <div class="w-100 d-sm-none mb-3 s162413">
1100
+ ${vmi.dataList
717
1101
  .map((item) => {
718
- return html `<div class="um-mobile-area">
719
- ${formatText(item.content)
1102
+ return html ` <div class="um-mobile-area">
1103
+ ${formatText(item.content)
720
1104
  .map((dd, index) => {
721
1105
  if (header[index].title === '') {
722
1106
  return dd;
723
1107
  }
724
- return html `<div class="um-mobile-text">${header[index].title}: ${dd}</div>`;
1108
+ return html ` <div class="um-mobile-text">
1109
+ ${header[index].title}: ${dd}
1110
+ </div>`;
725
1111
  })
726
1112
  .join('')}
727
- </div>`;
1113
+ </div>`;
728
1114
  })
729
1115
  .join('')}
730
- </div>
731
- </div>`;
1116
+ </div>
1117
+ </div>`;
732
1118
  }
733
1119
  },
734
1120
  divCreate: {},
@@ -751,7 +1137,8 @@ export class CheckoutIndex {
751
1137
  }).then((res) => __awaiter(this, void 0, void 0, function* () {
752
1138
  if (res.result && res.response.data) {
753
1139
  vmi.dataList = res.response.data.filter((item) => {
754
- return item.content.trigger === 'code' && isNowBetweenDates(item.content.start_ISO_Date, item.content.end_ISO_Date);
1140
+ return (item.content.trigger === 'code' &&
1141
+ isNowBetweenDates(item.content.start_ISO_Date, item.content.end_ISO_Date));
755
1142
  });
756
1143
  }
757
1144
  else {
@@ -766,19 +1153,21 @@ export class CheckoutIndex {
766
1153
  ApiShop.getCheckout(cloneCart).then((response) => {
767
1154
  resolve({
768
1155
  code,
769
- response
1156
+ response,
770
1157
  });
771
1158
  });
772
1159
  });
773
1160
  })).then((resolveArray) => {
774
1161
  vmi.dataList = vmi.dataList.map((item) => {
775
- const f = resolveArray.find(res => {
1162
+ const f = resolveArray.find((res) => {
776
1163
  return item.content.code === res.code;
777
1164
  });
778
1165
  if (f) {
779
1166
  const r = f.response;
780
1167
  if (r.result && r.response.data) {
781
- item.content.usePass = r.response.data.voucherList.length > 0;
1168
+ item.content.usePass = r.response.data.voucherList.some((dd) => {
1169
+ return dd.code === f.code;
1170
+ });
782
1171
  }
783
1172
  }
784
1173
  return item;
@@ -792,71 +1181,131 @@ export class CheckoutIndex {
792
1181
  },
793
1182
  };
794
1183
  })());
795
- }
1184
+ },
796
1185
  });
797
- })}">${(_a = vm.cartData.code) !== null && _a !== void 0 ? _a : '新增'}</div>
798
- </div>
799
- <div class="${gClass(['price-row', 'text-2'])}">
800
- <div>購物金折抵</div>
801
- <div>- NT. ${vm.cartData.discount.toLocaleString()}</div>
1186
+ })}"
1187
+ >
1188
+ ${vm.cartData.code
1189
+ ? html `${vm.cartData.code}<i
1190
+ class="fa-solid fa-xmark-large ms-2"
1191
+ style="cursor: pointer;"
1192
+ onclick="${gvc.event((e, event) => {
1193
+ event.stopPropagation();
1194
+ ApiCart.setCart((cartItem) => {
1195
+ cartItem.code = '';
1196
+ refreshCartData();
1197
+ });
1198
+ })}"
1199
+ ></i>`
1200
+ : '新增'}
802
1201
  </div>
803
- <div class="${gClass(['price-row', 'text-2'])}">
804
- <div
805
- style=" justify-content: flex-start; align-items: center; display: inline-flex;border:1px solid #EAEAEA;border-radius: 10px;overflow: hidden; ${document
806
- .body.clientWidth > 768
807
- ? 'gap: 18px; '
808
- : 'flex-direction: column; gap: 0px; '}"
809
- class="w-100"
810
- >
811
- <input
812
- class="flex-fill ${gClass('group-input')}"
813
- placeholder="請輸入購物金"
814
- value="${vm.cartData.use_rebate || ''}"
815
- />
816
- <div class="${gClass('group-button')}" >
817
- <div class="${gClass('button-text')}"
818
- onclick="${gvc.event((e) => {
819
- let text = e.value;
820
- const dialog = new ShareDialog(gvc.glitter);
821
- const textNumber = parseInt(text, 10);
822
- const subtotal = vm.cartData.total - vm.cartData.shipment_fee + vm.cartData.use_rebate;
823
- if (!CheckInput.isNumberString(text)) {
824
- dialog.infoMessage({ text: '僅限輸入數字' });
825
- }
826
- if (textNumber) {
827
- dialog.errorMessage({ text: `請輸入 0 到 ${Math.min(textNumber, subtotal)} 的數值` });
1202
+ </div>
1203
+ ${(() => {
1204
+ if (!GlobalUser.token) {
1205
+ return ``;
828
1206
  }
829
1207
  else {
830
- vm.cartData.use_rebate = text;
831
- refreshCartData();
832
- }
833
- })}">
834
- 套用
835
- </div>
836
- </div>
837
- </div>
838
- </div>
839
- <div class="${gClass(['price-row', 'text-2'])}">
1208
+ return html `${(() => {
1209
+ let tempRebate = 0;
1210
+ const dialog = new ShareDialog(gvc.glitter);
1211
+ return html `<div class="${gClass(['price-row', 'text-2'])}">
1212
+ <div>購物金折抵</div>
1213
+ <div>- NT. ${vm.cartData.use_rebate.toLocaleString()}</div>
1214
+ </div>
840
1215
 
841
- ${(() => {
842
- const sum = vm.cartData.user_rebate_sum || 0;
843
- if (!vm.cartData.useRebateInfo) {
844
- return '';
845
- }
846
- const info = vm.cartData.useRebateInfo;
847
- if (info.condition) {
848
- return `還差$ ${info.condition.toLocaleString()} 即可使用購物金折抵`;
849
- }
850
- if (info.limit) {
851
- return `您目前剩餘 ${sum || 0} 點購物金<br />此份訂單最多可折抵 ${info.limit.toLocaleString()} 點購物金`;
852
- }
853
- else {
854
- return `您目前剩餘 ${sum || 0} 點購物金`;
1216
+ <div class="${gClass(['price-row', 'text-2'])}">
1217
+ <div
1218
+ style="justify-content: flex-start; align-items: center; display: inline-flex;border:1px solid #EAEAEA;border-radius: 10px;overflow: hidden; ${document
1219
+ .body.clientWidth > 768
1220
+ ? 'gap: 18px; '
1221
+ : ' gap: 0px; '}"
1222
+ class="w-100"
1223
+ >
1224
+ <input
1225
+ class="flex-fill ${gClass('group-input')}"
1226
+ placeholder="請輸入購物金"
1227
+ style="${document.body.clientWidth < 800 ? `width:calc(100% - 150px) !important;` : ``}"
1228
+ value="${vm.cartData.use_rebate || ''}"
1229
+ onchange="${gvc.event((e, event) => {
1230
+ if (CheckInput.isNumberString(e.value)) {
1231
+ tempRebate = parseInt(e.value, 10);
1232
+ }
1233
+ else {
1234
+ dialog.errorMessage({ text: `請輸入數值` });
1235
+ gvc.notifyDataChange(ids.page);
1236
+ }
1237
+ })}"
1238
+ />
1239
+ <div class="${gClass('group-button')}">
1240
+ <div
1241
+ class="${gClass('button-text')}"
1242
+ onclick="${gvc.event((e) => __awaiter(this, void 0, void 0, function* () {
1243
+ const sum = yield new Promise((resolve, reject) => {
1244
+ ApiShop.getRebate({}).then((res) => __awaiter(this, void 0, void 0, function* () {
1245
+ if (res.result && res.response.sum) {
1246
+ resolve(res.response.sum);
1247
+ }
1248
+ else {
1249
+ resolve(0);
1250
+ }
1251
+ }));
1252
+ });
1253
+ const limit = vm.cartData.total - vm.cartData.shipment_fee + vm.cartData.use_rebate;
1254
+ if (tempRebate > Math.min(sum, limit)) {
1255
+ dialog.errorMessage({ text: `請輸入 0 到 ${Math.min(sum, limit)} 的數值` });
1256
+ }
1257
+ else {
1258
+ ApiCart.setCart((cartItem) => {
1259
+ cartItem.use_rebate = tempRebate;
1260
+ refreshCartData();
1261
+ });
1262
+ }
1263
+ }))}"
1264
+ >
1265
+ 套用
1266
+ </div>
1267
+ </div>
1268
+ </div>
1269
+ </div>`;
1270
+ })()}
1271
+ <div class="${gClass(['price-row', 'text-2'])}">
1272
+ ${(() => {
1273
+ return gvc.bindView(() => {
1274
+ return {
1275
+ bind: gvc.glitter.getUUID(),
1276
+ view: () => __awaiter(this, void 0, void 0, function* () {
1277
+ const sum = yield new Promise((resolve, reject) => {
1278
+ ApiShop.getRebate({}).then((res) => __awaiter(this, void 0, void 0, function* () {
1279
+ if (res.result && res.response.sum) {
1280
+ resolve(res.response.sum);
1281
+ }
1282
+ else {
1283
+ resolve(0);
1284
+ }
1285
+ }));
1286
+ });
1287
+ if (!vm.cartData.useRebateInfo) {
1288
+ return '';
1289
+ }
1290
+ const info = vm.cartData.useRebateInfo;
1291
+ if (info.condition) {
1292
+ return `還差$ ${info.condition.toLocaleString()} 即可使用購物金折抵`;
1293
+ }
1294
+ if (info.limit) {
1295
+ return `您目前剩餘 ${sum || 0} 點購物金<br />此份訂單最多可折抵 ${info.limit.toLocaleString()} 點購物金`;
1296
+ }
1297
+ else {
1298
+ return `您目前剩餘 ${sum || 0} 點購物金`;
1299
+ }
1300
+ }),
1301
+ };
1302
+ });
1303
+ })()}
1304
+ </div>`;
855
1305
  }
856
1306
  })()}
857
- </div>
858
- </div>
859
- </section>`;
1307
+ </div>
1308
+ </section>`;
860
1309
  },
861
1310
  };
862
1311
  })())}
@@ -874,43 +1323,76 @@ export class CheckoutIndex {
874
1323
  <div class="${gClass('banner-bgr')}">
875
1324
  <span class="${gClass('banner-text')}">付款及配送方式</span>
876
1325
  </div>
1326
+ ${vm.cartData.shipment_info ? `<div class="pt-2 mx-2 mx-sm-3">${vm.cartData.shipment_info}</div>` : ''}
877
1327
  <div class="row m-0 my-md-3">
878
- <div class="col-12 col-md-6">
1328
+ <div class="col-12 col-md-6 mb-2 mb-sm-0">
879
1329
  <label class="${gClass('label')}">付款方式</label>
880
1330
  <div>
881
- <select class="w-100 ${gClass('select')}"
882
- onchange="${gvc.event((e, event) => {
1331
+ <select
1332
+ class="w-100 ${gClass('select')}"
1333
+ onchange="${gvc.event((e, event) => {
883
1334
  vm.cartData.customer_info.payment_select = e.value;
884
1335
  this.storeLocalData(vm.cartData);
885
1336
  refreshCartData();
886
- })}">
1337
+ })}"
1338
+ >
887
1339
  ${(() => {
888
- return this.getPaymentMethod(vm.cartData).map((dd) => {
889
- return `<option value="${dd.value}" ${(localStorage.getItem('checkout-payment') === dd.value) ? `selected` : ``}>${dd.name}</option>`;
890
- }).join('');
1340
+ return this.getPaymentMethod(vm.cartData)
1341
+ .map((dd) => {
1342
+ return `<option value="${dd.value}" ${localStorage.getItem('checkout-payment') === dd.value ? `selected` : ``}>${dd.name}</option>`;
1343
+ })
1344
+ .join('');
891
1345
  })()}
892
1346
  </select>
893
1347
  </div>
894
1348
  </div>
895
- <div class="col-12 col-md-6">
1349
+ <div class="col-12 col-md-6 mb-2">
896
1350
  <label class="${gClass('label')}">配送方式</label>
897
1351
  <div>
898
- <select class="w-100 ${gClass('select')}"
899
- onchange="${gvc.event((e, event) => {
1352
+ <select
1353
+ class="w-100 ${gClass('select')}"
1354
+ onchange="${gvc.event((e, event) => {
1355
+ [
1356
+ 'CVSStoreName',
1357
+ 'MerchantTradeNo',
1358
+ 'LogisticsSubType',
1359
+ 'CVSStoreID',
1360
+ 'CVSStoreName',
1361
+ 'CVSTelephone',
1362
+ 'CVSOutSide',
1363
+ 'ExtraData',
1364
+ 'CVSAddress',
1365
+ ].map((dd) => {
1366
+ gvc.glitter.setUrlParameter(dd);
1367
+ });
900
1368
  vm.cartData.user_info.shipment = e.value;
901
1369
  this.storeLocalData(vm.cartData);
902
1370
  refreshCartData();
903
- })}">
1371
+ })}"
1372
+ >
904
1373
  ${(() => {
905
- return this.getShipmentMethod(vm.cartData).map((dd) => {
906
- return `<option value="${dd.value}" ${(vm.cartData.user_info.shipment === dd.value) ? `selected` : ``}>${dd.name}</option>`;
907
- }).join('');
1374
+ return this.getShipmentMethod(vm.cartData)
1375
+ .map((dd) => {
1376
+ return `<option value="${dd.value}" ${vm.cartData.user_info.shipment === dd.value ? `selected` : ``}>${dd.name}</option>`;
1377
+ })
1378
+ .join('');
908
1379
  })()}
909
1380
  </select>
910
1381
  </div>
911
1382
  </div>
1383
+ ${vm.cartData.user_info.shipment === 'normal'
1384
+ ? `<div class="col-12 col-md-6 mb-2">
1385
+ <label class="${gClass('label')}">配送地址</label>
1386
+ <input class="${gClass('input')}" type="address" placeholder="請輸入配送地址" value="${vm.cartData.user_info.address || ''}" onchange="${gvc.event((e, event) => {
1387
+ vm.cartData.user_info.address = e.value;
1388
+ this.storeLocalData(vm.cartData);
1389
+ })}">
1390
+ </div>`
1391
+ : ``}
912
1392
  <div class="col-12 ${['UNIMARTC2C', 'FAMIC2C', 'HILIFEC2C', 'OKMARTC2C'].includes(vm.cartData.user_info.shipment) ? `` : `d-none`}">
913
- <button class="${gClass('button-bgr')}" onclick="${gvc.event(() => {
1393
+ <button
1394
+ class="${gClass('button-bgr')}"
1395
+ onclick="${gvc.event(() => {
914
1396
  ApiDelivery.storeMaps({
915
1397
  returnURL: location.href,
916
1398
  logistics: vm.cartData.user_info.shipment,
@@ -918,54 +1400,800 @@ export class CheckoutIndex {
918
1400
  $('body').html(res.response.form);
919
1401
  document.querySelector('#submit').click();
920
1402
  }));
921
- })}">
922
- <span class="${gClass('button-text')}">${(() => {
923
- let cvs = glitter.getUrlParameter('CVSStoreName');
1403
+ })}"
1404
+ >
1405
+ <span class="${gClass('button-text')}"
1406
+ >${(() => {
1407
+ let cvs = glitter.getUrlParameter('CVSStoreName') || '';
924
1408
  if (decodeURIComponent(cvs)) {
925
1409
  return `${decodeURIComponent(cvs)} 『 點擊重選門市 』`;
926
1410
  }
927
1411
  else {
928
1412
  return `選擇配送門市`;
929
1413
  }
930
- })()}</span>
1414
+ })()}</span
1415
+ >
931
1416
  </button>
932
1417
  </div>
1418
+ ${(() => {
1419
+ var _a;
1420
+ try {
1421
+ vm.cartData.user_info.custom_form_delivery = (_a = vm.cartData.user_info.custom_form_delivery) !== null && _a !== void 0 ? _a : {};
1422
+ const form_array = JSON.parse(JSON.stringify(this.getShipmentMethod(vm.cartData).find((dd) => {
1423
+ return vm.cartData.user_info.shipment === dd.value;
1424
+ }).form));
1425
+ form_array.map((dd) => {
1426
+ dd.col = '4';
1427
+ dd.form_config.title_style = {
1428
+ list: [
1429
+ {
1430
+ class: gClass('label') + ' mb-2',
1431
+ style: 'return `color:${glitter.share.globalValue[`theme_color.0.title`]} !important;font-size:16px !important;`',
1432
+ stylist: [],
1433
+ dataType: 'code',
1434
+ style_from: 'code',
1435
+ classDataType: 'static',
1436
+ },
1437
+ ],
1438
+ class: 'form-label',
1439
+ style: 'font-size: 20px;font-style: normal;font-weight: 400;line-height: 140%; color:#393939 !important;',
1440
+ stylist: [],
1441
+ version: 'v2',
1442
+ dataType: 'static',
1443
+ style_from: 'code',
1444
+ classDataType: 'static',
1445
+ };
1446
+ dd.form_config.input_style = {
1447
+ list: [
1448
+ {
1449
+ class: gClass('input'),
1450
+ style: 'return `border-radius: ${widget.formData.radius}px !important;`',
1451
+ stylist: [],
1452
+ dataType: 'code',
1453
+ style_from: 'code',
1454
+ classDataType: 'static',
1455
+ },
1456
+ ],
1457
+ class: ' mb-3',
1458
+ style: 'background: #FFF;',
1459
+ stylist: [],
1460
+ version: 'v2',
1461
+ dataType: 'static',
1462
+ style_from: 'code',
1463
+ classDataType: 'static',
1464
+ };
1465
+ });
1466
+ return [
1467
+ FormWidget.editorView({
1468
+ gvc: gvc,
1469
+ array: form_array,
1470
+ refresh: () => {
1471
+ this.storeLocalData(vm.cartData);
1472
+ },
1473
+ formData: vm.cartData.user_info.custom_form_delivery,
1474
+ }),
1475
+ ].join('');
1476
+ }
1477
+ catch (e) {
1478
+ console.error(e);
1479
+ return ``;
1480
+ }
1481
+ })()}
933
1482
  </div>
934
1483
  </section>
935
- <section>
1484
+ <section class="${['UNIMARTC2C', 'FAMIC2C', 'HILIFEC2C', 'OKMARTC2C'].includes(vm.cartData.user_info.shipment) ? `` : `mt-4`}">
936
1485
  <div class="${gClass('banner-bgr')}">
937
1486
  <span class="${gClass('banner-text')}">顧客資料</span>
938
1487
  </div>
939
- <div class="row m-0 my-md-3">
940
- ${[{
1488
+ <div class="row m-0 mt-3 mb-2">
1489
+ ${[
1490
+ {
941
1491
  name: '姓名',
942
- key: 'name'
943
- }, {
1492
+ key: 'name',
1493
+ },
1494
+ {
944
1495
  name: '聯絡電話',
945
- key: 'phone'
946
- }, {
1496
+ key: 'phone',
1497
+ },
1498
+ {
947
1499
  name: '電子信箱',
948
- key: 'email'
949
- }].map((dd) => {
950
- return `<div class="col-12 col-md-6">
951
- <label class="${gClass('label')}">${dd.name}</label>
952
- <input class="${gClass('input')}" type="${dd.key}" onclick="${gvc.event((e, event) => {
1500
+ key: 'email',
1501
+ },
1502
+ ]
1503
+ .map((dd) => {
1504
+ return html ` <div class="col-12 col-md-4 mb-2">
1505
+ <label class="${gClass('label')}">${dd.name}</label>
1506
+ <input
1507
+ class="${gClass('input')}"
1508
+ type="${dd.key}"
1509
+ value="${vm.cartData.customer_info[dd.key] || ''}"
1510
+ onchange="${gvc.event((e, event) => {
953
1511
  vm.cartData.customer_info[dd.key] = e.value;
954
1512
  this.storeLocalData(vm.cartData);
955
- })}"/>
956
- </div>`;
957
- }).join('')}
1513
+ })}"
1514
+ />
1515
+ </div>`;
1516
+ })
1517
+ .join('')}
958
1518
  </div>
1519
+ ${gvc.bindView(() => {
1520
+ const id = gvc.glitter.getUUID();
1521
+ const vm_info = {
1522
+ loading: true,
1523
+ list: [],
1524
+ login_config: {},
1525
+ };
1526
+ ApiUser.getPublicConfig('custom_form_checkout', 'manager').then((res) => {
1527
+ var _a;
1528
+ vm_info.list = ((_a = res.response.value) !== null && _a !== void 0 ? _a : { list: [] }).list;
1529
+ vm.cartData.custom_form_format = vm_info.list;
1530
+ gvc.notifyDataChange(id);
1531
+ });
1532
+ return {
1533
+ bind: id,
1534
+ view: () => {
1535
+ const form_array = JSON.parse(JSON.stringify(vm_info.list));
1536
+ form_array.map((dd) => {
1537
+ dd.col = '4';
1538
+ dd.form_config.title_style = {
1539
+ list: [
1540
+ {
1541
+ class: gClass('label') + ' mb-2',
1542
+ style: 'return `color:${glitter.share.globalValue[`theme_color.0.title`]} !important;font-size:16px !important;`',
1543
+ stylist: [],
1544
+ dataType: 'code',
1545
+ style_from: 'code',
1546
+ classDataType: 'static',
1547
+ },
1548
+ ],
1549
+ class: 'form-label',
1550
+ style: 'font-size: 20px;font-style: normal;font-weight: 400;line-height: 140%; color:#393939 !important;',
1551
+ stylist: [],
1552
+ version: 'v2',
1553
+ dataType: 'static',
1554
+ style_from: 'code',
1555
+ classDataType: 'static',
1556
+ };
1557
+ dd.form_config.input_style = {
1558
+ list: [
1559
+ {
1560
+ class: gClass('input'),
1561
+ style: 'return `border-radius: ${widget.formData.radius}px !important;`',
1562
+ stylist: [],
1563
+ dataType: 'code',
1564
+ style_from: 'code',
1565
+ classDataType: 'static',
1566
+ },
1567
+ ],
1568
+ class: ' mb-3',
1569
+ style: 'background: #FFF;',
1570
+ stylist: [],
1571
+ version: 'v2',
1572
+ dataType: 'static',
1573
+ style_from: 'code',
1574
+ classDataType: 'static',
1575
+ };
1576
+ });
1577
+ return [
1578
+ FormWidget.editorView({
1579
+ gvc: gvc,
1580
+ array: form_array,
1581
+ refresh: () => {
1582
+ this.storeLocalData(vm.cartData);
1583
+ },
1584
+ formData: vm.cartData.custom_form_data,
1585
+ }),
1586
+ ].join('');
1587
+ },
1588
+ divCreate: {
1589
+ class: `w-100 `,
1590
+ },
1591
+ };
1592
+ })}
959
1593
  </section>
960
1594
  <section>
961
1595
  <div class="${gClass('banner-bgr')}">
962
1596
  <span class="${gClass('banner-text')}">收件人資料</span>
963
1597
  </div>
964
- <div class="row m-0 my-md-3">
965
- <div class="col-12 col-md-6">
966
- <label class="${gClass('label')}">電子信箱</label>
967
- <input class="${gClass('input')}" type="email"/>
968
- </div>
1598
+
1599
+ ${gvc.bindView(() => {
1600
+ const id = 'invoice_place';
1601
+ const vm_info = {
1602
+ loading: true,
1603
+ list: [],
1604
+ login_config: {},
1605
+ };
1606
+ let method = '';
1607
+ ApiShop.getInvoiceType().then((response) => {
1608
+ method = response.method;
1609
+ vm_info.loading = false;
1610
+ gvc.notifyDataChange(id);
1611
+ });
1612
+ const checkbox = this.getCheckedClass(gvc, '#393939');
1613
+ return {
1614
+ bind: id,
1615
+ view: () => {
1616
+ if (vm_info.loading) {
1617
+ return ``;
1618
+ }
1619
+ vm_info.list = [
1620
+ {
1621
+ col: '3',
1622
+ key: 'name',
1623
+ page: 'input',
1624
+ type: 'form_plugin_v2',
1625
+ group: '',
1626
+ title: '姓名',
1627
+ col_sm: '12',
1628
+ appName: 'cms_system',
1629
+ require: 'true',
1630
+ readonly: 'write',
1631
+ formFormat: '{}',
1632
+ moduleName: '輸入框',
1633
+ style_data: {
1634
+ input: {
1635
+ list: [],
1636
+ class: '',
1637
+ style: '',
1638
+ version: 'v2',
1639
+ },
1640
+ label: {
1641
+ list: [],
1642
+ class: 'form-label fs-base ',
1643
+ style: '',
1644
+ version: 'v2',
1645
+ },
1646
+ container: {
1647
+ list: [],
1648
+ class: '',
1649
+ style: '',
1650
+ version: 'v2',
1651
+ },
1652
+ },
1653
+ form_config: {
1654
+ type: 'name',
1655
+ title: '',
1656
+ input_style: { list: [], version: 'v2' },
1657
+ title_style: { list: [], version: 'v2' },
1658
+ place_holder: '請輸入姓名',
1659
+ },
1660
+ hidden_code: '',
1661
+ },
1662
+ {
1663
+ col: '3',
1664
+ key: 'phone',
1665
+ page: 'input',
1666
+ type: 'form_plugin_v2',
1667
+ group: '',
1668
+ title: '聯絡電話',
1669
+ col_sm: '12',
1670
+ appName: 'cms_system',
1671
+ require: 'true',
1672
+ readonly: 'write',
1673
+ formFormat: '{}',
1674
+ moduleName: '輸入框',
1675
+ style_data: {
1676
+ input: {
1677
+ list: [],
1678
+ class: '',
1679
+ style: '',
1680
+ version: 'v2',
1681
+ },
1682
+ label: {
1683
+ list: [],
1684
+ class: 'form-label fs-base ',
1685
+ style: '',
1686
+ version: 'v2',
1687
+ },
1688
+ container: {
1689
+ list: [],
1690
+ class: '',
1691
+ style: '',
1692
+ version: 'v2',
1693
+ },
1694
+ },
1695
+ form_config: {
1696
+ type: 'phone',
1697
+ title: '',
1698
+ input_style: { list: [], version: 'v2' },
1699
+ title_style: { list: [], version: 'v2' },
1700
+ place_holder: '請輸入聯絡電話',
1701
+ },
1702
+ hidden_code: '',
1703
+ },
1704
+ {
1705
+ col: '6',
1706
+ key: 'email',
1707
+ page: 'input',
1708
+ type: 'form_plugin_v2',
1709
+ group: '',
1710
+ title: '電子信箱',
1711
+ col_sm: '12',
1712
+ appName: 'cms_system',
1713
+ require: 'true',
1714
+ readonly: 'write',
1715
+ formFormat: '{}',
1716
+ moduleName: '輸入框',
1717
+ style_data: {
1718
+ input: {
1719
+ list: [],
1720
+ class: '',
1721
+ style: '',
1722
+ version: 'v2',
1723
+ },
1724
+ label: {
1725
+ list: [],
1726
+ class: 'form-label fs-base ',
1727
+ style: '',
1728
+ version: 'v2',
1729
+ },
1730
+ container: {
1731
+ list: [],
1732
+ class: '',
1733
+ style: '',
1734
+ version: 'v2',
1735
+ },
1736
+ },
1737
+ form_config: {
1738
+ type: 'email',
1739
+ title: '',
1740
+ input_style: { list: [], version: 'v2' },
1741
+ title_style: { list: [], version: 'v2' },
1742
+ place_holder: '請輸入電子信箱',
1743
+ },
1744
+ hidden_code: '',
1745
+ },
1746
+ {
1747
+ col: '6',
1748
+ key: 'invoice_type',
1749
+ page: 'form-select',
1750
+ type: 'form_plugin_v2',
1751
+ group: '',
1752
+ title: '發票開立對象',
1753
+ col_sm: '12',
1754
+ appName: 'cms_system',
1755
+ require: 'true',
1756
+ readonly: 'write',
1757
+ formFormat: '{}',
1758
+ moduleName: '下拉選單',
1759
+ style_data: {
1760
+ input: {
1761
+ list: [],
1762
+ class: '',
1763
+ style: '',
1764
+ version: 'v2',
1765
+ },
1766
+ label: {
1767
+ list: [],
1768
+ class: 'form-label fs-base ',
1769
+ style: '',
1770
+ version: 'v2',
1771
+ },
1772
+ container: {
1773
+ list: [],
1774
+ class: '',
1775
+ style: '',
1776
+ version: 'v2',
1777
+ },
1778
+ },
1779
+ form_config: {
1780
+ type: 'name',
1781
+ title: '',
1782
+ option: [
1783
+ { name: '個人', index: 0, value: 'me' },
1784
+ { name: '公司', index: 1, value: 'company' },
1785
+ { name: '捐贈發票', index: 2, value: 'donate' },
1786
+ ],
1787
+ input_style: { list: [], version: 'v2' },
1788
+ title_style: { list: [], version: 'v2' },
1789
+ place_holder: '',
1790
+ },
1791
+ hidden_code: "return (form_data['invoice_method']==='nouse')",
1792
+ },
1793
+ {
1794
+ col: '6',
1795
+ key: 'send_type',
1796
+ page: 'form-select',
1797
+ type: 'form_plugin_v2',
1798
+ group: '',
1799
+ title: '開立方式',
1800
+ col_sm: '12',
1801
+ appName: 'cms_system',
1802
+ require: 'true',
1803
+ readonly: 'write',
1804
+ formFormat: '{}',
1805
+ moduleName: '下拉選單',
1806
+ style_data: {
1807
+ input: {
1808
+ list: [],
1809
+ class: '',
1810
+ style: '',
1811
+ version: 'v2',
1812
+ },
1813
+ label: {
1814
+ list: [],
1815
+ class: 'form-label fs-base ',
1816
+ style: '',
1817
+ version: 'v2',
1818
+ },
1819
+ container: {
1820
+ list: [],
1821
+ class: '',
1822
+ style: '',
1823
+ version: 'v2',
1824
+ },
1825
+ },
1826
+ form_config: {
1827
+ type: 'name',
1828
+ title: '',
1829
+ option: [
1830
+ {
1831
+ name: '傳送至用戶信箱',
1832
+ index: 0,
1833
+ value: 'email',
1834
+ },
1835
+ {
1836
+ name: '手機條碼載具',
1837
+ index: 1,
1838
+ value: 'carrier',
1839
+ },
1840
+ ],
1841
+ input_style: { list: [], version: 'v2' },
1842
+ title_style: { list: [], version: 'v2' },
1843
+ place_holder: '',
1844
+ },
1845
+ hidden_code: " if(form_data['invoice_type']!=='me' || (form_data['invoice_method']==='nouse') || (form_data['invoice_method']==='off_line')){\n form_data[form_key]=undefined\nreturn true\n }else{\n return false\n }",
1846
+ },
1847
+ {
1848
+ key: 'carrier_num',
1849
+ page: 'input',
1850
+ type: 'form_plugin_v2',
1851
+ group: '',
1852
+ title: '載具號碼',
1853
+ appName: 'cms_system',
1854
+ require: 'false',
1855
+ readonly: 'write',
1856
+ formFormat: '{}',
1857
+ moduleName: '輸入框',
1858
+ col: '3',
1859
+ col_sm: '12',
1860
+ style_data: {
1861
+ input: {
1862
+ list: [],
1863
+ class: '',
1864
+ style: '',
1865
+ version: 'v2',
1866
+ },
1867
+ label: {
1868
+ list: [],
1869
+ class: 'form-label fs-base ',
1870
+ style: '',
1871
+ version: 'v2',
1872
+ },
1873
+ container: {
1874
+ list: [],
1875
+ class: '',
1876
+ style: '',
1877
+ version: 'v2',
1878
+ },
1879
+ },
1880
+ form_config: {
1881
+ type: 'name',
1882
+ title: '',
1883
+ input_style: { list: [], version: 'v2' },
1884
+ title_style: { list: [], version: 'v2' },
1885
+ place_holder: '請輸入載具號碼',
1886
+ },
1887
+ hidden_code: " \n if(form_data['invoice_type']!=='me' || form_data['send_type']!=='carrier'){\n form_data[form_key]=undefined\nreturn true\n }else{\n return false\n }",
1888
+ },
1889
+ {
1890
+ key: 'company',
1891
+ page: 'input',
1892
+ type: 'form_plugin_v2',
1893
+ group: '',
1894
+ title: '公司名稱',
1895
+ appName: 'cms_system',
1896
+ require: 'false',
1897
+ readonly: 'write',
1898
+ formFormat: '{}',
1899
+ moduleName: '輸入框',
1900
+ col: '3',
1901
+ col_sm: '12',
1902
+ style_data: {
1903
+ input: {
1904
+ list: [],
1905
+ class: '',
1906
+ style: '',
1907
+ version: 'v2',
1908
+ },
1909
+ label: {
1910
+ list: [],
1911
+ class: 'form-label fs-base ',
1912
+ style: '',
1913
+ version: 'v2',
1914
+ },
1915
+ container: {
1916
+ list: [],
1917
+ class: '',
1918
+ style: '',
1919
+ version: 'v2',
1920
+ },
1921
+ },
1922
+ form_config: {
1923
+ type: 'name',
1924
+ title: '',
1925
+ input_style: { list: [], version: 'v2' },
1926
+ title_style: { list: [], version: 'v2' },
1927
+ place_holder: '請輸入公司名稱',
1928
+ },
1929
+ hidden_code: " if(form_data['invoice_type']!=='company' || (form_data['invoice_method']==='nouse')){\n form_data[form_key]=undefined\nreturn true\n }else{\n return false\n }",
1930
+ },
1931
+ {
1932
+ key: 'gui_number',
1933
+ page: 'input',
1934
+ type: 'form_plugin_v2',
1935
+ group: '',
1936
+ title: '公司統一編號',
1937
+ col: '3',
1938
+ col_sm: '12',
1939
+ appName: 'cms_system',
1940
+ require: 'false',
1941
+ readonly: 'write',
1942
+ formFormat: '{}',
1943
+ moduleName: '輸入框',
1944
+ style_data: {
1945
+ input: {
1946
+ list: [],
1947
+ class: '',
1948
+ style: '',
1949
+ version: 'v2',
1950
+ },
1951
+ label: {
1952
+ list: [],
1953
+ class: 'form-label fs-base ',
1954
+ style: '',
1955
+ version: 'v2',
1956
+ },
1957
+ container: {
1958
+ list: [],
1959
+ class: '',
1960
+ style: '',
1961
+ version: 'v2',
1962
+ },
1963
+ },
1964
+ form_config: {
1965
+ type: 'name',
1966
+ title: '',
1967
+ input_style: { list: [], version: 'v2' },
1968
+ title_style: { list: [], version: 'v2' },
1969
+ place_holder: '請輸入公司統一編號',
1970
+ },
1971
+ hidden_code: " if(form_data['invoice_type']!=='company'){\n form_data[form_key]=undefined\nreturn true\n }else{\n return false\n }",
1972
+ },
1973
+ {
1974
+ col: '6',
1975
+ key: 'love_code',
1976
+ page: 'input',
1977
+ type: 'form_plugin_v2',
1978
+ group: '',
1979
+ title: '捐贈碼',
1980
+ col_sm: '12',
1981
+ appName: 'cms_system',
1982
+ require: 'false',
1983
+ readonly: 'write',
1984
+ formFormat: '{}',
1985
+ moduleName: '輸入框',
1986
+ style_data: {
1987
+ input: {
1988
+ list: [],
1989
+ class: '',
1990
+ style: '',
1991
+ version: 'v2',
1992
+ },
1993
+ label: {
1994
+ list: [],
1995
+ class: 'form-label fs-base ',
1996
+ style: '',
1997
+ version: 'v2',
1998
+ },
1999
+ container: {
2000
+ list: [],
2001
+ class: '',
2002
+ style: '',
2003
+ version: 'v2',
2004
+ },
2005
+ },
2006
+ form_config: {
2007
+ type: 'name',
2008
+ title: '',
2009
+ input_style: { list: [], version: 'v2' },
2010
+ title_style: { list: [], version: 'v2' },
2011
+ place_holder: '請輸入捐贈碼',
2012
+ },
2013
+ hidden_code: " if(form_data['invoice_type']!=='donate' || (form_data['invoice_method']==='nouse')){\n form_data[form_key]=undefined\nreturn true\n }else{\n return false\n }",
2014
+ },
2015
+ {
2016
+ col: '12',
2017
+ key: 'note',
2018
+ page: 'multiple_line_text',
2019
+ type: 'form_plugin_v2',
2020
+ group: '',
2021
+ title: '送貨備註',
2022
+ col_sm: '12',
2023
+ appName: 'cms_system',
2024
+ require: 'false',
2025
+ readonly: 'write',
2026
+ formFormat: '{}',
2027
+ moduleName: '多行文字區塊',
2028
+ style_data: {
2029
+ input: {
2030
+ list: [],
2031
+ class: '',
2032
+ style: '',
2033
+ version: 'v2',
2034
+ },
2035
+ label: {
2036
+ list: [],
2037
+ class: 'form-label fs-base ',
2038
+ style: '',
2039
+ version: 'v2',
2040
+ },
2041
+ container: {
2042
+ list: [],
2043
+ class: '',
2044
+ style: '',
2045
+ version: 'v2',
2046
+ },
2047
+ },
2048
+ form_config: {
2049
+ type: 'text',
2050
+ title: '',
2051
+ title_style: { list: [], version: 'v2' },
2052
+ place_holder: '請輸入送貨備註',
2053
+ },
2054
+ hidden_code: 'return false',
2055
+ },
2056
+ ].filter((dd) => {
2057
+ return (dd.key !== 'name' && dd.key !== 'phone' && dd.key !== 'email') || !vm.cartData.user_info_same;
2058
+ });
2059
+ vm.cartData.user_info.invoice_method = method;
2060
+ vm.cartData.user_info.invoice_type = vm.cartData.user_info.invoice_type || 'me';
2061
+ vm.cartData.user_info.send_type = vm.cartData.user_info.send_type || 'email';
2062
+ const form_array = JSON.parse(JSON.stringify(vm_info.list));
2063
+ form_array
2064
+ .map((dd) => {
2065
+ if (dd.key === 'send_type' && vm.cartData.user_info.send_type === 'carrier') {
2066
+ dd.col = 3;
2067
+ }
2068
+ dd.form_config.title_style = {
2069
+ list: [
2070
+ {
2071
+ class: ['company', 'gui_number', 'carrier_num'].includes(dd.key) ? gClass('label') + ' mt-2' : gClass('label') + ' mb-2',
2072
+ style: 'return `color:${glitter.share.globalValue[`theme_color.0.title`]} !important;font-size:16px !important;`',
2073
+ stylist: [],
2074
+ dataType: 'code',
2075
+ style_from: 'code',
2076
+ classDataType: 'static',
2077
+ },
2078
+ ],
2079
+ class: 'form-label',
2080
+ style: 'font-size: 20px;font-style: normal;font-weight: 400;line-height: 140%; color:#393939 !important;',
2081
+ stylist: [],
2082
+ version: 'v2',
2083
+ dataType: 'static',
2084
+ style_from: 'code',
2085
+ classDataType: 'static',
2086
+ };
2087
+ dd.form_config.input_style = {
2088
+ list: [
2089
+ {
2090
+ class: gClass('input'),
2091
+ style: 'return `border-radius: ${widget.formData.radius}px !important;`',
2092
+ stylist: [],
2093
+ dataType: 'code',
2094
+ style_from: 'code',
2095
+ classDataType: 'static',
2096
+ },
2097
+ ],
2098
+ class: ' mb-3',
2099
+ style: 'background: #FFF;',
2100
+ stylist: [],
2101
+ version: 'v2',
2102
+ dataType: 'static',
2103
+ style_from: 'code',
2104
+ classDataType: 'static',
2105
+ };
2106
+ })
2107
+ .filter((dd) => {
2108
+ return !(method === 'nouse' && ['invoice_type', 'send_type', 'carrier_num', 'company', 'gui_number', 'love_code'].includes(dd.key));
2109
+ });
2110
+ return [
2111
+ html ` <div
2112
+ class="d-flex ms-2 my-3"
2113
+ style="gap:10px;cursor:pointer;"
2114
+ onclick="${gvc.event(() => {
2115
+ vm.cartData.user_info_same = !vm.cartData.user_info_same;
2116
+ if (vm.cartData.user_info_same) {
2117
+ vm.cartData.user_info.name = vm.cartData.customer_info.name;
2118
+ vm.cartData.user_info.phone = vm.cartData.customer_info.phone;
2119
+ vm.cartData.user_info.email = vm.cartData.customer_info.email;
2120
+ }
2121
+ gvc.notifyDataChange(id);
2122
+ })}"
2123
+ >
2124
+ <input class="form-check-input form-checkbox ${checkbox}" type="checkbox" ${vm.cartData.user_info_same ? `checked` : ''} />
2125
+ 收件人同購買人資料
2126
+ </div>`,
2127
+ FormWidget.editorView({
2128
+ gvc: gvc,
2129
+ array: form_array,
2130
+ refresh: () => {
2131
+ this.storeLocalData(vm.cartData);
2132
+ gvc.notifyDataChange(id);
2133
+ },
2134
+ formData: vm.cartData.user_info,
2135
+ }),
2136
+ ].join('<div class="my-2"></div>');
2137
+ },
2138
+ divCreate: {
2139
+ class: `w-100 mt-2`,
2140
+ },
2141
+ };
2142
+ })}
2143
+ <div class="w-100 d-flex align-items-center justify-content-end px-2 mt-3">
2144
+ <button
2145
+ class="${gClass('button-bgr')}"
2146
+ onclick="${gvc.event(() => __awaiter(this, void 0, void 0, function* () {
2147
+ if (!(yield this.checkFormData(vm.cartData, widget))) {
2148
+ return;
2149
+ }
2150
+ ['MerchantTradeNo', 'LogisticsSubType', 'CVSStoreID', 'CVSStoreName', 'CVSTelephone', 'CVSOutSide', 'ExtraData', 'CVSAddress'].map((dd) => {
2151
+ if (gvc.glitter.getUrlParameter(dd)) {
2152
+ vm.cartData.user_info[dd] = decodeURI(glitter.getUrlParameter(dd));
2153
+ }
2154
+ });
2155
+ const dialog = new ShareDialog(gvc.glitter);
2156
+ dialog.dataLoading({ visible: true });
2157
+ ApiShop.toCheckout({
2158
+ line_items: vm.cartData.lineItems.map((dd) => {
2159
+ return {
2160
+ id: dd.id,
2161
+ spec: dd.spec,
2162
+ count: dd.count,
2163
+ };
2164
+ }),
2165
+ customer_info: vm.cartData.customer_info,
2166
+ return_url: (() => {
2167
+ const originalUrl = glitter.root_path + 'order_detail' + location.search;
2168
+ const urlObject = new URL(originalUrl);
2169
+ urlObject.searchParams.set('EndCheckout', '1');
2170
+ const newUrl = urlObject.toString();
2171
+ return newUrl;
2172
+ })(),
2173
+ user_info: vm.cartData.user_info,
2174
+ code: ApiCart.cart.code,
2175
+ use_rebate: ApiCart.cart.use_rebate,
2176
+ custom_form_format: vm.cartData.custom_form_format,
2177
+ custom_form_data: vm.cartData.custom_form_data,
2178
+ distribution_code: ApiCart.cart.distribution_code,
2179
+ give_away: ApiCart.cart.give_away,
2180
+ }).then((res) => {
2181
+ if (res.response.off_line || res.response.is_free) {
2182
+ ApiCart.clearCart();
2183
+ location.href = res.response.return_url;
2184
+ }
2185
+ else {
2186
+ const id = gvc.glitter.getUUID();
2187
+ $('body').append(`<div id="${id}" style="display: none;">${res.response.form}</div>`);
2188
+ document.querySelector(`#${id} #submit`).click();
2189
+ ApiCart.clearCart();
2190
+ }
2191
+ });
2192
+ }))}"
2193
+ style="width:200px;"
2194
+ >
2195
+ <span class="${gClass('button-text')}">下一步</span>
2196
+ </button>
969
2197
  </div>
970
2198
  </section>
971
2199
  </div>`;
@@ -977,88 +2205,176 @@ export class CheckoutIndex {
977
2205
  },
978
2206
  divCreate: {},
979
2207
  onCreate: () => {
980
- if (loadings.page) {
981
- new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
982
- new Promise((resolve, reject) => {
983
- setTimeout(() => {
984
- resolve(ApiCart.cart);
985
- });
986
- }).then((res) => __awaiter(this, void 0, void 0, function* () {
987
- var _a;
988
- const cartData = {
989
- line_items: [],
990
- total: 0,
991
- user_info: {
992
- shipment: localStorage.getItem('checkout-logistics'),
993
- },
994
- };
995
- if (res.line_items) {
996
- res.user_info = {
997
- shipment: localStorage.getItem('checkout-logistics'),
998
- };
999
- const cart = res;
1000
- ApiShop.getCheckout(cart).then((res) => {
1001
- if (res.result) {
1002
- resolve(res.response.data);
1003
- }
1004
- else {
1005
- resolve([]);
1006
- }
1007
- });
1008
- }
1009
- else {
1010
- for (const b of Object.keys(res)) {
1011
- cartData.line_items.push({
1012
- id: b.split('-')[0],
1013
- count: res[b],
1014
- spec: b.split('-').filter((dd, index) => {
1015
- return index !== 0;
1016
- }),
1017
- });
1018
- }
1019
- const voucher = ApiCart.cart.code;
1020
- const rebate = ApiCart.cart.use_rebate || 0;
1021
- const distributionCode = (_a = localStorage.getItem('distributionCode')) !== null && _a !== void 0 ? _a : '';
1022
- ApiShop.getCheckout({
1023
- line_items: cartData.line_items.map((dd) => {
1024
- return {
1025
- id: dd.id,
1026
- spec: dd.spec,
1027
- count: dd.count,
1028
- };
1029
- }),
1030
- code: voucher,
1031
- use_rebate: GlobalUser.token && rebate ? rebate : undefined,
1032
- distribution_code: distributionCode,
1033
- user_info: {
1034
- shipment: localStorage.getItem('checkout-logistics'),
1035
- },
1036
- }).then((res) => {
1037
- if (res.result) {
1038
- resolve(res.response.data);
1039
- }
1040
- else {
1041
- resolve([]);
1042
- }
1043
- });
1044
- }
1045
- }));
1046
- })).then((data) => {
1047
- vm.cartData = data;
1048
- gvc.addMtScript([
1049
- {
1050
- src: `https://unpkg.com/@lottiefiles/lottie-player@latest/dist/lottie-player.js`,
1051
- },
1052
- ], () => {
1053
- loadings.page = false;
1054
- gvc.notifyDataChange(ids.page);
1055
- }, () => { });
1056
- });
1057
- }
2208
+ Ad.gtagEvent('view_cart', {
2209
+ currency: 'TWD',
2210
+ value: vm.cartData.total,
2211
+ items: vm.cartData.lineItems.map((item) => {
2212
+ return {
2213
+ item_id: item.id,
2214
+ item_name: item.title,
2215
+ item_variant: item.spec.join('-'),
2216
+ price: item.sale_price,
2217
+ quantity: item.count,
2218
+ discount: item.discount_price,
2219
+ };
2220
+ }),
2221
+ });
2222
+ Ad.fbqEvent('AddPaymentInfo', {
2223
+ value: vm.cartData.total,
2224
+ currency: 'TWD',
2225
+ contents: vm.cartData.lineItems.map((item) => {
2226
+ return {
2227
+ id: item.id,
2228
+ quantity: item.count,
2229
+ };
2230
+ }),
2231
+ content_ids: vm.cartData.lineItems.map((item) => item.id),
2232
+ });
1058
2233
  },
1059
2234
  };
1060
2235
  })());
1061
2236
  }
2237
+ static checkFormData(cartData, widget) {
2238
+ function checkEmailPattern(input) {
2239
+ const emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
2240
+ return emailPattern.test(input);
2241
+ }
2242
+ function checkPhonePattern(input) {
2243
+ const phonePattern = /^09\d{8}$/;
2244
+ return phonePattern.test(input);
2245
+ }
2246
+ function checkReceiverPattern(input) {
2247
+ const receiverPattern = /^[\u4e00-\u9fa5]{2,5}|[a-zA-Z]{4,10}$/;
2248
+ return receiverPattern.test(input);
2249
+ }
2250
+ function checkAddressPattern(input) {
2251
+ const addressPattern = /^.{6,60}$/;
2252
+ return addressPattern.test(input);
2253
+ }
2254
+ return new Promise((resolve) => {
2255
+ var _a;
2256
+ let pass = true;
2257
+ const userData = cartData.customer_info;
2258
+ const subData = cartData.user_info;
2259
+ function checkString(text, errorMessage, type = '') {
2260
+ if ((pass && !text) || text === '') {
2261
+ pass = false;
2262
+ widget.event('error', { title: `請輸入「${errorMessage}」` });
2263
+ }
2264
+ if (pass && type === 'email' && !checkEmailPattern(text)) {
2265
+ pass = false;
2266
+ widget.event('error', { title: `「${errorMessage}」格式錯誤` });
2267
+ }
2268
+ if (pass && type === 'phone' && !checkPhonePattern(text)) {
2269
+ pass = false;
2270
+ widget.event('error', { title: `<div class="text-center">「${errorMessage}」格式錯誤<br/>請輸入 09 開頭的手機格式</div>` });
2271
+ }
2272
+ if (pass && type === 'name' && !checkReceiverPattern(text)) {
2273
+ pass = false;
2274
+ widget.event('error', { title: '姓名請設定為4~10字元(中文2~5個字, 英文4~10個字, 不得含指定特殊符號)' });
2275
+ }
2276
+ }
2277
+ if (subData['shipment'] === 'normal' && (!subData['address'] || subData['address'] === '')) {
2278
+ widget.event('error', { title: '請輸入「配送地址」' });
2279
+ }
2280
+ else if (subData['shipment'] === 'normal' && !checkAddressPattern(subData['address'])) {
2281
+ widget.event('error', { title: '地址長度需大於6個字元,且不可超過60個字元' });
2282
+ }
2283
+ else if (['UNIMARTC2C', 'FAMIC2C', 'HILIFEC2C', 'OKMARTC2C'].includes(subData['shipment']) && (!subData['CVSStoreName'] || subData['CVSStoreName'] === '')) {
2284
+ widget.event('error', { title: '請選擇「配送門市」' });
2285
+ }
2286
+ else if ((() => {
2287
+ const form = this.getShipmentMethod(cartData).find((dd) => {
2288
+ return dd.value === subData['shipment'];
2289
+ }).form;
2290
+ return FormWidget.checkLeakData(form, subData.custom_form_delivery);
2291
+ })()) {
2292
+ const form = this.getShipmentMethod(cartData).find((dd) => {
2293
+ return dd.value === subData['shipment'];
2294
+ }).form;
2295
+ widget.event('error', { title: `請輸入「${FormWidget.checkLeakData(form, subData)}」` });
2296
+ }
2297
+ else if ((() => {
2298
+ return FormWidget.checkLeakData(cartData.custom_form_format, cartData.custom_form_data);
2299
+ })()) {
2300
+ widget.event('error', { title: `請輸入「${FormWidget.checkLeakData(cartData.custom_form_format, cartData.custom_form_data)}」` });
2301
+ }
2302
+ else if (cartData.voucherList
2303
+ .filter((dd) => {
2304
+ return dd.reBackType === 'giveaway';
2305
+ })
2306
+ .find((dd) => {
2307
+ return !dd.select_gif.id;
2308
+ })) {
2309
+ widget.event('error', { title: '請選擇「贈品」' });
2310
+ }
2311
+ else {
2312
+ checkString(userData.name, '顧客姓名', 'name');
2313
+ checkString(userData.phone, '顧客電話', 'phone');
2314
+ checkString(userData.email, '顧客信箱', 'email');
2315
+ checkString(subData.name, '收件人姓名', 'name');
2316
+ checkString(subData.phone, '收件人電話', 'phone');
2317
+ checkString(subData.email, '收件人信箱', 'email');
2318
+ if (pass) {
2319
+ Ad.gtagEvent('begin_checkout', {
2320
+ currency: 'TWD',
2321
+ value: cartData.total,
2322
+ coupon: (_a = cartData.code) !== null && _a !== void 0 ? _a : '',
2323
+ items: cartData.lineItems.map((item) => {
2324
+ return {
2325
+ item_id: item.id,
2326
+ item_name: item.title,
2327
+ item_variant: item.spec.join('-'),
2328
+ price: item.sale_price,
2329
+ quantity: item.count,
2330
+ discount: item.discount_price,
2331
+ };
2332
+ }),
2333
+ });
2334
+ Ad.fbqEvent('Purchase', {
2335
+ value: cartData.total,
2336
+ currency: 'TWD',
2337
+ contents: cartData.lineItems.map((item) => {
2338
+ return {
2339
+ id: item.id,
2340
+ quantity: item.count,
2341
+ };
2342
+ }),
2343
+ content_type: 'product',
2344
+ });
2345
+ resolve(subData);
2346
+ }
2347
+ }
2348
+ });
2349
+ }
2350
+ static viewDialog(obj) {
2351
+ return obj.gvc.glitter.innerDialog((gvc) => {
2352
+ var _a;
2353
+ return html ` <div
2354
+ class="bg-white shadow rounded-3"
2355
+ style="overflow-y: auto; ${document.body.clientWidth > 768 ? `min-width: 600px; width: 700px;` : 'min-width: 90vw; max-width: 92.5vw;'}"
2356
+ >
2357
+ <div class="bg-white shadow rounded-3" style="width: 100%; overflow-y: auto; position: relative;">
2358
+ <div class="w-100 d-flex align-items-center p-3 border-bottom" style="position: sticky; top: 0; background: #fff;">
2359
+ <div style="font-size: 16px; font-weight: 700; color: #292218;">${(_a = obj.title) !== null && _a !== void 0 ? _a : ''}</div>
2360
+ <div class="flex-fill"></div>
2361
+ <i
2362
+ class="fa-regular fa-circle-xmark fs-5 text-dark"
2363
+ style="cursor: pointer"
2364
+ onclick="${gvc.event(() => {
2365
+ gvc.closeDialog();
2366
+ })}"
2367
+ ></i>
2368
+ </div>
2369
+ <div class="c_dialog">
2370
+ <div class="c_dialog_body">
2371
+ <div class="c_dialog_main" style="gap: 24px; height: auto; max-height: 500px; padding: 12px 20px;">${obj.innerHTML(gvc)}</div>
2372
+ </div>
2373
+ </div>
2374
+ </div>
2375
+ </div>`;
2376
+ }, obj.tag);
2377
+ }
1062
2378
  static getPaymentMethod(cartData) {
1063
2379
  var _a;
1064
2380
  let array = [];
@@ -1113,39 +2429,35 @@ export class CheckoutIndex {
1113
2429
  localStorage.setItem('cart_customer_info', JSON.stringify(cartData.customer_info));
1114
2430
  localStorage.setItem('shipment-select', cartData.user_info.shipment);
1115
2431
  localStorage.setItem('checkout-payment', cartData.customer_info.payment_select);
1116
- }
1117
- static viewDialog(obj) {
1118
- return obj.gvc.glitter.innerDialog((gvc) => {
1119
- var _a;
1120
- return html ` <div
1121
- class="bg-white shadow rounded-3"
1122
- style="overflow-y: auto; ${document.body.clientWidth > 768 ? `min-width: 600px; width: 700px;` : 'min-width: 90vw; max-width: 92.5vw;'}"
1123
- >
1124
- <div class="bg-white shadow rounded-3" style="width: 100%; overflow-y: auto; position: relative;">
1125
- <div class="w-100 d-flex align-items-center p-3 border-bottom" style="position: sticky; top: 0; background: #fff;">
1126
- <div style="font-size: 16px; font-weight: 700; color: #292218;">${(_a = obj.title) !== null && _a !== void 0 ? _a : ''}</div>
1127
- <div class="flex-fill"></div>
1128
- <i
1129
- class="fa-regular fa-circle-xmark fs-5 text-dark"
1130
- style="cursor: pointer"
1131
- onclick="${gvc.event(() => {
1132
- gvc.closeDialog();
1133
- })}"
1134
- ></i>
1135
- </div>
1136
- <div class="c_dialog">
1137
- <div class="c_dialog_body">
1138
- <div class="c_dialog_main" style="gap: 24px; height: auto; max-height: 500px; padding: 12px 20px;">${obj.innerHTML(gvc)}</div>
1139
- </div>
1140
- </div>
1141
- </div>
1142
- </div>`;
1143
- }, obj.tag);
2432
+ localStorage.setItem('custom_form_data', JSON.stringify(cartData.custom_form_data));
2433
+ localStorage.setItem('custom_user_info', JSON.stringify(cartData.user_info));
1144
2434
  }
1145
2435
  static initial(cartData) {
1146
- cartData.customer_info = JSON.parse(localStorage.getItem('cart_customer_info') || "{}");
2436
+ cartData.customer_info = JSON.parse(localStorage.getItem('cart_customer_info') || '{}');
2437
+ cartData.custom_form_data = JSON.parse(localStorage.getItem('custom_form_data') || '{}');
2438
+ cartData.user_info = JSON.parse(localStorage.getItem('custom_user_info') || '{}');
1147
2439
  this.getPaymentMethod(cartData);
1148
2440
  this.getShipmentMethod(cartData);
1149
2441
  }
2442
+ static getCheckedClass(gvc, color) {
2443
+ const className = Tool.randomString(6);
2444
+ gvc.addStyle(`
2445
+ .${className} {
2446
+ min-width: 1rem;
2447
+ min-height: 1rem;
2448
+ }
2449
+ .${className}:checked[type='checkbox'] {
2450
+ border: 2px solid ${color !== null && color !== void 0 ? color : '#000'};
2451
+ background-color: #fff;
2452
+ background-image: url(${this.checkedDataImage(color !== null && color !== void 0 ? color : '#000')});
2453
+ background-position: center center;
2454
+ }
2455
+ `);
2456
+ return className;
2457
+ }
2458
+ static checkedDataImage(color) {
2459
+ color = color.replace('#', '%23');
2460
+ return `"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='${color}' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10l3 3l6-6'/%3e%3c/svg%3e"`;
2461
+ }
1150
2462
  }
1151
2463
  window.glitter.setModule(import.meta.url, CheckoutIndex);