ts-glitter 20.8.7 → 20.8.9

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 (177) hide show
  1. package/lowcode/Entry.js +1 -1
  2. package/lowcode/Entry.ts +1 -1
  3. package/lowcode/backend-manager/bg-product.js +1 -1
  4. package/lowcode/backend-manager/bg-product.ts +1 -1
  5. package/lowcode/backend-manager/bg-recommend.js +1 -1
  6. package/lowcode/backend-manager/bg-recommend.ts +2 -2
  7. package/lowcode/backend-manager/bg-shopping.js +2 -5
  8. package/lowcode/backend-manager/bg-shopping.ts +2 -5
  9. package/lowcode/cms-plugin/POS-setting.js +58 -34
  10. package/lowcode/cms-plugin/POS-setting.ts +69 -33
  11. package/lowcode/cms-plugin/data-analyze-orders.js +0 -1
  12. package/lowcode/cms-plugin/data-analyze-orders.ts +1 -1
  13. package/lowcode/cms-plugin/data-analyze.js +1 -21
  14. package/lowcode/cms-plugin/data-analyze.ts +25 -25
  15. package/lowcode/cms-plugin/filter-options.js +1 -1
  16. package/lowcode/cms-plugin/filter-options.ts +1 -2
  17. package/lowcode/cms-plugin/information/information-module.js +275 -0
  18. package/lowcode/cms-plugin/information/information-module.ts +308 -0
  19. package/lowcode/cms-plugin/pos-pages/models.ts +3 -1
  20. package/lowcode/cms-plugin/pos-pages/payment-page.js +3 -11
  21. package/lowcode/cms-plugin/pos-pages/payment-page.ts +3 -11
  22. package/lowcode/cms-plugin/pos-pages/pos-function.js +1 -0
  23. package/lowcode/cms-plugin/pos-pages/pos-function.ts +1 -0
  24. package/lowcode/cms-plugin/pos-pages/products-page.js +1 -1
  25. package/lowcode/cms-plugin/pos-pages/products-page.ts +1 -1
  26. package/lowcode/cms-plugin/product-service.js +4 -9
  27. package/lowcode/cms-plugin/product-service.ts +4 -13
  28. package/lowcode/cms-plugin/shopping-discount-setting.js +76 -27
  29. package/lowcode/cms-plugin/shopping-discount-setting.ts +123 -63
  30. package/lowcode/cms-plugin/shopping-information.js +21 -167
  31. package/lowcode/cms-plugin/shopping-information.ts +35 -191
  32. package/lowcode/cms-plugin/shopping-order-return.js +212 -360
  33. package/lowcode/cms-plugin/shopping-order-return.ts +349 -482
  34. package/lowcode/cms-plugin/shopping-product-setting.js +8 -0
  35. package/lowcode/cms-plugin/shopping-product-setting.ts +12 -4
  36. package/lowcode/form-view/e-commerce/product-select.js +59 -51
  37. package/lowcode/form-view/e-commerce/product-select.ts +279 -266
  38. package/lowcode/glitter-base/global/language.js +2 -1
  39. package/lowcode/glitter-base/global/language.ts +2 -1
  40. package/lowcode/public-components/checkout/index.ts +2078 -2078
  41. package/lowcode/public-components/headers/sy-02.js +190 -179
  42. package/lowcode/public-components/headers/sy-02.ts +397 -370
  43. package/lowcode/public-components/headers/sy-03.js +133 -107
  44. package/lowcode/public-components/headers/sy-03.ts +276 -244
  45. package/lowcode/public-components/headers/sy-04.js +181 -146
  46. package/lowcode/public-components/headers/sy-04.ts +289 -247
  47. package/lowcode/public-components/product/pd-class.js +31 -23
  48. package/lowcode/public-components/product/pd-class.ts +51 -29
  49. package/lowcode/public-components/user-manager/um-voucher.js +1 -0
  50. package/lowcode/public-components/user-manager/um-voucher.ts +1 -0
  51. package/package.json +1 -1
  52. package/src/Language.js +1 -1
  53. package/src/Language.js.map +1 -1
  54. package/src/Language.ts +1 -1
  55. package/src/api-public/controllers/ai-chat.js.map +1 -1
  56. package/src/api-public/controllers/chat.js.map +1 -1
  57. package/src/api-public/controllers/customer-sessions.js.map +1 -1
  58. package/src/api-public/controllers/fb-message.js.map +1 -1
  59. package/src/api-public/controllers/fb-service.js.map +1 -1
  60. package/src/api-public/controllers/invoice.js.map +1 -1
  61. package/src/api-public/controllers/line-message.js.map +1 -1
  62. package/src/api-public/controllers/oauth.js.map +1 -1
  63. package/src/api-public/controllers/progress.js.map +1 -1
  64. package/src/api-public/controllers/rebate.js.map +1 -1
  65. package/src/api-public/controllers/recommend.js.map +1 -1
  66. package/src/api-public/controllers/reconciliation.js.map +1 -1
  67. package/src/api-public/controllers/shop.js +5 -2
  68. package/src/api-public/controllers/shop.js.map +1 -1
  69. package/src/api-public/controllers/shop.ts +7 -3
  70. package/src/api-public/controllers/shopee.js.map +1 -1
  71. package/src/api-public/controllers/sms.js.map +1 -1
  72. package/src/api-public/controllers/smtp.js.map +1 -1
  73. package/src/api-public/controllers/stock.js.map +1 -1
  74. package/src/api-public/controllers/track.js.map +1 -1
  75. package/src/api-public/controllers/voucher.js.map +1 -1
  76. package/src/api-public/models/glitter-finance.js +1 -2
  77. package/src/api-public/models/glitter-finance.js.map +1 -1
  78. package/src/api-public/services/EcInvoice.js.map +1 -1
  79. package/src/api-public/services/article.js.map +1 -1
  80. package/src/api-public/services/auto-send-email.js.map +1 -1
  81. package/src/api-public/services/chat.js.map +1 -1
  82. package/src/api-public/services/checkout-event.d.ts +1 -0
  83. package/src/api-public/services/checkout-event.js +17 -7
  84. package/src/api-public/services/checkout-event.js.map +1 -1
  85. package/src/api-public/services/checkout-event.ts +21 -9
  86. package/src/api-public/services/checkout.js.map +1 -1
  87. package/src/api-public/services/custom-code.js.map +1 -1
  88. package/src/api-public/services/customer-sessions.js.map +1 -1
  89. package/src/api-public/services/data-analyze.js +209 -196
  90. package/src/api-public/services/data-analyze.js.map +1 -1
  91. package/src/api-public/services/data-analyze.ts +219 -205
  92. package/src/api-public/services/delivery.js.map +1 -1
  93. package/src/api-public/services/ezpay/tool.d.ts +0 -1
  94. package/src/api-public/services/ezpay/tool.js.map +1 -1
  95. package/src/api-public/services/fake-data-model/fake-order.js.map +1 -1
  96. package/src/api-public/services/fake-data-model/fake-product.js.map +1 -1
  97. package/src/api-public/services/fake-data-model/fake-user.js.map +1 -1
  98. package/src/api-public/services/fb-api.js.map +1 -1
  99. package/src/api-public/services/filter-protect-data.js.map +1 -1
  100. package/src/api-public/services/financial-service.js +0 -1
  101. package/src/api-public/services/financial-service.js.map +1 -1
  102. package/src/api-public/services/form-check.js.map +1 -1
  103. package/src/api-public/services/graph-api.js.map +1 -1
  104. package/src/api-public/services/initial-fake-data.js.map +1 -1
  105. package/src/api-public/services/invoice.d.ts +3 -9
  106. package/src/api-public/services/invoice.js +66 -85
  107. package/src/api-public/services/invoice.js.map +1 -1
  108. package/src/api-public/services/invoice.ts +287 -293
  109. package/src/api-public/services/language-setting.js.map +1 -1
  110. package/src/api-public/services/mail.js.map +1 -1
  111. package/src/api-public/services/manager.js.map +1 -1
  112. package/src/api-public/services/paynow-logistics.js.map +1 -1
  113. package/src/api-public/services/phone-verify.js.map +1 -1
  114. package/src/api-public/services/pos.js.map +1 -1
  115. package/src/api-public/services/post.js.map +1 -1
  116. package/src/api-public/services/product-initial.js.map +1 -1
  117. package/src/api-public/services/rebate.js.map +1 -1
  118. package/src/api-public/services/reconciliation.js.map +1 -1
  119. package/src/api-public/services/schedule.d.ts +1 -0
  120. package/src/api-public/services/schedule.js +27 -0
  121. package/src/api-public/services/schedule.js.map +1 -1
  122. package/src/api-public/services/schedule.ts +30 -0
  123. package/src/api-public/services/shopping.d.ts +4 -3
  124. package/src/api-public/services/shopping.js +40 -20
  125. package/src/api-public/services/shopping.js.map +1 -1
  126. package/src/api-public/services/shopping.ts +52 -28
  127. package/src/api-public/services/stock.js.map +1 -1
  128. package/src/api-public/services/terms-check.js.map +1 -1
  129. package/src/api-public/services/updated-table-checked.js.map +1 -1
  130. package/src/api-public/services/user-update.js.map +1 -1
  131. package/src/api-public/services/user.d.ts +10 -0
  132. package/src/api-public/services/user.js +35 -8
  133. package/src/api-public/services/user.js.map +1 -1
  134. package/src/api-public/services/user.ts +50 -7
  135. package/src/api-public/services/voucher.js.map +1 -1
  136. package/src/api-public/utils/ut-database.js.map +1 -1
  137. package/src/app-project/android/app/src/main/res/xml/network_security_config.xml +3 -3
  138. package/src/app-project/android/app/src/main/res/xml/s.xml +5 -5
  139. package/src/app-project/android/gradlew.bat +94 -94
  140. package/src/app-project/serverless/src/controllers/index.js.map +1 -1
  141. package/src/app-project/serverless/src/controllers/sample.js.map +1 -1
  142. package/src/app-project/serverless/src/modules/database.d.ts +1 -2
  143. package/src/app-project/serverless/src/modules/database.js.map +1 -1
  144. package/src/app-project/serverless/src/modules/exception.js.map +1 -1
  145. package/src/app-project/serverless/src/modules/hooks.js.map +1 -1
  146. package/src/app-project/serverless/src/modules/logger.js.map +1 -1
  147. package/src/app-project/serverless/src/modules/redis.d.ts +1 -1
  148. package/src/app-project/serverless/src/modules/redis.js.map +1 -1
  149. package/src/app-project/serverless/src/modules/response.js.map +1 -1
  150. package/src/app-project/serverless/src/modules/ssh.js.map +1 -1
  151. package/src/controllers/ai.js.map +1 -1
  152. package/src/controllers/global-event.js.map +1 -1
  153. package/src/controllers/page.js.map +1 -1
  154. package/src/controllers/private_config.js.map +1 -1
  155. package/src/export/export-test.js.map +1 -1
  156. package/src/firebase/message.js +1 -2
  157. package/src/firebase/message.js.map +1 -1
  158. package/src/helper/app_creater.js +1 -2
  159. package/src/helper/app_creater.js.map +1 -1
  160. package/src/helper/glitter-util.d.ts +0 -1
  161. package/src/helper/glitter-util.js.map +1 -1
  162. package/src/lambda/interface.d.ts +1 -1
  163. package/src/lambda/interface.js +2 -2
  164. package/src/lambda/interface.js.map +1 -1
  165. package/src/modules/exception.js.map +1 -1
  166. package/src/modules/hooks.js.map +1 -1
  167. package/src/modules/response.js.map +1 -1
  168. package/src/modules/ssh.js.map +1 -1
  169. package/src/public-config-initial/auto-fcm.js.map +1 -1
  170. package/src/run.js.map +1 -1
  171. package/src/run.ts +12 -12
  172. package/src/services/ai.js.map +1 -1
  173. package/src/services/ses.js +1 -2
  174. package/src/services/ses.js.map +1 -1
  175. package/src/services/system-schedule.js.map +1 -1
  176. package/src/update-progress-track.js.map +1 -1
  177. package/src/update-script.js.map +1 -1
@@ -672,8 +672,8 @@ export class CheckoutIndex {
672
672
  <div>${Language.text('total_products')}</div>
673
673
  <div>
674
674
  ${Currency.convertCurrencyText(
675
- vm.cartData.total - vm.cartData.shipment_fee + vm.cartData.discount + vm.cartData.use_rebate
676
- )}
675
+ vm.cartData.total - vm.cartData.shipment_fee + vm.cartData.discount + vm.cartData.use_rebate
676
+ )}
677
677
  </div>
678
678
  </div>
679
679
  <div class="${gClass(['price-row', 'text-2'])}">
@@ -689,71 +689,71 @@ export class CheckoutIndex {
689
689
  <div
690
690
  style="cursor: pointer; color: #3564c0;"
691
691
  onclick="${gvc.event(() => {
692
- this.viewDialog({
693
- gvc: gvc,
694
- title: Language.text('available_coupons'),
695
- tag: '',
696
- innerHTML: (gvc: GVC) => {
697
- return gvc.bindView(
698
- (() => {
699
- const id = glitter.getUUID();
700
- const vmi = {
701
- dataList: [] as Voucher[],
702
- };
703
- const isWebsite = document.body.clientWidth > 768;
704
- let loading = true;
705
- return {
706
- bind: id,
707
- view: () => {
708
- try {
709
- if (loading) {
710
- return html` <div style="height: 400px">${spinner()}</div>`;
711
- } else {
712
- const header = [
713
- {
714
- title: Language.text('coupon_name'),
715
- },
716
- {
717
- title: Language.text('coupon_code'),
718
- },
719
- {
720
- title: Language.text('expiration_date'),
721
- },
722
- {
723
- title: '',
724
- },
725
- ];
726
-
727
- function formatText(item: UserVoucher) {
728
- return [
729
- item.title,
730
- item.code,
731
- (() => {
732
- const endText = item.end_ISO_Date
733
- ? glitter.ut.dateFormat(new Date(item.end_ISO_Date), 'yyyy/MM/dd')
734
- : Language.text('no_expiration');
735
- return `${glitter.ut.dateFormat(
736
- new Date(item.start_ISO_Date),
737
- 'yyyy/MM/dd'
738
- )} ~ ${endText}`;
739
- })(),
740
- item.usePass
741
- ? html` <button
692
+ this.viewDialog({
693
+ gvc: gvc,
694
+ title: Language.text('available_coupons'),
695
+ tag: '',
696
+ innerHTML: (gvc: GVC) => {
697
+ return gvc.bindView(
698
+ (() => {
699
+ const id = glitter.getUUID();
700
+ const vmi = {
701
+ dataList: [] as Voucher[],
702
+ };
703
+ const isWebsite = document.body.clientWidth > 768;
704
+ let loading = true;
705
+ return {
706
+ bind: id,
707
+ view: () => {
708
+ try {
709
+ if (loading) {
710
+ return html` <div style="height: 400px">${spinner()}</div>`;
711
+ } else {
712
+ const header = [
713
+ {
714
+ title: Language.text('coupon_name'),
715
+ },
716
+ {
717
+ title: Language.text('coupon_code'),
718
+ },
719
+ {
720
+ title: Language.text('expiration_date'),
721
+ },
722
+ {
723
+ title: '',
724
+ },
725
+ ];
726
+
727
+ function formatText(item: UserVoucher) {
728
+ return [
729
+ item.title,
730
+ item.code,
731
+ (() => {
732
+ const endText = item.end_ISO_Date
733
+ ? glitter.ut.dateFormat(new Date(item.end_ISO_Date), 'yyyy/MM/dd')
734
+ : Language.text('no_expiration');
735
+ return `${glitter.ut.dateFormat(
736
+ new Date(item.start_ISO_Date),
737
+ 'yyyy/MM/dd'
738
+ )} ~ ${endText}`;
739
+ })(),
740
+ item.usePass
741
+ ? html` <button
742
742
  class="${gClass('button-bgr')} my-2"
743
743
  style="max-width: 150px;"
744
744
  onclick="${gvc.event(() => {
745
- apiCart.setCart(cartItem => {
746
- cartItem.code = item.code;
747
- refreshCartData();
748
- gvc.closeDialog();
749
- });
750
- })}"
745
+ apiCart.setCart(cartItem => {
746
+ cartItem.code = item.code;
747
+ refreshCartData();
748
+ gvc.closeDialog();
749
+ });
750
+ })}"
751
751
  >
752
752
  <span class="${gClass('button-text')}"
753
753
  >${Language.text('select_to_use')}</span
754
754
  >
755
755
  </button>`
756
- : html` <button
756
+ : html` <button
757
757
  class="${gClass('button-bgr-disable')} my-2"
758
758
  style="max-width: 150px; cursor: not-allowed"
759
759
  >
@@ -761,41 +761,41 @@ export class CheckoutIndex {
761
761
  >${Language.text('not_meet_usage_criteria')}</span
762
762
  >
763
763
  </button>`,
764
- ];
765
- }
764
+ ];
765
+ }
766
766
 
767
- const dialog = new ShareDialog(gvc.glitter);
768
- const cloneCart = JSON.parse(JSON.stringify(vm.cartData));
769
-
770
- function checkCodeValue(code: string) {
771
- cloneCart.code = code;
772
- cloneCart.line_items = cloneCart.lineItems;
773
- dialog.dataLoading({ visible: true });
774
- ApiShop.getCheckout(cloneCart).then(r => {
775
- dialog.dataLoading({ visible: false });
776
- if (
777
- r.result &&
778
- r.response.data &&
779
- r.response.data.voucherList.some((dd: any) => {
780
- return dd.code === code;
781
- })
782
- ) {
783
- apiCart.setCart(cartItem => {
784
- cartItem.code = code;
785
- refreshCartData();
786
- gvc.closeDialog();
787
- });
788
- } else {
789
- dialog.errorMessage({
790
- text: Language.text('code_unusable'),
791
- });
792
- }
793
- });
794
- }
767
+ const dialog = new ShareDialog(gvc.glitter);
768
+ const cloneCart = JSON.parse(JSON.stringify(vm.cartData));
769
+
770
+ function checkCodeValue(code: string) {
771
+ cloneCart.code = code;
772
+ cloneCart.line_items = cloneCart.lineItems;
773
+ dialog.dataLoading({ visible: true });
774
+ ApiShop.getCheckout(cloneCart).then(r => {
775
+ dialog.dataLoading({ visible: false });
776
+ if (
777
+ r.result &&
778
+ r.response.data &&
779
+ r.response.data.voucherList.some((dd: any) => {
780
+ return dd.code === code;
781
+ })
782
+ ) {
783
+ apiCart.setCart(cartItem => {
784
+ cartItem.code = code;
785
+ refreshCartData();
786
+ gvc.closeDialog();
787
+ });
788
+ } else {
789
+ dialog.errorMessage({
790
+ text: Language.text('code_unusable'),
791
+ });
792
+ }
793
+ });
794
+ }
795
795
 
796
- if (isWebsite) {
797
- const flexList = [1.2, 1, 1.5, 1.5];
798
- return html`
796
+ if (isWebsite) {
797
+ const flexList = [1.2, 1, 1.5, 1.5];
798
+ return html`
799
799
  <div>
800
800
  <div class="d-flex align-items-center mb-2">
801
801
  <label class="${gClass('label')} mb-0 me-2" style="min-width: 80px;"
@@ -805,41 +805,41 @@ export class CheckoutIndex {
805
805
  class="${gClass('input')}"
806
806
  type="text"
807
807
  onchange="${gvc.event(e => {
808
- checkCodeValue(e.value);
809
- })}"
808
+ checkCodeValue(e.value);
809
+ })}"
810
810
  />
811
811
  </div>
812
812
  </div>
813
813
  <div class="w-100 d-sm-flex py-4 um-th-bar">
814
814
  ${header
815
- .map((item, index) => {
816
- return html` <div class="um-th" style="flex: ${flexList[index]};">
815
+ .map((item, index) => {
816
+ return html` <div class="um-th" style="flex: ${flexList[index]};">
817
817
  ${item.title}
818
818
  </div>`;
819
- })
820
- .join('')}
819
+ })
820
+ .join('')}
821
821
  </div>
822
822
  ${vmi.dataList
823
- .map((item, t1) => {
824
- const fText = formatText(item.content);
825
- return html` <div class="w-100 d-sm-flex py-1 align-items-center">
823
+ .map((item, t1) => {
824
+ const fText = formatText(item.content);
825
+ return html` <div class="w-100 d-sm-flex py-1 align-items-center">
826
826
  ${fText
827
- .map((dd, t2) => {
828
- return html` <div
827
+ .map((dd, t2) => {
828
+ return html` <div
829
829
  class="um-td ${t2 === fText.length - 1 ? 'text-center' : ''}"
830
830
  style="flex: ${flexList[t2]}"
831
831
  >
832
832
  ${dd}
833
833
  </div>`;
834
- })
835
- .join('')}
834
+ })
835
+ .join('')}
836
836
  </div>`;
837
- })
838
- .join('')}
837
+ })
838
+ .join('')}
839
839
  `;
840
- }
840
+ }
841
841
 
842
- return html` <div>
842
+ return html` <div>
843
843
  <div class="d-flex flex-column flex-sm-row align-items-center ">
844
844
  <div class="d-flex align-items-center">
845
845
  <input
@@ -852,8 +852,8 @@ export class CheckoutIndex {
852
852
  class="${gClass('button-bgr')}"
853
853
  style="width:100px;border-top-left-radius: 0;border-bottom-left-radius: 0px;"
854
854
  onclick="${gvc.event(e => {
855
- checkCodeValue(e.value);
856
- })}"
855
+ checkCodeValue(e.value);
856
+ })}"
857
857
  >
858
858
  <span class="${gClass('button-text')}"
859
859
  >${Language.text('confirm')}</span
