ts-glitter 20.8.6 → 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 (190) 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/ai-points.js.map +1 -1
  57. package/src/api-public/controllers/chat.js.map +1 -1
  58. package/src/api-public/controllers/customer-sessions.js.map +1 -1
  59. package/src/api-public/controllers/delivery.js.map +1 -1
  60. package/src/api-public/controllers/fb-message.js.map +1 -1
  61. package/src/api-public/controllers/fb-service.js.map +1 -1
  62. package/src/api-public/controllers/invoice.js.map +1 -1
  63. package/src/api-public/controllers/line-message.js.map +1 -1
  64. package/src/api-public/controllers/oauth.js.map +1 -1
  65. package/src/api-public/controllers/progress.js.map +1 -1
  66. package/src/api-public/controllers/rebate.js.map +1 -1
  67. package/src/api-public/controllers/recommend.js.map +1 -1
  68. package/src/api-public/controllers/reconciliation.js.map +1 -1
  69. package/src/api-public/controllers/shop.js +5 -2
  70. package/src/api-public/controllers/shop.js.map +1 -1
  71. package/src/api-public/controllers/shop.ts +7 -3
  72. package/src/api-public/controllers/shopee.js.map +1 -1
  73. package/src/api-public/controllers/sms-points.js.map +1 -1
  74. package/src/api-public/controllers/sms.js.map +1 -1
  75. package/src/api-public/controllers/smtp.js.map +1 -1
  76. package/src/api-public/controllers/stock.js.map +1 -1
  77. package/src/api-public/controllers/track.js.map +1 -1
  78. package/src/api-public/controllers/voucher.js.map +1 -1
  79. package/src/api-public/controllers/wallet.js.map +1 -1
  80. package/src/api-public/models/glitter-finance.js +1 -2
  81. package/src/api-public/models/glitter-finance.js.map +1 -1
  82. package/src/api-public/services/EcInvoice.js.map +1 -1
  83. package/src/api-public/services/ai-pointes.js.map +1 -1
  84. package/src/api-public/services/article.js.map +1 -1
  85. package/src/api-public/services/auto-send-email.js.map +1 -1
  86. package/src/api-public/services/chat.js.map +1 -1
  87. package/src/api-public/services/checkout-event.d.ts +1 -0
  88. package/src/api-public/services/checkout-event.js +17 -7
  89. package/src/api-public/services/checkout-event.js.map +1 -1
  90. package/src/api-public/services/checkout-event.ts +21 -9
  91. package/src/api-public/services/checkout.js.map +1 -1
  92. package/src/api-public/services/custom-code.js.map +1 -1
  93. package/src/api-public/services/customer-sessions.js.map +1 -1
  94. package/src/api-public/services/data-analyze.d.ts +1 -1
  95. package/src/api-public/services/data-analyze.js +209 -196
  96. package/src/api-public/services/data-analyze.js.map +1 -1
  97. package/src/api-public/services/data-analyze.ts +219 -205
  98. package/src/api-public/services/delivery.js.map +1 -1
  99. package/src/api-public/services/ezpay/tool.d.ts +0 -1
  100. package/src/api-public/services/ezpay/tool.js.map +1 -1
  101. package/src/api-public/services/fake-data-model/fake-order.js.map +1 -1
  102. package/src/api-public/services/fake-data-model/fake-product.js.map +1 -1
  103. package/src/api-public/services/fake-data-model/fake-user.js.map +1 -1
  104. package/src/api-public/services/fb-api.js.map +1 -1
  105. package/src/api-public/services/filter-protect-data.js.map +1 -1
  106. package/src/api-public/services/financial-service.d.ts +1 -0
  107. package/src/api-public/services/financial-service.js +10 -5
  108. package/src/api-public/services/financial-service.js.map +1 -1
  109. package/src/api-public/services/financial-service.ts +21 -16
  110. package/src/api-public/services/form-check.js.map +1 -1
  111. package/src/api-public/services/graph-api.js.map +1 -1
  112. package/src/api-public/services/initial-fake-data.js.map +1 -1
  113. package/src/api-public/services/invoice.d.ts +3 -9
  114. package/src/api-public/services/invoice.js +66 -85
  115. package/src/api-public/services/invoice.js.map +1 -1
  116. package/src/api-public/services/invoice.ts +287 -293
  117. package/src/api-public/services/language-setting.js.map +1 -1
  118. package/src/api-public/services/mail.js.map +1 -1
  119. package/src/api-public/services/manager.js.map +1 -1
  120. package/src/api-public/services/monitor.js.map +1 -1
  121. package/src/api-public/services/monitor.ts +1 -1
  122. package/src/api-public/services/paynow-logistics.js.map +1 -1
  123. package/src/api-public/services/phone-verify.js.map +1 -1
  124. package/src/api-public/services/pos.js.map +1 -1
  125. package/src/api-public/services/post.js.map +1 -1
  126. package/src/api-public/services/product-initial.js.map +1 -1
  127. package/src/api-public/services/rebate.js.map +1 -1
  128. package/src/api-public/services/reconciliation.js.map +1 -1
  129. package/src/api-public/services/schedule.d.ts +1 -0
  130. package/src/api-public/services/schedule.js +27 -0
  131. package/src/api-public/services/schedule.js.map +1 -1
  132. package/src/api-public/services/schedule.ts +30 -0
  133. package/src/api-public/services/shopping.d.ts +4 -3
  134. package/src/api-public/services/shopping.js +40 -20
  135. package/src/api-public/services/shopping.js.map +1 -1
  136. package/src/api-public/services/shopping.ts +52 -28
  137. package/src/api-public/services/sms-pointes.js.map +1 -1
  138. package/src/api-public/services/stock.js.map +1 -1
  139. package/src/api-public/services/terms-check.js.map +1 -1
  140. package/src/api-public/services/updated-table-checked.js.map +1 -1
  141. package/src/api-public/services/user-update.js.map +1 -1
  142. package/src/api-public/services/user.d.ts +10 -0
  143. package/src/api-public/services/user.js +35 -8
  144. package/src/api-public/services/user.js.map +1 -1
  145. package/src/api-public/services/user.ts +50 -7
  146. package/src/api-public/services/voucher.js.map +1 -1
  147. package/src/api-public/services/wallet.js.map +1 -1
  148. package/src/api-public/utils/ut-database.js.map +1 -1
  149. package/src/app-project/android/app/src/main/AndroidManifest.xml +4 -2
  150. package/src/app-project/android/app/src/main/res/xml/network_security_config.xml +3 -3
  151. package/src/app-project/android/app/src/main/res/xml/s.xml +5 -5
  152. package/src/app-project/android/gradlew.bat +94 -94
  153. package/src/app-project/serverless/src/controllers/index.js.map +1 -1
  154. package/src/app-project/serverless/src/controllers/sample.js.map +1 -1
  155. package/src/app-project/serverless/src/modules/database.d.ts +1 -2
  156. package/src/app-project/serverless/src/modules/database.js.map +1 -1
  157. package/src/app-project/serverless/src/modules/exception.js.map +1 -1
  158. package/src/app-project/serverless/src/modules/hooks.js.map +1 -1
  159. package/src/app-project/serverless/src/modules/logger.js.map +1 -1
  160. package/src/app-project/serverless/src/modules/redis.d.ts +1 -1
  161. package/src/app-project/serverless/src/modules/redis.js.map +1 -1
  162. package/src/app-project/serverless/src/modules/response.js.map +1 -1
  163. package/src/app-project/serverless/src/modules/ssh.js.map +1 -1
  164. package/src/controllers/ai.js.map +1 -1
  165. package/src/controllers/global-event.js.map +1 -1
  166. package/src/controllers/page.js.map +1 -1
  167. package/src/controllers/private_config.js.map +1 -1
  168. package/src/export/export-test.js.map +1 -1
  169. package/src/firebase/message.js +1 -2
  170. package/src/firebase/message.js.map +1 -1
  171. package/src/helper/app_creater.js +1 -2
  172. package/src/helper/app_creater.js.map +1 -1
  173. package/src/helper/glitter-util.d.ts +0 -1
  174. package/src/helper/glitter-util.js.map +1 -1
  175. package/src/lambda/interface.d.ts +1 -1
  176. package/src/lambda/interface.js +2 -2
  177. package/src/lambda/interface.js.map +1 -1
  178. package/src/modules/exception.js.map +1 -1
  179. package/src/modules/hooks.js.map +1 -1
  180. package/src/modules/response.js.map +1 -1
  181. package/src/modules/ssh.js.map +1 -1
  182. package/src/public-config-initial/auto-fcm.js.map +1 -1
  183. package/src/run.js.map +1 -1
  184. package/src/run.ts +12 -12
  185. package/src/services/ai.js.map +1 -1
  186. package/src/services/ses.js +1 -2
  187. package/src/services/ses.js.map +1 -1
  188. package/src/services/system-schedule.js.map +1 -1
  189. package/src/update-progress-track.js.map +1 -1
  190. package/src/update-script.js.map +1 -1
