ts-glitter 22.4.7 → 22.5.0

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 (98) hide show
  1. package/lib/glitterBundle/Glitter.css +74 -62
  2. package/lowcode/Entry.js +1 -1
  3. package/lowcode/Entry.ts +1 -1
  4. package/lowcode/backend-manager/bg-product.js +49 -32
  5. package/lowcode/backend-manager/bg-product.ts +57 -39
  6. package/lowcode/backend-manager/bg-widget.js +17 -0
  7. package/lowcode/backend-manager/bg-widget.ts +18 -0
  8. package/lowcode/cms-plugin/information/information-module.js +5 -5
  9. package/lowcode/cms-plugin/information/information-module.ts +9 -5
  10. package/lowcode/cms-plugin/menus-setting.js +69 -55
  11. package/lowcode/cms-plugin/menus-setting.ts +77 -61
  12. package/lowcode/cms-plugin/module/form-module.js +109 -89
  13. package/lowcode/cms-plugin/module/form-module.ts +680 -650
  14. package/lowcode/cms-plugin/module/product-excel.js +1 -0
  15. package/lowcode/cms-plugin/module/product-excel.ts +2 -0
  16. package/lowcode/cms-plugin/pos-pages/payment-page.js +28 -10
  17. package/lowcode/cms-plugin/pos-pages/payment-page.ts +29 -10
  18. package/lowcode/cms-plugin/shopping-allowance-manager.js +0 -1
  19. package/lowcode/cms-plugin/shopping-allowance-manager.ts +0 -1
  20. package/lowcode/cms-plugin/shopping-collections.js +367 -193
  21. package/lowcode/cms-plugin/shopping-collections.ts +664 -243
  22. package/lowcode/cms-plugin/shopping-information.js +392 -38
  23. package/lowcode/cms-plugin/shopping-information.ts +479 -87
  24. package/lowcode/cms-plugin/shopping-product-setting.js +2 -2
  25. package/lowcode/cms-plugin/shopping-product-setting.ts +2 -2
  26. package/lowcode/cms-plugin/shopping-setting-advance.js +906 -766
  27. package/lowcode/cms-plugin/shopping-setting-advance.ts +977 -841
  28. package/lowcode/cms-plugin/shopping-setting-basic.js +1547 -1285
  29. package/lowcode/cms-plugin/shopping-setting-basic.ts +1742 -1466
  30. package/lowcode/cms-plugin/stock-stores.js +1 -0
  31. package/lowcode/cms-plugin/stock-stores.ts +1 -0
  32. package/lowcode/cms-plugin/user-list.js +47 -12
  33. package/lowcode/cms-plugin/user-list.ts +52 -14
  34. package/lowcode/css/editor.css +6 -0
  35. package/lowcode/glitterBundle/Glitter.css +74 -62
  36. package/lowcode/jslib/nestable/index.html +317 -0
  37. package/lowcode/jslib/nestable/jquery.nestable.js +484 -0
  38. package/lowcode/official_view_component/form-widget/input-custom.js +98 -6
  39. package/lowcode/official_view_component/form-widget/input-custom.ts +121 -16
  40. package/lowcode/public-components/headers/header-class.js +63 -0
  41. package/lowcode/public-components/headers/header-class.ts +65 -0
  42. package/lowcode/public-components/headers/sy-02.js +386 -400
  43. package/lowcode/public-components/headers/sy-02.ts +482 -492
  44. package/lowcode/public-components/headers/sy-03.js +42 -43
  45. package/lowcode/public-components/headers/sy-03.ts +46 -43
  46. package/lowcode/public-components/headers/sy-04.js +43 -41
  47. package/lowcode/public-components/headers/sy-04.ts +48 -41
  48. package/lowcode/public-components/headers/sy-05.js +30 -27
  49. package/lowcode/public-components/headers/sy-05.ts +33 -27
  50. package/lowcode/public-components/product/product-list.js +160 -148
  51. package/lowcode/public-components/product/product-list.ts +186 -165
  52. package/lowcode/public-models/product.ts +26 -1
  53. package/lowcode/src/glitterBundle/Glitter.css +74 -62
  54. package/package.json +1 -1
  55. package/rxmnt81tnk.json +1 -0
  56. package/src/api-public/controllers/shop.js +10 -4
  57. package/src/api-public/controllers/shop.js.map +1 -1
  58. package/src/api-public/controllers/shop.ts +14 -9
  59. package/src/api-public/services/ezpay/tool.d.ts +1 -0
  60. package/src/api-public/services/mail.js +1 -1
  61. package/src/api-public/services/mail.js.map +1 -1
  62. package/src/api-public/services/mail.ts +1 -1
  63. package/src/api-public/services/schedule.d.ts +0 -1
  64. package/src/api-public/services/schedule.js +12 -35
  65. package/src/api-public/services/schedule.js.map +1 -1
  66. package/src/api-public/services/schedule.ts +15 -39
  67. package/src/api-public/services/shopee.js +7 -17
  68. package/src/api-public/services/shopping.d.ts +27 -6
  69. package/src/api-public/services/shopping.js +364 -85
  70. package/src/api-public/services/shopping.js.map +1 -1
  71. package/src/api-public/services/shopping.ts +510 -101
  72. package/src/api-public/services/updated-table-checked.js +58 -1
  73. package/src/api-public/services/updated-table-checked.js.map +1 -1
  74. package/src/api-public/services/updated-table-checked.ts +62 -1
  75. package/src/api-public/services/user-update.js +14 -0
  76. package/src/api-public/services/user-update.js.map +1 -1
  77. package/src/api-public/services/user-update.ts +15 -0
  78. package/src/api-public/services/user.js +1 -1
  79. package/src/api-public/services/user.js.map +1 -1
  80. package/src/api-public/services/user.ts +1 -1
  81. package/src/app-project/serverless/src/modules/database.d.ts +1 -1
  82. package/src/app-project/serverless/src/modules/redis.d.ts +1 -1
  83. package/src/helper/glitter-util.d.ts +1 -0
  84. package/src/index.js +7 -5
  85. package/src/index.js.map +1 -1
  86. package/src/index.ts +45 -38
  87. package/src/modules/firebase.js +1 -0
  88. package/src/modules/firebase.js.map +1 -1
  89. package/src/modules/firebase.ts +1 -0
  90. package/src/seo-config.d.ts +1 -1
  91. package/src/seo-config.js +1 -2
  92. package/src/seo-config.js.map +1 -1
  93. package/src/seo-config.ts +1 -2
  94. package/src/services/saas-table-check.js.map +1 -1
  95. package/src/services/ses.js +4 -3
  96. package/src/services/ses.js.map +1 -1
  97. package/src/services/system-schedule.js.map +1 -1
  98. package/src/services/system-schedule.ts +1 -0
@@ -12,26 +12,136 @@ import { BgProduct } from '../backend-manager/bg-product.js';
12
12
  import { ApiUser } from '../glitter-base/route/user.js';
13
13
  import { QuestionInfo } from './module/question-info.js';
14
14
  import { Tool } from '../modules/tool.js';
15
+ import { ShareDialog } from '../glitterBundle/dialog/ShareDialog.js';
15
16
  const html = String.raw;