@@ -863,151 +863,151 @@ export class CheckoutIndex {
863
863
  </div>
864
864
  <div class="w-100 d-sm-none mb-3 s162413">
865
865
  ${vmi.dataList
866
- .map(item => {
867
- return html` <div class="um-mobile-area">
866
+ .map(item => {
867
+ return html` <div class="um-mobile-area">
868
868
  ${formatText(item.content)
869
- .map((dd, index) => {
870
- if (header[index].title === '') {
871
- return dd;
872
- }
873
- return html` <div class="um-mobile-text">
869
+ .map((dd, index) => {
870
+ if (header[index].title === '') {
871
+ return dd;
872
+ }
873
+ return html` <div class="um-mobile-text">
874
874
  ${header[index].title} : ${dd}
875
875
  </div>`;
876
- })
877
- .join('')}
876
+ })
877
+ .join('')}
878
878
  </div>`;
879
- })
880
- .join('')}
879
+ })
880
+ .join('')}
881
881
  </div>
882
882
  </div>`;
883
- }
884
- } catch (e) {
885
- return ``;
886
- }
887
- },
888
- divCreate: {},
889
- onCreate: () => {
890
- if (loading) {
891
- function isNowBetweenDates(startIso: string, endIso: string): boolean {
892
- const now = new Date();
893
- const startDate = new Date(startIso);
894
- const endDate = new Date(endIso);
895
-
896
- // 確保 `startIso` 和 `endIso` 是有效的日期
897
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
898
- return true;
899
- }
883
+ }
884
+ } catch (e) {
885
+ return ``;
886
+ }
887
+ },
888
+ divCreate: {},
889
+ onCreate: () => {
890
+ if (loading) {
891
+ function isNowBetweenDates(startIso: string, endIso: string): boolean {
892
+ const now = new Date();
893
+ const startDate = new Date(startIso);
894
+ const endDate = new Date(endIso);
895
+
896
+ // 確保 `startIso` 和 `endIso` 是有效的日期
897
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
898
+ return true;
899
+ }
900
900
 
901
- // 判斷現在時間是否在範圍內
902
- return now >= startDate && now <= endDate;
903
- }
901
+ // 判斷現在時間是否在範圍內
902
+ return now >= startDate && now <= endDate;
903
+ }
904
904
 
905
- gvc.addMtScript(
906
- [
907
- {
908
- src: `${gvc.glitter.root_path}/jslib/lottie-player.js`,
909
- },
910
- ],
911
- () => {
912
- ApiShop.getVoucher({
913
- page: 0,
914
- limit: 10000,
915
- data_from: 'user',
916
- }).then(async res => {
917
- if (res.result && res.response.data) {
918
- vmi.dataList = res.response.data.filter((item: Voucher) => {
919
- return (
920
- item.content.trigger === 'code' &&
921
- isNowBetweenDates(
922
- item.content.start_ISO_Date,
923
- item.content.end_ISO_Date
924
- )
925
- );
905
+ gvc.addMtScript(
906
+ [
907
+ {
908
+ src: `${gvc.glitter.root_path}/jslib/lottie-player.js`,
909
+ },
910
+ ],
911
+ () => {
912
+ ApiShop.getVoucher({
913
+ page: 0,
914
+ limit: 10000,
915
+ data_from: 'user',
916
+ }).then(async res => {
917
+ if (res.result && res.response.data) {
918
+ vmi.dataList = res.response.data.filter((item: Voucher) => {
919
+ return (
920
+ item.content.trigger === 'code' &&
921
+ isNowBetweenDates(
922
+ item.content.start_ISO_Date,
923
+ item.content.end_ISO_Date
924
+ )
925
+ );
926
+ });
927
+ } else {
928
+ vmi.dataList = [];
929
+ }
930
+ const cloneCart = JSON.parse(JSON.stringify(vm.cartData));
931
+ Promise.all(
932
+ vmi.dataList.map((voucher, index) => {
933
+ return new Promise<{
934
+ code: string;
935
+ response: any;
936
+ }>(resolve => {
937
+ const code = voucher.content.code;
938
+ cloneCart.code = code;
939
+ cloneCart.line_items = cloneCart.lineItems;
940
+ ApiShop.getCheckout(cloneCart).then(response => {
941
+ resolve({
942
+ code,
943
+ response,
926
944
  });
927
- } else {
928
- vmi.dataList = [];
929
- }
930
- const cloneCart = JSON.parse(JSON.stringify(vm.cartData));
931
- Promise.all(
932
- vmi.dataList.map((voucher, index) => {
933
- return new Promise<{
934
- code: string;
935
- response: any;
936
- }>(resolve => {
937
- const code = voucher.content.code;
938
- cloneCart.code = code;
939
- cloneCart.line_items = cloneCart.lineItems;
940
- ApiShop.getCheckout(cloneCart).then(response => {
941
- resolve({
942
- code,
943
- response,
944
- });
945
- });
946
- });
947
- })
948
- ).then(
949
- (
950
- resolveArray: {
951
- code: string;
952
- response: any;
953
- }[]
954
- ) => {
955
- vmi.dataList = vmi.dataList.map(item => {
956
- const f = resolveArray.find(res => {
957
- return item.content.code === res.code;
958
- });
959
- if (f) {
960
- const r = f.response;
961
- if (r.result && r.response.data) {
962
- item.content.usePass = r.response.data.voucherList.some(
963
- (dd: any) => {
964
- return dd.code === f.code;
965
- }
966
- );
967
- }
945
+ });
946
+ });
947
+ })
948
+ ).then(
949
+ (
950
+ resolveArray: {
951
+ code: string;
952
+ response: any;
953
+ }[]
954
+ ) => {
955
+ vmi.dataList = vmi.dataList.map(item => {
956
+ const f = resolveArray.find(res => {
957
+ return item.content.code === res.code;
958
+ });
959
+ if (f) {
960
+ const r = f.response;
961
+ if (r.result && r.response.data) {
962
+ item.content.usePass = r.response.data.voucherList.some(
963
+ (dd: any) => {
964
+ return dd.code === f.code;
968
965
  }
969
- return item;
970
- });
971
- loading = false;
972
- gvc.notifyDataChange(id);
966
+ );
973
967
  }
974
- );
968
+ }
969
+ return item;
975
970
  });
976
- },
977
- () => {}
971
+ loading = false;
972
+ gvc.notifyDataChange(id);
973
+ }
978
974
  );
979
- }
975
+ });
980
976
  },
981
- };
982
- })()
983
- );
984
- },
985
- });
986
- })}"
977
+ () => {}
978
+ );
979
+ }
980
+ },
981
+ };
982
+ })()
983
+ );
984
+ },
985
+ });
986
+ })}"
987
987
  >
988
988
  ${vm.cartData.code
989
- ? html`${vm.cartData.code}<i
989
+ ? html`${vm.cartData.code}<i
990
990
  class="fa-solid fa-xmark-large ms-2"
991
991
  style="cursor: pointer;"
992
992
  onclick="${gvc.event((e, event) => {
993
- event.stopPropagation();
994
- apiCart.setCart(cartItem => {
995
- cartItem.code = '';
996
- refreshCartData();
997
- });
998
- })}"
993
+ event.stopPropagation();
994
+ apiCart.setCart(cartItem => {
995
+ cartItem.code = '';
996
+ refreshCartData();
997
+ });
998
+ })}"
999
999
  ></i>`
1000
- : Language.text('add')}
1000
+ : Language.text('add')}
1001
1001
  </div>
1002
1002
  </div>
1003
1003
  ${(() => {
1004
- if (!GlobalUser.token || !vm.cartData.useRebateInfo.status) {
1005
- return ``;
1006
- } else {
1007
- return html` ${(() => {
1008
- let tempRebate: number = 0;
1009
- const dialog = new ShareDialog(gvc.glitter);
1010
- return html` <div class="${gClass(['price-row', 'text-2'])}">
1004
+ if (!GlobalUser.token || !vm.cartData.useRebateInfo.status) {
1005
+ return ``;
1006
+ } else {
1007
+ return html` ${(() => {
1008
+ let tempRebate: number = 0;
1009
+ const dialog = new ShareDialog(gvc.glitter);
1010
+ return html` <div class="${gClass(['price-row', 'text-2'])}">
1011
1011
  <div>${vm.rebateConfig.title}${Language.text('discount')}</div>
1012
1012
  <div>- ${Currency.convertCurrencyText(vm.cartData.use_rebate)}</div>
1013
1013
  </div>
@@ -1019,110 +1019,110 @@ export class CheckoutIndex {
1019
1019
  <div class="${gClass(['price-row', 'text-2'])}">
1020
1020
  <div
1021
1021
  style=" justify-content: flex-start; align-items: center; display: inline-flex;border:1px solid #EAEAEA;border-radius: 10px;overflow: hidden; ${document
1022
- .body.clientWidth > 768
1023
- ? 'gap: 18px;'
1024
- : 'gap: 0px;'}"
1022
+ .body.clientWidth > 768
1023
+ ? 'gap: 18px;'
1024
+ : 'gap: 0px;'}"
1025
1025
  class="w-100"
1026
1026
  >
1027
1027
  <input
1028
1028
  class="flex-fill ${gClass('group-input')}"
1029
1029
  placeholder="${Language.text('please_enter')}${vm.rebateConfig.title}"
1030
1030
  style="${document.body.clientWidth < 800
1031
- ? `width:calc(100% - 150px) !important;`
1032
- : ``}"
1031
+ ? `width:calc(100% - 150px) !important;`
1032
+ : ``}"
1033
1033
  value="${vm.cartData.use_rebate || ''}"
1034
1034
  onchange="${gvc.event((e, event) => {
1035
- if (CheckInput.isNumberString(e.value)) {
1036
- tempRebate = parseInt(e.value, 10);
1037
- } else {
1038
- dialog.errorMessage({ text: Language.text('enter_value') });
1039
- gvc.notifyDataChange(ids.page);
1040
- }
1041
- })}"
1035
+ if (CheckInput.isNumberString(e.value)) {
1036
+ tempRebate = parseInt(e.value, 10);
1037
+ } else {
1038
+ dialog.errorMessage({ text: Language.text('enter_value') });
1039
+ gvc.notifyDataChange(ids.page);
1040
+ }
1041
+ })}"
1042
1042
  />
1043
1043
  <div class="${gClass('group-button')}">
1044
1044
  <div
1045
1045
  class="${gClass('button-text')}"
1046
1046
  onclick="${gvc.event(async () => {
1047
- const sum: number = await new Promise((resolve, reject) => {
1048
- ApiShop.getRebate({}).then(async res => {
1049
- if (res.result && res.response.sum) {
1050
- resolve(res.response.sum);
1051
- } else {
1052
- resolve(0);
1053
- }
1054
- });
1055
- });
1056
- const limit =
1057
- vm.cartData.total - vm.cartData.shipment_fee + vm.cartData.use_rebate;
1058
- if (sum === 0) {
1059
- dialog.errorMessage({
1060
- text: `您的 ${vm.rebateConfig.title} 為 0 點,無法折抵`,
1061
- });
1062
- return;
1063
- }
1064
- if (tempRebate > Math.min(sum, limit)) {
1065
- dialog.errorMessage({
1066
- text: `${Language.text('please_enter')} 0 到 ${Math.min(sum, limit)} 的數值`,
1067
- });
1068
- return;
1069
- }
1070
-
1071
- apiCart.setCart(cartItem => {
1072
- cartItem.use_rebate = tempRebate;
1073
- refreshCartData();
1074
- });
1075
- })}"
1047
+ const sum: number = await new Promise((resolve, reject) => {
1048
+ ApiShop.getRebate({}).then(async res => {
1049
+ if (res.result && res.response.sum) {
1050
+ resolve(res.response.sum);
1051
+ } else {
1052
+ resolve(0);
1053
+ }
1054
+ });
1055
+ });
1056
+ const limit =
1057
+ vm.cartData.total - vm.cartData.shipment_fee + vm.cartData.use_rebate;
1058
+ if (sum === 0) {
1059
+ dialog.errorMessage({
1060
+ text: `您的 ${vm.rebateConfig.title} 為 0 點,無法折抵`,
1061
+ });
1062
+ return;
1063
+ }
1064
+ if (tempRebate > Math.min(sum, limit)) {
1065
+ dialog.errorMessage({
1066
+ text: `${Language.text('please_enter')} 0 到 ${Math.min(sum, limit)} 的數值`,
1067
+ });
1068
+ return;
1069
+ }
1070
+
1071
+ apiCart.setCart(cartItem => {
1072
+ cartItem.use_rebate = tempRebate;
1073
+ refreshCartData();
1074
+ });
1075
+ })}"
1076
1076
  >
1077
1077
  ${Language.text('apply')}
1078
1078
  </div>
1079
1079
  </div>
1080
1080
  </div>
1081
1081
  </div>`;
1082
- })()}
1082
+ })()}
1083
1083
  <div class="${gClass(['price-row', 'text-2'])}">
1084
1084
  ${(() => {
1085
- return gvc.bindView(() => {
1086
- return {
1087
- bind: gvc.glitter.getUUID(),
1088
- view: async () => {
1089
- const sum = await new Promise((resolve, reject) => {
1090
- ApiShop.getRebate({}).then(async res => {
1091
- if (res.result && res.response.sum) {
1092
- resolve(res.response.sum);
1093
- } else {
1094
- resolve(0);
1095
- }
1096
- });
1097
- });
1098
- if (!vm.cartData.useRebateInfo) {
1099
- return '';
1100
- }
1085
+ return gvc.bindView(() => {
1086
+ return {
1087
+ bind: gvc.glitter.getUUID(),
1088
+ view: async () => {
1089
+ const sum = await new Promise((resolve, reject) => {
1090
+ ApiShop.getRebate({}).then(async res => {
1091
+ if (res.result && res.response.sum) {
1092
+ resolve(res.response.sum);
1093
+ } else {
1094
+ resolve(0);
1095
+ }
1096
+ });
1097
+ });
1098
+ if (!vm.cartData.useRebateInfo) {
1099
+ return '';
1100
+ }
1101
1101
 
1102
- const info = vm.cartData.useRebateInfo;
1103
- if (info.condition) {
1104
- return html`${Language.text('distance_from_target_amount')}$
1102
+ const info = vm.cartData.useRebateInfo;
1103
+ if (info.condition) {
1104
+ return html`${Language.text('distance_from_target_amount')}$
1105
1105
  ${info.condition.toLocaleString()} ${Language.text('can_use_now')}
1106
1106
  ${vm.rebateConfig.title} ${Language.text('discount')}`;
1107
- }
1108
- if (info.limit) {
1109
- return html`${Language.text('remaining_balance')} ${sum || 0}
1107
+ }
1108
+ if (info.limit) {
1109
+ return html`${Language.text('remaining_balance')} ${sum || 0}
1110
1110
  ${Language.text('point')} ${vm.rebateConfig.title} <br />${Language.text(
1111
- 'max_discount_order'
1112
- )}
1111
+ 'max_discount_order'
1112
+ )}
1113
1113
  ${info.limit.toLocaleString()} ${Language.text('point')} ${vm.rebateConfig.title}`;
1114
- } else {
1115
- return `${Language.text('remaining_balance')} ${sum || 0} ${Language.text('point')} ${
1116
- vm.rebateConfig.title
1117
- }`;
1118
- }
1119
- },
1120
- };
1121
- });
1122
- })()}
1114
+ } else {
1115
+ return `${Language.text('remaining_balance')} ${sum || 0} ${Language.text('point')} ${
1116
+ vm.rebateConfig.title
1117
+ }`;
1118
+ }
1119
+ },
1120
+ };
1121
+ });
1122
+ })()}
1123
1123
  </div>`;
1124
- }
1125
- })()}
1124
+ }
1125
+ })()}
1126
1126
  </div>`;
1127
1127
  if (!widget.share.receipt_form) {
1128
1128
  const res = await ApiUser.getPublicConfig('custom_form_checkout_recipient', 'manager');
@@ -1163,108 +1163,108 @@ export class CheckoutIndex {
1163
1163
 
1164
1164
  return html` <div class="w-100" style="margin-top:0 !important;">
1165
1165
  ${gvc.bindView(
1166
- (() => {
1167
- return {
1168
- bind: ids.cart,
1169
- view: () => {
1170
- let padding = (document.body.clientWidth - 1200) / 2;
1171
- if (gvc.glitter.getUrlParameter('page') !== 'checkout') {
1172
- padding = 0;
1173
- }
1174
- const shipmentSupportSet = new Set(vm.cartData.shipment_support);
1175
-
1176
- console.log(`shipmentSupportSet==>`,shipmentSupportSet)
1177
- const shipmentList = this.getShipmentMethod(vm.cartData).filter((dd: { value: string }) =>
1178
- shipmentSupportSet.has(dd.value)
1179
- );
1180
- console.log(`cartData.shipment_selector=>`, vm.cartData.shipment_selector);
1181
- console.log(`shipmentSupportSet=>`, shipmentSupportSet);
1182
- console.log(`shipmentList==>`, shipmentList);
1183
- const localShip = shipmentSupportSet.has(localStorage.getItem('shipment-select'));
1184
- if (shipmentList.length === 0) {
1185
- vm.cartData.user_info.shipment = 'none';
1186
- localStorage.setItem('shipment-select', 'none');
1187
- } else if (localShip) {
1188
- vm.cartData.user_info.shipment = localStorage.getItem('shipment-select');
1189
- } else {
1190
- vm.cartData.user_info.shipment = shipmentList[0].value;
1191
- localStorage.setItem('shipment-select', shipmentList[0].value);
1192
- }
1193
-
1194
- return html`
1166
+ (() => {
1167
+ return {
1168
+ bind: ids.cart,
1169
+ view: () => {
1170
+ let padding = (document.body.clientWidth - 1200) / 2;
1171
+ if (gvc.glitter.getUrlParameter('page') !== 'checkout') {
1172
+ padding = 0;
1173
+ }
1174
+ const shipmentSupportSet = new Set(vm.cartData.shipment_support);
1175
+
1176
+ console.log(`shipmentSupportSet==>`,shipmentSupportSet)
1177
+ const shipmentList = this.getShipmentMethod(vm.cartData).filter((dd: { value: string }) =>
1178
+ shipmentSupportSet.has(dd.value)
1179
+ );
1180
+ console.log(`cartData.shipment_selector=>`, vm.cartData.shipment_selector);
1181
+ console.log(`shipmentSupportSet=>`, shipmentSupportSet);
1182
+ console.log(`shipmentList==>`, shipmentList);
1183
+ const localShip = shipmentSupportSet.has(localStorage.getItem('shipment-select'));
1184
+ if (shipmentList.length === 0) {
1185
+ vm.cartData.user_info.shipment = 'none';
1186
+ localStorage.setItem('shipment-select', 'none');
1187
+ } else if (localShip) {
1188
+ vm.cartData.user_info.shipment = localStorage.getItem('shipment-select');
1189
+ } else {
1190
+ vm.cartData.user_info.shipment = shipmentList[0].value;
1191
+ localStorage.setItem('shipment-select', shipmentList[0].value);
1192
+ }
1193
+
1194
+ return html`
1195
1195
  <div
1196
1196
  class="d-flex flex-column flex-md-row justify-content-between w-100"
1197
1197
  style="${document.body.clientWidth > 800 &&
1198
- gvc.glitter.getUrlParameter('page') === 'checkout'
1199
- ? `height:calc(100vh - 150px);overflow-y:auto;`
1200
- : `gap:20px;`} padding-left:${padding > 0 ? padding : 10}px;padding-right:${padding > 0
1201
- ? padding
1202
- : 10}px;"
1198
+ gvc.glitter.getUrlParameter('page') === 'checkout'
1199
+ ? `height:calc(100vh - 150px);overflow-y:auto;`
1200
+ : `gap:20px;`} padding-left:${padding > 0 ? padding : 10}px;padding-right:${padding > 0
1201
+ ? padding
1202
+ : 10}px;"
1203
1203
  >
1204
1204
  <div
1205
1205
  style="${document.body.clientWidth > 800
1206
- ? `width:calc(66% - 10px);`
1207
- : `width:calc(100%);`}"
1206
+ ? `width:calc(66% - 10px);`
1207
+ : `width:calc(100%);`}"
1208
1208
  >
1209
1209
  <div
1210
1210
  style="padding-top:20px;"
1211
1211
  class="${gClass('banner-text')} fs-4 mb-3 pt-3 ${gvc.glitter.getUrlParameter(
1212
- 'page'
1213
- ) === 'checkout'
1214
- ? ``
1215
- : `d-none`}"
1212
+ 'page'
1213
+ ) === 'checkout'
1214
+ ? ``
1215
+ : `d-none`}"
1216
1216
  >
1217
1217
  ${Language.text(
1218
- ApiCart.checkoutCart === ApiCart.buyItNow ? 'buy_it_now' : 'your_shopping_cart'
1219
- )}
1218
+ ApiCart.checkoutCart === ApiCart.buyItNow ? 'buy_it_now' : 'your_shopping_cart'
1219
+ )}
1220
1220
  </div>
1221
1221
  <div style="" class="rounded-3 bg-white w-100 ">