@@ -1,279 +1,292 @@
1
- import {GVC} from '../../glitterBundle/GVController.js';
2
- import {EditorElem} from '../../glitterBundle/plugins/editor-elem.js';
3
- import {ApiShop} from '../../glitter-base/route/shopping.js';
4
- import {BgWidget} from '../../backend-manager/bg-widget.js';
5
- import {BgProduct} from '../../backend-manager/bg-product.js';
6
- import {Tool} from '../../modules/tool.js';
1
+ import { GVC } from '../../glitterBundle/GVController.js';
2
+ import { EditorElem } from '../../glitterBundle/plugins/editor-elem.js';
3
+ import { ApiShop } from '../../glitter-base/route/shopping.js';
4
+ import { BgWidget } from '../../backend-manager/bg-widget.js';
5
+ import { BgProduct } from '../../backend-manager/bg-product.js';
6
+ import { Tool } from '../../modules/tool.js';
7
7
 
8
8
  export class ProductSelect {
9
- public static getData(bundle: { gvc: GVC; formData: any; key: string; callback: (data: any) => void }) {
10
- const glitter = bundle.gvc.glitter;
11
- bundle.formData[bundle.key] = bundle.formData[bundle.key] ?? '';
12
- return bundle.gvc.bindView(() => {
13
- const id = glitter.getUUID();
14
- let interval: any = 0;
15
- const vm = {
16
- title: '',
17
- };
18
- ApiShop.getProduct({
9
+ public static getData(bundle: { gvc: GVC; formData: any; key: string; callback: (data: any) => void }) {
10
+ const glitter = bundle.gvc.glitter;
11
+ bundle.formData[bundle.key] = bundle.formData[bundle.key] ?? '';
12
+ return bundle.gvc.bindView(() => {
13
+ const id = glitter.getUUID();
14
+ let interval: any = 0;
15
+ const vm = {
16
+ title: '',
17
+ };
18
+ ApiShop.getProduct({
19
+ page: 0,
20
+ limit: 50,
21
+ id: bundle.formData[bundle.key],
22
+ }).then(data => {
23
+ if (data.result && data.response.result) {
24
+ vm.title = data.response.data.content.title;
25
+ } else {
26
+ vm.title = '';
27
+ }
28
+ bundle.gvc.notifyDataChange(id);
29
+ });
30
+
31
+ return {
32
+ bind: id,
33
+ view: () => {
34
+ return EditorElem.searchInputDynamic({
35
+ title: '搜尋商品',
36
+ gvc: bundle.gvc,
37
+ def: vm.title,
38
+ search: (text, callback) => {
39
+ clearInterval(interval);
40
+ interval = setTimeout(() => {
41
+ ApiShop.getProduct({
42
+ page: 0,
43
+ limit: 50,
44
+ search: '',
45
+ }).then(data => {
46
+ callback(
47
+ data.response.data.map((dd: any) => {
48
+ return dd.content.title;
49
+ })
50
+ );
51
+ });
52
+ }, 100);
53
+ },
54
+ callback: text => {
55
+ ApiShop.getProduct({
19
56
  page: 0,
20
57
  limit: 50,
21
- id: bundle.formData[bundle.key],
22
- }).then((data) => {
23
- if (data.result && data.response.result) {
24
- vm.title = data.response.data.content.title;
25
- } else {
26
- vm.title = '';
27
- }
28
- bundle.gvc.notifyDataChange(id);
29
- });
58
+ search: text,
59
+ }).then(data => {
60
+ bundle.formData['product_title'] = text;
61
+ bundle.formData[bundle.key] = data.response.data.find((dd: any) => {
62
+ return dd.content.title === text;
63
+ }).id;
64
+ bundle.callback(bundle.formData[bundle.key]);
65
+ });
66
+ },
67
+ placeHolder: '請輸入商品名稱',
68
+ });
69
+ },
70
+ divCreate: {
71
+ style: '',
72
+ },
73
+ };
74
+ });
75
+ }
30
76
 
31
- return {
32
- bind: id,
33
- view: () => {
34
- return EditorElem.searchInputDynamic({
35
- title: '搜尋商品',
36
- gvc: bundle.gvc,
37
- def: vm.title,
38
- search: (text, callback) => {
39
- clearInterval(interval);
40
- interval = setTimeout(() => {
41
- ApiShop.getProduct({
42
- page: 0,
43
- limit: 50,
44
- search: '',
45
- }).then((data) => {
46
- callback(
47
- data.response.data.map((dd: any) => {
48
- return dd.content.title;
49
- })
50
- );
51
- });
52
- }, 100);
53
- },
54
- callback: (text) => {
55
- ApiShop.getProduct({
56
- page: 0,
57
- limit: 50,
58
- search: text,
59
- }).then((data) => {
60
- bundle.formData['product_title'] = text;
61
- bundle.formData[bundle.key] = data.response.data.find((dd: any) => {
62
- return dd.content.title === text;
63
- }).id;
64
- bundle.callback(bundle.formData[bundle.key]);
65
- });
66
- },
67
- placeHolder: '請輸入商品名稱',
68
- });
69
- },
70
- divCreate: {
71
- style: '',
72
- },
73
- };
74
- });
77
+ public static getProducts(bundle: {
78
+ gvc: GVC;
79
+ formData: any;
80
+ key: string;
81
+ callback: (data: any) => void;
82
+ title: string;
83
+ }) {
84
+ const html = String.raw;
85
+ const gvc = bundle.gvc;
86
+ if (Array.isArray(bundle.formData[bundle.key]) || typeof bundle.formData[bundle.key] !== 'object') {
87
+ bundle.formData[bundle.key] = {
88
+ select: 'product',
89
+ };
75
90
  }
76
-
77
- public static getProducts(bundle: {
78
- gvc: GVC;
79
- formData: any;
80
- key: string;
81
- callback: (data: any) => void;
82
- title: string
83
- }) {
84
- const html = String.raw;
85
- const gvc = bundle.gvc;
86
- if (Array.isArray(bundle.formData[bundle.key]) || typeof bundle.formData[bundle.key] !== 'object') {
87
- bundle.formData[bundle.key] = {
88
- select: 'product',
89
- };
90
- }
91
- const subVM: any = {
92
- dataList: [],
93
- id: gvc.glitter.getUUID(),
94
- containerId: Tool.randomString(6),
95
- loading: true,
96
- };
97
- const is_page=(window.parent as any).glitter.getUrlParameter('page').startsWith('shop') || (window.parent as any).glitter.getUrlParameter('page').startsWith('hidden')
98
- //隱形賣場和一頁商店僅能單選
99
- if (is_page) {
100
- if (bundle.formData[bundle.key].select !== 'product') {
101
- bundle.formData[bundle.key].select = 'product'
102
- bundle.formData[bundle.key].value = []
103
- }
104
- }
105
- return gvc.bindView(() => {
106
- return {
107
- bind: subVM.id,
108
- view: () => {
109
- if (subVM.loading) {
110
- return BgWidget.spinner();
111
- }
112
- return new Promise(async (resolve) => {
113
- subVM.dataList = await (async () => {
114
- try {
115
- switch (bundle.formData[bundle.key].select) {
116
- case 'product':
117
- return await BgProduct.getProductOpts(bundle.formData[bundle.key].value);
118
- case 'collection':
119
- return bundle.formData[bundle.key].value;
120
- default:
121
- return [];
122
- }
123
- } catch (e) {
124
- return [];
125
- }
126
- })();
127
- resolve(html`
128
- <div class="d-flex flex-column py-2 my-2 border-top" style="gap: 18px;">
129
- <div class="d-flex align-items-center gray-bottom-line-18 pb-2"
130
- style="gap: 10px; justify-content: space-between;">
131
- <div class="flex-fill ">
132
- ${EditorElem.select({
133
- title: bundle.title,
134
- gvc: gvc,
135
- def: bundle.formData[bundle.key].select,
136
- array: (is_page) ? [{value: 'product', title: '單一商品'}]:[
137
- {value: 'collection', title: '商品系列'},
138
- {value: 'product', title: '單一商品'},
139
- {value: 'all', title: '所有商品'},
140
- ],
141
- callback: (text) => {
142
- bundle.formData[bundle.key].select = text;
143
- bundle.formData[bundle.key].value = [];
144
- bundle.callback(bundle.formData[bundle.key].value);
145
- gvc.notifyDataChange(subVM.id);
146
- },
147
- })}
148
- </div>
149
- <div class="${bundle.formData[bundle.key].select === 'all' ? `d-none` : ``}"
150
- style="margin-top: 30px;">
151
- ${BgWidget.grayButton(
152
- (() => {
153
- switch (bundle.formData[bundle.key].select) {
154
- case 'product':
155
- case 'collection':
156
- return `選取`;
157
- }
158
- return ``;
159
- })(),
160
- gvc.event(() => {
161
- if (bundle.formData[bundle.key].select === 'product') {
162
- bundle.formData[bundle.key].value = bundle.formData[bundle.key].value ?? [];
163
- BgProduct.productsDialog({
164
- gvc: gvc,
165
- default: bundle.formData[bundle.key].value,
166
- callback: async (value) => {
167
- bundle.formData[bundle.key].value = value;
168
- bundle.callback(bundle.formData[bundle.key].value);
169
- gvc.notifyDataChange(subVM.id);
170
- },
171
- });
172
- } else if (bundle.formData[bundle.key].select === 'collection') {
173
- bundle.formData[bundle.key].value = bundle.formData[bundle.key].value ?? [];
174
- BgProduct.collectionsDialog({
175
- gvc: gvc,
176
- default: bundle.formData[bundle.key].value,
177
- callback: async (value) => {
178
- bundle.formData[bundle.key].value = value;
179
- bundle.callback(bundle.formData[bundle.key].value);
180
- gvc.notifyDataChange(subVM.id);
181
- },
182
- });
183
- }
184
- }),
185
- {textStyle: 'font-weight: 400;'}
186
- )}
187
- </div>
188
- </div>
189
- <div class="d-flex flex-column gap-2" id="${subVM.containerId}">
190
- ${gvc.map(
191
- subVM.dataList.map((opt: any, index: number) => {
192
- switch (bundle.formData[bundle.key].select) {
193
- case 'collection':
194
- return html`
195
- <div class="d-flex align-items-center form-check-label c_updown_label gap-3">
196
- <span class="tx_normal">${index + 1}. ${opt}</span>
197
- </div>`;
198
- case 'product':
199
- return html`
200
- <div class="d-flex align-items-center form-check-label c_updown_label px-1"
201
- style="justify-content: space-between"
202
- data-index="${opt.key}">
203
- <div class="d-flex align-items-center gap-3 cursor_move" style="max-width: calc(100% - 50px);">
204
- <i class="fa-solid fa-grip-dots-vertical dragItem"></i>
205
- ${BgWidget.validImageBox({
206
- gvc,
207
- image: opt.image,
208
- width: 40,
209
- })}
210
- <div class="tx_normal ${opt.note ? 'mb-1' : ''}" style="white-space:normal;">
211
- ${opt.value}
212
- </div>
213
- </div>
214
- <i
215
- class="fa-regular fa-trash cursor_pointer"
216
- onclick="${gvc.event(() => {
217
- bundle.formData[bundle.key].value = bundle.formData[bundle.key].value.filter((id: number) => {
218
- return id !== opt.key;
219
- });
220
- bundle.callback(bundle.formData[bundle.key].value);
221
- gvc.notifyDataChange(subVM.id);
222
- })}"
223
- ></i>
224
- </div>`;
225
- case 'all':
226
- return ``;
227
- }
228
- })
229
- )}
230
- </div>
231
- </div>`);
232
- });
233
- },
234
- onCreate: () => {
235
- if (subVM.loading) {
236
- gvc.addMtScript(
237
- [
238
- {
239
- src: 'https://cdn.jsdelivr.net/npm/sortablejs@1.15.0/Sortable.min.js',
240
- },
241
- ],
242
- () => {
243
- const si = setInterval(() => {
244
- if ((window as any).Sortable !== undefined) {
245
- subVM.loading = false;
246
- clearInterval(si);
247
- gvc.notifyDataChange(subVM.id);
248
- }
249
- }, 300);
91
+ const subVM: any = {
92
+ dataList: [],
93
+ id: gvc.glitter.getUUID(),
94
+ containerId: Tool.randomString(6),
95
+ loading: true,
96
+ };
97
+ const is_page =
98
+ (window.parent as any).glitter.getUrlParameter('page').startsWith('shop') ||
99
+ (window.parent as any).glitter.getUrlParameter('page').startsWith('hidden');
100
+ //隱形賣場和一頁商店僅能單選
101
+ if (is_page) {
102
+ if (bundle.formData[bundle.key].select !== 'product') {
103
+ bundle.formData[bundle.key].select = 'product';
104
+ bundle.formData[bundle.key].value = [];
105
+ }
106
+ }
107
+ return gvc.bindView(() => {
108
+ return {
109
+ bind: subVM.id,
110
+ view: () => {
111
+ if (subVM.loading) {
112
+ return BgWidget.spinner();
113
+ }
114
+ return new Promise(async resolve => {
115
+ subVM.dataList = await (async () => {
116
+ try {
117
+ switch (bundle.formData[bundle.key].select) {
118
+ case 'product':
119
+ return await BgProduct.getProductOpts(bundle.formData[bundle.key].value);
120
+ case 'collection':
121
+ return bundle.formData[bundle.key].value;
122
+ default:
123
+ return [];
124
+ }
125
+ } catch (e) {
126
+ return [];
127
+ }
128
+ })();
129
+ resolve(
130
+ html` <div class="d-flex flex-column py-2 my-2 border-top" style="gap: 18px;">
131
+ <div
132
+ class="d-flex align-items-center gray-bottom-line-18 pb-2"
133
+ style="gap: 10px; justify-content: space-between;"
134
+ >
135
+ <div class="flex-fill ">
136
+ ${EditorElem.select({
137
+ title: bundle.title,
138
+ gvc: gvc,
139
+ def: bundle.formData[bundle.key].select,
140
+ array: is_page
141
+ ? [{ value: 'product', title: '特定商品' }]
142
+ : [
143
+ { value: 'collection', title: '商品系列' },
144
+ { value: 'product', title: '特定商品' },
145
+ { value: 'all', title: '所有商品' },
146
+ ],
147
+ callback: text => {
148
+ bundle.formData[bundle.key].select = text;
149
+ bundle.formData[bundle.key].value = [];
150
+ bundle.callback(bundle.formData[bundle.key].value);
151
+ gvc.notifyDataChange(subVM.id);
152
+ },
153
+ })}
154
+ </div>
155
+ <div
156
+ class="${bundle.formData[bundle.key].select === 'all' ? `d-none` : ``}"
157
+ style="margin-top: 30px;"
158
+ >
159
+ ${BgWidget.grayButton(
160
+ (() => {
161
+ switch (bundle.formData[bundle.key].select) {
162
+ case 'product':
163
+ case 'collection':
164
+ return `選取`;
165
+ }
166
+ return ``;
167
+ })(),
168
+ gvc.event(() => {
169
+ if (bundle.formData[bundle.key].select === 'product') {
170
+ bundle.formData[bundle.key].value = bundle.formData[bundle.key].value ?? [];
171
+ BgProduct.productsDialog({
172
+ gvc: gvc,
173
+ default: bundle.formData[bundle.key].value,
174
+ callback: async value => {
175
+ bundle.formData[bundle.key].value = value;
176
+ bundle.callback(bundle.formData[bundle.key].value);
177
+ gvc.notifyDataChange(subVM.id);
250
178
  },
251
- () => {
252
- }
253
- );
254
- } else {
255
- const el = document.querySelector(`#${subVM.containerId}`) as HTMLElement;
256
- (window as any).Sortable.create(el, {
257
- animation: 150,
258
- handle: '.dragItem',
259
- onEnd: function () {
260
- const elements = el.querySelectorAll('[data-index]');
261
- const dataIndices = Array.from(elements).map((element) => element.getAttribute('data-index'));
262
- const value = dataIndices.map((index) => {
263
- if (index) {
264
- return parseInt(index, 10);
265
- }
266
- });
267
- bundle.formData[bundle.key].value = value;
179
+ });
180
+ } else if (bundle.formData[bundle.key].select === 'collection') {
181
+ bundle.formData[bundle.key].value = bundle.formData[bundle.key].value ?? [];
182
+ BgProduct.collectionsDialog({
183
+ gvc: gvc,
184
+ default: bundle.formData[bundle.key].value,
185
+ callback: async value => {
186
+ bundle.formData[bundle.key].value = value;
187
+ bundle.callback(bundle.formData[bundle.key].value);
188
+ gvc.notifyDataChange(subVM.id);
189
+ },
190
+ });
191
+ }
192
+ }),
193
+ { textStyle: 'font-weight: 400;' }
194
+ )}
195
+ </div>
196
+ </div>
197
+ <div class="d-flex flex-column gap-2" id="${subVM.containerId}">
198
+ ${gvc.map(
199
+ subVM.dataList.map((opt: any, index: number) => {
200
+ switch (bundle.formData[bundle.key].select) {
201
+ case 'collection':
202
+ return html` <div class="d-flex align-items-center form-check-label c_updown_label gap-3">
203
+ <span class="tx_normal">${index + 1}. ${opt}</span>
204
+ </div>`;
205
+ case 'product':
206
+ return html` <div
207
+ class="d-flex align-items-center form-check-label c_updown_label px-1"
208
+ style="justify-content: space-between"
209
+ data-index="${opt.key}"
210
+ >
211
+ <div
212
+ class="d-flex align-items-center gap-3 cursor_move"
213
+ style="max-width: calc(100% - 50px);"
214
+ >
215
+ <i class="fa-solid fa-grip-dots-vertical dragItem"></i>
216
+ ${BgWidget.validImageBox({
217
+ gvc,
218
+ image: opt.image,
219
+ width: 40,
220
+ })}
221
+ <div class="tx_normal ${opt.note ? 'mb-1' : ''}" style="white-space:normal;">
222
+ ${opt.value}
223
+ </div>
224
+ </div>
225
+ <i
226
+ class="fa-regular fa-trash cursor_pointer"
227
+ onclick="${gvc.event(() => {
228
+ bundle.formData[bundle.key].value = bundle.formData[bundle.key].value.filter(
229
+ (id: number) => {
230
+ return id !== opt.key;
231
+ }
232
+ );
268
233
  bundle.callback(bundle.formData[bundle.key].value);
269
234
  gvc.notifyDataChange(subVM.id);
270
- },
271
- });
272
- }
235
+ })}"
236
+ ></i>
237
+ </div>`;
238
+ case 'all':
239
+ return ``;
240
+ }
241
+ })
242
+ )}
243
+ </div>
244
+ </div>`
245
+ );
246
+ });
247
+ },
248
+ onCreate: () => {
249
+ if (subVM.loading) {
250
+ gvc.addMtScript(
251
+ [
252
+ {
253
+ src: 'https://cdn.jsdelivr.net/npm/sortablejs@1.15.0/Sortable.min.js',
273
254
  },
274
- };
275
- });
276
- }
255
+ ],
256
+ () => {
257
+ const si = setInterval(() => {
258
+ if ((window as any).Sortable !== undefined) {
259
+ subVM.loading = false;
260
+ clearInterval(si);
261
+ gvc.notifyDataChange(subVM.id);
262
+ }
263
+ }, 300);
264
+ },
265
+ () => {}
266
+ );
267
+ } else {
268
+ const el = document.querySelector(`#${subVM.containerId}`) as HTMLElement;
269
+ (window as any).Sortable.create(el, {
270
+ animation: 150,
271
+ handle: '.dragItem',
272
+ onEnd: function () {
273
+ const elements = el.querySelectorAll('[data-index]');
274
+ const dataIndices = Array.from(elements).map(element => element.getAttribute('data-index'));
275
+ const value = dataIndices.map(index => {
276
+ if (index) {
277
+ return parseInt(index, 10);
278
+ }
279
+ });
280
+ bundle.formData[bundle.key].value = value;
281
+ bundle.callback(bundle.formData[bundle.key].value);
282
+ gvc.notifyDataChange(subVM.id);
283
+ },
284
+ });
285
+ }
286
+ },
287
+ };
288
+ });
289
+ }
277
290
  }
278
291
 
279
292
  (window as any).glitter.setModule(import.meta.url, ProductSelect);
@@ -259,6 +259,7 @@ export class Language {
259
259
  { key: 'send_to_user_email', tw: '傳送至用戶信箱', cn: '传送至用户邮箱', en: 'Send to user email' },
260
260
  { key: 'mobile_barcode_device', tw: '手機條碼載具', cn: '手机条码载具', en: 'Mobile barcode device' },
261
261
  { key: 'add_to_cart', tw: '加入購物車', cn: '加入购物车', en: 'Add to Cart' },
262
+ { key: 'preorder_item', tw: '預購商品', cn: '预购商品', en: 'Preorder Item' },
262
263
  { key: 'confirm_select', tw: '確認選擇', cn: '确认选择', en: 'Confirm selection' },
263
264
  { key: 'add_to_cart_success', tw: '加入成功', cn: '加入成功', en: 'Added successfully' },
264
265
  {
@@ -435,7 +436,7 @@ export class Language {
435
436
  { key: 'search', tw: '搜尋', cn: '搜索', en: 'Search' },
436
437
  { key: 'all_products', tw: '所有商品', cn: '所有商品', en: 'All Products' },
437
438
  { key: 'product_categories', tw: '商品分類', cn: '商品分类', en: 'Product Categories' },
438
- { key: 'products', tw: '單一商品', cn: '单一商品', en: 'Products' },
439
+ { key: 'products', tw: '特定商品', cn: '特定商品', en: 'Products' },
439
440
  { key: 'filter', tw: '篩選', cn: '筛选', en: 'Filter' },
440
441
  { key: 'sort_by_date', tw: '依照系統預設', cn: '依照系統預設', en: 'Sort by Default' },
441
442
  { key: 'sort_by_price_asc', tw: '價格由低至高', cn: '价格由低到高', en: 'Price Low to High' },
@@ -268,6 +268,7 @@ export class Language {
268
268
  { key: 'send_to_user_email', tw: '傳送至用戶信箱', cn: '传送至用户邮箱', en: 'Send to user email' },
269
269
  { key: 'mobile_barcode_device', tw: '手機條碼載具', cn: '手机条码载具', en: 'Mobile barcode device' },
270
270
  { key: 'add_to_cart', tw: '加入購物車', cn: '加入购物车', en: 'Add to Cart' },
271
+ { key: 'preorder_item', tw: '預購商品', cn: '预购商品', en: 'Preorder Item' },
271
272
  { key: 'confirm_select', tw: '確認選擇', cn: '确认选择', en: 'Confirm selection' },
272
273
  { key: 'add_to_cart_success', tw: '加入成功', cn: '加入成功', en: 'Added successfully' },
273
274
  {
@@ -444,7 +445,7 @@ export class Language {
444
445
  { key: 'search', tw: '搜尋', cn: '搜索', en: 'Search' },
445
446
  { key: 'all_products', tw: '所有商品', cn: '所有商品', en: 'All Products' },
446
447
  { key: 'product_categories', tw: '商品分類', cn: '商品分类', en: 'Product Categories' },
447
- { key: 'products', tw: '單一商品', cn: '单一商品', en: 'Products' },
448
+ { key: 'products', tw: '特定商品', cn: '特定商品', en: 'Products' },
448
449
  { key: 'filter', tw: '篩選', cn: '筛选', en: 'Filter' },
449
450
  { key: 'sort_by_date', tw: '依照系統預設', cn: '依照系統預設', en: 'Sort by Default' },
450
451
  { key: 'sort_by_price_asc', tw: '價格由低至高', cn: '价格由低到高', en: 'Price Low to High' },