17
+ const css = String.raw;
16
18
  export class ShoppingSettingAdvance {
17
19
  static main(obj) {
18
20
  const gvc = obj.gvc;
19
21
  const postMD = obj.postMD;
20
22
  const vm = obj.vm2;
23
+ const section_ID = {
24
+ tag: gvc.glitter.getUUID(),
25
+ };
21
26
  const categoryTitles = {
22
27
  commodity: '商品',
23
28
  course: '課程',
29
+ reserve: '預約'
24
30
  };
31
+ const id = section_ID.tag;
25
32
  const carTitle = categoryTitles[postMD.product_category] || '商品';
26
- return BgWidget.container(gvc.bindView(() => {
27
- const id = gvc.glitter.getUUID();
28
- return {
29
- bind: id,
30
- view: () => {
31
- var _a, _b;
32
- return [
33
- BgWidget.mainCard([
34
- html `
33
+ const dialog = new ShareDialog(gvc.glitter);
34
+ function drawReverseSection() {
35
+ var _a;
36
+ if (carTitle == "reserve") {
37
+ return ``;
38
+ }
39
+ gvc.addStyle(css `
40
+ .available-input{
41
+ height: 40px;
42
+ padding: 0 18px;
43
+ flex: 1 0 0;
44
+ gap: 10px;
45
+ border-radius: 10px;
46
+ border: 1px solid #DDD;
47
+ box-sizing: border-box;
48
+ }
49
+ `);
50
+ postMD.available_time = (_a = postMD.available_time) !== null && _a !== void 0 ? _a : {
51
+ earliest: {
52
+ value: "1",
53
+ unit: "month",
54
+ },
55
+ latest: {
56
+ value: "1",
57
+ unit: "day",
58
+ },
59
+ };
60
+ return BgWidget.mainCard(html `
61
+ <div class="d-flex flex-column" style="gap: 18px;">
62
+ <div class="tx_700">預約設定</div>
63
+ <div class="d-flex flex-column" style="gap: 8px;">
64
+ <div class="d-flex flex-column" style="gap: 4px">
65
+ <div class="tx_700">最早可預約時間</div>
66
+ <div class="tx_gray_14">最早可接受預約的時間,例如提前1個月</div>
67
+ </div>
68
+ <div class="d-flex " style="gap: 18px;">
69
+ <div class="d-flex align-items-center available-input w-50">
70
+ <input class="border-0 w-100" type="number" onchange="${gvc.event((e) => {
71
+ if (postMD.available_time.earliest.unit == 'day') {
72
+ if (Number(e.value) > 30) {
73
+ dialog.infoMessage({
74
+ text: "請設定小於30天",
75
+ callback: () => {
76
+ e.value = postMD.available_time.latest.value;
77
+ }
78
+ });
79
+ }
80
+ if (Number(e.value) > Number(postMD.available_time.latest.value)) {
81
+ dialog.infoMessage({
82
+ text: "最早可預約時間需早於最晚可預約時間",
83
+ callback: () => {
84
+ e.value = postMD.available_time.latest.value;
85
+ }
86
+ });
87
+ }
88
+ postMD.available_time.earliest.value = e.value;
89
+ }
90
+ else {
91
+ postMD.available_time.earliest.value = e.value;
92
+ }
93
+ })}">
94
+ </div>
95
+ <div class="w-50" style="box-sizing: border-box">
96
+ ${BgWidget.select({
97
+ default: postMD.available_time.earliest.unit,
98
+ gvc: gvc,
99
+ options: [
100
+ {
101
+ value: "月",
102
+ key: "month"
103
+ },
104
+ {
105
+ value: "日",
106
+ key: "day"
107
+ },
108
+ ],
109
+ callback(value) {
110
+ postMD.available_time.earliest.unit = value;
111
+ },
112
+ })}
113
+ </div>
114
+ </div>
115
+ </div>
116
+ <div >
117
+ <div class="d-flex flex-column" style="gap: 4px;margin-bottom: 8px;">
118
+ <div class="tx_700">最晚可預約時間</div>
119
+ <div class="tx_gray_14">最晚可接受預約的時間,例如提前1天前</div>
120
+ </div>
121
+ <div class="d-flex align-items-center available-input w-100 flex-shrink-0">
122
+ <input class="border-0 w-100" type="number" onchange="${gvc.event((e) => {
123
+ if (e.value > 30) {
124
+ dialog.infoMessage({
125
+ text: "請設定小於30天",
126
+ callback: () => {
127
+ e.value = postMD.available_time.latest.value;
128
+ }
129
+ });
130
+ }
131
+ else {
132
+ postMD.available_time.latest.value = e.value;
133
+ }
134
+ })}">
135
+ <div class="ms-auto tx_gray_16">天</div>
136
+ </div>
137
+ </div>
138
+ </div>
139
+ `);
140
+ }
141
+ function drawTagSection() {
142
+ var _a;
143
+ return BgWidget.mainCard([
144
+ html `
35
145
  <div class="guide5-4">
36
146
  <div class="d-flex align-items-center justify-content-between">
37
147
  <div>
@@ -42,219 +152,221 @@ export class ShoppingSettingAdvance {
42
152
  ${BgWidget.grayNote('用戶於前台搜尋標籤,即可搜尋到此' + carTitle)} ${BgWidget.mbContainer(4)}
43
153
  </div>
44
154
  ${BgWidget.blueNote('使用現有標籤', gvc.event(() => {
45
- var _a;
46
- BgProduct.useProductTags({
47
- gvc,
48
- config_key: 'product_general_tags',
49
- config_lang: vm.language,
50
- def: (_a = postMD.product_tag.language[vm.language]) !== null && _a !== void 0 ? _a : [],
51
- callback: tags => {
52
- postMD.product_tag.language[vm.language] = tags;
53
- gvc.notifyDataChange(id);
54
- },
55
- });
56
- }))}
155
+ var _a;
156
+ BgProduct.useProductTags({
157
+ gvc,
158
+ config_key: 'product_general_tags',
159
+ config_lang: vm.language,
160
+ def: (_a = postMD.product_tag.language[vm.language]) !== null && _a !== void 0 ? _a : [],
161
+ callback: tags => {
162
+ postMD.product_tag.language[vm.language] = tags;
163
+ gvc.notifyDataChange(id);
164
+ },
165
+ });
166
+ }))}
57
167
  </div>
58
168
  ${BgWidget.multipleInput(gvc, postMD.product_tag.language[vm.language], {
59
- save: def => {
60
- postMD.product_tag.language[vm.language] = def;
61
- },
62
- })}
169
+ save: def => {
170
+ postMD.product_tag.language[vm.language] = def;
171
+ },
172
+ })}
63
173
  </div>
64
174
  `,
65
- html `
175
+ html `
66
176
  <div class="d-flex align-items-center justify-content-between">
67
177
  <div>
68
178
  <div style="color: #393939; font-weight: 700;">${carTitle}管理員標籤</div>
69
179
  ${BgWidget.grayNote('操作後台人員登記與分類用,不會顯示於前台')} ${BgWidget.mbContainer(4)}
70
180
  </div>
71
181
  ${BgWidget.blueNote('使用現有標籤', gvc.event(() => {
72
- var _a;
73
- BgProduct.useProductTags({
74
- gvc,
75
- config_key: 'product_manager_tags',
76
- def: (_a = postMD.product_customize_tag) !== null && _a !== void 0 ? _a : [],
77
- callback: tags => {
78
- postMD.product_customize_tag = tags;
79
- gvc.notifyDataChange(id);
80
- },
81
- });
82
- }))}
182
+ var _a;
183
+ BgProduct.useProductTags({
184
+ gvc,
185
+ config_key: 'product_manager_tags',
186
+ def: (_a = postMD.product_customize_tag) !== null && _a !== void 0 ? _a : [],
187
+ callback: tags => {
188
+ postMD.product_customize_tag = tags;
189
+ gvc.notifyDataChange(id);
190
+ },
191
+ });
192
+ }))}
83
193
  </div>
84
194
  ${BgWidget.multipleInput(gvc, (_a = postMD.product_customize_tag) !== null && _a !== void 0 ? _a : [], {
85
- save: def => {
86
- postMD.product_customize_tag = [...new Set(def)];
87
- },
88
- }, true)}
195
+ save: def => {
196
+ postMD.product_customize_tag = [...new Set(def)];
197
+ },
198
+ }, true)}
89
199
  `,
90
- html ` <div class="d-flex align-items-center gap-2">
200
+ html ` <div class="d-flex align-items-center gap-2">
91
201
  <div style="color: #393939; font-weight: 700;">${carTitle}促銷標籤</div>
92
202
  ${BgWidget.questionButton(gvc.event(() => {
93
- QuestionInfo.promoteLabel(gvc);
94
- }))}
203
+ QuestionInfo.promoteLabel(gvc);
204
+ }))}
95
205
  </div>
96
206
  ${BgWidget.mbContainer(8)}
97
207
  ${gvc.bindView((() => {
98
- const id = gvc.glitter.getUUID();
99
- let options = [];
100
- ApiUser.getPublicConfig('promo-label', 'manager').then(data => {
101
- var _a;
102
- if (data.result && Array.isArray((_a = data.response) === null || _a === void 0 ? void 0 : _a.value)) {
103
- options = [
104
- ...data.response.value.map(({ id, title }) => ({
105
- key: id,
106
- value: title,
107
- })),
108
- { key: '', value: '不設定' },
109
- ];
110
- }
208
+ const id = gvc.glitter.getUUID();
209
+ let options = [];
210
+ ApiUser.getPublicConfig('promo-label', 'manager').then(data => {
211
+ var _a;
212
+ if (data.result && Array.isArray((_a = data.response) === null || _a === void 0 ? void 0 : _a.value)) {
213
+ options = [
214
+ ...data.response.value.map(({ id, title }) => ({
215
+ key: id,
216
+ value: title,
217
+ })),
218
+ { key: '', value: '不設定' },
219
+ ];
220
+ }
221
+ gvc.notifyDataChange(id);
222
+ });
223
+ return {
224
+ bind: id,
225
+ view: () => {
226
+ return BgWidget.select({
227
+ gvc: obj.gvc,
228
+ default: postMD.label || '',
229
+ options: options,
230
+ callback: (text) => {
231
+ postMD.label = text || undefined;
111
232
  gvc.notifyDataChange(id);
112
- });
113
- return {
114
- bind: id,
115
- view: () => {
116
- return BgWidget.select({
117
- gvc: obj.gvc,
118
- default: postMD.label || '',
119
- options: options,
120
- callback: (text) => {
121
- postMD.label = text || undefined;
122
- gvc.notifyDataChange(id);
123
- },
124
- });
125
- },
126
- };
127
- })())}`,
128
- postMD.product_category === 'course'
129
- ? ''
130
- : html ` <div class="d-flex align-items-center">
233
+ },
234
+ });
235
+ },
236
+ };
237
+ })())}`,
238
+ postMD.product_category === 'course'
239
+ ? ''
240
+ : html ` <div class="d-flex align-items-center">
131
241
  <div style="color: #393939; font-weight: 700;">數量單位</div>
132
242
  ${BgWidget.languageInsignia(vm.language, 'margin-left:5px;')}
133
243
  </div>
134
244
  ${BgWidget.grayNote('例如 : 坪、件、個、打,預設單位為件。')}