1222
1222
  ${gvc.bindView({
1223
- bind: glitter.getUUID(),
1224
- view: () => {
1225
- try {
1226
- return vm.cartData.lineItems
1227
- .map((item: any, index: number) => {
1228
- // min_qty
1229
- function getBadgeClass() {
1230
- if (item.is_add_on_items) {
1231
- return addItemBadge();
1232
- } else if (item.is_gift) {
1233
- return giftBadge();
1234
- } else if (item.is_hidden) {
1235
- return hiddenBadge();
1236
- } else {
1237
- return ``;
1238
- }
1239
- }
1223
+ bind: glitter.getUUID(),
1224
+ view: () => {
1225
+ try {
1226
+ return vm.cartData.lineItems
1227
+ .map((item: any, index: number) => {
1228
+ // min_qty
1229
+ function getBadgeClass() {
1230
+ if (item.is_add_on_items) {
1231
+ return addItemBadge();
1232
+ } else if (item.is_gift) {
1233
+ return giftBadge();
1234
+ } else if (item.is_hidden) {
1235
+ return hiddenBadge();
1236
+ } else {
1237
+ return ``;
1238
+ }
1239
+ }
1240
1240
 
1241
- const title =
1242
- (item.language_data &&
1243
- item.language_data[Language.getLanguage()].title) ||
1244
- item.title;
1245
- const spec = (() => {
1246
- if (item.spec) {
1247
- return item.spec.map((dd: string, index: number) => {
1248
- try {
1249
- return (
1250
- item.specs[index].option.find((d1: any) => {
1251
- return d1.title === dd;
1252
- }).language_title[Language.getLanguage()] || dd
1253
- );
1254
- } catch (e) {
1255
- return dd;
1256
- }
1257
- });
1258
- } else {
1259
- return ``;
1260
- }
1261
- })();
1241
+ const title =
1242
+ (item.language_data &&
1243
+ item.language_data[Language.getLanguage()].title) ||
1244
+ item.title;
1245
+ const spec = (() => {
1246
+ if (item.spec) {
1247
+ return item.spec.map((dd: string, index: number) => {
1248
+ try {
1249
+ return (
1250
+ item.specs[index].option.find((d1: any) => {
1251
+ return d1.title === dd;
1252
+ }).language_title[Language.getLanguage()] || dd
1253
+ );
1254
+ } catch (e) {
1255
+ return dd;
1256
+ }
1257
+ });
1258
+ } else {
1259
+ return ``;
1260
+ }
1261
+ })();
1262
1262
 
1263
- if (vm.cartData.lineItems.length === index + 1) {
1264
- gvc.notifyDataChange(ids.shipping);
1265
- }
1263
+ if (vm.cartData.lineItems.length === index + 1) {
1264
+ gvc.notifyDataChange(ids.shipping);
1265
+ }
1266
1266
 
1267
- return html`
1267
+ return html`
1268
1268
  <div class="d-flex flex-column p-lg-3 px-2 py-3 gap-2">
1269
1269
  <div class="d-flex w-100 position-relative" style="gap:20px;">
1270
1270
  <div class=" justify-content-start ">
@@ -1279,8 +1279,8 @@ export class CheckoutIndex {
1279
1279
  <span
1280
1280
  class="fw-bold pe-4"
1281
1281
  style="gap:5px;font-size:${document.body.clientWidth > 800
1282
- ? `16`
1283
- : `14`}px;max-width:calc(100% - 10px); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; "
1282
+ ? `16`
1283
+ : `14`}px;max-width:calc(100% - 10px); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; "
1284
1284
  >${title}</span
1285
1285
  >
1286
1286
  <div class="${gClass(['66text'])} fs-sm">
@@ -1290,24 +1290,24 @@ export class CheckoutIndex {
1290
1290
  <div class="d-flex flex-column align-items-start " style="gap:2px;">
1291
1291
  <div class="fw-bold fs-6 ${gClass('price-text')}">
1292
1292
  ${(() => {
1293
- if (item.is_gift) {
1294
- return Currency.convertCurrencyText(0);
1295
- }
1296
- return Currency.convertCurrencyText(
1297
- parseFloat(item.sale_price)
1298
- );
1299
- })()}
1293
+ if (item.is_gift) {
1294
+ return Currency.convertCurrencyText(0);
1295
+ }
1296
+ return Currency.convertCurrencyText(
1297
+ parseFloat(item.sale_price)
1298
+ );
1299
+ })()}
1300
1300
  </div>
1301
1301
  ${(() => {
1302
- if (item.is_gift || item.sale_price >= item.origin_price) {
1303
- return '';
1304
- }
1305
- return html` <div
1302
+ if (item.is_gift || item.sale_price >= item.origin_price) {
1303
+ return '';
1304
+ }
1305
+ return html` <div
1306
1306
  style="text-decoration: line-through; font-size: 12px;"
1307
1307
  >
1308
1308
  ${Currency.convertCurrencyText(parseFloat(item.origin_price))}
1309
1309
  </div>`;
1310
- })()}
1310
+ })()}
1311
1311
  </div>
1312
1312
  <div class="w-100 d-flex">
1313
1313
  <div class="flex-fill"></div>
@@ -1317,23 +1317,23 @@ export class CheckoutIndex {
1317
1317
  >
1318
1318
  <div
1319
1319
  class="${item.is_gift
1320
- ? `d-none`
1321
- : `d-flex`} align-items-center justify-content-center"
1320
+ ? `d-none`
1321
+ : `d-flex`} align-items-center justify-content-center"
1322
1322
  style="width:38px;height: 38px;cursor: pointer;"
1323
1323
  onclick="${gvc.event(() => {
1324
- apiCart.setCart(cartItem => {
1325
- const find = cartItem.line_items.find(dd => {
1326
- return (
1327
- dd.id === item.id &&
1328
- item.spec.join('') === dd.spec.join('')
1329
- );
1330
- })!;
1331
- if (find.count - 1 > 0) {
1332
- find.count = find.count - 1;
1333
- refreshCartData();
1334
- }
1335
- });
1336
- })}"
1324
+ apiCart.setCart(cartItem => {
1325
+ const find = cartItem.line_items.find(dd => {
1326
+ return (
1327
+ dd.id === item.id &&
1328
+ item.spec.join('') === dd.spec.join('')
1329
+ );
1330
+ })!;
1331
+ if (find.count - 1 > 0) {
1332
+ find.count = find.count - 1;
1333
+ refreshCartData();
1334
+ }
1335
+ });
1336
+ })}"
1337
1337
  >
1338
1338
  <i class="fa-solid fa-minus" style="color:black;"></i>
1339
1339
  </div>
@@ -1342,69 +1342,69 @@ export class CheckoutIndex {
1342
1342
  style="
1343
1343
 
1344
1344
  ${item.is_gift
1345
- ? `border:none;`
1346
- : `border-top:none;border-bottom: none;`}
1345
+ ? `border:none;`
1346
+ : `border-top:none;border-bottom: none;`}
1347
1347
  border-radius: 0px; color: #575757; width: 50px;height:38px;background-image:none;${parseInt(
1348
- vm.quantity,
1349
- 10
1350
- ) < 10
1351
- ? `text-indent: 43%;`
1352
- : `text-indent: 40%;`}"
1348
+ vm.quantity,
1349
+ 10
1350
+ ) < 10
1351
+ ? `text-indent: 43%;`
1352
+ : `text-indent: 40%;`}"
1353
1353
  onchange="${gvc.event(e => {
1354
- apiCart.setCart(cartItem => {
1355
- cartItem.line_items.find(dd => {
1356
- return (
1357
- dd.id === item.id &&
1358
- item.spec.join('') === dd.spec.join('')
1359
- );
1360
- })!.count = parseInt(e.value, 10);
1361
- refreshCartData();
1362
- });
1363
- })}"
1354
+ apiCart.setCart(cartItem => {
1355
+ cartItem.line_items.find(dd => {
1356
+ return (
1357
+ dd.id === item.id &&
1358
+ item.spec.join('') === dd.spec.join('')
1359
+ );
1360
+ })!.count = parseInt(e.value, 10);
1361
+ refreshCartData();
1362
+ });
1363
+ })}"
1364
1364
  ${item.is_gift ? `disabled` : ``}
1365
1365
  >
1366
1366
  ${[
1367
- ...new Array(
1368
- (() => {
1369
- if (item.show_understocking === 'false') {
1370
- return 50;
1371
- }
1372
- return item.stock < 50 ? item.stock : 50;
1373
- })()
1374
- ),
1375
- ]
1376
- .map((_, index) => {
1377
- return html` <option
1367
+ ...new Array(
1368
+ (() => {
1369
+ if (item.show_understocking === 'false') {
1370
+ return 50;
1371
+ }
1372
+ return item.stock < 50 ? item.stock : 50;
1373
+ })()
1374
+ ),
1375
+ ]
1376
+ .map((_, index) => {
1377
+ return html` <option
1378
1378
  value="${index + 1}"
1379
1379
  ${index + 1 === item.count ? `selected` : ``}
1380
1380
  >
1381
1381
  ${index + 1}
1382
1382
  </option>`;
1383
- })
1384
- .join('')}
1383
+ })
1384
+ .join('')}
1385
1385
  </select>
1386
1386
  <div
1387
1387
  class=" align-items-center justify-content-center ${item.is_gift
1388
- ? `d-none`
1389
- : `d-flex`}"
1388
+ ? `d-none`
1389
+ : `d-flex`}"
1390
1390
  style="width:38px;height: 38px;cursor: pointer;"
1391
1391
  onclick="${gvc.event(() => {
1392
- apiCart.setCart(cartItem => {
1393
- const find = cartItem.line_items.find(dd => {
1394
- return (
1395
- dd.id === item.id &&
1396
- item.spec.join('') === dd.spec.join('')
1397
- );
1398
- })!;
1399
- if (
1400
- item.show_understocking === 'false' ||
1401
- find.count + 1 < item.stock
1402
- ) {
1403
- find.count = find.count + 1;
1404
- refreshCartData();
1405
- }
1406
- });
1407
- })}"
1392
+ apiCart.setCart(cartItem => {
1393
+ const find = cartItem.line_items.find(dd => {
1394
+ return (
1395
+ dd.id === item.id &&
1396
+ item.spec.join('') === dd.spec.join('')
1397
+ );
1398
+ })!;
1399
+ if (
1400
+ item.show_understocking === 'false' ||
1401
+ find.count + 1 < item.stock
1402
+ ) {
1403
+ find.count = find.count + 1;
1404
+ refreshCartData();
1405
+ }
1406
+ });
1407
+ })}"
1408
1408
  >
1409
1409
  <i class="fa-solid fa-plus" style="color:black;"></i>
1410
1410
  </div>
@@ -1418,101 +1418,101 @@ export class CheckoutIndex {
1418
1418
  class="fa-solid fa-xmark-large"
1419
1419
  style="cursor: pointer;color:gray;"
1420
1420
  onclick="${gvc.event(() => {
1421
- apiCart.setCart(cartItem => {
1422
- cartItem.line_items = cartItem.line_items.filter(dd => {
1423
- return !(
1424
- dd.id === item.id &&
1425
- item.spec.join('') === dd.spec.join('')
1426
- );
1427
- });
1428
- refreshCartData();
1429
- });
1430
- })}"
1421
+ apiCart.setCart(cartItem => {
1422
+ cartItem.line_items = cartItem.line_items.filter(dd => {
1423
+ return !(
1424
+ dd.id === item.id &&
1425
+ item.spec.join('') === dd.spec.join('')
1426
+ );
1427
+ });
1428
+ refreshCartData();
1429
+ });
1430
+ })}"
1431
1431
  ></i>
1432
1432
  </div>
1433
1433
  </div>
1434
1434
  </div>
1435
1435
  <div>
1436
1436
  ${vm.cartData.voucherList
1437
- .filter((dd: any) => {
1438
- return (
1439
- dd.bind.find((d2: any) => {
1440
- return d2.id === item.id;
1441
- }) &&
1442
- dd.reBackType !== 'giveaway' &&
1443
- dd.reBackType !== 'add_on_items'
1444
- );
1445
- })
1446
- .map((dd: any) => {
1447
- return `<div class=" w-100 " style="${document.body.clientWidth < 800 ? `font-size:12px;` : `font-size:14px;`}"><i class="fa-solid fa-tickets-perforated me-2"></i>${dd.title}</div>`;
1448
- })
1449
- .join('<div class="my-1"></div>')}
1437
+ .filter((dd: any) => {
1438
+ return (
1439
+ dd.bind.find((d2: any) => {
1440
+ return d2.id === item.id;
1441
+ }) &&
1442
+ dd.reBackType !== 'giveaway' &&
1443
+ dd.reBackType !== 'add_on_items'
1444
+ );
1445
+ })
1446
+ .map((dd: any) => {
1447
+ return `<div class=" w-100 " style="${document.body.clientWidth < 800 ? `font-size:12px;` : `font-size:14px;`}"><i class="fa-solid fa-tickets-perforated me-2"></i>${dd.title}</div>`;
1448
+ })
1449
+ .join('<div class="my-1"></div>')}
1450
1450
  ${(() => {
1451
- let min = (item.min_qty && parseInt(item.min_qty, 10)) || 1;
1452
- let count = 0;
1453
- for (const b of vm.cartData.lineItems) {
1454
- if (b.id === item.id) {
1455
- count += b.count;
1456
- }
1457
- }
1458
- if (count < min) {
1459
- return `<div class="text-danger">${Language.text('min_p_count').replace('_c_', min)}</div>`;
1460
- } else {
1461
- return ``;
1462
- }
1463
- })()}
1451
+ let min = (item.min_qty && parseInt(item.min_qty, 10)) || 1;
1452
+ let count = 0;
1453
+ for (const b of vm.cartData.lineItems) {
1454
+ if (b.id === item.id) {
1455
+ count += b.count;
1456
+ }
1457
+ }
1458
+ if (count < min) {
1459
+ return `<div class="text-danger">${Language.text('min_p_count').replace('_c_', min)}</div>`;
1460
+ } else {
1461
+ return ``;
1462
+ }
1463
+ })()}
1464
1464
  ${(() => {
1465
- let max_qty =
1466
- (item.max_qty && parseInt(item.max_qty, 10)) || Infinity;
1467
- let count = 0;
1468
- for (const b of vm.cartData.lineItems) {
1469
- if (b.id === item.id) {
1470
- count += b.count;
1471
- }
1472
- }
1465
+ let max_qty =
1466
+ (item.max_qty && parseInt(item.max_qty, 10)) || Infinity;
1467
+ let count = 0;
1468
+ for (const b of vm.cartData.lineItems) {
1469
+ if (b.id === item.id) {
1470
+ count += b.count;
1471
+ }
1472
+ }
1473
1473
 
1474
- if (count > max_qty) {
1475
- return `<div class="text-danger">${Language.text('max_p_count').replace('_c_', max_qty)}</div>`;
1476
- } else {
1477
- return ``;
1478
- }
1479
- })()}
1474
+ if (count > max_qty) {
1475
+ return `<div class="text-danger">${Language.text('max_p_count').replace('_c_', max_qty)}</div>`;
1476
+ } else {
1477
+ return ``;
1478
+ }
1479
+ })()}
1480
1480
  </div>
1481
1481
  </div>
1482
1482
  `;
1483
- })
1484
- .join(`<div class="border-bottom w-100"></div>`);
1485
- } catch (e) {
1486
- console.error(`error 1 =>`, e);
1487
- return '';
1488
- }
1489
- },
1490
- })}
1483
+ })
1484
+ .join(`<div class="border-bottom w-100"></div>`);
1485
+ } catch (e) {
1486
+ console.error(`error 1 =>`, e);
1487
+ return '';
1488
+ }
1489
+ },
1490
+ })}
1491
1491
  </div>
1492
1492
  <!--加購品-->
1493
1493
  ${(() => {
1494
- let add_on: any[] = [];
1495
- vm.cartData.voucherList.filter((dd: any) => {
1496
- if (dd.reBackType === 'add_on_items') {
1497
- add_on = add_on.concat(dd.add_on_products);
1498
- }
1494
+ let add_on: any[] = [];
1495
+ vm.cartData.voucherList.filter((dd: any) => {
1496
+ if (dd.reBackType === 'add_on_items') {
1497
+ add_on = add_on.concat(dd.add_on_products);
1498
+ }
1499
+ });
1500
+ if (add_on.length) {
1501
+ return gvc.bindView(() => {
1502
+ const id = gvc.glitter.getUUID();
1503
+ return {
1504
+ bind: id,
1505
+ view: async () => {
1506
+ const add_products = await ApiShop.getProduct({
1507
+ page: 0,
1508
+ limit: 100,
1509
+ productType: 'addProduct',
1510
+ id_list: add_on.join(','),
1499
1511
  });
1500
- if (add_on.length) {
1501
- return gvc.bindView(() => {
1502
- const id = gvc.glitter.getUUID();
1503
- return {
1504
- bind: id,
1505
- view: async () => {
1506
- const add_products = await ApiShop.getProduct({
1507
- page: 0,
1508
- limit: 100,
1509
- productType: 'addProduct',
1510
- id_list: add_on.join(','),
1511
- });
1512
- if (!add_products.response.data.length) {
1513
- return ``;
1514
- }
1515
- return html`
1512
+ if (!add_products.response.data.length) {
1513
+ return ``;
1514
+ }
1515
+ return html`
1516
1516
  <div class="rounded-3 mt-3 p-3 bg-white">
1517
1517
  <span class="${gClass('banner-text')}"
1518
1518
  >${Language.text('additional_purchase_items')}</span
@@ -1522,8 +1522,8 @@ export class CheckoutIndex {
1522
1522
  style="overflow-x:auto;gap:10px;"
1523
1523
  >
1524
1524
  ${add_products.response.data
1525
- .map((dd: any) => {
1526
- return html` <div
1525
+ .map((dd: any) => {
1526
+ return html` <div
1527
1527
  class="d-flex py-3 align-items-center"
1528
1528
  style="gap:10px;"
1529
1529
  >
@@ -1541,29 +1541,29 @@ export class CheckoutIndex {
1541
1541
  <button
1542
1542
  class="${gClass('button-bgr')} mb-0 mt-2"
1543
1543
  onclick="${gvc.event(() => {
1544
- const titleFontColor =
1545
- glitter.share.globalValue['theme_color.0.title'] ??
1546
- '#333333';
1547
- gvc.glitter.innerDialog(
1548
- (gvc: GVC) => {
1549
- return html` <div
1544
+ const titleFontColor =
1545
+ glitter.share.globalValue['theme_color.0.title'] ??
1546
+ '#333333';
1547
+ gvc.glitter.innerDialog(
1548
+ (gvc: GVC) => {
1549
+ return html` <div
1550
1550
  class=" bg-white shadow ${document.body.clientWidth >
1551
- 768
1552
- ? `rounded-3`
1553
- : ` position-absolute bottom-0`}"
1551
+ 768
1552
+ ? `rounded-3`
1553
+ : ` position-absolute bottom-0`}"
1554
1554
  style=" ${document.body.clientWidth > 768
1555
- ? `min-width: 400px; width: 1000px;max-height:calc(100% - 150px);overflow-y: auto;`
1556
- : 'width:calc(100vw);height:100%;'}"
1555
+ ? `min-width: 400px; width: 1000px;max-height:calc(100% - 150px);overflow-y: auto;`
1556
+ : 'width:calc(100vw);height:100%;'}"
1557
1557
  >
1558
1558
  <div
1559
1559
  class="bg-white shadow ${document.body
1560
- .clientWidth > 768
1561
- ? `rounded-3`
1562
- : `h-100`}"
1560
+ .clientWidth > 768
1561
+ ? `rounded-3`
1562
+ : `h-100`}"
1563
1563
  style="width: 100%; position: relative;${document
1564
- .body.clientWidth > 768
1565
- ? ``
1566
- : `overflow-y: auto;`}"
1564
+ .body.clientWidth > 768
1565
+ ? ``
1566
+ : `overflow-y: auto;`}"
1567
1567
  >
1568
1568
  <div
1569
1569
  class="w-100 d-flex align-items-center p-3 border-bottom"
@@ -1580,77 +1580,77 @@ export class CheckoutIndex {
1580
1580
  class="fa-regular fa-circle-xmark fs-5 text-dark"
1581
1581
  style="cursor: pointer"
1582
1582
  onclick="${gvc.event(() => {
1583
- gvc.closeDialog();
1584
- })}"
1583
+ gvc.closeDialog();
1584
+ })}"
1585
1585
  ></i>
1586
1586
  </div>
1587
1587
  <div
1588
1588
  class="c_dialog_main"
1589
1589
  style="gap: 24px; max-height: calc(100% - 100px); ${document
1590
- .body.clientWidth < 800
1591
- ? `padding: 12px 20px;`
1592
- : `padding: 30px;`}"
1590
+ .body.clientWidth < 800
1591
+ ? `padding: 12px 20px;`
1592
+ : `padding: 30px;`}"
1593
1593
  >
1594
1594
  ${PdClass.selectSpec({
1595
- gvc,
1596
- titleFontColor:
1597
- glitter.share.globalValue[
1598
- 'theme_color.0.title'
1599
- ] ?? '#333333',
1600
- prod: dd.content,
1601
- vm: {
1602
- specs: dd.content.specs.map(
1603
- (spec: {
1604
- option: {
1605
- title: string;
1606
- }[];
1607
- }) => {
1608
- return spec.option[0].title;
1609
- }
1610
- ),
1611
- quantity: '1',
1612
- wishStatus: (
1613
- glitter.share.wishList ?? []
1614
- ).some((item: { id: number }) => {
1615
- return item.id === dd.id;
1616
- }),
1617
- },
1618
- preview: true,
1619
- with_qty: false,
1620
- is_gift: true,
1621
- callback: () => {
1622
- gvc.closeDialog();
1623
- console.log(`vm.cartData=>`, vm.cartData);
1624
- let find = vm.cartData.lineItems.find(
1625
- (d1: any) => {
1626
- return dd.add_on_products.find(
1627
- (d2: any) => {
1628
- return d2.id === d1.id;
1629
- }
1630
- );
1631
- }
1632
- );
1633
- console.log(`find=>`, find);
1634
- if (find) {
1635
- apiCart.setCart(cartItem => {
1636
- cartItem.line_items.map(dd => {
1637
- if (dd.id === find.id) {
1638
- dd.count--;
1639
- }
1640
- });
1641
- cartItem.line_items =
1642
- cartItem.line_items.filter(dd => {
1643
- return dd.count > 0;
1644
- });
1645
- refreshCartData();
1646
- gvc.closeDialog();
1647
- });
1648
- } else {
1649
- refreshCartData();
1650
- gvc.closeDialog();
1651
- }
1652
- },
1653
- })}
1595
+ gvc,
1596
+ titleFontColor:
1597
+ glitter.share.globalValue[
1598
+ 'theme_color.0.title'
1599
+ ] ?? '#333333',
1600
+ prod: dd.content,
1601
+ vm: {
1602
+ specs: dd.content.specs.map(
1603
+ (spec: {
1604
+ option: {
1605
+ title: string;
1606
+ }[];
1607
+ }) => {
1608
+ return spec.option[0].title;
1609
+ }
1610
+ ),
1611
+ quantity: '1',
1612
+ wishStatus: (
1613
+ glitter.share.wishList ?? []
1614
+ ).some((item: { id: number }) => {
1615
+ return item.id === dd.id;
1616
+ }),
1617
+ },
1618
+ preview: true,
1619
+ with_qty: false,
1620
+ is_gift: true,
1621
+ callback: () => {
1622
+ gvc.closeDialog();
1623
+ console.log(`vm.cartData=>`, vm.cartData);
1624
+ let find = vm.cartData.lineItems.find(
1625
+ (d1: any) => {
1626
+ return dd.add_on_products.find(
1627
+ (d2: any) => {
1628
+ return d2.id === d1.id;
1629
+ }
1630
+ );
1631
+ }
1632
+ );
1633
+ console.log(`find=>`, find);
1634
+ if (find) {
1635
+ apiCart.setCart(cartItem => {
1636
+ cartItem.line_items.map(dd => {
1637
+ if (dd.id === find.id) {
1638
+ dd.count--;
1639
+ }
1640
+ });
1641
+ cartItem.line_items =
1642
+ cartItem.line_items.filter(dd => {
1643
+ return dd.count > 0;
1644
+ });
1645
+ refreshCartData();
1646
+ gvc.closeDialog();
1647
+ });
1648
+ } else {
1649
+ refreshCartData();
1650
+ gvc.closeDialog();
1651
+ }
1652
+ },
1653
+ })}
1654
1654
  <div
1655
1655
  class="d-sm-none"
1656
1656
  style="height:100px;"
@@ -1658,16 +1658,16 @@ export class CheckoutIndex {
1658
1658
  </div>
1659
1659
  </div>
1660
1660
  </div>`;
1661
- },
1662
- Tool.randomString(7),
1663
- {
1664
- animation:
1665
- document.body.clientWidth < 768
1666
- ? Animation.popup
1667
- : Animation.fade,
1668
- }
1669
- );
1670
- })}"
1661
+ },
1662
+ Tool.randomString(7),
1663
+ {
1664
+ animation:
1665
+ document.body.clientWidth < 768
1666
+ ? Animation.popup
1667
+ : Animation.fade,
1668
+ }
1669
+ );
1670
+ })}"
1671
1671
  >
1672
1672
  <span class="${gClass('button-text')}"
1673
1673
  >${Language.text('add_to_cart')}</span
@@ -1675,46 +1675,46 @@ export class CheckoutIndex {
1675
1675
  </button>
1676
1676
  </div>
1677
1677
  </div>`;
1678
- })
1679
- .join('')}
1678
+ })
1679
+ .join('')}
1680
1680
  </div>
1681
1681
  </div>
1682
1682
  `;
1683
- },
1684
- divCreate: {
1685
- class: `w-100`,
1686
- },
1687
- };
1688
- });
1689
- } else {
1690
- return '';
1691
- }
1692
- })()}
1683
+ },
1684
+ divCreate: {
1685
+ class: `w-100`,
1686
+ },
1687
+ };
1688
+ });
1689
+ } else {
1690
+ return '';
1691
+ }
1692
+ })()}
1693
1693
  <!--贈品-->
1694
1694
  ${(() => {
1695
- let already_add: any[] = vm.cartData.lineItems.filter((dd: any) => {
1696
- return dd.is_gift;
1697
- });
1698
- const giftHtml = vm.cartData.voucherList
1699
- .filter((d1: any) => {
1700
- return d1.reBackType === 'giveaway';
1701
- })
1702
- .map((dd: any) => {
1703
- let isSelected = already_add.find(d2 => {
1704
- return dd.add_on_products.find((d1: any) => {
1705
- return d1.id === d2.id;
1706
- });
1707
- });
1708
- already_add = already_add.filter(dd => {
1709
- return !dd === isSelected;
1710
- });
1711
- return html`
1695
+ let already_add: any[] = vm.cartData.lineItems.filter((dd: any) => {
1696
+ return dd.is_gift;
1697
+ });
1698
+ const giftHtml = vm.cartData.voucherList
1699
+ .filter((d1: any) => {
1700
+ return d1.reBackType === 'giveaway';
1701
+ })
1702
+ .map((dd: any) => {
1703
+ let isSelected = already_add.find(d2 => {
1704
+ return dd.add_on_products.find((d1: any) => {
1705
+ return d1.id === d2.id;
1706
+ });
1707
+ });
1708
+ already_add = already_add.filter(dd => {
1709
+ return !dd === isSelected;
1710
+ });
1711
+ return html`
1712
1712
  <span class="${gClass('banner-text')}">${dd.title}</span>
1713
1713
  <div class="d-flex align-items-center w-100" style="overflow-x:auto;gap:10px;">
1714
1714
  ${dd.add_on_products
1715
- .map((pd: any) => {
1716
- try {
1717
- return html` <div
1715
+ .map((pd: any) => {
1716
+ try {
1717
+ return html` <div
1718
1718
  class="d-flex py-3 align-items-center"
1719
1719
  style="gap:10px;"
1720
1720
  >
@@ -1732,35 +1732,35 @@ export class CheckoutIndex {
1732
1732
  <button
1733
1733
  class="${gClass('button-bgr')} mb-0 mt-2"
1734
1734
  style="${isSelected
1735
- ? isSelected.id === pd.id
1736
- ? `background: gray !important;`
1737
- : ``
1738
- : ``}"
1735
+ ? isSelected.id === pd.id
1736
+ ? `background: gray !important;`
1737
+ : ``
1738
+ : ``}"
1739
1739
  onclick="${gvc.event(() => {
1740
- if (isSelected && isSelected.id === pd.id) {
1741
- return;
1742
- }
1743
- const titleFontColor =
1744
- glitter.share.globalValue['theme_color.0.title'] ?? '#333333';
1745
- gvc.glitter.innerDialog(
1746
- (gvc: GVC) => {
1747
- return html` <div
1740
+ if (isSelected && isSelected.id === pd.id) {
1741
+ return;
1742
+ }
1743
+ const titleFontColor =
1744
+ glitter.share.globalValue['theme_color.0.title'] ?? '#333333';
1745
+ gvc.glitter.innerDialog(
1746
+ (gvc: GVC) => {
1747
+ return html` <div
1748
1748
  class=" bg-white shadow ${document.body.clientWidth > 768
1749
- ? `rounded-3`
1750
- : ` position-absolute bottom-0`}"
1749
+ ? `rounded-3`
1750
+ : ` position-absolute bottom-0`}"
1751
1751
  style=" ${document.body.clientWidth > 768
1752
- ? `min-width: 400px; width: 1000px;max-height:calc(100% - 150px);overflow-y: auto;`
1753
- : 'width:calc(100vw);height:100%;'}"
1752
+ ? `min-width: 400px; width: 1000px;max-height:calc(100% - 150px);overflow-y: auto;`
1753
+ : 'width:calc(100vw);height:100%;'}"
1754
1754
  >
1755
1755
  <div
1756
1756
  class="bg-white shadow ${document.body.clientWidth >
1757
- 768
1758
- ? `rounded-3`
1759
- : `h-100`}"
1757
+ 768
1758
+ ? `rounded-3`
1759
+ : `h-100`}"
1760
1760
  style="width: 100%; position: relative;${document.body
1761
- .clientWidth > 768
1762
- ? ``
1763
- : `overflow-y: auto;`}"
1761
+ .clientWidth > 768
1762
+ ? ``
1763
+ : `overflow-y: auto;`}"
1764
1764
  >
1765
1765
  <div
1766
1766
  class="w-100 d-flex align-items-center p-3 border-bottom"
@@ -1777,110 +1777,110 @@ export class CheckoutIndex {
1777
1777
  class="fa-regular fa-circle-xmark fs-5 text-dark"
1778
1778
  style="cursor: pointer"
1779
1779
  onclick="${gvc.event(() => {
1780
- gvc.closeDialog();
1781
- })}"
1780
+ gvc.closeDialog();
1781
+ })}"
1782
1782
  ></i>
1783
1783
  </div>
1784
1784
  <div
1785
1785
  class="c_dialog_main"
1786
1786
  style="gap: 24px; max-height: calc(100% - 100px); ${document
1787
- .body.clientWidth < 800
1788
- ? `padding: 12px 20px;`
1789
- : `padding: 30px;`}"
1787
+ .body.clientWidth < 800
1788
+ ? `padding: 12px 20px;`
1789
+ : `padding: 30px;`}"
1790
1790
  >
1791
1791
  ${PdClass.selectSpec({
1792
- gvc,
1793
- titleFontColor:
1794
- glitter.share.globalValue[
1795
- 'theme_color.0.title'
1796
- ] ?? '#333333',
1797
- prod: pd,
1798
- vm: {
1799
- specs: pd.specs.map(
1800
- (spec: {
1801
- option: {
1802
- title: string;
1803
- }[];
1804
- }) => {
1805
- return spec.option[0].title;
1806
- }
1807
- ),
1808
- quantity: '1',
1809
- wishStatus: (glitter.share.wishList ?? []).some(
1810
- (item: { id: number }) => {
1811
- return item.id === dd.id;
1812
- }
1813
- ),
1814
- },
1815
- preview: true,
1816
- with_qty: false,
1817
- is_gift: true,
1818
- callback: () => {
1819
- console.log(`vm.cartData=>`, vm.cartData);
1820
- let find = vm.cartData.lineItems.find(
1821
- (d1: any) => {
1822
- return dd.add_on_products.find((d2: any) => {
1823
- return d2.id === d1.id;
1824
- });
1825
- }
1826
- );
1827
- console.log(`find=>`, find);
1828
- if (find) {
1829
- apiCart.setCart(cartItem => {
1830
- cartItem.line_items.map(dd => {
1831
- if (dd.id === find.id) {
1832
- dd.count--;
1833
- }
1834
- });
1835
- cartItem.line_items =
1836
- cartItem.line_items.filter(dd => {
1837
- return dd.count > 0;
1838
- });
1839
- refreshCartData();
1840
- gvc.closeDialog();
1841
- });
1842
- } else {
1843
- refreshCartData();
1844
- gvc.closeDialog();
1845
- }
1846
- },
1847
- })}
1792
+ gvc,
1793
+ titleFontColor:
1794
+ glitter.share.globalValue[
1795
+ 'theme_color.0.title'
1796
+ ] ?? '#333333',
1797
+ prod: pd,
1798
+ vm: {
1799
+ specs: pd.specs.map(
1800
+ (spec: {
1801
+ option: {
1802
+ title: string;
1803
+ }[];
1804
+ }) => {
1805
+ return spec.option[0].title;
1806
+ }
1807
+ ),
1808
+ quantity: '1',
1809
+ wishStatus: (glitter.share.wishList ?? []).some(
1810
+ (item: { id: number }) => {
1811
+ return item.id === dd.id;
1812
+ }
1813
+ ),
1814
+ },
1815
+ preview: true,
1816
+ with_qty: false,
1817
+ is_gift: true,
1818
+ callback: () => {
1819
+ console.log(`vm.cartData=>`, vm.cartData);
1820
+ let find = vm.cartData.lineItems.find(
1821
+ (d1: any) => {
1822
+ return dd.add_on_products.find((d2: any) => {
1823
+ return d2.id === d1.id;
1824
+ });
1825
+ }
1826
+ );
1827
+ console.log(`find=>`, find);
1828
+ if (find) {
1829
+ apiCart.setCart(cartItem => {
1830
+ cartItem.line_items.map(dd => {
1831
+ if (dd.id === find.id) {
1832
+ dd.count--;
1833
+ }
1834
+ });
1835
+ cartItem.line_items =
1836
+ cartItem.line_items.filter(dd => {
1837
+ return dd.count > 0;
1838
+ });
1839
+ refreshCartData();
1840
+ gvc.closeDialog();
1841
+ });
1842
+ } else {
1843
+ refreshCartData();
1844
+ gvc.closeDialog();
1845
+ }
1846
+ },
1847
+ })}
1848
1848
  <div class="d-sm-none" style="height:100px;"></div>
1849
1849
  </div>
1850
1850
  </div>
1851
1851
  </div>`;
1852
- },
1853
- Tool.randomString(7),
1854
- {
1855
- animation:
1856
- document.body.clientWidth < 768
1857
- ? Animation.popup
1858
- : Animation.fade,
1859
- }
1860
- );
1861
- })}"
1852
+ },
1853
+ Tool.randomString(7),
1854
+ {
1855
+ animation:
1856
+ document.body.clientWidth < 768
1857
+ ? Animation.popup
1858
+ : Animation.fade,
1859
+ }
1860
+ );
1861
+ })}"
1862
1862
  >
1863
1863
  <span class="${gClass('button-text')}"
1864
1864
  >${isSelected
1865
- ? isSelected.id === pd.id
1866
- ? Language.text('selected')
1867
- : Language.text('change_gift')
1868
- : Language.text('select_gift')}</span
1865
+ ? isSelected.id === pd.id
1866
+ ? Language.text('selected')
1867
+ : Language.text('change_gift')
1868
+ : Language.text('select_gift')}</span
1869
1869
  >
1870
1870
  </button>
1871
1871
  </div>
1872
1872
  </div>`;
1873
- } catch (e) {
1874
- console.error(`error 2 =>`, e);
1875
- }
1876
- })
1877
- .join('')}
1873
+ } catch (e) {
1874
+ console.error(`error 2 =>`, e);
1875
+ }
1876
+ })
1877
+ .join('')}
1878
1878
  </div>
1879
1879
  `;
1880
- })
1881
- .join('');
1882
- return giftHtml && `<div class="rounded-3 bg-white p-3 mt-3">${giftHtml}</div>`;
1883
- })()}
1880
+ })
1881
+ .join('');
1882
+ return giftHtml && `<div class="rounded-3 bg-white p-3 mt-3">${giftHtml}</div>`;
1883
+ })()}
1884
1884
  <!--配送資訊-->
1885
1885
  <div class="rounded-3 bg-white w-100 p-1 mt-3">
1886
1886
  ${html` <section>
@@ -1888,8 +1888,8 @@ export class CheckoutIndex {
1888
1888
  ${Language.text('payment_and_shipping_methods')}
1889
1889
  </div>
1890
1890
  ${vm.cartData.shipment_info
1891
- ? html` <div class="pt-2 mx-2 mx-sm-3">${vm.cartData.shipment_info}</div>`
1892
- : ''}
1891
+ ? html` <div class="pt-2 mx-2 mx-sm-3">${vm.cartData.shipment_info}</div>`
1892
+ : ''}
1893
1893
  <div class="row mt-3 mx-1 mx-sm-0 my-md-3">
1894
1894
  <div class="col-12 col-md-6 mb-2 mb-sm-0">
1895
1895
  <label class="${gClass('label')}">${Language.text('payment_method')}</label>
@@ -1897,118 +1897,118 @@ export class CheckoutIndex {
1897
1897
  <select
1898
1898
  class="w-100 ${gClass('select')}"
1899
1899
  onchange="${gvc.event(e => {
1900
- vm.cartData.customer_info.payment_select = e.value;
1901
- this.storeLocalData(vm.cartData);
1902
- refreshCartData();
1903
- })}"
1900
+ vm.cartData.customer_info.payment_select = e.value;
1901
+ this.storeLocalData(vm.cartData);
1902
+ refreshCartData();
1903
+ })}"
1904
1904
  >
1905
1905
  ${(() => {
1906
- return this.getPaymentMethod(vm.cartData)
1907
- .map((dd: { name: string; value: string }) => {
1908
- return html` <option
1906
+ return this.getPaymentMethod(vm.cartData)
1907
+ .map((dd: { name: string; value: string }) => {
1908
+ return html` <option
1909
1909
  value="${dd.value}"
1910
1910
  ${localStorage.getItem('checkout-payment') === dd.value
1911
- ? `selected`
1912
- : ``}
1911
+ ? `selected`
1912
+ : ``}
1913
1913
  >
1914
1914
  ${Language.getLanguageCustomText(dd.name) ||
1915
- Language.text(dd.value)}
1915
+ Language.text(dd.value)}
1916
1916
  </option>`;
1917
- })
1918
- .join('');
1919
- })()}
1917
+ })
1918
+ .join('');
1919
+ })()}
1920
1920
  </select>
1921
1921
  </div>
1922
1922
  </div>
1923
1923
  <div class="col-12 col-md-6 mb-2">
1924
1924
  <label class="${gClass('label')}">${Language.text('shipping_method')}</label>
1925
1925
  ${gvc.bindView({
1926
- bind: ids.shipping,
1927
- view: () => {
1928
- return html` <div>
1926
+ bind: ids.shipping,
1927
+ view: () => {
1928
+ return html` <div>
1929
1929
  <select
1930
1930
  class="w-100 ${gClass('select')}"
1931
1931
  onchange="${gvc.event(e => {
1932
- [
1933
- 'CVSStoreName',
1934
- 'MerchantTradeNo',
1935
- 'LogisticsSubType',
1936
- 'CVSStoreID',
1937
- 'CVSTelephone',
1938
- 'CVSOutSide',
1939
- 'ExtraData',
1940
- 'CVSAddress',
1941
- ].map(dd => {
1942
- gvc.glitter.setUrlParameter(dd);
1943
- });
1944
- vm.cartData.user_info.shipment = e.value;
1945
- this.storeLocalData(vm.cartData);
1946
- refreshCartData();
1947
- })}"
1932
+ [
1933
+ 'CVSStoreName',
1934
+ 'MerchantTradeNo',
1935
+ 'LogisticsSubType',
1936
+ 'CVSStoreID',
1937
+ 'CVSTelephone',
1938
+ 'CVSOutSide',
1939
+ 'ExtraData',
1940
+ 'CVSAddress',
1941
+ ].map(dd => {
1942
+ gvc.glitter.setUrlParameter(dd);
1943
+ });
1944
+ vm.cartData.user_info.shipment = e.value;
1945
+ this.storeLocalData(vm.cartData);
1946
+ refreshCartData();
1947
+ })}"
1948
1948
  >
1949
1949
  ${shipmentList.length > 0
1950
- ? shipmentList
1951
- .map((dd: { name: string; value: string }) => {
1952
- return html` <option
1950
+ ? shipmentList
1951
+ .map((dd: { name: string; value: string }) => {
1952
+ return html` <option
1953
1953
  value="${dd.value}"
1954
1954
  ${vm.cartData.user_info.shipment === dd.value
1955
- ? `selected`
1956
- : ``}
1955
+ ? `selected`
1956
+ : ``}
1957
1957
  >
1958
1958
  ${Language.text(`ship_${dd.value}`) ||
1959
- Language.getLanguageCustomText(dd.name)}
1959
+ Language.getLanguageCustomText(dd.name)}
1960
1960
  </option>`;
1961
- })
1962
- .join('')
1963
- : html` <option selected>(${Language.text('disable_ship')})</option>`}
1961
+ })
1962
+ .join('')
1963
+ : html` <option selected>(${Language.text('disable_ship')})</option>`}
1964
1964
  </select>
1965
1965
  </div>`;
1966
- },
1967
- })}
1966
+ },
1967
+ })}
1968
1968
  </div>
1969
1969
  <div class="col-12">
1970
1970
  ${gvc.bindView(() => {
1971
- return {
1972
- bind: gvc.glitter.getUUID(),
1973
- view: async () => {
1974
- const log_config = (
1975
- await ApiUser.getPublicConfig(
1976
- 'shipment_config_' + vm.cartData.user_info.shipment,
1977
- 'manager'
1978
- )
1979
- ).response.value;
1980
- if (log_config.content) {
1981
- return html` <label class="${gClass('label')}"
1971
+ return {
1972
+ bind: gvc.glitter.getUUID(),
1973
+ view: async () => {
1974
+ const log_config = (
1975
+ await ApiUser.getPublicConfig(
1976
+ 'shipment_config_' + vm.cartData.user_info.shipment,
1977
+ 'manager'
1978
+ )
1979
+ ).response.value;
1980
+ if (log_config.content) {
1981
+ return html` <label class="${gClass('label')}"
1982
1982
  >${Language.text('shipping_instructions')}</label
1983
1983
  >
1984
1984
  <div class="border rounded-3 p-2">${log_config.content}</div>`;
1985
- }
1986
- return ``;
1987
- },
1988
- };
1989
- })}
1985
+ }
1986
+ return ``;
1987
+ },
1988
+ };
1989
+ })}
1990
1990
  </div>
1991
1991
  <!-- 配送地址 -->
1992
1992
  ${(() => {
1993
- if (vm.cartData.user_info.shipment === 'none') {
1994
- return false;
1995
- }
1996
- const ship_method = this.getShipmentMethod(vm.cartData).find((dd: any) => {
1997
- return vm.cartData.user_info.shipment === dd.value;
1998
- });
1999
- if (ship_method && ship_method.system_form) {
2000
- return (ship_method.system_form ?? []).includes('tw-address-selector');
2001
- }
2002
- // ['normal', 'black_cat', 'black_cat_freezing', 'black_cat_ice'].includes(
2003
- // vm.cartData.user_info.shipment
2004
- // )
2005
- return ['normal', 'black_cat', 'black_cat_freezing', 'black_cat_ice'].includes(
2006
- vm.cartData.user_info.shipment
2007
- );
2008
- })()
2009
- ? gvc.bindView(() => {
2010
- const id = gvc.glitter.getUUID();
2011
- gvc.addStyle(`
1993
+ if (vm.cartData.user_info.shipment === 'none') {
1994
+ return false;
1995
+ }
1996
+ const ship_method = this.getShipmentMethod(vm.cartData).find((dd: any) => {
1997
+ return vm.cartData.user_info.shipment === dd.value;
1998
+ });
1999
+ if (ship_method && ship_method.system_form) {
2000
+ return (ship_method.system_form ?? []).includes('tw-address-selector');
2001
+ }
2002
+ // ['normal', 'black_cat', 'black_cat_freezing', 'black_cat_ice'].includes(
2003
+ // vm.cartData.user_info.shipment
2004
+ // )
2005
+ return ['normal', 'black_cat', 'black_cat_freezing', 'black_cat_ice'].includes(
2006
+ vm.cartData.user_info.shipment
2007
+ );
2008
+ })()
2009
+ ? gvc.bindView(() => {
2010
+ const id = gvc.glitter.getUUID();
2011
+ gvc.addStyle(`
2012
2012
  .city-selector select {
2013
2013
  -webkit-appearance: none;
2014
2014
  -moz-appearance: none;
@@ -2021,12 +2021,12 @@ export class CheckoutIndex {
2021
2021
  flex: 1;
2022
2022
  }
2023
2023
  `);
2024
- let select_id = '';
2025
- return {
2026
- bind: id,
2027
- view: () => {
2028
- select_id = gvc.glitter.getUUID();
2029
- return html`<label
2024
+ let select_id = '';
2025
+ return {
2026
+ bind: id,
2027
+ view: () => {
2028
+ select_id = gvc.glitter.getUUID();
2029
+ return html`<label
2030
2030
  class="${gClass('label')} w-100 d-flex align-items-center"
2031
2031
  >${Language.text('shipping_address')}
2032
2032
  <div class="flex-fill"></div>
@@ -2034,13 +2034,13 @@ export class CheckoutIndex {
2034
2034
  class="fs-sm fw-500 ${!GlobalUser.token ? `d-none` : ``}"
2035
2035
  style="cursor: pointer; color: #3366bb;"
2036
2036
  onclick="${gvc.event(() => {
2037
- ApiUser.getUserData(GlobalUser.token, 'me').then(res => {
2038
- vm.cartData.user_info.address =
2039
- res.response.userData.consignee_address;
2040
- this.storeLocalData(vm.cartData);
2041
- gvc.notifyDataChange(id);
2042
- });
2043
- })}"
2037
+ ApiUser.getUserData(GlobalUser.token, 'me').then(res => {
2038
+ vm.cartData.user_info.address =
2039
+ res.response.userData.consignee_address;
2040
+ this.storeLocalData(vm.cartData);
2041
+ gvc.notifyDataChange(id);
2042
+ });
2043
+ })}"
2044
2044
  >
2045
2045
  ${Language.text('quick_input')}
2046
2046
  </div>
@@ -2061,211 +2061,211 @@ export class CheckoutIndex {
2061
2061
  placeholder="${Language.text('please_enter_street_location')}"
2062
2062
  value="${vm.cartData.user_info.address || ''}"
2063
2063
  onchange="${gvc.event(e => {
2064
- vm.cartData.user_info.address = e.value;
2065
- this.storeLocalData(vm.cartData);
2066
- })}"
2064
+ vm.cartData.user_info.address = e.value;
2065
+ this.storeLocalData(vm.cartData);
2066
+ })}"
2067
2067
  />
2068
2068
  </div>
2069
2069
  </div> `;
2070
- },
2071
- divCreate: {
2072
- class: `col-12 mb-2`,
2073
- },
2074
- onCreate: () => {
2075
- gvc.glitter.addMtScript(
2076
- [
2077
- {
2078
- src: 'https://cdn.jsdelivr.net/npm/tw-city-selector@2.1.1/dist/tw-city-selector.min.js',
2079
- },
2080
- ],
2081
- () => {
2082
- //@ts-ignore
2083
- const tw_selector = new TwCitySelector({
2084
- el: `.d_${select_id}`,
2085
- });
2086
- const interVal = setInterval(() => {
2087
- if (document.querySelector(`#select_id_${id} .county`) as any) {
2088
- clearInterval(interVal);
2089
- (
2090
- document.querySelector(`#select_id_${id} .county`) as any
2091
- ).addEventListener('change', (event: any) => {
2092
- // 獲取當前選中的值
2093
- const selectedValue = event.target.value;
2094
- // 在控制台輸出當前選中的值
2095
- console.log(`選中的值是: ${selectedValue}`);
2096
- // 根據選中的值執行其他操作
2097
- vm.cartData.user_info.city = selectedValue;
2098
- vm.cartData.user_info.area = undefined;
2099
- this.storeLocalData(vm.cartData);
2100
- });
2101
- (
2102
- document.querySelector(`#select_id_${id} .district`) as any
2103
- ).addEventListener('change', (event: any) => {
2104
- // 獲取當前選中的值
2105
- const selectedValue = event.target.value;
2106
-
2107
- // 在控制台輸出當前選中的值
2108
- console.log(`選中的值是: ${selectedValue}`);
2109
-
2110
- // 根據選中的值執行其他操作
2111
- vm.cartData.user_info.area = selectedValue;
2112
- this.storeLocalData(vm.cartData);
2113
- });
2114
-
2115
- if (vm.cartData.user_info.city && vm.cartData.user_info.area) {
2116
- tw_selector.setValue(
2117
- vm.cartData.user_info.city,
2118
- vm.cartData.user_info.area
2119
- );
2120
- } else if (vm.cartData.user_info.city) {
2121
- tw_selector.setValue(vm.cartData.user_info.city);
2122
- }
2123
- }
2124
- glitter.share.tw_selector = tw_selector;
2125
- }, 100);
2126
- },
2127
- () => {}
2128
- );
2129
- },
2130
- };
2131
- })
2132
- : ``}
2070
+ },
2071
+ divCreate: {
2072
+ class: `col-12 mb-2`,
2073
+ },
2074
+ onCreate: () => {
2075
+ gvc.glitter.addMtScript(
2076
+ [
2077
+ {
2078
+ src: 'https://cdn.jsdelivr.net/npm/tw-city-selector@2.1.1/dist/tw-city-selector.min.js',
2079
+ },
2080
+ ],
2081
+ () => {
2082
+ //@ts-ignore
2083
+ const tw_selector = new TwCitySelector({
2084
+ el: `.d_${select_id}`,
2085
+ });
2086
+ const interVal = setInterval(() => {
2087
+ if (document.querySelector(`#select_id_${id} .county`) as any) {
2088
+ clearInterval(interVal);
2089
+ (
2090
+ document.querySelector(`#select_id_${id} .county`) as any
2091
+ ).addEventListener('change', (event: any) => {
2092
+ // 獲取當前選中的值
2093
+ const selectedValue = event.target.value;
2094
+ // 在控制台輸出當前選中的值
2095
+ console.log(`選中的值是: ${selectedValue}`);
2096
+ // 根據選中的值執行其他操作
2097
+ vm.cartData.user_info.city = selectedValue;
2098
+ vm.cartData.user_info.area = undefined;
2099
+ this.storeLocalData(vm.cartData);
2100
+ });
2101
+ (
2102
+ document.querySelector(`#select_id_${id} .district`) as any
2103
+ ).addEventListener('change', (event: any) => {
2104
+ // 獲取當前選中的值
2105
+ const selectedValue = event.target.value;
2106
+
2107
+ // 在控制台輸出當前選中的值
2108
+ console.log(`選中的值是: ${selectedValue}`);
2109
+
2110
+ // 根據選中的值執行其他操作
2111
+ vm.cartData.user_info.area = selectedValue;
2112
+ this.storeLocalData(vm.cartData);
2113
+ });
2114
+
2115
+ if (vm.cartData.user_info.city && vm.cartData.user_info.area) {
2116
+ tw_selector.setValue(
2117
+ vm.cartData.user_info.city,
2118
+ vm.cartData.user_info.area
2119
+ );
2120
+ } else if (vm.cartData.user_info.city) {
2121
+ tw_selector.setValue(vm.cartData.user_info.city);
2122
+ }
2123
+ }
2124
+ glitter.share.tw_selector = tw_selector;
2125
+ }, 100);
2126
+ },
2127
+ () => {}
2128
+ );
2129
+ },
2130
+ };
2131
+ })
2132
+ : ``}
2133
2133
  <!-- 選取超商 -->