135
245
  ${BgWidget.editeInput({
136
- gvc: obj.gvc,
137
- default: `${postMD.unit[vm.language] || ''}`,
138
- title: '',
139
- type: 'text',
140
- placeHolder: '件',
141
- callback: (text) => {
142
- postMD.unit[vm.language] = text;
143
- gvc.notifyDataChange(id);
144
- },
145
- })}`,
146
- html `
246
+ gvc: obj.gvc,
247
+ default: `${postMD.unit[vm.language] || ''}`,
248
+ title: '',
249
+ type: 'text',
250
+ placeHolder: '件',
251
+ callback: (text) => {
252
+ postMD.unit[vm.language] = text;
253
+ gvc.notifyDataChange(id);
254
+ },
255
+ })}`,
256
+ html `
147
257
  <div class="d-flex align-items-center">
148
258
  <div style="color: #393939; font-weight: 700;">排序權重</div>
149
259
  </div>
150
260
  ${BgWidget.grayNote('數字越大商品排序會越靠前。')}
151
261
  ${BgWidget.editeInput({
152
- gvc: obj.gvc,
153
- default: `${postMD.sort_weight || ''}`,
154
- title: '',
155
- type: 'text',
156
- placeHolder: '數字越大商品排序會越靠前',
157
- callback: (text) => {
158
- postMD.sort_weight = text;
159
- gvc.notifyDataChange(id);
160
- },
161
- })}
262
+ gvc: obj.gvc,
263
+ default: `${postMD.sort_weight || ''}`,
264
+ title: '',
265
+ type: 'text',
266
+ placeHolder: '數字越大商品排序會越靠前',
267
+ callback: (text) => {
268
+ postMD.sort_weight = text;
269
+ gvc.notifyDataChange(id);
270
+ },
271
+ })}
162
272
  `,
163
- ]
164
- .filter(Boolean)
165
- .join(BgWidget.mbContainer(18))),
166
- BgWidget.mainCard([
167
- html `
273
+ ]
274
+ .filter(Boolean)
275
+ .join(BgWidget.mbContainer(18)));
276
+ }
277
+ function drawBuyLimit() {
278
+ return BgWidget.mainCard([
279
+ html `
168
280
  <div class="d-flex flex-column guide5-4">
169
281
  <div style="font-weight: 700;" class="mb-2">${carTitle}購買限制</div>
170
282
  </div>
171
283
  `,
172
- ...(postMD.productType.giveaway
173
- ? []
174
- : [
175
- {
176
- title: '最低需要購買多少',
177
- key: 'min_qty',
178
- checked: postMD.min_qty,
179
- },
180
- {
181
- title: '最高只能購買多少',
182
- key: 'max_qty',
183
- checked: postMD.max_qty,
184
- },
185
- {
186
- title: `需連同特定${carTitle}一併購買`,
187
- key: 'match_by_with',
188
- checked: postMD.match_by_with,
189
- },
284
+ ...(postMD.productType.giveaway
285
+ ? []
286
+ : [
287
+ {
288
+ title: `最低需要${carTitle}多少`,
289
+ key: 'min_qty',
290
+ checked: postMD.min_qty,
291
+ },
292
+ {
293
+ title: `最高只能${carTitle}多少`,
294
+ key: 'max_qty',
295
+ checked: postMD.max_qty,
296
+ },
297
+ {
298
+ title: `需連同特定${carTitle}一併購買`,
299
+ key: 'match_by_with',
300
+ checked: postMD.match_by_with,
301
+ },
302
+ {
303
+ title: `過往購買過特定${carTitle}才能購買此${carTitle}`,
304
+ key: 'legacy_by_with',
305
+ checked: postMD.legacy_by_with,
306
+ },
307
+ ].map(dd => {
308
+ const stringArray = [
309
+ BgWidget.inlineCheckBox({
310
+ title: '',
311
+ gvc: gvc,
312
+ def: [dd.checked ? dd.key : ''],
313
+ array: [
190
314
  {
191
- title: `過往購買過特定${carTitle}才能購買此${carTitle}`,
192
- key: 'legacy_by_with',
193
- checked: postMD.legacy_by_with,
315
+ title: dd.title,
316
+ value: dd.key,
194
317
  },
195
- ].map(dd => {
196
- const stringArray = [
197
- BgWidget.inlineCheckBox({
198
- title: '',
199
- gvc: gvc,
200
- def: [dd.checked ? dd.key : ''],
201
- array: [
202
- {
203
- title: dd.title,
204
- value: dd.key,
205
- },
206
- ],
207
- callback: () => {
208
- const handleToggle = (key, defaultValue) => {
209
- if (postMD[key]) {
210
- delete postMD[key];
211
- }
212
- else {
213
- postMD[key] = defaultValue;
214
- }
215
- gvc.notifyDataChange(id);
216
- };
217
- switch (dd.key) {
218
- case 'min_qty':
219
- case 'max_qty':
220
- handleToggle(dd.key, 1);
221
- break;
222
- case 'match_by_with':
223
- case 'legacy_by_with':
224
- handleToggle(dd.key, []);
225
- break;
226
- }
227
- },
228
- type: 'multiple',
229
- }),
230
- ];
231
- if (dd.checked) {
232
- switch (dd.key) {
233
- case 'min_qty':
234
- case 'max_qty':
235
- stringArray.push(html ` <div class="d-flex align-items-center fw-500" style="gap:10px;">
318
+ ],
319
+ callback: () => {
320
+ const handleToggle = (key, defaultValue) => {
321
+ if (postMD[key]) {
322
+ delete postMD[key];
323
+ }
324
+ else {
325
+ postMD[key] = defaultValue;
326
+ }
327
+ gvc.notifyDataChange(id);
328
+ };
329
+ switch (dd.key) {
330
+ case 'min_qty':
331
+ case 'max_qty':
332
+ handleToggle(dd.key, 1);
333
+ break;
334
+ case 'match_by_with':
335
+ case 'legacy_by_with':
336
+ handleToggle(dd.key, []);
337
+ break;
338
+ }
339
+ },
340
+ type: 'multiple',
341
+ }),
342
+ ];
343
+ if (dd.checked) {
344
+ switch (dd.key) {
345
+ case 'min_qty':
346
+ case 'max_qty':
347
+ stringArray.push(html ` <div class="d-flex align-items-center fw-500" style="gap:10px;">
236
348
  ${BgWidget.editeInput({
237
- gvc: obj.gvc,
238
- default: `${postMD[dd.key] || ''}`,
239
- title: '',
240
- type: 'number',
241
- placeHolder: `1`,
242
- callback: (text) => {
243
- postMD[dd.key] = parseInt(text, 10);
244
- gvc.notifyDataChange(id);
245
- },
246
- })}
349
+ gvc: obj.gvc,
350
+ default: `${postMD[dd.key] || ''}`,
351
+ title: '',
352
+ type: 'number',
353
+ placeHolder: `1`,
354
+ callback: (text) => {
355
+ postMD[dd.key] = parseInt(text, 10);
356
+ gvc.notifyDataChange(id);
357
+ },
358
+ })}
247
359
 
248
360
  </div>`);
249
- break;
250
- case 'match_by_with':
251
- stringArray.push(obj.gvc.bindView(() => {
252
- const id = gvc.glitter.getUUID();
253
- return {
254
- bind: id,
255
- view: () => {
256
- try {
257
- return html `
361
+ break;
362
+ case 'match_by_with':
363
+ stringArray.push(obj.gvc.bindView(() => {
364
+ const id = gvc.glitter.getUUID();
365
+ return {
366
+ bind: id,
367
+ view: () => {
368
+ try {
369
+ return html `
258
370
  <div style="font-weight: 700;" class=" d-flex flex-column">
259
371
  ${BgWidget.grayNote(`購物車必須連同包含以下其中一個${postMD.product_category === 'course' ? `課程或商品` : `商品`}才可結帳`)}
260
372
  </div>
@@ -266,82 +378,82 @@ export class ShoppingSettingAdvance {
266
378
  <div class="tx_normal">商品列表</div>
267
379
  </div>
268
380
  ${BgWidget.grayButton('選擇商品', gvc.event(() => {
269
- BgProduct.productsDialog({
270
- gvc: gvc,
271
- default: postMD.match_by_with,
272
- callback: (value) => __awaiter(this, void 0, void 0, function* () {
273
- postMD.match_by_with = value;
274
- gvc.notifyDataChange(id);
275
- }),
276
- filter: dd => dd.key !== postMD.id,
277
- });
278
- }), { textStyle: 'font-weight: 400;' })}
381
+ BgProduct.productsDialog({
382
+ gvc: gvc,
383
+ default: postMD.match_by_with,
384
+ callback: (value) => __awaiter(this, void 0, void 0, function* () {
385
+ postMD.match_by_with = value;
386
+ gvc.notifyDataChange(id);
387
+ }),
388
+ filter: dd => dd.key !== postMD.id,
389
+ });
390
+ }), { textStyle: 'font-weight: 400;' })}
279
391
  </div>
280
392
  ${gvc.bindView(() => {
281
- const vm = {
282
- id: gvc.glitter.getUUID(),
283
- loading: true,
284
- data: [],
285
- };
286
- BgProduct.getProductOpts(postMD.match_by_with).then(res => {
287
- vm.data = res;
288
- vm.loading = false;
289
- gvc.notifyDataChange(vm.id);
290
- });
291
- return {
292
- bind: vm.id,
293
- view: () => __awaiter(this, void 0, void 0, function* () {
294
- if (vm.loading) {
295
- return BgWidget.spinner();
296
- }
297
- return vm.data
298
- .map((opt, index) => {
299
- return html ` <div
393
+ const vm = {
394
+ id: gvc.glitter.getUUID(),
395
+ loading: true,
396
+ data: [],
397
+ };
398
+ BgProduct.getProductOpts(postMD.match_by_with).then(res => {
399
+ vm.data = res;
400
+ vm.loading = false;
401
+ gvc.notifyDataChange(vm.id);
402
+ });
403
+ return {
404
+ bind: vm.id,
405
+ view: () => __awaiter(this, void 0, void 0, function* () {
406
+ if (vm.loading) {
407
+ return BgWidget.spinner();
408
+ }
409
+ return vm.data
410
+ .map((opt, index) => {
411
+ return html ` <div
300
412
  class="d-flex align-items-center form-check-label c_updown_label gap-3"
301
413
  >
302
414
  <span class="tx_normal">${index + 1} .</span>
303
415
  ${BgWidget.validImageBox({
304
- gvc: gvc,
305
- image: opt.image,
306
- width: 40,
307
- })}
416
+ gvc: gvc,
417
+ image: opt.image,
418
+ width: 40,
419
+ })}
308
420
  <div class="tx_normal ${opt.note ? 'mb-1' : ''}">
309
421
  ${opt.value}
310
422
  </div>
311
423
  ${opt.note
312
- ? html ` <div class="tx_gray_12">${opt.note}</div> `
313
- : ''}
424
+ ? html ` <div class="tx_gray_12">${opt.note}</div> `
425
+ : ''}
314
426
  </div>`;
315
- })
316
- .join('');
317
- }),
318
- divCreate: {
319
- class: `d-flex py-2 flex-column`,
320
- style: `gap:10px;`,
321
- },
322
- };
323
- })}
427
+ })
428
+ .join('');
429
+ }),
430
+ divCreate: {
431
+ class: `d-flex py-2 flex-column`,
432
+ style: `gap:10px;`,
433
+ },
434
+ };
435
+ })}
324
436
  `;
325
- }
326
- catch (e) {
327
- console.error(e);
328
- return '';
329
- }
330
- },
331
- divCreate: {
332
- class: `w-100`,
333
- },
334
- };
335
- }));
336
- break;
337
- case 'legacy_by_with':
338
- stringArray.push(obj.gvc.bindView(() => {
339
- const id = gvc.glitter.getUUID();
340
- return {
341
- bind: id,
342
- view: () => {
343
- try {
344
- return html `
437
+ }
438
+ catch (e) {
439
+ console.error(e);
440
+ return '';
441
+ }
442
+ },
443
+ divCreate: {
444
+ class: `w-100`,
445
+ },
446
+ };
447
+ }));
448
+ break;
449
+ case 'legacy_by_with':
450
+ stringArray.push(obj.gvc.bindView(() => {
451
+ const id = gvc.glitter.getUUID();
452
+ return {
453
+ bind: id,
454
+ view: () => {
455
+ try {
456
+ return html `
345
457
  <div style="font-weight: 700;" class=" d-flex flex-column">
346
458
  ${BgWidget.grayNote(`已購買過的訂單記錄中,必須包含以下${postMD.product_category === 'course' ? `課程或商品` : `商品`}才可以結帳`)}
347
459
  </div>
@@ -353,192 +465,197 @@ export class ShoppingSettingAdvance {
353
465
  <div class="tx_normal">商品列表</div>
354
466
  </div>
355
467
  ${BgWidget.grayButton('選擇商品', gvc.event(() => {
356
- BgProduct.productsDialog({
357
- gvc: gvc,
358
- default: postMD.match_by_with,
359
- callback: (value) => __awaiter(this, void 0, void 0, function* () {
360
- postMD.match_by_with = value;
361
- gvc.notifyDataChange(id);
362
- }),
363
- filter: dd => dd.key !== postMD.id,
364
- });
365
- }), { textStyle: 'font-weight: 400;' })}
468
+ BgProduct.productsDialog({
469
+ gvc: gvc,
470
+ default: postMD.match_by_with,
471
+ callback: (value) => __awaiter(this, void 0, void 0, function* () {
472
+ postMD.match_by_with = value;
473
+ gvc.notifyDataChange(id);
474
+ }),
475
+ filter: dd => dd.key !== postMD.id,
476
+ });
477
+ }), { textStyle: 'font-weight: 400;' })}
366
478
  </div>
367
479
  ${gvc.bindView(() => {
368
- const vm = {
369
- id: gvc.glitter.getUUID(),
370
- loading: true,
371
- data: [],
372
- };
373
- BgProduct.getProductOpts(postMD.match_by_with).then(res => {
374
- vm.data = res;
375
- vm.loading = false;
376
- gvc.notifyDataChange(vm.id);
377
- });
378
- return {
379
- bind: vm.id,
380
- view: () => __awaiter(this, void 0, void 0, function* () {
381
- if (vm.loading) {
382
- return BgWidget.spinner();
383
- }
384
- return vm.data
385
- .map((opt, index) => {
386
- return html ` <div
480
+ const vm = {
481
+ id: gvc.glitter.getUUID(),
482
+ loading: true,
483
+ data: [],
484
+ };
485
+ BgProduct.getProductOpts(postMD.match_by_with).then(res => {
486
+ vm.data = res;
487
+ vm.loading = false;
488
+ gvc.notifyDataChange(vm.id);
489
+ });
490
+ return {
491
+ bind: vm.id,
492
+ view: () => __awaiter(this, void 0, void 0, function* () {
493
+ if (vm.loading) {
494
+ return BgWidget.spinner();
495
+ }
496
+ return vm.data
497
+ .map((opt, index) => {
498
+ return html ` <div
387
499
  class="d-flex align-items-center form-check-label c_updown_label gap-3"
388
500
  >
389
501
  <span class="tx_normal">${index + 1} .</span>
390
502
  ${BgWidget.validImageBox({
391
- gvc: gvc,
392
- image: opt.image,
393
- width: 40,
394
- })}
503
+ gvc: gvc,
504
+ image: opt.image,
505
+ width: 40,
506
+ })}
395
507
  <div class="tx_normal ${opt.note ? 'mb-1' : ''}">
396
508
  ${opt.value}
397
509
  </div>
398
510
  ${opt.note
399
- ? html ` <div class="tx_gray_12">${opt.note}</div> `
400
- : ''}
511
+ ? html ` <div class="tx_gray_12">${opt.note}</div> `
512
+ : ''}
401
513
  </div>`;
402
- })
403
- .join('');
404
- }),
405
- divCreate: {
406
- class: `d-flex py-2 flex-column`,
407
- style: `gap:10px;`,
408
- },
409
- };
410
- })}
514
+ })
515
+ .join('');
516
+ }),
517
+ divCreate: {
518
+ class: `d-flex py-2 flex-column`,
519
+ style: `gap:10px;`,
520
+ },
521
+ };
522
+ })}
411
523
  `;
412
- }
413
- catch (e) {
414
- console.error(e);
415
- return '';
416
- }
417
- },
418
- divCreate: {
419
- class: `w-100`,
420
- },
421
- };
422
- }));
423
- break;
424
- }
425
- }
426
- return stringArray.join('');
427
- })),
428
- ].join('')),
429
- BgWidget.mainCard([
430
- html `
524
+ }
525
+ catch (e) {
526
+ console.error(e);
527
+ return '';
528
+ }
529
+ },
530
+ divCreate: {
531
+ class: `w-100`,
532
+ },
533
+ };
534
+ }));
535
+ break;
536
+ }
537
+ }
538
+ return stringArray.join('');
539
+ })),
540
+ ].join(''));
541
+ }
542
+ function drawTaxSection() {
543
+ var _a;
544
+ return BgWidget.mainCard([
545
+ html `
431
546
  <div class="d-flex flex-column guide5-4">
432
547
  <div style="font-weight: 700;" class="mb-2">商品稅額</div>
433
548
  </div>
434
549
  `,
435
- BgWidget.select({
436
- gvc: gvc,
437
- callback: text => {
438
- postMD.tax = text;
439
- },
440
- default: (_b = postMD.tax) !== null && _b !== void 0 ? _b : '5',
441
- options: [
442
- {
443
- key: '5',
444
- value: '一般稅額(5%)',
445
- },
446
- {
447
- key: '0',
448
- value: '免稅商品(0%)',
449
- },
450
- ],
550
+ BgWidget.select({
551
+ gvc: gvc,
552
+ callback: text => {
553
+ postMD.tax = text;
554
+ },
555
+ default: (_a = postMD.tax) !== null && _a !== void 0 ? _a : '5',
556
+ options: [
557
+ {
558
+ key: '5',
559
+ value: '一般稅額(5%)',
560
+ },
561
+ {
562
+ key: '0',
563
+ value: '免稅商品(0%)',
564
+ },
565
+ ],
566
+ }),
567
+ ].join(''));
568
+ }
569
+ function drawSpecialPriceSection() {
570
+ return BgWidget.mainCard((() => {
571
+ const priceVM = {
572
+ id: gvc.glitter.getUUID(),
573
+ loading: true,
574
+ typeData: [],
575
+ showPriceDetail: false,
576
+ };
577
+ const isDesktop = document.body.clientWidth > 768;
578
+ const getIndexStyle = (index) => index === 0
579
+ ? `height: 100%; padding: 0; min-width: ${isDesktop ? 250 : 200}px; max-width: ${isDesktop ? 250 : 200}px;position: sticky; left: 0; background: #fff; box-shadow: 1px 0px 0px 0px rgba(0, 0, 0, 0.10);`
580
+ : 'height: 100%; padding: 0; text-align: center; justify-content: center; min-width: 126px;';
581
+ const resetPostList = (result, type) => {
582
+ var _a, _b, _c;
583
+ const existingPrices = new Map((_a = postMD.multi_sale_price) === null || _a === void 0 ? void 0 : _a.filter(m => {
584
+ return m.type === type;
585
+ }).map(m => {
586
+ return [m.key, new Map(m.variants.map(v => [v.spec.join(','), v.price]))];
587
+ }));
588
+ postMD.multi_sale_price = [
589
+ ...((_c = (_b = postMD.multi_sale_price) === null || _b === void 0 ? void 0 : _b.filter(item => item.type !== type)) !== null && _c !== void 0 ? _c : []),
590
+ ...result.map(key => ({
591
+ type,
592
+ key,
593
+ variants: postMD.variants.map(v => {
594
+ var _a, _b;
595
+ return ({
596
+ spec: v.spec,
597
+ price: (_b = (_a = existingPrices.get(key)) === null || _a === void 0 ? void 0 : _a.get(v.spec.join(','))) !== null && _b !== void 0 ? _b : 0,
598
+ });
451
599
  }),
452
- ].join('')),
453
- BgWidget.mainCard((() => {
454
- const priceVM = {
455
- id: gvc.glitter.getUUID(),
456
- loading: true,
457
- typeData: [],
458
- showPriceDetail: false,
459
- };
460
- const isDesktop = document.body.clientWidth > 768;
461
- const getIndexStyle = (index) => index === 0
462
- ? `height: 100%; padding: 0; min-width: ${isDesktop ? 250 : 200}px; max-width: ${isDesktop ? 250 : 200}px;position: sticky; left: 0; background: #fff; box-shadow: 1px 0px 0px 0px rgba(0, 0, 0, 0.10);`
463
- : 'height: 100%; padding: 0; text-align: center; justify-content: center; min-width: 126px;';
464
- const resetPostList = (result, type) => {
465
- var _a, _b, _c;
466
- const existingPrices = new Map((_a = postMD.multi_sale_price) === null || _a === void 0 ? void 0 : _a.filter(m => {
467
- return m.type === type;
468
- }).map(m => {
469
- return [m.key, new Map(m.variants.map(v => [v.spec.join(','), v.price]))];
470
- }));
471
- postMD.multi_sale_price = [
472
- ...((_c = (_b = postMD.multi_sale_price) === null || _b === void 0 ? void 0 : _b.filter(item => item.type !== type)) !== null && _c !== void 0 ? _c : []),
473
- ...result.map(key => ({
474
- type,
475
- key,
476
- variants: postMD.variants.map(v => {
477
- var _a, _b;
478
- return ({
479
- spec: v.spec,
480
- price: (_b = (_a = existingPrices.get(key)) === null || _a === void 0 ? void 0 : _a.get(v.spec.join(','))) !== null && _b !== void 0 ? _b : 0,
481
- });
482
- }),
483
- })),
484
- ];
485
- gvc.notifyDataChange(priceVM.id);
486
- };
487
- const toggleObject = (type) => {
488
- return {
489
- gvc,
490
- postData: postMD.multi_sale_price
491
- ? postMD.multi_sale_price.filter(item => item.type === type).map(item => item.key)
492
- : [],
493
- callback: (result) => resetPostList(result, type),
494
- };
495
- };
496
- const createToggleList = () => [
497
- {
498
- title: '會員等級價格開啟',
499
- note: '開啟後即可為各個會員等級設置專屬的價格',
500
- type: 'level',
501
- event: () => {
502
- BgProduct.setMemberPriceSetting(toggleObject('level'));
503
- },
504
- },
505
- {
506
- title: '門市專屬價格開啟',
507
- note: '開啟後即可為各個門市設置專屬的價格',
508
- type: 'store',
509
- event: () => {
510
- BgProduct.setStorePriceSetting(toggleObject('store'));
511
- },
512
- },
513
- {
514
- title: '顧客標籤價格開啟',
515
- note: '開啟後即可為各個顧客標籤設置專屬的價格',
516
- type: 'tags',
517
- event: () => {
518
- BgProduct.setUserTagPriceSetting(toggleObject('tags'));
519
- },
520
- },
521
- ];
522
- return gvc.bindView({
523
- bind: priceVM.id,
524
- view: () => {
525
- if (priceVM.loading)
526
- return BgWidget.spinner();
527
- const toggleList = createToggleList();
528
- const particularKeys = priceVM.typeData.filter(item => {
529
- var _a;
530
- return (_a = postMD.multi_sale_price) === null || _a === void 0 ? void 0 : _a.some(m => m.type === item.type && m.key === item.key);
531
- });
532
- try {
533
- return html `
600
+ })),
601
+ ];
602
+ gvc.notifyDataChange(priceVM.id);
603
+ };
604
+ const toggleObject = (type) => {
605
+ return {
606
+ gvc,
607
+ postData: postMD.multi_sale_price
608
+ ? postMD.multi_sale_price.filter(item => item.type === type).map(item => item.key)
609
+ : [],
610
+ callback: (result) => resetPostList(result, type),
611
+ };
612
+ };
613
+ const createToggleList = () => [
614
+ {
615
+ title: '會員等級價格開啟',
616
+ note: '開啟後即可為各個會員等級設置專屬的價格',
617
+ type: 'level',
618
+ event: () => {
619
+ BgProduct.setMemberPriceSetting(toggleObject('level'));
620
+ },
621
+ },
622
+ {
623
+ title: '門市專屬價格開啟',
624
+ note: '開啟後即可為各個門市設置專屬的價格',
625
+ type: 'store',
626
+ event: () => {
627
+ BgProduct.setStorePriceSetting(toggleObject('store'));
628
+ },
629
+ },
630
+ {
631
+ title: '顧客標籤價格開啟',
632
+ note: '開啟後即可為各個顧客標籤設置專屬的價格',
633
+ type: 'tags',
634
+ event: () => {
635
+ BgProduct.setUserTagPriceSetting(toggleObject('tags'));
636
+ },
637
+ },
638
+ ];
639
+ return gvc.bindView({
640
+ bind: priceVM.id,
641
+ view: () => {
642
+ if (priceVM.loading)
643
+ return BgWidget.spinner();
644
+ const toggleList = createToggleList();
645
+ const particularKeys = priceVM.typeData.filter(item => {
646
+ var _a;
647
+ return (_a = postMD.multi_sale_price) === null || _a === void 0 ? void 0 : _a.some(m => m.type === item.type && m.key === item.key);
648
+ });
649
+ try {
650
+ return html `
534
651
  <div class="title-container px-0 mb-2">
535
652
  <div style="color:#393939;font-weight: 700;">專屬價格</div>
536
653
  <div class="flex-fill"></div>
537
654
  </div>
538
655
  ${toggleList
539
- .map(item => {
540
- var _a;
541
- return html `
656
+ .map(item => {
657
+ var _a;
658
+ return html `
542
659
  <div class="d-flex align-items-center">
543
660
  <div>
544
661
  <div class="d-flex align-items-center gap-2 mb-1">
@@ -549,15 +666,15 @@ export class ShoppingSettingAdvance {
549
666
  style="cursor: pointer;"
550
667
  type="checkbox"
551
668
  onchange="${gvc.event(e => {
552
- var _a;
553
- if (e.checked) {
554
- item.event();
555
- }
556
- else {
557
- postMD.multi_sale_price = (_a = postMD.multi_sale_price) === null || _a === void 0 ? void 0 : _a.filter(m => m.type !== item.type);
558
- gvc.notifyDataChange(priceVM.id);
559
- }
560
- })}"
669
+ var _a;
670
+ if (e.checked) {
671
+ item.event();
672
+ }
673
+ else {
674
+ postMD.multi_sale_price = (_a = postMD.multi_sale_price) === null || _a === void 0 ? void 0 : _a.filter(m => m.type !== item.type);
675
+ gvc.notifyDataChange(priceVM.id);
676
+ }
677
+ })}"
561
678
  ${((_a = postMD.multi_sale_price) === null || _a === void 0 ? void 0 : _a.some(m => m.type === item.type)) ? `checked` : ''}
562
679
  />
563
680
  </div>
@@ -570,10 +687,10 @@ export class ShoppingSettingAdvance {
570
687
  </div>
571
688
  </div>
572
689
  `;
573
- })
574
- .join(`<div class="w-100 my-3 border-top"></div>`)}
690
+ })
691
+ .join(`<div class="w-100 my-3 border-top"></div>`)}
575
692
  ${particularKeys.length > 1
576
- ? html `
693
+ ? html `
577
694
  <div
578
695
  class="d-flex justify-content-start align-items-center mt-2 my-1"
579
696
  style="border-radius: 10px; padding: 10px 20px; background: #F7F7F7;"
@@ -583,269 +700,273 @@ export class ShoppingSettingAdvance {
583
700
  >
584
701
  </div>
585
702
  `
586
- : ''}
703
+ : ''}
587
704
  ${postMD.multi_sale_price && postMD.multi_sale_price.length > 0
588
- ? html ` <div class="mt-3 d-grid" style="overflow: scroll;" id="scrollDiv">
705
+ ? html ` <div class="mt-3 d-grid" style="overflow: scroll;" id="scrollDiv">
589
706
  <div class="d-flex">
590
707
  ${['商品名稱', '成本', '原價', '售價', ...particularKeys.map(item => item.name)]
591
- .map((item, index) => html `
708
+ .map((item, index) => html `
592
709
  <div style="${getIndexStyle(index)}">
593
710
  <div>${item}</div>
594
711
  ${BgWidget.horizontalLine({ margin: '1rem 0 0;' })}
595
712
  </div>
596
713
  `)
597
- .join('')}
714
+ .join('')}
598
715
  </div>
599
716
  <div class="w-100 d-flex flex-column">
600
717
  ${postMD.variants
601
- .map((variant, index) => {
602
- const { spec, cost = 0, sale_price, preview_image, compare_price } = variant;
603
- return html ` <div class="d-flex align-items-center">
718
+ .map((variant, index) => {
719
+ const { spec, cost = 0, sale_price, preview_image, compare_price } = variant;
720
+ return html ` <div class="d-flex align-items-center">
604
721
  ${[
605
- [
606
- BgWidget.validImageBox({
607
- gvc,
608
- image: preview_image,
609
- width: 40,
610
- style: 'border-radius: 5px;',
611
- }),
612
- gvc.bindView({
613
- bind: `spec-bar-${index}`,
614
- dataList: [{ obj: priceVM, key: 'showPriceDetail' }],
615
- view: () => {
616
- return html `
722
+ [
723
+ BgWidget.validImageBox({
724
+ gvc,
725
+ image: preview_image,
726
+ width: 40,
727
+ style: 'border-radius: 5px;',
728
+ }),
729
+ gvc.bindView({
730
+ bind: `spec-bar-${index}`,
731
+ dataList: [{ obj: priceVM, key: 'showPriceDetail' }],
732
+ view: () => {
733
+ return html `
617
734
  <div>
618
735
  ${spec && spec.length > 0
619
- ? spec.join(' / ')
620
- : Tool.truncateString(postMD.title, 10)}
736
+ ? spec.join(' / ')
737
+ : Tool.truncateString(postMD.title, 10)}
621
738
  </div>
622
739
  ${priceVM.showPriceDetail
623
- ? html ` <div style="color: #8D8D8D;">
740
+ ? html ` <div style="color: #8D8D8D;">
624
741
  定價 : ${compare_price.toLocaleString()} / 售價 :
625
742
  ${sale_price.toLocaleString()}
626
743
  </div>`
627
- : ''}
744
+ : ''}
628
745
  `;
629
- },
630
- divCreate: {
631
- class: 'ms-2',
632
- style: 'font-size: 14px;',
633
- },
634
- }),
635
- ].join(''),
636
- `$ ${cost.toLocaleString()}`,
637
- `$ ${compare_price.toLocaleString()}`,
638
- `$ ${sale_price.toLocaleString()}`,
639
- ...particularKeys.map(item => gvc.bindView((() => {
640
- const id = gvc.glitter.getUUID();
641
- return {
642
- bind: id,
643
- view: () => {
644
- var _a, _b;
645
- const priceObj = (_a = postMD.multi_sale_price) === null || _a === void 0 ? void 0 : _a.find(m => m.type === item.type && m.key === item.key);
646
- const variantObj = priceObj === null || priceObj === void 0 ? void 0 : priceObj.variants.find(v => v.spec.join(',') === spec.join(','));
647
- return BgWidget.editeInput({
648
- gvc,
649
- title: '',
650
- default: `${(_b = variantObj === null || variantObj === void 0 ? void 0 : variantObj.price) !== null && _b !== void 0 ? _b : 0}`,
651
- placeHolder: '',
652
- callback: value => {
653
- const n = parseInt(`${value !== null && value !== void 0 ? value : 0}`, 10);
654
- if (variantObj && !isNaN(n) && n > 0) {
655
- variantObj.price = n;
656
- }
657
- gvc.notifyDataChange(id);
658
- },
659
- });
660
- },
661
- divCreate: {
662
- style: 'width: 120px;',
663
- },
664
- };
665
- })())),
666
- ]
667
- .map((item, index) => html `
746
+ },
747
+ divCreate: {
748
+ class: 'ms-2',
749
+ style: 'font-size: 14px;',
750
+ },
751
+ }),
752
+ ].join(''),
753
+ `$ ${cost.toLocaleString()}`,
754
+ `$ ${compare_price.toLocaleString()}`,
755
+ `$ ${sale_price.toLocaleString()}`,
756
+ ...particularKeys.map(item => gvc.bindView((() => {
757
+ const id = gvc.glitter.getUUID();
758
+ return {
759
+ bind: id,
760
+ view: () => {
761
+ var _a, _b;
762
+ const priceObj = (_a = postMD.multi_sale_price) === null || _a === void 0 ? void 0 : _a.find(m => m.type === item.type && m.key === item.key);
763
+ const variantObj = priceObj === null || priceObj === void 0 ? void 0 : priceObj.variants.find(v => v.spec.join(',') === spec.join(','));
764
+ return BgWidget.editeInput({
765
+ gvc,
766
+ title: '',
767
+ default: `${(_b = variantObj === null || variantObj === void 0 ? void 0 : variantObj.price) !== null && _b !== void 0 ? _b : 0}`,
768
+ placeHolder: '',
769
+ callback: value => {
770
+ const n = parseInt(`${value !== null && value !== void 0 ? value : 0}`, 10);
771
+ if (variantObj && !isNaN(n) && n > 0) {
772
+ variantObj.price = n;
773
+ }
774
+ gvc.notifyDataChange(id);
775
+ },
776
+ });
777
+ },
778
+ divCreate: {
779
+ style: 'width: 120px;',
780
+ },
781
+ };
782
+ })())),
783
+ ]
784
+ .map((item, index) => html `
668
785
  <div class="d-flex align-items-center" style="${getIndexStyle(index)}">
669
786
  ${item}
670
787
  </div>
671
788
  `)
672
- .join('')}
789
+ .join('')}
673
790
  </div>`;
674
- })
675
- .join('')}
791
+ })
792
+ .join('')}
676
793
  </div>
677
794
  </div>`
678
- : ''}
795
+ : ''}
679
796
  `;
797
+ }
798
+ catch (error) {
799
+ console.error(error);
800
+ return '';
801
+ }
802
+ },
803
+ onCreate: () => {
804
+ if (priceVM.loading) {
805
+ Promise.all([
806
+ ApiUser.getUserGroupList('level').then(r => {
807
+ if (r.result && r.response && Array.isArray(r.response.data)) {
808
+ return r.response.data.map((item) => ({
809
+ type: 'level',
810
+ key: item.tag || 'default',
811
+ name: item.title.replace('會員等級 - ', ''),
812
+ }));
680
813
  }
681
- catch (error) {
682
- console.error(error);
683
- return '';
684
- }
685
- },
686
- onCreate: () => {
687
- if (priceVM.loading) {
688
- Promise.all([
689
- ApiUser.getUserGroupList('level').then(r => {
690
- if (r.result && r.response && Array.isArray(r.response.data)) {
691
- return r.response.data.map((item) => ({
692
- type: 'level',
693
- key: item.tag || 'default',
694
- name: item.title.replace('會員等級 - ', ''),
695
- }));
696
- }
697
- return [];
698
- }),
699
- ApiUser.getPublicConfig('store_manager', 'manager').then((r) => {
700
- if (r.result && Array.isArray(r.response.value.list)) {
701
- return r.response.value.list.map((d) => ({
702
- type: 'store',
703
- key: d.id,
704
- name: d.name,
705
- }));
706
- }
707
- return [];
708
- }),
709
- ApiUser.getPublicConfig('user_general_tags', 'manager').then((r) => {
710
- if (r.result && Array.isArray(r.response.value.list)) {
711
- return r.response.value.list.map((tag) => ({
712
- type: 'tags',
713
- key: tag,
714
- name: tag,
715
- }));
716
- }
717
- return [];
718
- }),
719
- ]).then((dlist) => {
720
- priceVM.typeData = dlist.flat();
721
- priceVM.loading = false;
722
- gvc.notifyDataChange(priceVM.id);
723
- });
814
+ return [];
815
+ }),
816
+ ApiUser.getPublicConfig('store_manager', 'manager').then((r) => {
817
+ if (r.result && Array.isArray(r.response.value.list)) {
818
+ return r.response.value.list.map((d) => ({
819
+ type: 'store',
820
+ key: d.id,
821
+ name: d.name,
822
+ }));
724
823
  }
725
- else {
726
- const scrollDiv = document.getElementById('scrollDiv');
727
- if (scrollDiv) {
728
- function setStatus(scrollDiv, delta = 360) {
729
- const status = scrollDiv.scrollLeft > delta;
730
- if (priceVM.showPriceDetail !== status) {
731
- priceVM.showPriceDetail = status;
732
- }
733
- }
734
- if (isDesktop) {
735
- scrollDiv.addEventListener('scroll', () => {
736
- setStatus(scrollDiv);
737
- });
738
- }
739
- else {
740
- scrollDiv.addEventListener('touchmove', () => {
741
- setStatus(scrollDiv);
742
- });
743
- }
744
- }
824
+ return [];
825
+ }),
826
+ ApiUser.getPublicConfig('user_general_tags', 'manager').then((r) => {
827
+ if (r.result && Array.isArray(r.response.value.list)) {
828
+ return r.response.value.list.map((tag) => ({
829
+ type: 'tags',
830
+ key: tag,
831
+ name: tag,
832
+ }));
745
833
  }
746
- },
834
+ return [];
835
+ }),
836
+ ]).then((dlist) => {
837
+ priceVM.typeData = dlist.flat();
838
+ priceVM.loading = false;
839
+ gvc.notifyDataChange(priceVM.id);
747
840
  });
748
- })()),
749
- postMD.product_category === 'commodity'
750
- ? BgWidget.mainCard(obj.gvc.bindView(() => {
751
- var _a;
752
- let loading = true;
753
- let dataList = [];
754
- postMD.designated_logistics = (_a = postMD.designated_logistics) !== null && _a !== void 0 ? _a : { group: '' };
755
- return {
756
- bind: 'designatedLogistics',
757
- view: () => {
758
- if (loading) {
759
- return '';
760
- }
761
- return html ` <div class="tx_700">指定物流配送方式</div>
841
+ }
842
+ else {
843
+ const scrollDiv = document.getElementById('scrollDiv');
844
+ if (scrollDiv) {
845
+ function setStatus(scrollDiv, delta = 360) {
846
+ const status = scrollDiv.scrollLeft > delta;
847
+ if (priceVM.showPriceDetail !== status) {
848
+ priceVM.showPriceDetail = status;
849
+ }
850
+ }
851
+ if (isDesktop) {
852
+ scrollDiv.addEventListener('scroll', () => {
853
+ setStatus(scrollDiv);
854
+ });
855
+ }
856
+ else {
857
+ scrollDiv.addEventListener('touchmove', () => {
858
+ setStatus(scrollDiv);
859
+ });
860
+ }
861
+ }
862
+ }
863
+ },
864
+ });
865
+ })());
866
+ }
867
+ function drawLogisticsSection() {
868
+ return postMD.product_category === 'commodity'
869
+ ? BgWidget.mainCard(obj.gvc.bindView(() => {
870
+ var _a;
871
+ let loading = true;
872
+ let dataList = [];
873
+ postMD.designated_logistics = (_a = postMD.designated_logistics) !== null && _a !== void 0 ? _a : { group: '' };
874
+ return {
875
+ bind: 'designatedLogistics',
876
+ view: () => {
877
+ if (loading) {
878
+ return '';
879
+ }
880
+ return html ` <div class="tx_700">指定物流配送方式</div>
762
881
  ${BgWidget.mbContainer(18)}
763
882
  ${gvc.bindView(() => {
764
- const id = gvc.glitter.getUUID();
765
- return {
766
- bind: id,
767
- view: () => {
768
- return html `
883
+ const id = gvc.glitter.getUUID();
884
+ return {
885
+ bind: id,
886
+ view: () => {
887
+ return html `
769
888
  <div style="display: flex; flex-direction: column; gap: 8px;">
770
889
  ${BgWidget.selectFilter({
890
+ gvc: gvc,
891
+ callback: text => {
892
+ postMD.designated_logistics.type = text;
893
+ gvc.notifyDataChange(id);
894
+ },
895
+ default: postMD.designated_logistics.type,
896
+ options: [
897
+ {
898
+ key: 'all',
899
+ value: '全部',
900
+ },
901
+ {
902
+ key: 'designated',
903
+ value: '指定物流群組',
904
+ },
905
+ ].filter(item => {
906
+ return !(item.key === 'designated' && dataList.length === 0);
907
+ }),
908
+ style: 'width: 100%;',
909
+ })}
910
+ <div>
911
+ ${(() => {
912
+ switch (postMD.designated_logistics.type) {
913
+ case 'designated':
914
+ return BgWidget.selectDropList({
771
915
  gvc: gvc,
772
- callback: text => {
773
- postMD.designated_logistics.type = text;
916
+ callback: (value) => {
917
+ postMD.designated_logistics.group = value;
774
918
  gvc.notifyDataChange(id);
775
919
  },
776
- default: postMD.designated_logistics.type,
777
- options: [
778
- {
779
- key: 'all',
780
- value: '全部',
781
- },
782
- {
783
- key: 'designated',
784
- value: '指定物流群組',
785
- },
786
- ].filter(item => {
787
- return !(item.key === 'designated' && dataList.length === 0);
920
+ default: postMD.designated_logistics.group || [],
921
+ options: dataList.map((data) => {
922
+ return {
923
+ key: data.key,
924
+ value: data.name,
925
+ };
788
926
  }),
789
927
  style: 'width: 100%;',
790
- })}
791
- <div>
792
- ${(() => {
793
- switch (postMD.designated_logistics.type) {
794
- case 'designated':
795
- return BgWidget.selectDropList({
796
- gvc: gvc,
797
- callback: (value) => {
798
- postMD.designated_logistics.group = value;
799
- gvc.notifyDataChange(id);
800
- },
801
- default: postMD.designated_logistics.group || [],
802
- options: dataList.map((data) => {
803
- return {
804
- key: data.key,
805
- value: data.name,
806
- };
807
- }),
808
- style: 'width: 100%;',
809
- });
810
- default:
811
- return '';
812
- }
813
- })()}
928
+ });
929
+ default:
930
+ return '';
931
+ }
932
+ })()}
814
933
  </div>
815
934
  </div>
816
935
  `;
817
- },
818
- };
819
- })}`;
820
- },
821
- onCreate: () => {
822
- if (loading) {
823
- ApiUser.getPublicConfig('logistics_group', 'manager').then(r => {
824
- dataList = (() => {
825
- try {
826
- return r.response.value;
827
- }
828
- catch (error) {
829
- return dataList;
830
- }
831
- })();
832
- loading = false;
833
- gvc.notifyDataChange('designatedLogistics');
834
- });
835
- }
836
936
  },
837
937
  };
838
- }))
839
- : '',
840
- BgWidget.mainCard(obj.gvc.bindView(() => {
841
- const id = gvc.glitter.getUUID();
842
- return {
843
- bind: id,
844
- view: () => {
845
- var _a;
846
- postMD.relative_product = (_a = postMD.relative_product) !== null && _a !== void 0 ? _a : [];
847
- try {
848
- return html `
938
+ })}`;
939
+ },
940
+ onCreate: () => {
941
+ if (loading) {
942
+ ApiUser.getPublicConfig('logistics_group', 'manager').then(r => {
943
+ dataList = (() => {
944
+ try {
945
+ return r.response.value;
946
+ }
947
+ catch (error) {
948
+ return dataList;
949
+ }
950
+ })();
951
+ loading = false;
952
+ gvc.notifyDataChange('designatedLogistics');
953
+ });
954
+ }
955
+ },
956
+ };
957
+ }))
958
+ : '';
959
+ }
960
+ function drawRelateProductSection() {
961
+ return BgWidget.mainCard(obj.gvc.bindView(() => {
962
+ const id = gvc.glitter.getUUID();
963
+ return {
964
+ bind: id,
965
+ view: () => {
966
+ var _a;
967
+ postMD.relative_product = (_a = postMD.relative_product) !== null && _a !== void 0 ? _a : [];
968
+ try {
969
+ return html `
849
970
  <div style="font-weight: 700;" class="mb-3 d-flex flex-column">
850
971
  相關商品 ${BgWidget.grayNote('相關商品將會顯示於商品頁底部')}
851
972
  </div>
@@ -857,155 +978,174 @@ export class ShoppingSettingAdvance {
857
978
  <div class="tx_normal">商品列表</div>
858
979
  </div>
859
980
  ${BgWidget.grayButton('選擇商品', gvc.event(() => {
860
- BgProduct.productsDialog({
861
- gvc: gvc,
862
- default: postMD.relative_product,
863
- callback: (value) => __awaiter(this, void 0, void 0, function* () {
864
- postMD.relative_product = value;
865
- gvc.notifyDataChange(id);
866
- }),
867
- filter: dd => dd.key !== postMD.id,
868
- });
869
- }), { textStyle: 'font-weight: 400;' })}
981
+ BgProduct.productsDialog({
982
+ gvc: gvc,
983
+ default: postMD.relative_product,
984
+ callback: (value) => __awaiter(this, void 0, void 0, function* () {
985
+ postMD.relative_product = value;
986
+ gvc.notifyDataChange(id);
987
+ }),
988
+ filter: dd => dd.key !== postMD.id,
989
+ });
990
+ }), { textStyle: 'font-weight: 400;' })}
870
991
  </div>