2134
2134
  ${ShipmentConfig.supermarketList.includes(vm.cartData.user_info.shipment)
2135
- ? html` <div class="col-12">
2135
+ ? html` <div class="col-12">
2136
2136
  <button
2137
2137
  class="${gClass('button-bgr')}"
2138
2138
  onclick="${gvc.event(() => {
2139
- ApiDelivery.storeMaps({
2140
- returnURL: (()=>{
2141
- if(ApplicationConfig.device_type==='ios'){
2142
- const url=new URL(location.href);
2143
- url.searchParams.set("select_map_finish","true");
2144
- return url.href;
2145
- }else{
2146
- return location.href;
2147
- }
2148
- })(),
2149
- logistics: vm.cartData.user_info.shipment,
2150
- }).then(async res => {
2151
- if (ApplicationConfig.device_type === 'ios') {
2152
- glitter.runJsInterFace(
2153
- 'post_form',
2154
- {
2155
- form: res.response.form,
2156
- },
2157
- () => {}
2158
- );
2159
- } else {
2160
- const form_id = gvc.glitter.getUUID();
2161
- $('body').append(`<div id="${form_id}">${res.response.form}</div>`);
2162
- (document.querySelector(`#${form_id} #submit`) as any).click();
2163
- }
2164
- });
2165
- })}"
2139
+ ApiDelivery.storeMaps({
2140
+ returnURL: (()=>{
2141
+ if(ApplicationConfig.device_type==='ios'){
2142
+ const url=new URL(location.href);
2143
+ url.searchParams.set("select_map_finish","true");
2144
+ return url.href;
2145
+ }else{
2146
+ return location.href;
2147
+ }
2148
+ })(),
2149
+ logistics: vm.cartData.user_info.shipment,
2150
+ }).then(async res => {
2151
+ if (ApplicationConfig.device_type === 'ios') {
2152
+ glitter.runJsInterFace(
2153
+ 'post_form',
2154
+ {
2155
+ form: res.response.form,
2156
+ },
2157
+ () => {}
2158
+ );
2159
+ } else {
2160
+ const form_id = gvc.glitter.getUUID();
2161
+ $('body').append(`<div id="${form_id}">${res.response.form}</div>`);
2162
+ (document.querySelector(`#${form_id} #submit`) as any).click();
2163
+ }
2164
+ });
2165
+ })}"
2166
2166
  >
2167
2167
  <span class="${gClass('button-text')}"
2168
2168
  >${(() => {
2169
- let cvs = glitter.getUrlParameter('CVSStoreName') || '';
2170
- if (decodeURIComponent(cvs)) {
2171
- return `${decodeURIComponent(cvs)} 『 ${Language.text('click_to_reselct_store')} 』`;
2172
- } else {
2173
- return Language.text('select_pickup_store');
2174
- }
2175
- })()}</span
2169
+ let cvs = glitter.getUrlParameter('CVSStoreName') || '';
2170
+ if (decodeURIComponent(cvs)) {
2171
+ return `${decodeURIComponent(cvs)} 『 ${Language.text('click_to_reselct_store')} 』`;
2172
+ } else {
2173
+ return Language.text('select_pickup_store');
2174
+ }
2175
+ })()}</span
2176
2176
  >
2177
2177
  </button>
2178
2178
  </div>`
2179
- : ''}
2179
+ : ''}
2180
2180
  ${(() => {
2181
- if (vm.cartData.user_info.shipment === 'none') {
2182
- return false;
2181
+ if (vm.cartData.user_info.shipment === 'none') {
2182
+ return false;
2183
+ }
2184
+ const ship_method = this.getShipmentMethod(vm.cartData).find((dd: any) => {
2185
+ return vm.cartData.user_info.shipment === dd.value;
2186
+ });
2187
+ if (ship_method && ship_method.system_form) {
2188
+ return (ship_method.system_form ?? []).includes('global-address-selector');
2189
+ }
2190
+ // ['normal', 'black_cat', 'black_cat_freezing', 'black_cat_ice'].includes(
2191
+ // vm.cartData.user_info.shipment
2192
+ // )
2193
+ return ['global_express'].includes(vm.cartData.user_info.shipment);
2194
+ })()
2195
+ ? [
2196
+ html`<label class="${gClass('label')}">${Language.text('country')}</label>
2197
+ ${gvc.bindView(() => {
2198
+ const id = gvc.glitter.getUUID();
2199
+ return {
2200
+ bind: id,
2201
+ view: async () => {
2202
+ let country_select: any = [];
2203
+ const support_country = (
2204
+ await ApiUser.getPublicConfig('global_express_country', 'manager')
2205
+ ).response.value.country;
2206
+ await new Promise((resolve, reject) => {
2207
+ glitter.getModule(
2208
+ (() => {
2209
+ switch (Language.getLanguage()) {
2210
+ case 'en-US':
2211
+ return `${gvc.glitter.root_path}/modules/country-language/country-en.js`;
2212
+ case 'zh-CN':
2213
+ return `${gvc.glitter.root_path}/modules/country-language/country-zh.js`;
2214
+ default:
2215
+ return `${gvc.glitter.root_path}/modules/country-language/country-tw.js`;
2183
2216
  }
2184
- const ship_method = this.getShipmentMethod(vm.cartData).find((dd: any) => {
2185
- return vm.cartData.user_info.shipment === dd.value;
2217
+ })(),
2218
+ response => {
2219
+ country_select = response.filter((dd: any) => {
2220
+ return support_country.includes(dd.countryCode);
2186
2221
  });
2187
- if (ship_method && ship_method.system_form) {
2188
- return (ship_method.system_form ?? []).includes('global-address-selector');
2189
- }
2190
- // ['normal', 'black_cat', 'black_cat_freezing', 'black_cat_ice'].includes(
2191
- // vm.cartData.user_info.shipment
2192
- // )
2193
- return ['global_express'].includes(vm.cartData.user_info.shipment);
2194
- })()
2195
- ? [
2196
- html`<label class="${gClass('label')}">${Language.text('country')}</label>
2197
- ${gvc.bindView(() => {
2198
- const id = gvc.glitter.getUUID();
2199
- return {
2200
- bind: id,
2201
- view: async () => {
2202
- let country_select: any = [];
2203
- const support_country = (
2204
- await ApiUser.getPublicConfig('global_express_country', 'manager')
2205
- ).response.value.country;
2206
- await new Promise((resolve, reject) => {
2207
- glitter.getModule(
2208
- (() => {
2209
- switch (Language.getLanguage()) {
2210
- case 'en-US':
2211
- return `${gvc.glitter.root_path}/modules/country-language/country-en.js`;
2212
- case 'zh-CN':
2213
- return `${gvc.glitter.root_path}/modules/country-language/country-zh.js`;
2214
- default:
2215
- return `${gvc.glitter.root_path}/modules/country-language/country-tw.js`;
2216
- }
2217
- })(),
2218
- response => {
2219
- country_select = response.filter((dd: any) => {
2220
- return support_country.includes(dd.countryCode);
2221
- });
2222
- resolve(true);
2223
- }
2224
- );
2225
- });
2226
- return html`<select
2222
+ resolve(true);
2223
+ }
2224
+ );
2225
+ });
2226
+ return html`<select
2227
2227
  class="w-100 ${gClass('select')}"
2228
2228
  onchange="${gvc.event((e, event) => {
2229
- vm.cartData.user_info.country = e.value;
2230
- this.storeLocalData(vm.cartData);
2231
- refreshCartData();
2232
- })}"
2229
+ vm.cartData.user_info.country = e.value;
2230
+ this.storeLocalData(vm.cartData);
2231
+ refreshCartData();
2232
+ })}"
2233
2233
  >
2234
2234
  ${(() => {
2235
- let map = country_select.map(
2236
- (dd: { countryCode: string; countryName: string }) => {
2237
- return html`
2235
+ let map = country_select.map(
2236
+ (dd: { countryCode: string; countryName: string }) => {
2237
+ return html`
2238
2238
  <option
2239
2239
  value="${dd.countryCode}"
2240
2240
  ${vm.cartData.user_info.country === dd.countryCode
2241
- ? `selected`
2242
- : ``}
2241
+ ? `selected`
2242
+ : ``}
2243
2243
  >
2244
2244
  ${dd.countryName}
2245
2245
  </option>
2246
2246
  `;
2247
- }
2248
- );
2249
- if (
2250
- !country_select.find((dd: any) => {
2251
- return dd.countryCode === vm.cartData.user_info.country;
2252
- })
2253
- ) {
2254
- delete vm.cartData.user_info.country;
2255
- map.push(
2256
- html` <option class="d-none" selected>
2247
+ }
2248
+ );
2249
+ if (
2250
+ !country_select.find((dd: any) => {
2251
+ return dd.countryCode === vm.cartData.user_info.country;
2252
+ })
2253
+ ) {
2254
+ delete vm.cartData.user_info.country;
2255
+ map.push(
2256
+ html` <option class="d-none" selected>
2257
2257
  ${Language.text('select_country')}
2258
2258
  </option>`
2259
- );
2260
- }
2261
- return map.join('');
2262
- })()}
2259
+ );
2260
+ }
2261
+ return map.join('');
2262
+ })()}
2263
2263
  </select>`;
2264
- },
2265
- divCreate: {},
2266
- };
2267
- })}`,
2268
- html` <label class="${gClass('label')}"
2264
+ },
2265
+ divCreate: {},
2266
+ };
2267
+ })}`,
2268
+ html` <label class="${gClass('label')}"
2269
2269
  >${Language.text('shipping_address')}</label
2270
2270
  >
2271
2271
  <input
@@ -2274,22 +2274,22 @@ export class CheckoutIndex {
2274
2274
  placeholder="${Language.text('please_enter_delivery_address')}"
2275
2275
  value="${vm.cartData.user_info.address || ''}"
2276
2276
  onchange="${gvc.event(e => {
2277
- vm.cartData.user_info.address = e.value;
2278
- this.storeLocalData(vm.cartData);
2279
- })}"
2277
+ vm.cartData.user_info.address = e.value;
2278
+ this.storeLocalData(vm.cartData);
2279
+ })}"
2280
2280
  />`,
2281
- html` <label class="${gClass('label')}">${Language.text('city')}</label>
2281
+ html` <label class="${gClass('label')}">${Language.text('city')}</label>
2282
2282
  <input
2283
2283
  class="${gClass('input')}"
2284
2284
  type="city"
2285
2285
  placeholder="${Language.text('city')}"
2286
2286
  value="${vm.cartData.user_info.city || ''}"
2287
2287
  onchange="${gvc.event(e => {
2288
- vm.cartData.user_info.city = e.value;
2289
- this.storeLocalData(vm.cartData);
2290
- })}"
2288
+ vm.cartData.user_info.city = e.value;
2289
+ this.storeLocalData(vm.cartData);
2290
+ })}"
2291
2291
  />`,
2292
- html` <label class="${gClass('label')}">${Language.text('state')}</label>
2292
+ html` <label class="${gClass('label')}">${Language.text('state')}</label>
2293
2293
  <input
2294
2294
  class="${gClass('input')}"
2295
2295
  class="${gClass('input')}"
@@ -2297,11 +2297,11 @@ export class CheckoutIndex {
2297
2297
  placeholder="${Language.text('state')}"
2298
2298
  value="${vm.cartData.user_info.state || ''}"
2299
2299
  onchange="${gvc.event(e => {
2300
- vm.cartData.user_info.state = e.value;
2301
- this.storeLocalData(vm.cartData);
2302
- })}"
2300
+ vm.cartData.user_info.state = e.value;
2301
+ this.storeLocalData(vm.cartData);
2302
+ })}"
2303
2303
  />`,
2304
- html` <label class="${gClass('label')}"
2304
+ html` <label class="${gClass('label')}"
2305
2305
  >${Language.text('postal_code')}</label
2306
2306
  >
2307
2307
  <input
@@ -2310,46 +2310,46 @@ export class CheckoutIndex {
2310
2310
  placeholder="${Language.text('postal_code')}"
2311
2311
  value="${vm.cartData.user_info.postal_code || ''}"
2312
2312
  onchange="${gvc.event(e => {
2313
- vm.cartData.user_info.postal_code = e.value;
2314
- this.storeLocalData(vm.cartData);
2315
- })}"
2313
+ vm.cartData.user_info.postal_code = e.value;
2314
+ this.storeLocalData(vm.cartData);
2315
+ })}"
2316
2316
  />`,
2317
- ]
2318
- .map(dd => {
2319
- return html` <div class="col-12 col-md-6 mb-2">${dd}</div>`;
2320
- })
2321
- .join('')
2322
- : ''}
2317
+ ]
2318
+ .map(dd => {
2319
+ return html` <div class="col-12 col-md-6 mb-2">${dd}</div>`;
2320
+ })
2321
+ .join('')
2322
+ : ''}
2323
2323
  ${(() => {
2324
- try {
2325
- vm.cartData.user_info.custom_form_delivery =
2326
- vm.cartData.user_info.custom_form_delivery ?? {};
2327
- const formData = this.getShipmentMethod(vm.cartData).find((dd: any) => {
2328
- return vm.cartData.user_info.shipment === dd.value;
2329
- }).form;
2330
-
2331
- if (!formData) {
2332
- return '';
2333
- }
2334
- const form_array = JSON.parse(JSON.stringify(formData));
2335
- form_array.map((dd: any) => {
2336
- return formatterFormElement(dd);
2337
- });
2338
- return [
2339
- FormWidget.editorView({
2340
- gvc: gvc,
2341
- array: form_array,
2342
- refresh: () => {
2343
- this.storeLocalData(vm.cartData);
2344
- },
2345
- formData: vm.cartData.user_info.custom_form_delivery,
2346
- }),
2347
- ].join('');
2348
- } catch (e) {
2349
- console.error(`error 3 =>`, e);
2350
- return ``;
2351
- }
2352
- })()}
2324
+ try {
2325
+ vm.cartData.user_info.custom_form_delivery =
2326
+ vm.cartData.user_info.custom_form_delivery ?? {};
2327
+ const formData = this.getShipmentMethod(vm.cartData).find((dd: any) => {
2328
+ return vm.cartData.user_info.shipment === dd.value;
2329
+ }).form;
2330
+
2331
+ if (!formData) {
2332
+ return '';
2333
+ }
2334
+ const form_array = JSON.parse(JSON.stringify(formData));
2335
+ form_array.map((dd: any) => {
2336
+ return formatterFormElement(dd);
2337
+ });
2338
+ return [
2339
+ FormWidget.editorView({
2340
+ gvc: gvc,
2341
+ array: form_array,
2342
+ refresh: () => {
2343
+ this.storeLocalData(vm.cartData);
2344
+ },
2345
+ formData: vm.cartData.user_info.custom_form_delivery,
2346
+ }),
2347
+ ].join('');
2348
+ } catch (e) {
2349
+ console.error(`error 3 =>`, e);
2350
+ return ``;
2351
+ }
2352
+ })()}
2353
2353
  </div>
2354
2354
  </section>`}
2355
2355
  </div>
@@ -2362,614 +2362,85 @@ export class CheckoutIndex {
2362
2362
  class="fs-sm fw-500 ${!GlobalUser.token ? `d-none` : ``}"
2363
2363
  style="cursor: pointer; color: #3366bb;"
2364
2364
  onclick="${gvc.event(() => {
2365
- ApiUser.getUserData(GlobalUser.token, 'me').then(res => {
2366
- console.log(`res.response.userData=>`, res.response.userData);
2367
- ['name', 'phone', 'email'].map(dd => {
2368
- vm.cartData.customer_info[dd] =
2369
- res.response.userData[dd] || vm.cartData.customer_info[dd];
2370
- });
2371
- this.storeLocalData(vm.cartData);
2372
- gvc.notifyDataChange('customer-info');
2373
- });
2374
- })}"
2375
- >
2376
- ${Language.text('quick_input')}
2377
- </div>
2378
- </div>
2379
- ${gvc.bindView(() => {
2380
- const id = 'customer-info';
2381
- const vm_info: {
2382
- loading: boolean;
2383
- list: any[];
2384
- } = {
2385
- loading: true,
2386
- list: [],
2387
- };
2388
- vm_info.list = widget.share.custom_form_checkout;
2389
- return {
2390
- bind: id,
2391
- view: () => {
2392
- return new Promise(async (resolve, reject) => {
2393
- vm_info.list = widget.share.custom_form_checkout;
2394
- resolve(
2395
- [
2396
- html` <div class="row m-0 mt-3 mb-2">
2397
- ${[
2398
- {
2399
- name: Language.text('name'),
2400
- key: 'name',
2401
- },
2402
- {
2403
- name: Language.text('contact_number'),
2404
- key: 'phone',
2405
- },
2406
- {
2407
- name: Language.text('email'),
2408
- key: 'email',
2409
- },
2410
- ]
2411
- .filter(dd => {
2412
- return vm_info.list.find(d1 => {
2413
- return d1.key === dd.key && `${d1.hidden}` !== 'true';
2414
- });
2415
- })
2416
- .map(dd => {
2417
- return html` <div class="col-12 col-md-4 mb-2">
2418
- <label class="${gClass('label')}">${dd.name}</label>
2419
- <input
2420
- class="${gClass('input')}"
2421
- type="${dd.key}"
2422
- value="${vm.cartData.customer_info[dd.key] || ''}"
2423
- onchange="${gvc.event((e, event) => {
2424
- vm.cartData.customer_info[dd.key] = e.value;
2425
- this.storeLocalData(vm.cartData);
2426
- })}"
2427
- />
2428
- </div>`;
2429
- })
2430
- .join('')}
2431
- </div>`,
2432
- gvc.bindView(() => {
2433
- const id = gvc.glitter.getUUID();
2434
- return {
2435
- bind: id,
2436
- view: () => {
2437
- const form_array = JSON.parse(JSON.stringify(vm_info.list));
2438
- form_array.map((dd: any) => {
2439
- dd.col = '4';
2440
- dd.form_config.title_style = {
2441
- list: [
2442
- {
2443
- class: gClass('label') + ' mb-2',
2444
- style:
2445
- 'return `color:${glitter.share.globalValue[`theme_color.0.title`]} !important;font-size:16px !important;`',
2446
- stylist: [],
2447
- dataType: 'code',
2448
- style_from: 'code',
2449
- classDataType: 'static',
2450
- },
2451
- ],
2452
- class: 'form-label',
2453
- style:
2454
- 'font-size: 20px;font-style: normal;font-weight: 400;line-height: 140%; color:#393939 !important;',
2455
- stylist: [],
2456
- version: 'v2',
2457
- dataType: 'static',
2458
- style_from: 'code',
2459
- classDataType: 'static',
2460
- };
2461
- dd.form_config.input_style = {
2462
- list: [
2463
- {
2464
- class: gClass('input'),
2465
- style:
2466
- 'return `border-radius: ${widget.formData.radius}px !important;`',
2467
- stylist: [],
2468
- dataType: 'code',
2469
- style_from: 'code',
2470
- classDataType: 'static',
2471
- },
2472
- ],
2473
- class: ' mb-3',
2474
- style: 'background: #FFF;',
2475
- stylist: [],
2476
- version: 'v2',
2477
- dataType: 'static',
2478
- style_from: 'code',
2479
- classDataType: 'static',
2480
- };
2481
- });
2482
- return [
2483
- FormWidget.editorView({
2484
- gvc: gvc,
2485
- array: form_array.filter((dd: any) => {
2486
- return !['name', 'email', 'phone'].includes(dd.key);
2487
- }),
2488
- refresh: () => {
2489
- this.storeLocalData(vm.cartData);
2490
- },
2491
- formData: vm.cartData.custom_form_data,
2492
- }),
2493
- ].join('');
2494
- },
2495
- divCreate: {
2496
- class: `w-100 `,
2497
- },
2498
- };
2499
- }),
2500
- ].join('')
2501
- );
2502
- });
2503
- },
2504
- };
2505
- })}
2506
- </div>
2507
- <!--收件人資料-->
2508
- <div class="rounded-3 bg-white w-100 p-1 mt-3">
2509
- <div class="${gClass('banner-text')} px-3 pt-3 d-flex align-items-center">
2510
- ${Language.text('recipient_info')}
2511
- <div class="flex-fill"></div>
2512
- <div
2513
- class="fs-sm fw-500 ${!GlobalUser.token ? `d-none` : ``}"
2514
- style="cursor: pointer; color: #3366bb;"
2515
- onclick="${gvc.event(() => {
2516
- ApiUser.getUserData(GlobalUser.token, 'me').then(res => {
2517
- console.log(`res.response.userData=>`, res.response.userData);
2518
- ['name', 'phone', 'email'].map(dd => {
2519
- vm.cartData.user_info[dd] =
2520
- res.response.userData[dd] || vm.cartData.user_info[dd];
2521
- });
2522
-
2523
- [
2524
- {
2525
- key: 'carrier_num',
2526
- refer: res.response.userData['carrier_number'],
2527
- },
2528
- {
2529
- key: 'gui_number',
2530
- refer: res.response.userData['gui_number'],
2531
- },
2532
- {
2533
- key: 'send_type',
2534
- refer:
2535
- res.response.userData['gui_number'] ||
2536
- !res.response.userData['carrier_number']
2537
- ? 'email'
2538
- : 'carrier_num',
2539
- },
2540
- {
2541
- key: 'invoice_type',
2542
- refer: res.response.userData['gui_number'] ? 'company' : 'me',
2543
- },
2544
- {
2545
- key: 'company',
2546
- refer: res.response.userData['company'],
2547
- },
2548
- ].map(dd => {
2549
- vm.cartData.user_info[dd.key] = dd.refer || vm.cartData.user_info[dd.key];
2550
- });
2551
-
2552
- this.storeLocalData(vm.cartData);
2553
- gvc.notifyDataChange('invoice_place');
2554
- });
2555
- })}"
2365
+ ApiUser.getUserData(GlobalUser.token, 'me').then(res => {
2366
+ console.log(`res.response.userData=>`, res.response.userData);
2367
+ ['name', 'phone', 'email'].map(dd => {
2368
+ vm.cartData.customer_info[dd] =
2369
+ res.response.userData[dd] || vm.cartData.customer_info[dd];
2370
+ });
2371
+ this.storeLocalData(vm.cartData);
2372
+ gvc.notifyDataChange('customer-info');
2373
+ });
2374
+ })}"
2556
2375
  >
2557
2376
  ${Language.text('quick_input')}
2558
2377
  </div>
2559
2378
  </div>
2560
- ${gvc.bindView(() => {
2561
- const id = 'invoice_place';
2562
- const vm_info: {
2563
- loading: boolean;
2564
- list: any[];
2565
- } = {
2566
- loading: true,
2567
- list: [],
2568
- };
2569
- //nouse
2570
- let method = widget.share.invoice_method || '';
2571
- if (widget.share.invoice_method) {
2572
- vm_info.loading = false;
2573
- gvc.notifyDataChange(id);
2574
- } else {
2575
- ApiShop.getInvoiceType().then((res: any) => {
2576
- method = res.response.method;
2577
- vm_info.loading = false;
2578
- widget.share.invoice_method = method;
2579
- gvc.notifyDataChange(id);
2580
- });
2581
- }
2582
- const checkbox = this.getCheckedClass(gvc, '#393939');
2583
- return {
2584
- bind: id,
2585
- view: async () => {
2586
- try {
2587
- if (vm_info.loading) {
2588
- return ``;
2589
- }
2590
- const receipt_form = JSON.parse(
2591
- JSON.stringify(widget.share.receipt_form)
2592
- ).map((dd: any) => {
2593
- switch (dd.key) {
2594
- case 'name':
2595
- dd.form_config.place_holder = Language.text('please_enter_name');
2596
- dd.title = Language.text('name');
2597
- break;
2598
- case 'phone':
2599
- dd.form_config.place_holder =
2600
- Language.text('please_enter_contact_number');
2601
- dd.title = Language.text('contact_number');
2602
- break;
2603
- case 'email':
2604
- dd.form_config.place_holder = Language.text('please_enter_email');
2605
- dd.title = Language.text('email');
2606
- break;
2607
- }
2608
- dd.col = '4';
2609
- return dd;
2610
- });
2611
- vm_info.list = [
2612
- ...receipt_form,
2613
- ...(method === 'nouse'
2614
- ? []
2615
- : [
2616
- {
2617
- col: '6',
2618
- key: 'invoice_type',
2619
- page: 'form-select',
2620
- type: 'form_plugin_v2',
2621
- group: '',
2622
- title: Language.text('invoice_recipient'),
2623
- col_sm: '12',
2624
- appName: 'cms_system',
2625
- require: 'true',
2626
- readonly: 'write',
2627
- formFormat: '{}',
2628
- moduleName: '下拉選單',
2629
- style_data: {
2630
- input: {
2631
- list: [],
2632
- class: '',
2633
- style: '',
2634
- version: 'v2',
2635
- },
2636
- label: {
2637
- list: [],
2638
- class: 'form-label fs-base ',
2639
- style: '',
2640
- version: 'v2',
2641
- },
2642
- container: {
2643
- list: [],
2644
- class: '',
2645
- style: '',
2646
- version: 'v2',
2647
- },
2648
- },
2649
- form_config: {
2650
- type: 'name',
2651
- title: '',
2652
- option: [
2653
- {
2654
- name: Language.text('personal'),
2655
- index: 0,
2656
- value: 'me',
2657
- },
2658
- {
2659
- name: Language.text('company'),
2660
- index: 1,
2661
- value: 'company',
2662
- },
2663
- {
2664
- name: Language.text('donate_invoice'),
2665
- index: 2,
2666
- value: 'donate',
2667
- },
2668
- ],
2669
- input_style: { list: [], version: 'v2' },
2670
- title_style: { list: [], version: 'v2' },
2671
- place_holder: '',
2672
- },
2673
- hidden_code: "return (form_data['invoice_method']==='nouse')",
2674
- },
2675
- {
2676
- col: '6',
2677
- key: 'send_type',
2678
- page: 'form-select',
2679
- type: 'form_plugin_v2',
2680
- group: '',
2681
- title: Language.text('invoice_method'),
2682
- col_sm: '12',
2683
- appName: 'cms_system',
2684
- require: 'true',
2685
- readonly: 'write',
2686
- formFormat: '{}',
2687
- moduleName: '下拉選單',
2688
- style_data: {
2689
- input: {
2690
- list: [],
2691
- class: '',
2692
- style: '',
2693
- version: 'v2',
2694
- },
2695
- label: {
2696
- list: [],
2697
- class: 'form-label fs-base ',
2698
- style: '',
2699
- version: 'v2',
2700
- },
2701
- container: {
2702
- list: [],
2703
- class: '',
2704
- style: '',
2705
- version: 'v2',
2706
- },
2707
- },
2708
- form_config: {
2709
- type: 'name',
2710
- title: '',
2711
- option: [
2712
- {
2713
- name: Language.text('send_to_user_email'),
2714
- index: 0,
2715
- value: 'email',
2716
- },
2717
- {
2718
- name: Language.text('mobile_barcode_device'),
2719
- index: 1,
2720
- value: 'carrier',
2721
- },
2722
- ],
2723
- input_style: { list: [], version: 'v2' },
2724
- title_style: { list: [], version: 'v2' },
2725
- place_holder: '',
2726
- },
2727
- hidden_code:
2728
- " 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 }",
2729
- },
2730
- {
2731
- key: 'carrier_num',
2732
- page: 'input',
2733
- type: 'form_plugin_v2',
2734
- group: '',
2735
- title: Language.text('carrier_number'),
2736
- appName: 'cms_system',
2737
- require: 'false',
2738
- readonly: 'write',
2739
- formFormat: '{}',
2740
- moduleName: '輸入框',
2741
- col: '3',
2742
- col_sm: '12',
2743
- style_data: {
2744
- input: {
2745
- list: [],
2746
- class: '',
2747
- style: '',
2748
- version: 'v2',
2749
- },
2750
- label: {
2751
- list: [],
2752
- class: 'form-label fs-base ',
2753
- style: '',
2754
- version: 'v2',
2755
- },
2756
- container: {
2757
- list: [],
2758
- class: '',
2759
- style: '',
2760
- version: 'v2',
2761
- },
2762
- },
2763
- form_config: {
2764
- type: 'name',
2765
- title: '',
2766
- input_style: { list: [], version: 'v2' },
2767
- title_style: { list: [], version: 'v2' },
2768
- place_holder: Language.text('please_enter_carrier_number'),
2769
- },
2770
- hidden_code:
2771
- " \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 }",
2772
- },
2773
- {
2774
- key: 'company',
2775
- page: 'input',
2776
- type: 'form_plugin_v2',
2777
- group: '',
2778
- title: Language.text('company_name'),
2779
- appName: 'cms_system',
2780
- require: 'false',
2781
- readonly: 'write',
2782
- formFormat: '{}',
2783
- moduleName: '輸入框',
2784
- col: '3',
2785
- col_sm: '12',
2786
- style_data: {
2787
- input: {
2788
- list: [],
2789
- class: '',
2790
- style: '',
2791
- version: 'v2',
2792
- },
2793
- label: {
2794
- list: [],
2795
- class: 'form-label fs-base ',
2796
- style: '',
2797
- version: 'v2',
2798
- },
2799
- container: {
2800
- list: [],
2801
- class: '',
2802
- style: '',
2803
- version: 'v2',
2804
- },
2805
- },
2806
- form_config: {
2807
- type: 'name',
2808
- title: '',
2809
- input_style: { list: [], version: 'v2' },
2810
- title_style: { list: [], version: 'v2' },
2811
- place_holder: Language.text('please_enter_company_name'),
2812
- },
2813
- hidden_code:
2814
- " 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 }",
2815
- },
2816
- {
2817
- key: 'gui_number',
2818
- page: 'input',
2819
- type: 'form_plugin_v2',
2820
- group: '',
2821
- title: Language.text('company_tax_id'),
2822
- col: '3',
2823
- col_sm: '12',
2824
- appName: 'cms_system',
2825
- require: 'false',
2826
- readonly: 'write',
2827
- formFormat: '{}',
2828
- moduleName: '輸入框',
2829
- style_data: {
2830
- input: {
2831
- list: [],
2832
- class: '',
2833
- style: '',
2834
- version: 'v2',
2835
- },
2836
- label: {
2837
- list: [],
2838
- class: 'form-label fs-base ',
2839
- style: '',
2840
- version: 'v2',
2841
- },
2842
- container: {
2843
- list: [],
2844
- class: '',
2845
- style: '',
2846
- version: 'v2',
2847
- },
2848
- },
2849
- form_config: {
2850
- type: 'name',
2851
- title: '',
2852
- input_style: { list: [], version: 'v2' },
2853
- title_style: { list: [], version: 'v2' },
2854
- place_holder: Language.text('please_enter_company_tax_id'),
2855
- },
2856
- hidden_code:
2857
- " if(form_data['invoice_type']!=='company'){\n form_data[form_key]=undefined\nreturn true\n }else{\n return false\n }",
2858
- },
2859
- {
2860
- col: '6',
2861
- key: 'love_code',
2862
- page: 'input',
2863
- type: 'form_plugin_v2',
2864
- group: '',
2865
- title: Language.text('donation_code'),
2866
- col_sm: '12',
2867
- appName: 'cms_system',
2868
- require: 'false',
2869
- readonly: 'write',
2870
- formFormat: '{}',
2871
- moduleName: '輸入框',
2872
- style_data: {
2873
- input: {
2874
- list: [],
2875
- class: '',
2876
- style: '',
2877
- version: 'v2',
2878
- },
2879
- label: {
2880
- list: [],
2881
- class: 'form-label fs-base ',
2882
- style: '',
2883
- version: 'v2',
2884
- },
2885
- container: {
2886
- list: [],
2887
- class: '',
2888
- style: '',
2889
- version: 'v2',
2890
- },
2891
- },
2892
- form_config: {
2893
- type: 'name',
2894
- title: '',
2895
- input_style: { list: [], version: 'v2' },
2896
- title_style: { list: [], version: 'v2' },
2897
- place_holder: Language.text('please_enter_donation_code'),
2898
- },
2899
- hidden_code:
2900
- " 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 }",
2901
- },
2902
- ]),
2903
- {
2904
- col: '12',
2905
- key: 'note',
2906
- page: 'multiple_line_text',
2907
- type: 'form_plugin_v2',
2908
- group: '',
2909
- title: Language.text('delivery_notes'),
2910
- col_sm: '12',
2911
- appName: 'cms_system',
2912
- require: 'false',
2913
- readonly: 'write',
2914
- formFormat: '{}',
2915
- moduleName: '多行文字區塊',
2916
- style_data: {
2917
- input: {
2918
- list: [],
2919
- class: '',
2920
- style: '',
2921
- version: 'v2',
2922
- },
2923
- label: {
2924
- list: [],
2925
- class: 'form-label fs-base ',
2926
- style: '',
2927
- version: 'v2',
2928
- },
2929
- container: {
2930
- list: [],
2931
- class: '',
2932
- style: '',
2933
- version: 'v2',
2934
- },
2935
- },
2936
- form_config: {
2937
- type: 'text',
2938
- title: '',
2939
- title_style: { list: [], version: 'v2' },
2940
- place_holder: Language.text('enter_delivery_notes'),
2941
- },
2942
- hidden_code: 'return false',
2943
- },
2944
- ].filter(dd => {
2945
- return (
2946
- (dd.key !== 'name' && dd.key !== 'phone' && dd.key !== 'email') ||
2947
- !vm.cartData.user_info_same ||
2948
- !widget.share.custom_form_checkout.find((d1: any) => {
2949
- return d1.key === dd.key && d1.require;
2950
- })
2951
- );
2952
- });
2953
- vm.cartData.user_info.invoice_method = method;
2954
- vm.cartData.user_info.invoice_type =
2955
- vm.cartData.user_info.invoice_type || 'me';
2956
- vm.cartData.user_info.send_type = vm.cartData.user_info.send_type || 'email';
2957
-
2379
+ ${gvc.bindView(() => {
2380
+ const id = 'customer-info';
2381
+ const vm_info: {
2382
+ loading: boolean;
2383
+ list: any[];
2384
+ } = {
2385
+ loading: true,
2386
+ list: [],
2387
+ };
2388
+ vm_info.list = widget.share.custom_form_checkout;
2389
+ return {
2390
+ bind: id,
2391
+ view: () => {
2392
+ return new Promise(async (resolve, reject) => {
2393
+ vm_info.list = widget.share.custom_form_checkout;
2394
+ resolve(
2395
+ [
2396
+ html` <div class="row m-0 mt-3 mb-2">
2397
+ ${[
2398
+ {
2399
+ name: Language.text('name'),
2400
+ key: 'name',
2401
+ },
2402
+ {
2403
+ name: Language.text('contact_number'),
2404
+ key: 'phone',
2405
+ },
2406
+ {
2407
+ name: Language.text('email'),
2408
+ key: 'email',
2409
+ },
2410
+ ]
2411
+ .filter(dd => {
2412
+ return vm_info.list.find(d1 => {
2413
+ return d1.key === dd.key && `${d1.hidden}` !== 'true';
2414
+ });
2415
+ })
2416
+ .map(dd => {
2417
+ return html` <div class="col-12 col-md-4 mb-2">
2418
+ <label class="${gClass('label')}">${dd.name}</label>
2419
+ <input
2420
+ class="${gClass('input')}"
2421
+ type="${dd.key}"
2422
+ value="${vm.cartData.customer_info[dd.key] || ''}"
2423
+ onchange="${gvc.event((e, event) => {
2424
+ vm.cartData.customer_info[dd.key] = e.value;
2425
+ this.storeLocalData(vm.cartData);
2426
+ })}"
2427
+ />
2428
+ </div>`;
2429
+ })
2430
+ .join('')}
2431
+ </div>`,
2432
+ gvc.bindView(() => {
2433
+ const id = gvc.glitter.getUUID();
2434
+ return {
2435
+ bind: id,
2436
+ view: () => {
2958
2437
  const form_array = JSON.parse(JSON.stringify(vm_info.list));
2959
-
2960
2438
  form_array.map((dd: any) => {
2961
- if (
2962
- dd.key === 'send_type' &&
2963
- vm.cartData.user_info.send_type === 'carrier'
2964
- ) {
2965
- dd.col = 3;
2966
- }
2439
+ dd.col = '4';
2967
2440
  dd.form_config.title_style = {
2968
2441
  list: [
2969
2442
  {
2970
- class: ['company', 'gui_number', 'carrier_num'].includes(dd.key)
2971
- ? gClass('label') + ' mt-2'
2972
- : gClass('label') + ' mb-2',
2443
+ class: gClass('label') + ' mb-2',
2973
2444
  style:
2974
2445
  'return `color:${glitter.share.globalValue[`theme_color.0.title`]} !important;font-size:16px !important;`',
2975
2446
  stylist: [],
@@ -3007,21 +2478,550 @@ export class CheckoutIndex {
3007
2478
  style_from: 'code',
3008
2479
  classDataType: 'static',
3009
2480
  };
3010
- return dd;
3011
2481
  });
3012
2482
  return [
3013
- html` <div
2483
+ FormWidget.editorView({
2484
+ gvc: gvc,
2485
+ array: form_array.filter((dd: any) => {
2486
+ return !['name', 'email', 'phone'].includes(dd.key);
2487
+ }),
2488
+ refresh: () => {
2489
+ this.storeLocalData(vm.cartData);
2490
+ },
2491
+ formData: vm.cartData.custom_form_data,
2492
+ }),
2493
+ ].join('');
2494
+ },
2495
+ divCreate: {
2496
+ class: `w-100 `,
2497
+ },
2498
+ };
2499
+ }),
2500
+ ].join('')
2501
+ );
2502
+ });
2503
+ },
2504
+ };
2505
+ })}
2506
+ </div>
2507
+ <!--收件人資料-->
2508
+ <div class="rounded-3 bg-white w-100 p-1 mt-3">
2509
+ <div class="${gClass('banner-text')} px-3 pt-3 d-flex align-items-center">
2510
+ ${Language.text('recipient_info')}
2511
+ <div class="flex-fill"></div>
2512
+ <div
2513
+ class="fs-sm fw-500 ${!GlobalUser.token ? `d-none` : ``}"
2514
+ style="cursor: pointer; color: #3366bb;"
2515
+ onclick="${gvc.event(() => {
2516
+ ApiUser.getUserData(GlobalUser.token, 'me').then(res => {
2517
+ console.log(`res.response.userData=>`, res.response.userData);
2518
+ ['name', 'phone', 'email'].map(dd => {
2519
+ vm.cartData.user_info[dd] =
2520
+ res.response.userData[dd] || vm.cartData.user_info[dd];
2521
+ });
2522
+
2523
+ [
2524
+ {
2525
+ key: 'carrier_num',
2526
+ refer: res.response.userData['carrier_number'],
2527
+ },
2528
+ {
2529
+ key: 'gui_number',
2530
+ refer: res.response.userData['gui_number'],
2531
+ },
2532
+ {
2533
+ key: 'send_type',
2534
+ refer:
2535
+ res.response.userData['gui_number'] ||
2536
+ !res.response.userData['carrier_number']
2537
+ ? 'email'
2538
+ : 'carrier_num',
2539
+ },
2540
+ {
2541
+ key: 'invoice_type',
2542
+ refer: res.response.userData['gui_number'] ? 'company' : 'me',
2543
+ },
2544
+ {
2545
+ key: 'company',
2546
+ refer: res.response.userData['company'],
2547
+ },
2548
+ ].map(dd => {
2549
+ vm.cartData.user_info[dd.key] = dd.refer || vm.cartData.user_info[dd.key];
2550
+ });
2551
+
2552
+ this.storeLocalData(vm.cartData);
2553
+ gvc.notifyDataChange('invoice_place');
2554
+ });
2555
+ })}"
2556
+ >
2557
+ ${Language.text('quick_input')}
2558
+ </div>
2559
+ </div>
2560
+ ${gvc.bindView(() => {
2561
+ const id = 'invoice_place';
2562
+ const vm_info: {
2563
+ loading: boolean;
2564
+ list: any[];
2565
+ } = {
2566
+ loading: true,
2567
+ list: [],
2568
+ };
2569
+ //nouse
2570
+ let method = widget.share.invoice_method || '';
2571
+ if (widget.share.invoice_method) {
2572
+ vm_info.loading = false;
2573
+ gvc.notifyDataChange(id);
2574
+ } else {
2575
+ ApiShop.getInvoiceType().then((res: any) => {
2576
+ method = res.response.method;
2577
+ vm_info.loading = false;
2578
+ widget.share.invoice_method = method;
2579
+ gvc.notifyDataChange(id);
2580
+ });
2581
+ }
2582
+ const checkbox = this.getCheckedClass(gvc, '#393939');
2583
+ return {
2584
+ bind: id,
2585
+ view: async () => {
2586
+ try {
2587
+ if (vm_info.loading) {
2588
+ return ``;
2589
+ }
2590
+ const receipt_form = JSON.parse(
2591
+ JSON.stringify(widget.share.receipt_form)
2592
+ ).map((dd: any) => {
2593
+ switch (dd.key) {
2594
+ case 'name':
2595
+ dd.form_config.place_holder = Language.text('please_enter_name');
2596
+ dd.title = Language.text('name');
2597
+ break;
2598
+ case 'phone':
2599
+ dd.form_config.place_holder =
2600
+ Language.text('please_enter_contact_number');
2601
+ dd.title = Language.text('contact_number');
2602
+ break;
2603
+ case 'email':
2604
+ dd.form_config.place_holder = Language.text('please_enter_email');
2605
+ dd.title = Language.text('email');
2606
+ break;
2607
+ }
2608
+ dd.col = '4';
2609
+ return dd;
2610
+ });
2611
+ vm_info.list = [
2612
+ ...receipt_form,
2613
+ ...(method === 'nouse'
2614
+ ? []
2615
+ : [
2616
+ {
2617
+ col: '6',
2618
+ key: 'invoice_type',
2619
+ page: 'form-select',
2620
+ type: 'form_plugin_v2',
2621
+ group: '',
2622
+ title: Language.text('invoice_recipient'),
2623
+ col_sm: '12',
2624
+ appName: 'cms_system',
2625
+ require: 'true',
2626
+ readonly: 'write',
2627
+ formFormat: '{}',
2628
+ moduleName: '下拉選單',
2629
+ style_data: {
2630
+ input: {
2631
+ list: [],
2632
+ class: '',
2633
+ style: '',
2634
+ version: 'v2',
2635
+ },
2636
+ label: {
2637
+ list: [],
2638
+ class: 'form-label fs-base ',
2639
+ style: '',
2640
+ version: 'v2',
2641
+ },
2642
+ container: {
2643
+ list: [],
2644
+ class: '',
2645
+ style: '',
2646
+ version: 'v2',
2647
+ },
2648
+ },
2649
+ form_config: {
2650
+ type: 'name',
2651
+ title: '',
2652
+ option: [
2653
+ {
2654
+ name: Language.text('personal'),
2655
+ index: 0,
2656
+ value: 'me',
2657
+ },
2658
+ {
2659
+ name: Language.text('company'),
2660
+ index: 1,
2661
+ value: 'company',
2662
+ },
2663
+ {
2664
+ name: Language.text('donate_invoice'),
2665
+ index: 2,
2666
+ value: 'donate',
2667
+ },
2668
+ ],
2669
+ input_style: { list: [], version: 'v2' },
2670
+ title_style: { list: [], version: 'v2' },
2671
+ place_holder: '',
2672
+ },
2673
+ hidden_code: "return (form_data['invoice_method']==='nouse')",
2674
+ },
2675
+ {
2676
+ col: '6',
2677
+ key: 'send_type',
2678
+ page: 'form-select',
2679
+ type: 'form_plugin_v2',
2680
+ group: '',
2681
+ title: Language.text('invoice_method'),
2682
+ col_sm: '12',
2683
+ appName: 'cms_system',
2684
+ require: 'true',
2685
+ readonly: 'write',
2686
+ formFormat: '{}',
2687
+ moduleName: '下拉選單',
2688
+ style_data: {
2689
+ input: {
2690
+ list: [],
2691
+ class: '',
2692
+ style: '',
2693
+ version: 'v2',
2694
+ },
2695
+ label: {
2696
+ list: [],
2697
+ class: 'form-label fs-base ',
2698
+ style: '',
2699
+ version: 'v2',
2700
+ },
2701
+ container: {
2702
+ list: [],
2703
+ class: '',
2704
+ style: '',
2705
+ version: 'v2',
2706
+ },
2707
+ },
2708
+ form_config: {
2709
+ type: 'name',
2710
+ title: '',
2711
+ option: [
2712
+ {
2713
+ name: Language.text('send_to_user_email'),
2714
+ index: 0,
2715
+ value: 'email',
2716
+ },
2717
+ {
2718
+ name: Language.text('mobile_barcode_device'),
2719
+ index: 1,
2720
+ value: 'carrier',
2721
+ },
2722
+ ],
2723
+ input_style: { list: [], version: 'v2' },
2724
+ title_style: { list: [], version: 'v2' },
2725
+ place_holder: '',
2726
+ },
2727
+ hidden_code:
2728
+ " 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 }",
2729
+ },
2730
+ {
2731
+ key: 'carrier_num',
2732
+ page: 'input',
2733
+ type: 'form_plugin_v2',
2734
+ group: '',
2735
+ title: Language.text('carrier_number'),
2736
+ appName: 'cms_system',
2737
+ require: 'false',
2738
+ readonly: 'write',
2739
+ formFormat: '{}',
2740
+ moduleName: '輸入框',
2741
+ col: '3',
2742
+ col_sm: '12',
2743
+ style_data: {
2744
+ input: {
2745
+ list: [],
2746
+ class: '',
2747
+ style: '',
2748
+ version: 'v2',
2749
+ },
2750
+ label: {
2751
+ list: [],
2752
+ class: 'form-label fs-base ',
2753
+ style: '',
2754
+ version: 'v2',
2755
+ },
2756
+ container: {
2757
+ list: [],
2758
+ class: '',
2759
+ style: '',
2760
+ version: 'v2',
2761
+ },
2762
+ },
2763
+ form_config: {
2764
+ type: 'name',
2765
+ title: '',
2766
+ input_style: { list: [], version: 'v2' },
2767
+ title_style: { list: [], version: 'v2' },
2768
+ place_holder: Language.text('please_enter_carrier_number'),
2769
+ },
2770
+ hidden_code:
2771
+ " \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 }",
2772
+ },
2773
+ {
2774
+ key: 'company',
2775
+ page: 'input',
2776
+ type: 'form_plugin_v2',
2777
+ group: '',
2778
+ title: Language.text('company_name'),
2779
+ appName: 'cms_system',
2780
+ require: 'false',
2781
+ readonly: 'write',
2782
+ formFormat: '{}',
2783
+ moduleName: '輸入框',
2784
+ col: '3',
2785
+ col_sm: '12',
2786
+ style_data: {
2787
+ input: {
2788
+ list: [],
2789
+ class: '',
2790
+ style: '',
2791
+ version: 'v2',
2792
+ },
2793
+ label: {
2794
+ list: [],
2795
+ class: 'form-label fs-base ',
2796
+ style: '',
2797
+ version: 'v2',
2798
+ },
2799
+ container: {
2800
+ list: [],
2801
+ class: '',
2802
+ style: '',
2803
+ version: 'v2',
2804
+ },
2805
+ },
2806
+ form_config: {
2807
+ type: 'name',
2808
+ title: '',
2809
+ input_style: { list: [], version: 'v2' },
2810
+ title_style: { list: [], version: 'v2' },
2811
+ place_holder: Language.text('please_enter_company_name'),
2812
+ },
2813
+ hidden_code:
2814
+ " 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 }",
2815
+ },
2816
+ {
2817
+ key: 'gui_number',
2818
+ page: 'input',
2819
+ type: 'form_plugin_v2',
2820
+ group: '',
2821
+ title: Language.text('company_tax_id'),
2822
+ col: '3',
2823
+ col_sm: '12',
2824
+ appName: 'cms_system',
2825
+ require: 'false',
2826
+ readonly: 'write',
2827
+ formFormat: '{}',
2828
+ moduleName: '輸入框',
2829
+ style_data: {
2830
+ input: {
2831
+ list: [],
2832
+ class: '',
2833
+ style: '',
2834
+ version: 'v2',
2835
+ },
2836
+ label: {
2837
+ list: [],
2838
+ class: 'form-label fs-base ',
2839
+ style: '',
2840
+ version: 'v2',
2841
+ },
2842
+ container: {
2843
+ list: [],
2844
+ class: '',
2845
+ style: '',
2846
+ version: 'v2',
2847
+ },
2848
+ },
2849
+ form_config: {
2850
+ type: 'name',
2851
+ title: '',
2852
+ input_style: { list: [], version: 'v2' },
2853
+ title_style: { list: [], version: 'v2' },
2854
+ place_holder: Language.text('please_enter_company_tax_id'),
2855
+ },
2856
+ hidden_code:
2857
+ " if(form_data['invoice_type']!=='company'){\n form_data[form_key]=undefined\nreturn true\n }else{\n return false\n }",
2858
+ },
2859
+ {
2860
+ col: '6',
2861
+ key: 'love_code',
2862
+ page: 'input',
2863
+ type: 'form_plugin_v2',
2864
+ group: '',
2865
+ title: Language.text('donation_code'),
2866
+ col_sm: '12',
2867
+ appName: 'cms_system',
2868
+ require: 'false',
2869
+ readonly: 'write',
2870
+ formFormat: '{}',
2871
+ moduleName: '輸入框',
2872
+ style_data: {
2873
+ input: {
2874
+ list: [],
2875
+ class: '',
2876
+ style: '',
2877
+ version: 'v2',
2878
+ },
2879
+ label: {
2880
+ list: [],
2881
+ class: 'form-label fs-base ',
2882
+ style: '',
2883
+ version: 'v2',
2884
+ },
2885
+ container: {
2886
+ list: [],
2887
+ class: '',
2888
+ style: '',
2889
+ version: 'v2',
2890
+ },
2891
+ },
2892
+ form_config: {
2893
+ type: 'name',
2894
+ title: '',
2895
+ input_style: { list: [], version: 'v2' },
2896
+ title_style: { list: [], version: 'v2' },
2897
+ place_holder: Language.text('please_enter_donation_code'),
2898
+ },
2899
+ hidden_code:
2900
+ " 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 }",
2901
+ },
2902
+ ]),
2903
+ {
2904
+ col: '12',
2905
+ key: 'note',
2906
+ page: 'multiple_line_text',
2907
+ type: 'form_plugin_v2',
2908
+ group: '',
2909
+ title: Language.text('delivery_notes'),
2910
+ col_sm: '12',
2911
+ appName: 'cms_system',
2912
+ require: 'false',
2913
+ readonly: 'write',
2914
+ formFormat: '{}',
2915
+ moduleName: '多行文字區塊',
2916
+ style_data: {
2917
+ input: {
2918
+ list: [],
2919
+ class: '',
2920
+ style: '',
2921
+ version: 'v2',
2922
+ },
2923
+ label: {
2924
+ list: [],
2925
+ class: 'form-label fs-base ',
2926
+ style: '',
2927
+ version: 'v2',
2928
+ },
2929
+ container: {
2930
+ list: [],
2931
+ class: '',
2932
+ style: '',
2933
+ version: 'v2',
2934
+ },
2935
+ },
2936
+ form_config: {
2937
+ type: 'text',
2938
+ title: '',
2939
+ title_style: { list: [], version: 'v2' },
2940
+ place_holder: Language.text('enter_delivery_notes'),
2941
+ },
2942
+ hidden_code: 'return false',
2943
+ },
2944
+ ].filter(dd => {
2945
+ return (
2946
+ (dd.key !== 'name' && dd.key !== 'phone' && dd.key !== 'email') ||
2947
+ !vm.cartData.user_info_same ||
2948
+ !widget.share.custom_form_checkout.find((d1: any) => {
2949
+ return d1.key === dd.key && d1.require;
2950
+ })
2951
+ );
2952
+ });
2953
+ vm.cartData.user_info.invoice_method = method;
2954
+ vm.cartData.user_info.invoice_type =
2955
+ vm.cartData.user_info.invoice_type || 'me';
2956
+ vm.cartData.user_info.send_type = vm.cartData.user_info.send_type || 'email';
2957
+
2958
+ const form_array = JSON.parse(JSON.stringify(vm_info.list));
2959
+
2960
+ form_array.map((dd: any) => {
2961
+ if (
2962
+ dd.key === 'send_type' &&
2963
+ vm.cartData.user_info.send_type === 'carrier'
2964
+ ) {
2965
+ dd.col = 3;
2966
+ }
2967
+ dd.form_config.title_style = {
2968
+ list: [
2969
+ {
2970
+ class: ['company', 'gui_number', 'carrier_num'].includes(dd.key)
2971
+ ? gClass('label') + ' mt-2'
2972
+ : gClass('label') + ' mb-2',
2973
+ style:
2974
+ 'return `color:${glitter.share.globalValue[`theme_color.0.title`]} !important;font-size:16px !important;`',
2975
+ stylist: [],
2976
+ dataType: 'code',
2977
+ style_from: 'code',
2978
+ classDataType: 'static',
2979
+ },
2980
+ ],
2981
+ class: 'form-label',
2982
+ style:
2983
+ 'font-size: 20px;font-style: normal;font-weight: 400;line-height: 140%; color:#393939 !important;',
2984
+ stylist: [],
2985
+ version: 'v2',
2986
+ dataType: 'static',
2987
+ style_from: 'code',
2988
+ classDataType: 'static',
2989
+ };
2990
+ dd.form_config.input_style = {
2991
+ list: [
2992
+ {
2993
+ class: gClass('input'),
2994
+ style:
2995
+ 'return `border-radius: ${widget.formData.radius}px !important;`',
2996
+ stylist: [],
2997
+ dataType: 'code',
2998
+ style_from: 'code',
2999
+ classDataType: 'static',
3000
+ },
3001
+ ],
3002
+ class: ' mb-3',
3003
+ style: 'background: #FFF;',
3004
+ stylist: [],
3005
+ version: 'v2',
3006
+ dataType: 'static',
3007
+ style_from: 'code',
3008
+ classDataType: 'static',
3009
+ };
3010
+ return dd;
3011
+ });
3012
+ return [
3013
+ html` <div
3014
3014
  class="d-flex ms-2 my-3"
3015
3015
  style="gap:10px;cursor:pointer;"
3016
3016
  onclick="${gvc.event(() => {
3017
- vm.cartData.user_info_same = !vm.cartData.user_info_same;
3018
- if (vm.cartData.user_info_same) {
3019
- vm.cartData.user_info.name = vm.cartData.customer_info.name;
3020
- vm.cartData.user_info.phone = vm.cartData.customer_info.phone;
3021
- vm.cartData.user_info.email = vm.cartData.customer_info.email;
3022
- }
3023
- gvc.notifyDataChange(id);
3024
- })}"
3017
+ vm.cartData.user_info_same = !vm.cartData.user_info_same;
3018
+ if (vm.cartData.user_info_same) {
3019
+ vm.cartData.user_info.name = vm.cartData.customer_info.name;
3020
+ vm.cartData.user_info.phone = vm.cartData.customer_info.phone;
3021
+ vm.cartData.user_info.email = vm.cartData.customer_info.email;
3022
+ }
3023
+ gvc.notifyDataChange(id);
3024
+ })}"
3025
3025
  >
3026
3026
  <input
3027
3027
  class="form-check-input form-checkbox ${checkbox}"
@@ -3030,48 +3030,48 @@ export class CheckoutIndex {
3030
3030
  />
3031
3031
  ${Language.text('same_as_buyer_info')}
3032
3032
  </div>`,
3033
- FormWidget.editorView({
3034
- gvc: gvc,
3035
- array: form_array.map((dd: any, index: number) => {
3036
- dd.col = '6';
3037
- if (index === form_array.length - 1) {
3038
- dd.col = '12';
3039
- }
3040
- return dd;
3041
- }),
3042
- refresh: () => {
3043
- this.storeLocalData(vm.cartData);
3044
- gvc.notifyDataChange(id);
3045
- },
3046
- formData: vm.cartData.user_info,
3047
- }),
3048
- ].join('<div class="my-2"></div>');
3049
- } catch (e) {
3050
- console.error(`error 4 =>`, e);
3051
- return '';
3052
- }
3053
- },
3054
- divCreate: {
3055
- class: `w-100 mt-2`,
3056
- },
3057
- };
3058
- })}
3033
+ FormWidget.editorView({
3034
+ gvc: gvc,
3035
+ array: form_array.map((dd: any, index: number) => {
3036
+ dd.col = '6';
3037
+ if (index === form_array.length - 1) {
3038
+ dd.col = '12';
3039
+ }
3040
+ return dd;
3041
+ }),
3042
+ refresh: () => {
3043
+ this.storeLocalData(vm.cartData);
3044
+ gvc.notifyDataChange(id);
3045
+ },
3046
+ formData: vm.cartData.user_info,
3047
+ }),
3048
+ ].join('<div class="my-2"></div>');
3049
+ } catch (e) {
3050
+ console.error(`error 4 =>`, e);
3051
+ return '';
3052
+ }
3053
+ },
3054
+ divCreate: {
3055
+ class: `w-100 mt-2`,
3056
+ },
3057
+ };
3058
+ })}
3059
3059
  ${(() => {
3060
- const verify = [];
3061
- const shipment = vm.cartData.shipment_selector.find(
3062
- (item: any) => item.value === vm.cartData.user_info.shipment
3063
- );
3064
- if (shipment.isExcludedByTotal) {
3065
- verify.push(
3066
- '提示:若總金額超過20,000元,結帳系統無法提供四大超商配送,請調整購買項目'
3067
- );
3068
- }
3069
- if (shipment.isExcludedByWeight) {
3070
- verify.push(
3071
- '提示:若訂單總重超過20公斤,無法提供中華郵政/黑貓宅配服務,請調整購買項目'
3072
- );
3073
- }
3074
- return html`
3060
+ const verify = [];
3061
+ const shipment = vm.cartData.shipment_selector.find(
3062
+ (item: any) => item.value === vm.cartData.user_info.shipment
3063
+ );
3064
+ if (shipment.isExcludedByTotal) {
3065
+ verify.push(
3066
+ '提示:若總金額超過20,000元,結帳系統無法提供四大超商配送,請調整購買項目'
3067
+ );
3068
+ }
3069
+ if (shipment.isExcludedByWeight) {
3070
+ verify.push(
3071
+ '提示:若訂單總重超過20公斤,無法提供中華郵政/黑貓宅配服務,請調整購買項目'
3072
+ );
3073
+ }
3074
+ return html`
3075
3075
  <div style="height:100px;"></div>
3076
3076
 
3077
3077
  <div
@@ -3079,14 +3079,14 @@ export class CheckoutIndex {
3079
3079
  style="min-height:76px;z-index:10;"
3080
3080
  >
3081
3081
  ${(() => {
3082
- if (verify.length > 0) {
3083
- return verify
3084
- .map(dd => {
3085
- return `<div class="text-danger" style="font-size: 13px;">${dd}</div>`;
3086
- })
3087
- .join('');
3088
- } else {
3089
- return ` <div
3082
+ if (verify.length > 0) {
3083
+ return verify
3084
+ .map(dd => {
3085
+ return `<div class="text-danger" style="font-size: 13px;">${dd}</div>`;
3086
+ })
3087
+ .join('');
3088
+ } else {
3089
+ return ` <div
3090
3090
  class="d-flex align-items-center justify-content-end"
3091
3091
  style="width:1180px;max-width: 100%;gap:24px;"
3092
3092
  >
@@ -3105,167 +3105,167 @@ export class CheckoutIndex {
3105
3105
  <button
3106
3106
  class="${gClass(verify.length > 0 ? 'button-bgr-disable' : 'button-bgr')}"
3107
3107
  style="${
3108
- document.body.clientWidth < 800
3109
- ? `min-width:100px;`
3110
- : `min-width:380px;`
3111
- }"
3108
+ document.body.clientWidth < 800
3109
+ ? `min-width:100px;`
3110
+ : `min-width:380px;`
3111
+ }"
3112
3112
  onclick="${gvc.event(() => {
3113
- const that = this;
3114
- if (onlineData?.interaction?.status == 3) {
3115
- const dialog = new ShareDialog(gvc.glitter);
3116
- dialog.infoMessage({
3117
- text: `很抱歉,團購的結帳時間已截止,無法再進行訂單結算。感謝您的支持,期待下次再為您服務!`,
3118
- });
3119
- return;
3120
- }
3121
-
3122
- if (
3123
- (window as any).login_config.login_in_to_order &&
3124
- !GlobalUser.token
3125
- ) {
3126
- GlobalUser.loginRedirect = location.href;
3127
- gvc.glitter.href = '/login';
3128
- return;
3129
- }
3130
-
3131
- function next() {
3132
- if (vm.cartData.user_info_same) {
3133
- vm.cartData.user_info.name = vm.cartData.customer_info.name;
3134
- vm.cartData.user_info.phone = vm.cartData.customer_info.phone;
3135
- vm.cartData.user_info.email = vm.cartData.customer_info.email;
3136
- }
3137
- if (verify.length > 0) {
3138
- return;
3139
- }
3113
+ const that = this;
3114
+ if (onlineData?.interaction?.status == 3) {
3115
+ const dialog = new ShareDialog(gvc.glitter);
3116
+ dialog.infoMessage({
3117
+ text: `很抱歉,團購的結帳時間已截止,無法再進行訂單結算。感謝您的支持,期待下次再為您服務!`,
3118
+ });
3119
+ return;
3120
+ }
3121
+
3122
+ if (
3123
+ (window as any).login_config.login_in_to_order &&
3124
+ !GlobalUser.token
3125
+ ) {
3126
+ GlobalUser.loginRedirect = location.href;
3127
+ gvc.glitter.href = '/login';
3128
+ return;
3129
+ }
3130
+
3131
+ function next() {
3132
+ if (vm.cartData.user_info_same) {
3133
+ vm.cartData.user_info.name = vm.cartData.customer_info.name;
3134
+ vm.cartData.user_info.phone = vm.cartData.customer_info.phone;
3135
+ vm.cartData.user_info.email = vm.cartData.customer_info.email;
3136
+ }
3137
+ if (verify.length > 0) {
3138
+ return;
3139
+ }
3140
3140
 
3141
- if (shipmentList.length === 0) {
3142
- vm.cartData.user_info.shipment = 'none';
3143
- }
3141
+ if (shipmentList.length === 0) {
3142
+ vm.cartData.user_info.shipment = 'none';
3143
+ }
3144
3144
 
3145
- const dialog = new ShareDialog(gvc.glitter);
3146
- if (!that.checkFormData(gvc, vm.cartData, widget)) {
3147
- return;
3148
- }
3149
- for (const item of vm.cartData.lineItems) {
3150
- const title =
3151
- (item.language_data &&
3152
- item.language_data[Language.getLanguage()].title) ||
3153
- item.title;
3154
- let min = (item.min_qty && parseInt(item.min_qty, 10)) || 1;
3155
- let max_qty =
3156
- (item.max_qty && parseInt(item.max_qty, 10)) || Infinity;
3157
- let count = 0;
3158
- for (const b of vm.cartData.lineItems) {
3159
- if (b.id === item.id) {
3160
- count += b.count;
3161
- }
3162
- }
3163
- if (count < min) {
3164
- dialog.errorMessage({
3165
- text: Language.text('min_p_count_d')
3166
- .replace('_c_', min)
3167
- .replace('_p_', `『${title}』`),
3168
- });
3169
- return;
3170
- }
3171
- if (count > max_qty) {
3172
- dialog.errorMessage({
3173
- text: Language.text('max_p_count_d')
3174
- .replace('_c_', max_qty)
3175
- .replace('_p_', `『${title}』`),
3176
- });
3177
- return;
3178
- }
3179
- if (max_qty > 0 && count + item.buy_history_count > max_qty) {
3180
- dialog.errorMessage({
3181
- text: Language.text('trigger_maximum_item').replace(
3182
- '_p_',
3183
- `『${title}』`
3184
- ),
3185
- });
3186
- return;
3187
- }
3188
- }
3189
- [
3190
- 'MerchantTradeNo',
3191
- 'LogisticsSubType',
3192
- 'CVSStoreID',
3193
- 'CVSStoreName',
3194
- 'CVSTelephone',
3195
- 'CVSOutSide',
3196
- 'ExtraData',
3197
- 'CVSAddress',
3198
- ].map(dd => {
3199
- if (gvc.glitter.getUrlParameter(dd)) {
3200
- vm.cartData.user_info[dd] = decodeURI(
3201
- glitter.getUrlParameter(dd)
3202
- );
3203
- }
3204
- });
3205
- dialog.dataLoading({ visible: true });
3206
- vm.cartData.user_info.note =
3207
- (vm.cartData.user_info.note ?? '') + (check_out_sub.note ?? '');
3208
- ApiShop.toCheckout({
3209
- line_items: vm.cartData.lineItems.map((dd: any) => {
3210
- return {
3211
- id: dd.id,
3212
- spec: dd.spec,
3213
- count: dd.count,
3214
- };
3215
- }),
3216
- customer_info: vm.cartData.customer_info,
3217
- return_url: (() => {
3218
- const originalUrl =
3219
- glitter.root_path + 'order_detail' + location.search;
3220
- const urlObject = new URL(originalUrl);
3221
- urlObject.searchParams.set('EndCheckout', '1');
3222
- const newUrl = urlObject.toString();
3223
- if ((ApplicationConfig.device_type !== 'web') && ['jkopay','line_pay'].includes(vm.cartData.customer_info.payment_select)) {
3224
- return `${ApplicationConfig.bundle_id}://?path=${encodeURIComponent(newUrl)}`;
3225
- } else {
3226
- return newUrl;
3227
- }
3228
- })(),
3229
- user_info: vm.cartData.user_info,
3230
- code: apiCart.cart.code,
3231
- use_rebate: apiCart.cart.use_rebate,
3232
- custom_form_format: vm.cartData.custom_form_format,
3233
- custom_form_data: vm.cartData.custom_form_data,
3234
- custom_receipt_form: vm.cartData.receipt_form,
3235
- distribution_code: localStorage.getItem('distributionCode') ?? '',
3236
- give_away: apiCart.cart.give_away,
3237
- }).then(res => {
3238
- dialog.dataLoading({ visible: false });
3239
- if (vm.cartData.customer_info.payment_select == 'paynow') {
3240
- if (!res.response?.data?.result?.secret) {
3241
- return 'paynow API失敗';
3242
- }
3243
- glitter.innerDialog(
3244
- (gvc: GVC) => {
3245
- document.body.style.setProperty(
3246
- 'overflow-y',
3247
- 'hidden',
3248
- 'important'
3249
- );
3250
- return gvc.bindView({
3251
- bind: `paynow`,
3252
- view: () => {
3253
- return html` <div
3145
+ const dialog = new ShareDialog(gvc.glitter);
3146
+ if (!that.checkFormData(gvc, vm.cartData, widget)) {
3147
+ return;
3148
+ }
3149
+ for (const item of vm.cartData.lineItems) {
3150
+ const title =
3151
+ (item.language_data &&
3152
+ item.language_data[Language.getLanguage()].title) ||
3153
+ item.title;
3154
+ let min = (item.min_qty && parseInt(item.min_qty, 10)) || 1;
3155
+ let max_qty =
3156
+ (item.max_qty && parseInt(item.max_qty, 10)) || Infinity;
3157
+ let count = 0;
3158
+ for (const b of vm.cartData.lineItems) {
3159
+ if (b.id === item.id) {
3160
+ count += b.count;
3161
+ }
3162
+ }
3163
+ if (count < min) {
3164
+ dialog.errorMessage({
3165
+ text: Language.text('min_p_count_d')
3166
+ .replace('_c_', min)
3167
+ .replace('_p_', `『${title}』`),
3168
+ });
3169
+ return;
3170
+ }
3171
+ if (count > max_qty) {
3172
+ dialog.errorMessage({
3173
+ text: Language.text('max_p_count_d')
3174
+ .replace('_c_', max_qty)
3175
+ .replace('_p_', `『${title}』`),
3176
+ });
3177
+ return;
3178
+ }
3179
+ if (max_qty > 0 && count + item.buy_history_count > max_qty) {
3180
+ dialog.errorMessage({
3181
+ text: Language.text('trigger_maximum_item').replace(
3182
+ '_p_',
3183
+ `『${title}』`
3184
+ ),
3185
+ });
3186
+ return;
3187
+ }
3188
+ }
3189
+ [
3190
+ 'MerchantTradeNo',
3191
+ 'LogisticsSubType',
3192
+ 'CVSStoreID',
3193
+ 'CVSStoreName',
3194
+ 'CVSTelephone',
3195
+ 'CVSOutSide',
3196
+ 'ExtraData',
3197
+ 'CVSAddress',
3198
+ ].map(dd => {
3199
+ if (gvc.glitter.getUrlParameter(dd)) {
3200
+ vm.cartData.user_info[dd] = decodeURI(
3201
+ glitter.getUrlParameter(dd)
3202
+ );
3203
+ }
3204
+ });
3205
+ dialog.dataLoading({ visible: true });
3206
+ vm.cartData.user_info.note =
3207
+ (vm.cartData.user_info.note ?? '') + (check_out_sub.note ?? '');
3208
+ ApiShop.toCheckout({
3209
+ line_items: vm.cartData.lineItems.map((dd: any) => {
3210
+ return {
3211
+ id: dd.id,
3212
+ spec: dd.spec,
3213
+ count: dd.count,
3214
+ };
3215
+ }),
3216
+ customer_info: vm.cartData.customer_info,
3217
+ return_url: (() => {
3218
+ const originalUrl =
3219
+ glitter.root_path + 'order_detail' + location.search;
3220
+ const urlObject = new URL(originalUrl);
3221
+ urlObject.searchParams.set('EndCheckout', '1');
3222
+ const newUrl = urlObject.toString();
3223
+ if ((ApplicationConfig.device_type !== 'web') && ['jkopay','line_pay'].includes(vm.cartData.customer_info.payment_select)) {
3224
+ return `${ApplicationConfig.bundle_id}://?path=${encodeURIComponent(newUrl)}`;
3225
+ } else {
3226
+ return newUrl;
3227
+ }
3228
+ })(),
3229
+ user_info: vm.cartData.user_info,
3230
+ code: apiCart.cart.code,
3231
+ use_rebate: apiCart.cart.use_rebate,
3232
+ custom_form_format: vm.cartData.custom_form_format,
3233
+ custom_form_data: vm.cartData.custom_form_data,
3234
+ custom_receipt_form: vm.cartData.receipt_form,
3235
+ distribution_code: localStorage.getItem('distributionCode') ?? '',
3236
+ give_away: apiCart.cart.give_away,
3237
+ }).then(res => {
3238
+ dialog.dataLoading({ visible: false });
3239
+ if (vm.cartData.customer_info.payment_select == 'paynow') {
3240
+ if (!res.response?.data?.result?.secret) {
3241
+ return 'paynow API失敗';
3242
+ }
3243
+ glitter.innerDialog(
3244
+ (gvc: GVC) => {
3245
+ document.body.style.setProperty(
3246
+ 'overflow-y',
3247
+ 'hidden',
3248
+ 'important'
3249
+ );
3250
+ return gvc.bindView({
3251
+ bind: `paynow`,
3252
+ view: () => {
3253
+ return html` <div
3254
3254
  class="w-100 h-100 d-flex align-items-center justify-content-center"
3255
3255
  >
3256
3256
  ${document.body.clientWidth < 800
3257
- ? `
3257
+ ? `
3258
3258
  <div class="bg-white position-relative vw-100" style="height: ${window.innerHeight}px;overflow-y: auto;
3259
3259
  padding-top:${50 + glitter.share.top_inset}px;
3260
3260
  ">
3261
3261
  `
3262
- : `<div class="p-3 bg-white position-relative" style="max-height: calc(100vh - 90px);overflow-y:auto;">`}
3262
+ : `<div class="p-3 bg-white position-relative" style="max-height: calc(100vh - 90px);overflow-y:auto;">`}
3263
3263
  <div
3264
3264
  style="position: absolute; right: 15px;top:${15 +
3265
- glitter.share.top_inset}px;z-index:1;"
3265
+ glitter.share.top_inset}px;z-index:1;"
3266
3266
  onclick="${gvc.event(() => {
3267
- gvc.closeDialog();
3268
- })}"
3267
+ gvc.closeDialog();
3268
+ })}"
3269
3269
  >
3270
3270
  <i
3271
3271
  class="fa-regular fa-circle-xmark fs-5 text-dark cursor_pointer"
@@ -3279,28 +3279,28 @@ export class CheckoutIndex {
3279
3279
  <div class="px-3 px-sm-0 w-100">
3280
3280
  <button
3281
3281
  class="${gClass(
3282
- verify.length > 0
3283
- ? 'button-bgr-disable'
3284
- : 'button-bgr'
3285
- )} "
3282
+ verify.length > 0
3283
+ ? 'button-bgr-disable'
3284
+ : 'button-bgr'
3285
+ )} "
3286
3286
  id="checkoutButton"
3287
3287
  onclick="${gvc.event(() => {
3288
- // const inputGroup = document.querySelector('#paynow-container');
3289
- // console.log("inputGroup -- " , inputGroup)
3290
- const PayNow = (window as any).PayNow;
3291
- const dialog = new ShareDialog(gvc.glitter);
3292
- dialog.dataLoading({ visible: true });
3293
- PayNow.checkout().then((response: any) => {
3294
- dialog.dataLoading({ visible: false });
3295
- if (response.error) {
3296
- dialog.errorMessage({
3297
- text: response.error.message,
3298
- });
3299
- // handle error
3300
- }
3301
- // handle success
3302
- });
3303
- })}"
3288
+ // const inputGroup = document.querySelector('#paynow-container');
3289
+ // console.log("inputGroup -- " , inputGroup)
3290
+ const PayNow = (window as any).PayNow;
3291
+ const dialog = new ShareDialog(gvc.glitter);
3292
+ dialog.dataLoading({ visible: true });
3293
+ PayNow.checkout().then((response: any) => {
3294
+ dialog.dataLoading({ visible: false });
3295
+ if (response.error) {
3296
+ dialog.errorMessage({
3297
+ text: response.error.message,
3298
+ });
3299
+ // handle error
3300
+ }
3301
+ // handle success
3302
+ });
3303
+ })}"
3304
3304
  >
3305
3305
  <span class="${gClass('button-text')}"
3306
3306
  >確認結帳</span
@@ -3308,160 +3308,160 @@ export class CheckoutIndex {
3308
3308
  </button>
3309
3309
  </div>
3310
3310
  </div>`;
3311
- },
3312
- divCreate: {
3313
- class: ` h-100 d-flex align-items-center justify-content-center`,
3314
- style: `max-width:100vw;${document.body.clientWidth < 800 ? 'width:100%;' : 'width:400px;'};`,
3315
- },
3316
- onCreate: () => {
3317
- const publicKey = res.response.publicKey;
3318
- const secret = res.response.data.result.secret;
3319
- const env =
3320
- res.response.BETA == 'true' ? 'sandbox' : 'production';
3321
- // res.response.result.secret
3322
- const PayNow = (window as any).PayNow;
3323
- PayNow.createPayment({
3324
- publicKey: publicKey,
3325
- secret: secret,
3326
- env: env,
3327
- });
3328
- PayNow.mount('#paynow-container', {
3329
- locale: 'zh_tw',
3330
- appearance: {
3331
- variables: {
3332
- fontFamily: 'monospace',
3333
- colorPrimary: '#0078ab',
3334
- colorDefault: '#0a0a0a',
3335
- colorBorder: '#cccccc',
3336
- colorPlaceholder: '#eeeeee',
3337
- borderRadius: '.3rem',
3338
- colorDanger: '#ff3d3d',
3339
- },
3340
- },
3341
- });
3342
- },
3343
- });
3344
- },
3345
- `paynow`,
3346
- {
3347
- animation:
3348
- document.body.clientWidth > 800
3349
- ? Animation.fade
3350
- : Animation.popup,
3351
- dismiss: () => {
3352
- document.body.style.setProperty('overflow-y', 'auto');
3353
- },
3354
- }
3355
- );
3356
- }
3311
+ },
3312
+ divCreate: {
3313
+ class: ` h-100 d-flex align-items-center justify-content-center`,
3314
+ style: `max-width:100vw;${document.body.clientWidth < 800 ? 'width:100%;' : 'width:400px;'};`,
3315
+ },
3316
+ onCreate: () => {
3317
+ const publicKey = res.response.publicKey;
3318
+ const secret = res.response.data.result.secret;
3319
+ const env =
3320
+ res.response.BETA == 'true' ? 'sandbox' : 'production';
3321
+ // res.response.result.secret
3322
+ const PayNow = (window as any).PayNow;
3323
+ PayNow.createPayment({
3324
+ publicKey: publicKey,
3325
+ secret: secret,
3326
+ env: env,
3327
+ });
3328
+ PayNow.mount('#paynow-container', {
3329
+ locale: 'zh_tw',
3330
+ appearance: {
3331
+ variables: {
3332
+ fontFamily: 'monospace',
3333
+ colorPrimary: '#0078ab',
3334
+ colorDefault: '#0a0a0a',
3335
+ colorBorder: '#cccccc',
3336
+ colorPlaceholder: '#eeeeee',
3337
+ borderRadius: '.3rem',
3338
+ colorDanger: '#ff3d3d',
3339
+ },
3340
+ },
3341
+ });
3342
+ },
3343
+ });
3344
+ },
3345
+ `paynow`,
3346
+ {
3347
+ animation:
3348
+ document.body.clientWidth > 800
3349
+ ? Animation.fade
3350
+ : Animation.popup,
3351
+ dismiss: () => {
3352
+ document.body.style.setProperty('overflow-y', 'auto');
3353
+ },
3354
+ }
3355
+ );
3356
+ }
3357
3357
 
3358
- localStorage.setItem(
3359
- 'clear_cart_items',
3360
- JSON.stringify(vm.cartData.lineItems.map((item: any) => item.id))
3361
- );
3358
+ localStorage.setItem(
3359
+ 'clear_cart_items',
3360
+ JSON.stringify(vm.cartData.lineItems.map((item: any) => item.id))
3361
+ );
3362
3362
 
3363
- if (res.response.off_line || res.response.is_free) {
3364
- location.href = res.response.return_url;
3365
- } else {
3366
- if (
3367
- res.response.returnCode == '0000' &&
3368
- vm.cartData.customer_info.payment_select == 'line_pay'
3369
- ) {
3370
- if (glitter.share.is_application) {
3371
- gvc.glitter.runJsInterFace(
3372
- 'intent_url',
3373
- {
3374
- url: res.response.info.paymentUrl.app,
3375
- },
3376
- () => {}
3377
- );
3378
- // location.href = res.response.info.paymentUrl.app;
3379
- } else {
3380
- location.href = res.response.info.paymentUrl.web;
3381
- }
3382
- // todo 手機跳轉用這個
3383
- // location.href = res.response.form.info.paymentUrl.app;
3384
- } else if (res.response.approveLink) {
3385
- location.href = res.response.approveLink;
3386
- } else if (vm.cartData.customer_info.payment_select == 'jkopay') {
3387
- if (glitter.share.is_application) {
3388
- gvc.glitter.runJsInterFace(
3389
- 'intent_url',
3390
- {
3391
- url: res.response.result_object.payment_url,
3392
- },
3393
- () => {}
3394
- );
3395
- } else {
3396
- location.href = res.response.result_object.payment_url;
3397
- }
3398
- } else {
3399
- const id = gvc.glitter.getUUID();
3400
- $('body').append(
3401
- html` <div id="${id}" style="display: none;">
3363
+ if (res.response.off_line || res.response.is_free) {
3364
+ location.href = res.response.return_url;
3365
+ } else {
3366
+ if (
3367
+ res.response.returnCode == '0000' &&
3368
+ vm.cartData.customer_info.payment_select == 'line_pay'
3369
+ ) {
3370
+ if (glitter.share.is_application) {
3371
+ gvc.glitter.runJsInterFace(
3372
+ 'intent_url',
3373
+ {
3374
+ url: res.response.info.paymentUrl.app,
3375
+ },
3376
+ () => {}
3377
+ );
3378
+ // location.href = res.response.info.paymentUrl.app;
3379
+ } else {
3380
+ location.href = res.response.info.paymentUrl.web;
3381
+ }
3382
+ // todo 手機跳轉用這個
3383
+ // location.href = res.response.form.info.paymentUrl.app;
3384
+ } else if (res.response.approveLink) {
3385
+ location.href = res.response.approveLink;
3386
+ } else if (vm.cartData.customer_info.payment_select == 'jkopay') {
3387
+ if (glitter.share.is_application) {
3388
+ gvc.glitter.runJsInterFace(
3389
+ 'intent_url',
3390
+ {
3391
+ url: res.response.result_object.payment_url,
3392
+ },
3393
+ () => {}
3394
+ );
3395
+ } else {
3396
+ location.href = res.response.result_object.payment_url;
3397
+ }
3398
+ } else {
3399
+ const id = gvc.glitter.getUUID();
3400
+ $('body').append(
3401
+ html` <div id="${id}" style="display: none;">
3402
3402
  ${res.response.form}
3403
3403
  </div>`
3404
- );
3405
- (document.querySelector(`#${id} #submit`) as any).click();
3406
- }
3407
- }
3408
- });
3409
- }
3410
-
3411
- if (
3412
- (window as any).login_config.login_in_to_order &&
3413
- !GlobalUser.token
3414
- ) {
3415
- GlobalUser.loginRedirect = location.href;
3416
- gvc.glitter.href = '/login';
3417
- return;
3418
- } else {
3419
- ApiUser.getUserData(GlobalUser.token, 'me').then(res => {
3420
- if (
3421
- res.response.userData &&
3422
- !res.response.userData.phone &&
3423
- (window as any).login_config.phone_verify &&
3424
- glitter.getUrlParameter('page') !== 'account_edit'
3425
- ) {
3426
- const dialog = new ShareDialog(glitter);
3427
- dialog.infoMessage({
3428
- text: Language.text('phone_verify_check'),
3429
- });
3430
- glitter.href = '/account_edit';
3431
- } else {
3432
- next();
3433
- }
3434
- });
3435
- }
3436
- })}"
3404
+ );
3405
+ (document.querySelector(`#${id} #submit`) as any).click();
3406
+ }
3407
+ }
3408
+ });
3409
+ }
3410
+
3411
+ if (
3412
+ (window as any).login_config.login_in_to_order &&
3413
+ !GlobalUser.token
3414
+ ) {
3415
+ GlobalUser.loginRedirect = location.href;
3416
+ gvc.glitter.href = '/login';
3417
+ return;
3418
+ } else {
3419
+ ApiUser.getUserData(GlobalUser.token, 'me').then(res => {
3420
+ if (
3421
+ res.response.userData &&
3422
+ !res.response.userData.phone &&
3423
+ (window as any).login_config.phone_verify &&
3424
+ glitter.getUrlParameter('page') !== 'account_edit'
3425
+ ) {
3426
+ const dialog = new ShareDialog(glitter);
3427
+ dialog.infoMessage({
3428
+ text: Language.text('phone_verify_check'),
3429
+ });
3430
+ glitter.href = '/account_edit';
3431
+ } else {
3432
+ next();
3433
+ }
3434
+ });
3435
+ }
3436
+ })}"
3437
3437
  >