871
992
  ${gvc.bindView(() => {
872
- const vm = {
873
- id: gvc.glitter.getUUID(),
874
- loading: true,
875
- data: [],
876
- };
877
- BgProduct.getProductOpts(postMD.relative_product).then(res => {
878
- vm.data = res;
879
- vm.loading = false;
880
- gvc.notifyDataChange(vm.id);
881
- });
882
- return {
883
- bind: vm.id,
884
- view: () => __awaiter(this, void 0, void 0, function* () {
885
- if (vm.loading) {
886
- return BgWidget.spinner();
887
- }
888
- return vm.data
889
- .map((opt, index) => {
890
- return html ` <div
993
+ const vm = {
994
+ id: gvc.glitter.getUUID(),
995
+ loading: true,
996
+ data: [],
997
+ };
998
+ BgProduct.getProductOpts(postMD.relative_product).then(res => {
999
+ vm.data = res;
1000
+ vm.loading = false;
1001
+ gvc.notifyDataChange(vm.id);
1002
+ });
1003
+ return {
1004
+ bind: vm.id,
1005
+ view: () => __awaiter(this, void 0, void 0, function* () {
1006
+ if (vm.loading) {
1007
+ return BgWidget.spinner();
1008
+ }
1009
+ return vm.data
1010
+ .map((opt, index) => {
1011
+ return html ` <div
891
1012
  class="d-flex align-items-center form-check-label c_updown_label gap-3"
892
1013
  >
893
1014
  <span class="tx_normal">${index + 1} .</span>
894
1015
  ${BgWidget.validImageBox({
895
- gvc: gvc,
896
- image: opt.image,
897
- width: 40,
898
- })}
1016
+ gvc: gvc,
1017
+ image: opt.image,
1018
+ width: 40,
1019
+ })}
899
1020
  <div class="tx_normal ${opt.note ? 'mb-1' : ''}">${opt.value}</div>
900
1021
  ${opt.note ? html ` <div class="tx_gray_12">${opt.note}</div> ` : ''}
901
1022
  </div>`;
902
- })
903
- .join('');
904
- }),
905
- divCreate: {
906
- class: `d-flex py-2 flex-column`,
907
- style: `gap:10px;`,
908
- },
909
- };
910
- })}
1023
+ })
1024
+ .join('');
1025
+ }),
1026
+ divCreate: {
1027
+ class: `d-flex py-2 flex-column`,
1028
+ style: `gap:10px;`,
1029
+ },
1030
+ };
1031
+ })}
911
1032
  `;
912
- }
913
- catch (e) {
914
- console.error(e);
915
- return '';
916
- }
917
- },
918
- divCreate: {
919
- class: `w-100`,
920
- },
921
- };
922
- })),
923
- BgWidget.mainCard(obj.gvc.bindView(() => {
924
- const id = gvc.glitter.getUUID();
925
- return {
926
- bind: id,
927
- view: () => {
928
- var _a, _b;
929
- postMD.relative_product = (_a = postMD.relative_product) !== null && _a !== void 0 ? _a : [];
930
- try {
931
- return html `
1033
+ }
1034
+ catch (e) {
1035
+ console.error(e);
1036
+ return '';
1037
+ }
1038
+ },
1039
+ divCreate: {
1040
+ class: `w-100`,
1041
+ },
1042
+ };
1043
+ }));
1044
+ }
1045
+ function drawNoticeSection() {
1046
+ return BgWidget.mainCard(obj.gvc.bindView(() => {
1047
+ const id = gvc.glitter.getUUID();
1048
+ return {
1049
+ bind: id,
1050
+ view: () => {
1051
+ var _a, _b;
1052
+ postMD.relative_product = (_a = postMD.relative_product) !== null && _a !== void 0 ? _a : [];
1053
+ try {
1054
+ return html `
932
1055
  <div style="font-weight: 700;" class="mb-3 d-flex flex-column">
933
1056
  ${carTitle}通知 ${BgWidget.grayNote(`購買此${carTitle}會收到的通知信,內容為空則不寄送。`)}
934
1057
  </div>
935
1058
  ${BgWidget.richTextEditor({
936
- gvc: gvc,
937
- content: (_b = postMD.email_notice) !== null && _b !== void 0 ? _b : '',
938
- callback: content => {
939
- postMD.email_notice = content;
940
- },
941
- title: '內容編輯',
942
- quick_insert: BgWidget.richTextQuickList.filter(item => {
943
- return !['訂單號碼', '訂單金額'].includes(item.title);
944
- }),
945
- })}
946
- `;
947
- }
948
- catch (e) {
949
- console.error(e);
950
- return '';
951
- }
952
- },
953
- divCreate: {
954
- class: `w-100`,
1059
+ gvc: gvc,
1060
+ content: (_b = postMD.email_notice) !== null && _b !== void 0 ? _b : '',
1061
+ callback: content => {
1062
+ postMD.email_notice = content;
955
1063
  },
956
- };
957
- })),
958
- BgWidget.mainCard(obj.gvc.bindView(() => {
959
- const id = obj.gvc.glitter.getUUID();
960
- return {
961
- bind: id,
962
- view: () => {
963
- return [
964
- html ` <div class="title-container px-0">
1064
+ title: '內容編輯',
1065
+ quick_insert: BgWidget.richTextQuickList.filter(item => {
1066
+ return !['訂單號碼', '訂單金額'].includes(item.title);
1067
+ }),
1068
+ })}
1069
+ `;
1070
+ }
1071
+ catch (e) {
1072
+ console.error(e);
1073
+ return '';
1074
+ }
1075
+ },
1076
+ divCreate: {
1077
+ class: `w-100`,
1078
+ },
1079
+ };
1080
+ }));
1081
+ }
1082
+ function drawAIDesSection() {
1083
+ return BgWidget.mainCard(obj.gvc.bindView(() => {
1084
+ const id = obj.gvc.glitter.getUUID();
1085
+ return {
1086
+ bind: id,
1087
+ view: () => {
1088
+ return [
1089
+ html ` <div class="title-container px-0">
965
1090
  <div style="color:#393939;font-weight: 700;">AI 選品</div>
966
1091
  <div class="flex-fill"></div>
967
1092
  ${BgWidget.grayButton('設定描述語句', gvc.event(() => {
968
- let description = postMD.ai_description;
969
- BgWidget.settingDialog({
970
- gvc: gvc,
971
- title: '描述語句',
972
- innerHTML: gvc => {
973
- return BgWidget.textArea({
974
- gvc: gvc,
975
- title: '',
976
- default: postMD.ai_description || '',
977
- placeHolder: `請告訴我這是什麼商品,範例:現代極簡風格的淺灰色布藝沙發,可以同時乘坐3個人,配金屬腳座,採用鈦合金製作十分的堅固。`,
978
- callback: text => {
979
- description = text;
980
- },
981
- style: `min-height:100px;`,
982
- });
983
- },
984
- footer_html: gvc => {
985
- return [
986
- BgWidget.save(gvc.event(() => {
987
- postMD.ai_description = description;
988
- gvc.notifyDataChange(id);
989
- gvc.closeDialog();
990
- })),
991
- ].join('');
992
- },
993
- });
994
- }), {
995
- textStyle: 'width:100%;',
996
- })}
1093
+ let description = postMD.ai_description;
1094
+ BgWidget.settingDialog({
1095
+ gvc: gvc,
1096
+ title: '描述語句',
1097
+ innerHTML: gvc => {
1098
+ return BgWidget.textArea({
1099
+ gvc: gvc,
1100
+ title: '',
1101
+ default: postMD.ai_description || '',
1102
+ placeHolder: `請告訴我這是什麼商品,範例:現代極簡風格的淺灰色布藝沙發,可以同時乘坐3個人,配金屬腳座,採用鈦合金製作十分的堅固。`,
1103
+ callback: text => {
1104
+ description = text;
1105
+ },
1106
+ style: `min-height:100px;`,
1107
+ });
1108
+ },
1109
+ footer_html: gvc => {
1110
+ return [
1111
+ BgWidget.save(gvc.event(() => {
1112
+ postMD.ai_description = description;
1113
+ gvc.notifyDataChange(id);
1114
+ gvc.closeDialog();
1115
+ })),
1116
+ ].join('');
1117
+ },
1118
+ });
1119
+ }), {
1120
+ textStyle: 'width:100%;',
1121
+ })}
997
1122
  </div>`,
998
- html `
1123
+ html `
999
1124
  <div>
1000
1125
  ${postMD.ai_description
1001
- ? `您設定的描述語句:${postMD.ai_description}`
1002
- : BgWidget.grayNote('尚未設定描述語句,透過設定描述語句,可以幫助AI更準確的定位產品。')}
1126
+ ? `您設定的描述語句:${postMD.ai_description}`
1127
+ : BgWidget.grayNote('尚未設定描述語句,透過設定描述語句,可以幫助AI更準確的定位產品。')}
1003
1128
  </div>
1004
1129
  `,
1005
- ].join(BgWidget.mbContainer(18));
1006
- },
1007
- };
1008
- })),
1130
+ ].join(BgWidget.mbContainer(18));
1131
+ },
1132
+ };
1133
+ }));
1134
+ }
1135
+ return BgWidget.container(gvc.bindView(() => {
1136
+ return {
1137
+ bind: id,
1138
+ view: () => {
1139
+ return [
1140
+ drawReverseSection(),
1141
+ drawTagSection(),
1142
+ drawBuyLimit(),
1143
+ drawTaxSection(),
1144
+ drawSpecialPriceSection(),
1145
+ drawLogisticsSection(),
1146
+ drawRelateProductSection(),
1147
+ drawNoticeSection(),
1148
+ drawAIDesSection(),
1009
1149
  ]
1010
1150
  .filter(Boolean)
1011
1151
  .join(html ` <div class="my-3"></div>`);