3438
3438
  <span class="${gClass('button-text')} "
3439
3439
  style="${verify.length > 0 ? `font-size:13px;` : ``}"
3440
3440
  >
3441
3441
  ${
3442
- verify.length > 0
3443
- ? verify.join('<br/>')
3444
- : (window as any).login_config.login_in_to_order &&
3445
- !GlobalUser.token
3446
- ? Language.text('login_in_to_checkout')
3447
- : Language.text('next')
3448
- }
3442
+ verify.length > 0
3443
+ ? verify.join('<br/>')
3444
+ : (window as any).login_config.login_in_to_order &&
3445
+ !GlobalUser.token
3446
+ ? Language.text('login_in_to_checkout')
3447
+ : Language.text('next')
3448
+ }
3449
3449
  </span >
3450
3450
  </button>
3451
3451
  </div>
3452
3452
  </div>`;
3453
- }
3454
- })()}
3453
+ }
3454
+ })()}
3455
3455
  </div>
3456
3456
  `;
3457
- })()}
3457
+ })()}
3458
3458
  </div>
3459
3459
  <div class="d-none d-sm-block" style="height:120px;"></div>
3460
3460
  </div>
3461
3461
  <div
3462
3462
  style="${document.body.clientWidth > 800
3463
- ? `width:calc(34% - 10px);position: sticky; top: 65px;`
3464
- : `width:calc(100%);`}"
3463
+ ? `width:calc(34% - 10px);position: sticky; top: 65px;`
3464
+ : `width:calc(100%);`}"
3465
3465
  >
3466
3466
  <!--明細-->
3467
3467
  <div style="" class="rounded-3 bg-white w-100 p-3">${detail_info}</div>
@@ -3469,10 +3469,10 @@ export class CheckoutIndex {
3469
3469
  </div>
3470
3470
  </div>
3471
3471
  `;
3472
- },
3473
- };
3474
- })()
3475
- )}
3472
+ },
3473
+ };
3474
+ })()
3475
+ )}
3476
3476
  </div>`;
3477
3477
  } catch (e) {
3478
3478
  console.error(`error 5 =>`, e);
@@ -3741,8 +3741,8 @@ export class CheckoutIndex {
3741
3741
  return html` <div
3742
3742
  class="bg-white shadow rounded-3"
3743
3743
  style="overflow-y: auto;${document.body.clientWidth > 768
3744
- ? `min-width: 600px; width: 700px;`
3745
- : 'min-width: 90vw; max-width: 92.5vw;'}"
3744
+ ? `min-width: 600px; width: 700px;`
3745
+ : 'min-width: 90vw; max-width: 92.5vw;'}"
3746
3746
  >
3747
3747
  <div class="bg-white shadow rounded-3" style="width: 100%; overflow-y: auto; position: relative;">
3748
3748
  <div
@@ -3755,8 +3755,8 @@ export class CheckoutIndex {
3755
3755
  class="fa-regular fa-circle-xmark fs-5 text-dark"
3756
3756
  style="cursor: pointer"
3757
3757
  onclick="${gvc.event(() => {
3758
- gvc.closeDialog();
3759
- })}"
3758
+ gvc.closeDialog();
3759
+ })}"
3760
3760
  ></i>
3761
3761
  </div>
3762
3762
  <div class="c_dialog">
@@ -3819,20 +3819,20 @@ export class CheckoutIndex {
3819
3819
  cartData.off_line_support = cartData.off_line_support ?? {};
3820
3820
  console.log(cartData.off_line_support);
3821
3821
  cartData.off_line_support.atm &&
3822
- array.push({
3823
- name: '銀行轉帳',
3824
- value: 'atm',
3825
- });
3822
+ array.push({
3823
+ name: '銀行轉帳',
3824
+ value: 'atm',
3825
+ });
3826
3826
  cartData.off_line_support.line &&
3827
- array.push({
3828
- name: 'Line轉帳',
3829
- value: 'line',
3830
- });
3827
+ array.push({
3828
+ name: 'Line轉帳',
3829
+ value: 'line',
3830
+ });
3831
3831
  cartData.off_line_support.cash_on_delivery &&
3832
- array.push({
3833
- name: '貨到付款',
3834
- value: 'cash_on_delivery',
3835
- });
3832
+ array.push({
3833
+ name: '貨到付款',
3834
+ value: 'cash_on_delivery',
3835
+ });
3836
3836
  if (cartData.payment_info_custom && cartData.payment_info_custom.length > 0) {
3837
3837
  cartData.payment_info_custom.map((item: any) => {
3838
3838
  if (cartData.off_line_support[item.id]) {