ts-glitter 22.5.7 → 22.5.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 (91) hide show
  1. package/lowcode/Entry.js +1 -1
  2. package/lowcode/Entry.ts +1 -1
  3. package/lowcode/backend-manager/bg-product.js +13 -13
  4. package/lowcode/backend-manager/bg-product.ts +13 -13
  5. package/lowcode/backend-manager/bg-shopping.js +8 -13
  6. package/lowcode/backend-manager/bg-shopping.ts +8 -15
  7. package/lowcode/backend-manager/bg-widget.js +62 -49
  8. package/lowcode/backend-manager/bg-widget.ts +129 -93
  9. package/lowcode/cms-plugin/POS-setting.js +30 -9
  10. package/lowcode/cms-plugin/POS-setting.ts +49 -16
  11. package/lowcode/cms-plugin/cms-router.js +27 -21
  12. package/lowcode/cms-plugin/cms-router.ts +116 -101
  13. package/lowcode/cms-plugin/filter-options.js +25 -17
  14. package/lowcode/cms-plugin/filter-options.ts +27 -17
  15. package/lowcode/cms-plugin/module/product-excel.js +2 -0
  16. package/lowcode/cms-plugin/module/product-excel.ts +2 -0
  17. package/lowcode/cms-plugin/module/product-setting.js +13 -12
  18. package/lowcode/cms-plugin/module/product-setting.ts +26 -23
  19. package/lowcode/cms-plugin/order/order-module.js +91 -68
  20. package/lowcode/cms-plugin/order/order-module.ts +105 -73
  21. package/lowcode/cms-plugin/pos-checkout-setting.js +46 -39
  22. package/lowcode/cms-plugin/pos-checkout-setting.ts +237 -227
  23. package/lowcode/cms-plugin/pos-config-setting.js +25 -23
  24. package/lowcode/cms-plugin/pos-config-setting.ts +35 -32
  25. package/lowcode/cms-plugin/pos-pages/payment-function.js +253 -139
  26. package/lowcode/cms-plugin/pos-pages/payment-function.ts +405 -279
  27. package/lowcode/cms-plugin/pos-pages/payment-page.js +348 -267
  28. package/lowcode/cms-plugin/pos-pages/payment-page.ts +378 -296
  29. package/lowcode/cms-plugin/pos-pages/pos-function.js +76 -19
  30. package/lowcode/cms-plugin/pos-pages/pos-function.ts +84 -19
  31. package/lowcode/cms-plugin/shopping-discount-setting.js +2 -2
  32. package/lowcode/cms-plugin/shopping-discount-setting.ts +2 -2
  33. package/lowcode/cms-plugin/shopping-finance-setting.js +1590 -1701
  34. package/lowcode/cms-plugin/shopping-finance-setting.ts +1967 -2011
  35. package/lowcode/cms-plugin/shopping-order-manager.js +74 -62
  36. package/lowcode/cms-plugin/shopping-order-manager.ts +119 -85
  37. package/lowcode/cms-plugin/shopping-product-text.js +874 -531
  38. package/lowcode/cms-plugin/shopping-product-text.ts +1656 -1305
  39. package/lowcode/cms-plugin/shopping-setting-advance.js +1 -1
  40. package/lowcode/cms-plugin/shopping-setting-advance.ts +2 -1
  41. package/lowcode/cms-plugin/shopping-setting-basic.js +152 -124
  42. package/lowcode/cms-plugin/shopping-setting-basic.ts +315 -247
  43. package/lowcode/css/editor.css +3 -2
  44. package/lowcode/glitter-base/global/language.js +5 -3
  45. package/lowcode/glitter-base/global/language.ts +8 -6
  46. package/lowcode/glitter-base/global/payment-config.js +6 -0
  47. package/lowcode/glitter-base/global/payment-config.ts +6 -3
  48. package/lowcode/public-components/product/pd-class.js +1 -3
  49. package/lowcode/public-components/product/pd-class.ts +1 -3
  50. package/lowcode/public-components/user-manager/um-order.js +2 -1
  51. package/lowcode/public-components/user-manager/um-order.ts +2 -1
  52. package/package.json +1 -1
  53. package/src/api-public/controllers/index.js +14 -3
  54. package/src/api-public/controllers/index.js.map +1 -1
  55. package/src/api-public/controllers/index.ts +16 -3
  56. package/src/api-public/controllers/shop.js +14 -7
  57. package/src/api-public/controllers/shop.js.map +1 -1
  58. package/src/api-public/controllers/shop.ts +14 -8
  59. package/src/api-public/services/data-analyze.d.ts +1 -1
  60. package/src/api-public/services/ezpay/tool.d.ts +0 -1
  61. package/src/api-public/services/financial-serviceV2.js +7 -17
  62. package/src/api-public/services/financial-serviceV2.js.map +1 -1
  63. package/src/api-public/services/schedule.js +1 -1
  64. package/src/api-public/services/schedule.js.map +1 -1
  65. package/src/api-public/services/schedule.ts +1 -1
  66. package/src/api-public/services/shopee.js.map +1 -1
  67. package/src/api-public/services/updated-table-checked.js +20 -0
  68. package/src/api-public/services/updated-table-checked.js.map +1 -1
  69. package/src/api-public/services/updated-table-checked.ts +21 -0
  70. package/src/api-public/services/user.js +22 -12
  71. package/src/api-public/services/user.js.map +1 -1
  72. package/src/api-public/services/user.ts +31 -22
  73. package/src/app-project/serverless/src/modules/database.d.ts +1 -1
  74. package/src/app-project/serverless/src/modules/redis.d.ts +1 -1
  75. package/src/helper/glitter-util.d.ts +0 -1
  76. package/src/index.js +3 -3
  77. package/src/index.js.map +13 -1
  78. package/src/modules/tool.d.ts +2 -0
  79. package/src/modules/tool.js +7 -0
  80. package/src/modules/tool.js.map +1 -1
  81. package/src/modules/tool.ts +7 -0
  82. package/src/seo-config.js +3 -3
  83. package/src/seo-config.js.map +9 -1
  84. package/src/services/private_config.js +11 -0
  85. package/src/services/private_config.js.map +1 -1
  86. package/src/services/private_config.ts +11 -0
  87. package/src/services/saas-table-check.js +12 -0
  88. package/src/services/saas-table-check.js.map +1 -1
  89. package/src/services/saas-table-check.ts +12 -0
  90. package/src/services/ses.js +3 -4
  91. package/src/services/ses.js.map +1 -1
@@ -7,6 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
+ var _a;
10
11
  import { EditorElem } from '../glitterBundle/plugins/editor-elem.js';
11
12
  import { ShareDialog } from '../glitterBundle/dialog/ShareDialog.js';
12
13
  import { BgWidget } from '../backend-manager/bg-widget.js';
@@ -25,839 +26,174 @@ import { ShoppingShipmentSetting } from './shopping-shipment-setting.js';
25
26
  const html = String.raw;
26
27
  export class ShoppingFinanceSetting {
27
28
  static main(gvc, pos) {
29
+ this.gvc = gvc;
30
+ this.id = 'shopping-finance-setting-main';
31
+ this.loading = true;
28
32
  pos = `${pos}` === 'true';
29
- const dialog = new ShareDialog(gvc.glitter);
30
- const saasConfig = window.parent.saasConfig;
33
+ let keyData = { payment_info_custom: [] };
31
34
  const vm = {
32
- id: gvc.glitter.getUUID(),
35
+ id: this.id,
33
36
  onBoxId: gvc.glitter.getUUID(),
34
37
  posBoxId: gvc.glitter.getUUID(),
35
38
  offBoxId: gvc.glitter.getUUID(),
36
- loading: true,
37
39
  page: pos ? 'pos' : 'online',
38
40
  };
39
- let keyData = { payment_info_custom: [] };
40
- function refresh() {
41
- gvc.notifyDataChange(vm.id);
42
- }
43
- function saveData() {
44
- saasConfig.api.setPrivateConfig(saasConfig.config.appName, 'glitter_finance', keyData).then(() => {
45
- vm.loading = true;
46
- refresh();
47
- });
48
- }
49
- function updateCustomFinance(obj) {
41
+ const dialog = new ShareDialog(gvc.glitter);
42
+ const saasConfig = this.saasConfig;
43
+ const saveData = () => {
44
+ saasConfig.api.setPrivateConfig(saasConfig.config.appName, 'glitter_finance', keyData).then(() => this.refresh());
45
+ };
46
+ const customFinance = (obj) => {
50
47
  const custom_finance = structuredClone(obj.data || {
51
48
  id: gvc.glitter.getUUID(),
52
49
  name: '',
53
50
  text: '',
54
51
  shipmentSupport: [],
55
52
  });
56
- let form = undefined;
57
- BgWidget.settingDialog({
58
- gvc: gvc,
59
- title: obj.function === 'replace' ? '修改金流設定' : '新增自訂金流',
60
- width: 800,
61
- innerHTML: gvc => {
62
- const id = gvc.glitter.getUUID();
63
- form = BgWidget.customForm(gvc, [
64
- {
65
- title: html ` <div class="tx_normal fw-bolder mt-2 d-flex flex-column" style="margin-bottom: 12px;">
66
- 自訂線下金流表單
67
- <span style="color: #8D8D8D; font-size: 12px;">當客戶選擇此付款方式時,所需上傳的付款證明</span>
68
- </div>`,
69
- key: `form_finance_${custom_finance.id}`,
70
- no_padding: true,
71
- },
72
- ]);
53
+ const form = BgWidget.customForm(gvc, [
54
+ {
55
+ title: html ` <div class="tx_normal fw-bolder mt-2 d-flex flex-column" style="margin-bottom: 12px;">
56
+ 自訂線下金流表單
57
+ <span style="color: #8D8D8D; font-size: 12px;">當客戶選擇此付款方式時,所需上傳的付款證明</span>
58
+ </div>`,
59
+ key: `form_finance_${custom_finance.id}`,
60
+ no_padding: true,
61
+ },
62
+ ]);
63
+ const setting = {
64
+ title: '金流設定',
65
+ key: 'setting',
66
+ html: (gvc) => {
67
+ return [
68
+ BgWidget.editeInput({
69
+ gvc: gvc,
70
+ title: '自訂金流名稱',
71
+ default: custom_finance.name,
72
+ callback: text => {
73
+ custom_finance.name = text;
74
+ },
75
+ placeHolder: '請輸入自訂金流名稱',
76
+ global_language: true,
77
+ }),
78
+ form.view,
79
+ ].join('');
80
+ },
81
+ };
82
+ const note = {
83
+ title: '付款說明',
84
+ key: 'note',
85
+ html: (gvc) => {
86
+ return [
87
+ html ` <div class="d-flex justify-content-between mb-3">
88
+ <div class="tx_normal">付款說明</div>
89
+ </div>`,
90
+ BgWidget.richTextEditor({
91
+ gvc: gvc,
92
+ content: custom_finance.text,
93
+ callback: content => {
94
+ custom_finance.text = content;
95
+ },
96
+ title: '付款說明',
97
+ }),
98
+ ].join('');
99
+ },
100
+ };
101
+ const shipment = {
102
+ key: 'shipment',
103
+ title: '指定物流',
104
+ html: (gvc) => {
73
105
  return gvc.bindView({
74
- bind: id,
75
- view: () => {
76
- const setting = {
77
- title: '金流設定',
78
- key: 'setting',
79
- html: [
80
- BgWidget.editeInput({
81
- gvc: gvc,
82
- title: '自訂金流名稱',
83
- default: custom_finance.name,
84
- callback: text => {
85
- custom_finance.name = text;
86
- },
87
- placeHolder: '請輸入自訂金流名稱',
88
- global_language: true,
89
- }),
90
- form.view,
91
- ].join(''),
92
- };
93
- const note = {
94
- title: '付款說明',
95
- key: 'note',
96
- html: [
97
- html ` <div class="d-flex justify-content-between mb-3">
98
- <div class="tx_normal">付款說明</div>
99
- </div>`,
100
- BgWidget.richTextEditor({
101
- gvc: gvc,
102
- content: custom_finance.text,
103
- callback: content => {
104
- custom_finance.text = content;
105
- },
106
- title: '付款說明',
107
- }),
108
- ].join(''),
109
- };
110
- const shipment = {
111
- key: 'shipment',
112
- title: '指定物流',
113
- html: gvc.bindView({
114
- bind: gvc.glitter.getUUID(),
115
- view: () => ShoppingFinanceSetting.setShipmentSupport(gvc, custom_finance),
116
- }),
117
- };
118
- const cartSetting = {
119
- key: 'cartSetting',
120
- title: '購物車設定',
121
- html: gvc.bindView({
122
- bind: gvc.glitter.getUUID(),
123
- view: () => ShoppingFinanceSetting.setCartSetting(gvc, custom_finance),
124
- }),
125
- };
126
- return ShoppingFinanceSetting.tabView(gvc, [setting, note, shipment, cartSetting]);
127
- },
106
+ bind: gvc.glitter.getUUID(),
107
+ view: () => ShoppingFinanceSetting.setShipmentSupport(gvc, custom_finance),
128
108
  });
129
109
  },
130
- footer_html: gvc => {
131
- const saveButton = BgWidget.save(gvc.event(() => {
132
- return new Promise(() => __awaiter(this, void 0, void 0, function* () {
133
- var _a;
134
- if (!custom_finance.name) {
135
- dialog.errorMessage({ text: '請輸入金流名稱' });
136
- return;
137
- }
138
- keyData.payment_info_custom = (_a = keyData.payment_info_custom) !== null && _a !== void 0 ? _a : [];
139
- if (obj.function === 'plus') {
140
- const newFinance = JSON.parse(JSON.stringify(custom_finance));
141
- keyData.payment_info_custom.push(newFinance);
142
- }
143
- else {
144
- const index = keyData.payment_info_custom.findIndex((d1) => d1.id === custom_finance.id);
145
- if (index !== -1) {
146
- keyData.payment_info_custom[index] = custom_finance;
147
- }
148
- else {
149
- console.error('找不到對應的金流設定 ID:', custom_finance.id);
110
+ };
111
+ const cartSetting = {
112
+ key: 'cartSetting',
113
+ title: '購物車設定',
114
+ html: (gvc) => {
115
+ return gvc.bindView({
116
+ bind: gvc.glitter.getUUID(),
117
+ view: () => ShoppingFinanceSetting.setCartSetting(gvc, custom_finance),
118
+ });
119
+ },
120
+ };
121
+ return (obj.function === 'plus' ? [setting] : [setting, note, shipment, cartSetting]).map(item => {
122
+ return {
123
+ button: { color: 'gray', size: 'sm' },
124
+ text: { name: item.title },
125
+ event: gvc.event(() => __awaiter(this, void 0, void 0, function* () {
126
+ this.settingDialog(gvc, item.title, gvc => html `<div>${item.html(gvc)}</div>`, gvc => {
127
+ return BgWidget.save(gvc.event(() => __awaiter(this, void 0, void 0, function* () {
128
+ var _b;
129
+ if (!custom_finance.name) {
130
+ dialog.errorMessage({ text: '請輸入金流名稱' });
150
131
  return;
151
132
  }
152
- }
153
- dialog.dataLoading({ visible: true });
154
- try {
155
- yield form.save();
156
- yield saasConfig.api.setPrivateConfig(saasConfig.config.appName, 'glitter_finance', keyData);
157
- dialog.successMessage({ text: '設定成功' });
158
- }
159
- catch (error) {
160
- console.error('更新金流設定失敗:', error);
161
- dialog.errorMessage({ text: '設定失敗,請稍後再試' });
162
- }
163
- finally {
164
- dialog.dataLoading({ visible: false });
165
- }
166
- gvc.closeDialog();
167
- refresh();
168
- }));
169
- }));
170
- if (obj.function === 'plus') {
171
- return saveButton;
172
- }
173
- return [
174
- BgWidget.danger(gvc.event(() => {
175
- dialog.checkYesOrNot({
176
- text: '是否確認刪除?',
177
- callback: response => {
178
- if (response) {
179
- keyData.payment_info_custom = keyData.payment_info_custom.filter((d1) => {
180
- return obj.data.id !== d1.id;
181
- });
182
- dialog.dataLoading({ visible: true });
183
- saasConfig.api.setPrivateConfig(saasConfig.config.appName, 'glitter_finance', keyData);
184
- dialog.dataLoading({ visible: false });
185
- gvc.closeDialog();
186
- refresh();
133
+ if (vm.page === 'pos') {
134
+ custom_finance.type = 'pos';
135
+ }
136
+ keyData.payment_info_custom = (_b = keyData.payment_info_custom) !== null && _b !== void 0 ? _b : [];
137
+ if (obj.function === 'plus') {
138
+ const newFinance = JSON.parse(JSON.stringify(custom_finance));
139
+ keyData.payment_info_custom.push(newFinance);
140
+ }
141
+ else {
142
+ const index = keyData.payment_info_custom.findIndex((d1) => d1.id === custom_finance.id);
143
+ if (index !== -1) {
144
+ keyData.payment_info_custom[index] = custom_finance;
187
145
  }
188
- },
189
- });
190
- })),
191
- saveButton,
192
- ].join('');
193
- },
146
+ else {
147
+ console.error('找不到對應的金流設定 ID:', custom_finance.id);
148
+ return;
149
+ }
150
+ }
151
+ dialog.dataLoading({ visible: true });
152
+ try {
153
+ yield form.save();
154
+ yield saasConfig.api.setPrivateConfig(saasConfig.config.appName, 'glitter_finance', keyData);
155
+ dialog.successMessage({ text: '設定成功' });
156
+ }
157
+ catch (error) {
158
+ console.error('更新金流設定失敗:', error);
159
+ dialog.errorMessage({ text: '設定失敗,請稍後再試' });
160
+ }
161
+ finally {
162
+ dialog.dataLoading({ visible: false });
163
+ }
164
+ this.refresh(gvc);
165
+ })));
166
+ }, () => this.refresh(gvc));
167
+ })),
168
+ };
194
169
  });
195
- }
196
- return BgWidget.container(html `
197
- ${[
198
- html ` <div class="title-container ${pos ? `d-none` : ''}">
199
- ${BgWidget.title('金流設定')}
200
- <div class="flex-fill"></div>
201
- </div>`,
170
+ };
171
+ return BgWidget.container([
172
+ html ` <div class="title-container ${pos ? 'd-none' : ''}">
173
+ ${BgWidget.title('金流設定')}
174
+ <div class="flex-fill"></div>
175
+ </div>`,
202
176
  gvc.bindView({
203
177
  bind: vm.id,
204
178
  view: () => {
205
- var _a;
206
- if (vm.loading) {
179
+ if (this.loading) {
207
180
  return BgWidget.spinner();
208
181
  }
209
182
  try {
210
- keyData.off_line_support = (_a = keyData.off_line_support) !== null && _a !== void 0 ? _a : Object.assign({ line: false, atm: false, cash_on_delivery: false }, keyData.payment_info_custom.map((dd) => {
211
- return {
212
- [dd.id]: false,
213
- };
214
- }));
215
- Object.keys(keyData.off_line_support).map(key => {
216
- if (['line', 'atm', 'cash_on_delivery'].includes(key) ||
217
- keyData.payment_info_custom.some((item) => item.id === key)) {
218
- return;
219
- }
220
- delete keyData.off_line_support[key];
221
- });
222
- let h = '';
223
- const cloneData = structuredClone(keyData);
224
- if (vm.page === 'online') {
225
- h = html ` <div class="px-md-0 px-2 mb-2">
226
- ${BgWidget.normalInsignia('透過線上金流,消費者可於線上進行結帳付款')}
227
- </div>
228
- <div class="row m-0">
229
- ${PaymentConfig.onlinePay
230
- .filter(item => item.type !== 'pos')
231
- .map(dd => {
232
- var _a;
233
- keyData[dd.key] = (_a = keyData[dd.key]) !== null && _a !== void 0 ? _a : {};
234
- return html ` <div class="col-12 col-lg-3 col-md-4 p-0 p-md-2">
235
- <div
236
- class="w-100 position-relative main-card"
237
- style=" background: white; overflow: hidden; flex-direction: column; justify-content: flex-start; align-items: flex-start; gap: 10px; display: inline-flex;"
238
- >
239
- <div
240
- class="pt-4"
241
- style="align-self: stretch; justify-content: flex-start; align-items: center; gap: 28px; display: inline-flex"
242
- >
243
- <div style="min-width: 46px;max-width: 46px;">
244
- <img src="${dd.img || BgWidget.noImageURL}" />
245
- </div>
246
- <div
247
- style="flex-direction: column; justify-content: center; align-items: flex-start; gap: 4px; display: inline-flex"
248
- >
249
- <div class="tx_normal">${dd.name}</div>
250
- <div class="d-flex align-items-center" style="gap:4px;">
251
- <div class="tx_normal">${keyData[dd.key].toggle ? `開啟` : `關閉`}</div>
252
- <div class="cursor_pointer form-check form-switch" style="margin-top: 10px;">
253
- <input
254
- class="form-check-input"
255
- type="checkbox"
256
- onchange="${gvc.event((e, event) => {
257
- keyData[dd.key].toggle = !keyData[dd.key].toggle;
258
- saveData();
259
- })}"
260
- ${keyData[dd.key].toggle ? `checked` : ''}
261
- />
262
- </div>
263
- </div>
264
- </div>
265
- </div>
266
- <div class="position-absolute " style="right:10px;top:10px;">
267
- ${BgWidget.customButton({
268
- button: {
269
- color: 'gray',
270
- size: 'sm',
271
- },
272
- text: {
273
- name: '金流設定',
274
- },
275
- event: gvc.event(() => {
276
- const payData = dd;
277
- const key_d = structuredClone(keyData[payData.key]);
278
- BgWidget.settingDialog({
279
- gvc: gvc,
280
- title: '金流設定',
281
- width: 800,
282
- innerHTML: (gvc) => {
283
- try {
284
- const setting = {
285
- key: 'setting',
286
- title: '基本設定',
287
- html: html ` ${BgWidget.editeInput({
288
- gvc: gvc,
289
- title: html `<div>
290
- 自訂金流名稱 ${BgWidget.grayNote('未輸入則參照預設')}
291
- </div>`,
292
- default: key_d.custome_name,
293
- callback: text => {
294
- key_d.custome_name = text;
295
- },
296
- placeHolder: '請輸入自訂顯示名稱',
297
- global_language: true,
298
- })}
299
- <div style="margin-top: 8px;">
300
- ${(() => {
301
- switch (payData.key) {
302
- case 'newWebPay':
303
- case 'ecPay':
304
- return [
305
- BgWidget.inlineCheckBox({
306
- title: '串接路徑',
307
- gvc: gvc,
308
- def: key_d.ActionURL,
309
- array: (() => {
310
- if (payData.key === 'newWebPay') {
311
- return [
312
- {
313
- title: '正式站',
314
- value: 'https://core.newebpay.com/MPG/mpg_gateway',
315
- },
316
- {
317
- title: '測試站',
318
- value: 'https://ccore.newebpay.com/MPG/mpg_gateway',
319
- },
320
- ];
321
- }
322
- else {
323
- return [
324
- {
325
- title: '正式站',
326
- value: 'https://payment.ecpay.com.tw/Cashier/AioCheckOut/V5',
327
- },
328
- {
329
- title: '測試站',
330
- value: 'https://payment-stage.ecpay.com.tw/Cashier/AioCheckOut/V5',
331
- },
332
- ];
333
- }
334
- })(),
335
- callback: (text) => {
336
- key_d.ActionURL = text;
337
- },
338
- }),
339
- BgWidget.inlineCheckBox({
340
- title: '開通付款方式',
341
- gvc: gvc,
342
- def: [
343
- 'credit',
344
- 'atm',
345
- 'web_atm',
346
- 'c_code',
347
- 'c_bar_code',
348
- ].filter(dd => {
349
- return key_d[dd];
350
- }),
351
- array: [
352
- {
353
- title: '信用卡',
354
- value: 'credit',
355
- },
356
- {
357
- title: '一般 ATM',
358
- value: 'atm',
359
- },
360
- {
361
- title: '網路 ATM',
362
- value: 'web_atm',
363
- },
364
- {
365
- title: '超商代碼',
366
- value: 'c_code',
367
- },
368
- {
369
- title: '超商條碼',
370
- value: 'c_bar_code',
371
- },
372
- ],
373
- callback: (array) => {
374
- ['credit', 'atm', 'web_atm', 'c_code', 'c_bar_code'].map(dd => {
375
- key_d[dd] = !!array.find((d1) => {
376
- return d1 === dd;
377
- });
378
- });
379
- },
380
- type: 'multiple',
381
- }),
382
- BgWidget.editeInput({
383
- gvc: gvc,
384
- title: '特店編號',
385
- default: key_d.MERCHANT_ID,
386
- callback: text => {
387
- key_d.MERCHANT_ID = text;
388
- },
389
- placeHolder: '請輸入特店編號',
390
- }),
391
- BgWidget.editeInput({
392
- gvc: gvc,
393
- title: 'HASH_KEY',
394
- default: key_d.HASH_KEY,
395
- callback: text => {
396
- key_d.HASH_KEY = text;
397
- },
398
- placeHolder: '請輸入HASH_KEY',
399
- }),
400
- BgWidget.editeInput({
401
- gvc: gvc,
402
- title: 'HASH_IV',
403
- default: key_d.HASH_IV,
404
- callback: text => {
405
- key_d.HASH_IV = text;
406
- },
407
- placeHolder: '請輸入HASH_IV',
408
- }),
409
- BgWidget.editeInput({
410
- gvc: gvc,
411
- title: '信用卡授權檢查碼',
412
- default: key_d.CreditCheckCode,
413
- callback: text => {
414
- key_d.CreditCheckCode = text;
415
- },
416
- placeHolder: '請輸入信用卡檢查碼',
417
- }),
418
- ].join('');
419
- case 'paypal':
420
- return [
421
- BgWidget.inlineCheckBox({
422
- title: '串接路徑',
423
- gvc: gvc,
424
- def: `${key_d.BETA}`,
425
- array: [
426
- {
427
- title: '正式站',
428
- value: `false`,
429
- },
430
- {
431
- title: '測試站',
432
- value: `true`,
433
- },
434
- ],
435
- callback: (text) => {
436
- key_d.BETA = text;
437
- },
438
- }),
439
- BgWidget.editeInput({
440
- gvc: gvc,
441
- title: 'CLIENT_ID',
442
- default: key_d.PAYPAL_CLIENT_ID,
443
- callback: text => {
444
- key_d.PAYPAL_CLIENT_ID = text;
445
- },
446
- placeHolder: '請輸入CLIENT_ID',
447
- }),
448
- BgWidget.editeInput({
449
- gvc: gvc,
450
- title: 'SECRET',
451
- default: key_d.PAYPAL_SECRET,
452
- callback: text => {
453
- key_d.PAYPAL_SECRET = text;
454
- },
455
- placeHolder: '請輸入SECRET',
456
- }),
457
- ].join('');
458
- case 'line_pay':
459
- return [
460
- BgWidget.inlineCheckBox({
461
- title: '串接路徑',
462
- gvc: gvc,
463
- def: `${key_d.BETA}`,
464
- array: [
465
- {
466
- title: '正式站',
467
- value: `false`,
468
- },
469
- {
470
- title: '測試站',
471
- value: `true`,
472
- },
473
- ],
474
- callback: (text) => {
475
- key_d.BETA = text;
476
- },
477
- }),
478
- BgWidget.editeInput({
479
- gvc: gvc,
480
- title: 'CLIENT_ID',
481
- default: key_d.CLIENT_ID,
482
- callback: text => {
483
- key_d.CLIENT_ID = text;
484
- },
485
- placeHolder: '請輸入CLIENT_ID',
486
- }),
487
- BgWidget.editeInput({
488
- gvc: gvc,
489
- title: 'SECRET',
490
- default: key_d.SECRET,
491
- callback: text => {
492
- key_d.SECRET = text;
493
- },
494
- placeHolder: '請輸入SECRET',
495
- }),
496
- ].join('');
497
- case 'jkopay':
498
- return [
499
- BgWidget.editeInput({
500
- gvc: gvc,
501
- title: 'STORE_ID',
502
- default: key_d.STORE_ID,
503
- callback: text => {
504
- key_d.STORE_ID = text;
505
- },
506
- placeHolder: '請輸入STORE_ID',
507
- }),
508
- ].join('');
509
- case 'paynow':
510
- return [
511
- BgWidget.inlineCheckBox({
512
- title: '串接路徑',
513
- gvc: gvc,
514
- def: `${key_d.BETA}`,
515
- array: [
516
- {
517
- title: '正式站',
518
- value: `false`,
519
- },
520
- {
521
- title: '測試站',
522
- value: `true`,
523
- },
524
- ],
525
- callback: (text) => {
526
- key_d.BETA = text;
527
- },
528
- }),
529
- BgWidget.editeInput({
530
- gvc: gvc,
531
- title: '串接帳號',
532
- default: key_d.account,
533
- callback: text => {
534
- key_d.account = text;
535
- },
536
- placeHolder: '請輸入串接帳號',
537
- }),
538
- BgWidget.editeInput({
539
- gvc: gvc,
540
- title: '串接密碼',
541
- default: key_d.pwd,
542
- callback: text => {
543
- key_d.pwd = text;
544
- },
545
- placeHolder: '請輸入串接密碼',
546
- }),
547
- ].join('');
548
- }
549
- return '';
550
- })()}
551
- </div>`,
552
- };
553
- const shipment = {
554
- key: 'shipment',
555
- title: '指定物流',
556
- html: gvc.bindView({
557
- bind: gvc.glitter.getUUID(),
558
- view: () => ShoppingFinanceSetting.setShipmentSupport(gvc, key_d),
559
- }),
560
- };
561
- const cartSetting = {
562
- key: 'cartSetting',
563
- title: '購物車設定',
564
- html: gvc.bindView({
565
- bind: gvc.glitter.getUUID(),
566
- view: () => ShoppingFinanceSetting.setCartSetting(gvc, key_d),
567
- }),
568
- };
569
- return ShoppingFinanceSetting.tabView(gvc, [setting, shipment, cartSetting]);
570
- }
571
- catch (e) {
572
- console.error(e);
573
- return `${e}`;
574
- }
575
- },
576
- footer_html: gvc => {
577
- return [
578
- BgWidget.cancel(gvc.event(() => {
579
- keyData = cloneData;
580
- gvc.closeDialog();
581
- })),
582
- BgWidget.save(gvc.event(() => {
583
- if (payData.key == 'ecPay' &&
584
- key_d.ActionURL ==
585
- 'https://payment-stage.ecpay.com.tw/Cashier/AioCheckOut/V5') {
586
- key_d.MERCHANT_ID = '3002607';
587
- key_d.HASH_KEY = 'pwFHCqoQZGmho4w6';
588
- key_d.HASH_IV = 'EkRm7iFT261dpevs';
589
- }
590
- keyData[payData.key] = key_d;
591
- saveData();
592
- gvc.closeDialog();
593
- })),
594
- ].join('');
595
- },
596
- closeCallback: () => {
597
- keyData = cloneData;
598
- },
599
- });
600
- }),
601
- })}
602
- </div>
603
- </div>
604
- </div>`;
605
- })
606
- .join('')}
607
- </div>`;
608
- }
609
- if (vm.page === 'offline') {
610
- const offlinePayArray = [
611
- ...PaymentConfig.defalutOfflinePay,
612
- ...keyData.payment_info_custom.map((dd) => {
613
- return {
614
- key: dd.id,
615
- name: html `${Language.getLanguageCustomText(dd.name)}`,
616
- custom: true,
617
- };
618
- }),
619
- ];
620
- h = html ` <div class="px-md-0 px-2 mb-2">
621
- ${BgWidget.normalInsignia('透過設定線下金流,結帳後訂單將進入手動核款的流程,亦可使用超商取貨付款')}
622
- </div>
623
- <div class="row m-0">
624
- ${offlinePayArray
625
- .map((dd) => {
626
- return html ` <div class="col-12 col-lg-3 col-md-4 p-0 p-md-2">
627
- <div
628
- class="w-100 position-relative main-card "
629
- style=" background: white; overflow: hidden; flex-direction: column; justify-content: flex-start; align-items: flex-start;gap:10px; display: inline-flex;"
630
- >
631
- <div
632
- class="pt-4"
633
- style="align-self: stretch; justify-content: flex-start; align-items: center; gap: 28px; display: inline-flex"
634
- >
635
- <div style="min-width: 46px;max-width: 46px;">
636
- ${dd.img
637
- ? html `<img class="rounded-2" src="${dd.img}" />`
638
- : html `<i class="fa-regular fa-puzzle-piece-simple fs-4" aria-hidden="true"></i>`}
639
- </div>
640
- <div
641
- style="flex-direction: column; justify-content: center; align-items: flex-start; gap: 4px; display: inline-flex"
642
- >
643
- <div class="tx_normal">${dd.name}</div>
644
- <div class="d-flex align-items-center" style="gap:4px;">
645
- <div class="tx_normal">
646
- ${keyData.off_line_support[dd.key] ? `開啟` : `關閉`}
647
- </div>
648
- <div class="cursor_pointer form-check form-switch" style="margin-top: 10px;">
649
- <input
650
- class="form-check-input"
651
- type="checkbox"
652
- onchange="${gvc.event((e, event) => {
653
- keyData.off_line_support[dd.key] = !keyData.off_line_support[dd.key];
654
- saveData();
655
- })}"
656
- ${keyData.off_line_support[dd.key] ? `checked` : ''}
657
- />
658
- </div>
659
- </div>
660
- </div>
661
- </div>
662
- <div
663
- class=" position-absolute ${dd.hide_setting ? `d-none` : ''}"
664
- style="right:10px;top:10px;"
665
- >
666
- ${BgWidget.customButton({
667
- button: {
668
- color: 'gray',
669
- size: 'sm',
670
- },
671
- text: {
672
- name: '金流設定',
673
- },
674
- event: gvc.event(() => {
675
- if (dd.custom) {
676
- updateCustomFinance({
677
- function: 'replace',
678
- data: keyData.payment_info_custom.find((d1) => dd.key === d1.id),
679
- });
680
- return;
681
- }
682
- BgWidget.settingDialog({
683
- gvc: gvc,
684
- title: '金流設定',
685
- width: 800,
686
- innerHTML: gvc => {
687
- const keyMap = {
688
- atm: this.atm(gvc, keyData),
689
- line: this.lineIPassMoney(gvc, keyData),
690
- cash_on_delivery: this.cashOnDelivery(gvc, keyData),
691
- };
692
- return html `<div>${keyMap[dd.key] || ''}</div>`;
693
- },
694
- footer_html: gvc => {
695
- return [
696
- BgWidget.cancel(gvc.event(() => {
697
- keyData = cloneData;
698
- gvc.closeDialog();
699
- })),
700
- BgWidget.save(gvc.event(() => {
701
- saveData();
702
- gvc.closeDialog();
703
- })),
704
- ].join('');
705
- },
706
- closeCallback: () => {
707
- keyData = cloneData;
708
- },
709
- });
710
- }),
711
- })}
712
- </div>
713
- </div>
714
- </div>`;
715
- })
716
- .join('')}
717
- <div
718
- class="col-12 col-lg-3 col-md-4 p-0 p-md-2"
719
- style="cursor: pointer;"
720
- onclick="${gvc.event(() => {
721
- updateCustomFinance({ function: 'plus' });
722
- })}"
723
- >
724
- <div
725
- class="w-100 main-card"
726
- style="min-height:119.09px;padding: 24px; background: white; overflow: hidden; flex-direction: column; justify-content: center; align-items: center; gap: 18px; display: inline-flex"
727
- >
728
- <div
729
- class="fw-bold"
730
- style="align-self: stretch; justify-content: center; align-items: center; gap: 14px; display: inline-flex;color:#4D86DB;"
731
- >
732
- <i class="fa-regular fa-circle-plus fs-5"></i>
733
- <div class="fs-5">新增自訂付款</div>
734
- </div>
735
- </div>
736
- </div>
737
- </div>`;
738
- }
739
- if (vm.page === 'pos') {
740
- h = html `<div class="px-md-0 px-2 mb-2">
741
- ${BgWidget.normalInsignia('設定實體店面所需串接的付款方式')}
742
- </div>
743
- <div class="row m-0">
744
- ${PaymentConfig.onlinePay
745
- .filter(item => item.type === 'pos')
746
- .map(dd => {
747
- return html ` <div class="col-12 col-lg-3 col-md-4 p-0 p-md-2">
748
- <div
749
- class="w-100 position-relative main-card"
750
- style=" background: white; overflow: hidden; flex-direction: column; justify-content: flex-start; align-items: flex-start; gap: 10px; display: inline-flex;"
751
- >
752
- <div
753
- class="pt-4"
754
- style="align-self: stretch; justify-content: flex-start; align-items: center; gap: 28px; display: inline-flex"
755
- >
756
- <div style="min-width: 46px;max-width: 46px;">
757
- <img src="${dd.img || BgWidget.noImageURL}" />
758
- </div>
759
- <div
760
- style="flex-direction: column; justify-content: center; align-items: flex-start; gap: 4px; display: inline-flex"
761
- >
762
- <div class="tx_normal">${dd.name}</div>
763
- <div class="d-flex align-items-center" style="gap:4px;">
764
- <div class="tx_normal">${keyData[dd.key].toggle ? `開啟` : `關閉`}</div>
765
- <div class="cursor_pointer form-check form-switch" style="margin-top: 10px;">
766
- <input
767
- class="form-check-input"
768
- type="checkbox"
769
- onchange="${gvc.event(() => {
770
- keyData[dd.key].toggle = !keyData[dd.key].toggle;
771
- saveData();
772
- })}"
773
- ${keyData[dd.key].toggle ? `checked` : ''}
774
- />
775
- </div>
776
- </div>
777
- </div>
778
- </div>
779
-
780
- <div class="position-absolute" style="right:10px;top:10px;">
781
- ${BgWidget.customButton({
782
- button: {
783
- color: 'gray',
784
- size: 'sm',
785
- },
786
- text: {
787
- name: '金流設定',
788
- },
789
- event: gvc.event(() => {
790
- const payData = dd;
791
- const key_d = structuredClone(keyData[payData.key]);
792
- BgWidget.settingDialog({
793
- gvc: gvc,
794
- title: '金流設定',
795
- width: 800,
796
- innerHTML: (gvc) => {
797
- try {
798
- return html `<div>
799
- ${(() => {
800
- switch (payData.key) {
801
- case 'line_pay_scan':
802
- return this.linePayScan(gvc, key_d);
803
- case 'ut_credit_card':
804
- return this.utCreditCard(gvc, key_d);
805
- }
806
- return '';
807
- })()}
808
- </div>`;
809
- }
810
- catch (error) {
811
- console.error(error);
812
- return '';
813
- }
814
- },
815
- footer_html: gvc => {
816
- return [
817
- BgWidget.cancel(gvc.event(() => {
818
- keyData = cloneData;
819
- gvc.closeDialog();
820
- })),
821
- BgWidget.save(gvc.event(() => {
822
- keyData[payData.key] = key_d;
823
- saveData();
824
- gvc.closeDialog();
825
- })),
826
- ].join('');
827
- },
828
- closeCallback: () => {
829
- keyData = cloneData;
830
- },
831
- });
832
- }),
833
- })}
834
- </div>
835
- </div>
836
- </div>`;
837
- })
838
- .join('')}
839
- </div>`;
840
- }
183
+ this.initOfflineSupport(keyData);
184
+ this.cleanupOfflineSupport(keyData);
841
185
  return [
842
- pos
843
- ? ''
844
- : BgWidget.tab([
845
- { key: 'online', title: '線上金流' },
846
- { key: 'offline', title: '線下金流' },
847
- ], gvc, vm.page, (key) => {
848
- vm.page = key;
849
- gvc.notifyDataChange(vm.id);
850
- }),
851
- h,
186
+ pos ? '' : this.renderTabs(gvc, vm),
187
+ this.renderPageContent(gvc, vm, keyData, saveData, customFinance),
852
188
  ].join('');
853
189
  }
854
190
  catch (e) {
855
191
  console.error(e);
856
- return `${e}`;
192
+ return '發生錯誤';
857
193
  }
858
194
  },
859
195
  onCreate: () => {
860
- if (vm.loading) {
196
+ if (this.loading) {
861
197
  return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
862
198
  const data = yield saasConfig.api.getPrivateConfig(saasConfig.config.appName, 'glitter_finance');
863
199
  if (data.response.result[0]) {
@@ -865,7 +201,7 @@ export class ShoppingFinanceSetting {
865
201
  }
866
202
  resolve();
867
203
  })).then(() => {
868
- vm.loading = false;
204
+ this.loading = false;
869
205
  gvc.notifyDataChange(vm.id);
870
206
  });
871
207
  }
@@ -878,23 +214,240 @@ export class ShoppingFinanceSetting {
878
214
  }
879
215
  },
880
216
  }),
881
- ].join('')}
882
- ${pos ? '' : BgWidget.mbContainer(240)}
883
- `, {
884
- style: pos ? `margin-top: 0px !important;` : '',
217
+ pos ? '' : BgWidget.mbContainer(240),
218
+ ].join(''), {
219
+ style: pos ? 'margin-top: 0px !important;' : '',
220
+ });
221
+ }
222
+ static initOfflineSupport(keyData) {
223
+ var _b;
224
+ keyData.off_line_support = (_b = keyData.off_line_support) !== null && _b !== void 0 ? _b : Object.assign({ line: false, atm: false, cash_on_delivery: false }, keyData.payment_info_custom.map((dd) => ({
225
+ [dd.id]: false,
226
+ })));
227
+ }
228
+ static cleanupOfflineSupport(keyData) {
229
+ Object.keys(keyData.off_line_support).forEach(key => {
230
+ const isValidKey = ['line', 'atm', 'cash_on_delivery'].includes(key) ||
231
+ keyData.payment_info_custom.some((item) => item.id === key);
232
+ if (!isValidKey) {
233
+ delete keyData.off_line_support[key];
234
+ }
885
235
  });
886
236
  }
237
+ static renderTabs(gvc, vm) {
238
+ return BgWidget.tab([
239
+ { key: 'online', title: '線上金流' },
240
+ { key: 'offline', title: '線下金流' },
241
+ ], gvc, vm.page, (key) => {
242
+ vm.page = key;
243
+ gvc.notifyDataChange(vm.id);
244
+ });
245
+ }
246
+ static renderPageContent(gvc, vm, keyData, saveData, setCustomFinance) {
247
+ switch (vm.page) {
248
+ case 'online':
249
+ return this.onlinePayment(gvc, keyData, saveData);
250
+ case 'offline':
251
+ return this.offlinePayment(gvc, keyData, saveData, setCustomFinance);
252
+ case 'pos':
253
+ return this.posPayment(gvc, keyData, saveData, setCustomFinance);
254
+ default:
255
+ return '';
256
+ }
257
+ }
258
+ static onlinePayment(gvc, keyData, saveData) {
259
+ return html ` <div class="px-md-0 px-2 mb-2">
260
+ ${BgWidget.normalInsignia('透過線上金流,消費者可於線上進行結帳付款')}
261
+ </div>
262
+ <div class="row m-0">
263
+ ${PaymentConfig.onlinePay
264
+ .filter(item => item.type !== 'pos')
265
+ .map(dd => {
266
+ var _b;
267
+ keyData[dd.key] = (_b = keyData[dd.key]) !== null && _b !== void 0 ? _b : {};
268
+ return this.card({
269
+ title: dd.name,
270
+ img: html `<img src="${dd.img || BgWidget.noImageURL}" />`,
271
+ toggle: keyData[dd.key].toggle,
272
+ toggleEvent: gvc.event(() => {
273
+ keyData[dd.key].toggle = !keyData[dd.key].toggle;
274
+ saveData();
275
+ }),
276
+ buttonAction: this.formatOnlinePayList(gvc, dd.key, keyData[dd.key]) || [],
277
+ });
278
+ })
279
+ .join('')}
280
+ </div>`;
281
+ }
282
+ static offlinePayment(gvc, keyData, saveData, offlineCustomFinance) {
283
+ const dialog = new ShareDialog(gvc.glitter);
284
+ const saasConfig = this.saasConfig;
285
+ const offlinePayArray = [
286
+ ...PaymentConfig.defalutOfflinePay,
287
+ ...keyData.payment_info_custom
288
+ .filter((dd) => {
289
+ return dd.type !== 'pos';
290
+ })
291
+ .map((dd) => {
292
+ return {
293
+ key: dd.id,
294
+ name: html `${Language.getLanguageCustomText(dd.name)}`,
295
+ custom: true,
296
+ };
297
+ }),
298
+ ];
299
+ const deleteEvent = (key) => gvc.event(() => {
300
+ dialog.checkYesOrNot({
301
+ text: '是否確認刪除此金流?',
302
+ callback: (response) => __awaiter(this, void 0, void 0, function* () {
303
+ if (response) {
304
+ const data = yield saasConfig.api.getPrivateConfig(saasConfig.config.appName, 'glitter_finance');
305
+ if (data.response.result[0]) {
306
+ const keyData = data.response.result[0].value;
307
+ keyData.payment_info_custom = keyData.payment_info_custom.filter((d1) => {
308
+ return key !== d1.id;
309
+ });
310
+ dialog.dataLoading({ visible: true });
311
+ saasConfig.api.setPrivateConfig(saasConfig.config.appName, 'glitter_finance', keyData);
312
+ dialog.dataLoading({ visible: false });
313
+ this.refresh();
314
+ }
315
+ }
316
+ }),
317
+ });
318
+ });
319
+ const keyMap = key => {
320
+ const maps = {
321
+ atm: this.atm(gvc, key, keyData),
322
+ line: this.lineIPassMoney(gvc, key, keyData),
323
+ cash_on_delivery: this.cashOnDelivery(gvc, key, keyData),
324
+ };
325
+ return maps[key] || [];
326
+ };
327
+ return html ` <div class="px-md-0 px-2 mb-2">
328
+ ${BgWidget.normalInsignia('透過設定線下金流,結帳後訂單將進入手動核款的流程,亦可使用超商取貨付款')}
329
+ </div>
330
+ <div class="row m-0">
331
+ ${offlinePayArray
332
+ .map((dd) => {
333
+ var _b;
334
+ keyData[dd.key] = (_b = keyData[dd.key]) !== null && _b !== void 0 ? _b : {};
335
+ const button_action = dd.custom
336
+ ? offlineCustomFinance({
337
+ function: 'replace',
338
+ data: keyData.payment_info_custom.find((d1) => dd.key === d1.id),
339
+ }).map(item => {
340
+ return BgWidget.customButton(item);
341
+ })
342
+ : keyMap(dd.key) || [];
343
+ return this.card({
344
+ title: dd.name,
345
+ img: dd.img
346
+ ? html `<img class="rounded-2" src="${dd.img}" />`
347
+ : html `<i class="fa-regular fa-puzzle-piece-simple fs-4" aria-hidden="true"></i>`,
348
+ toggle: keyData.off_line_support[dd.key],
349
+ toggleEvent: gvc.event(() => {
350
+ keyData.off_line_support[dd.key] = !keyData.off_line_support[dd.key];
351
+ saveData();
352
+ }),
353
+ buttonAction: button_action,
354
+ deleteEvent: dd.custom ? deleteEvent(dd.key) : undefined,
355
+ });
356
+ })
357
+ .join('')}
358
+ ${this.addCard('新增自訂付款', offlineCustomFinance({ function: 'plus' })[0].event)}
359
+ </div>`;
360
+ }
361
+ static posPayment(gvc, keyData, saveData, posCustomFinance) {
362
+ const dialog = new ShareDialog(gvc.glitter);
363
+ const saasConfig = this.saasConfig;
364
+ const posCashflow = [
365
+ ...PaymentConfig.onlinePay.filter(item => item.type === 'pos'),
366
+ ...keyData.payment_info_custom
367
+ .filter((dd) => {
368
+ return dd.type === 'pos';
369
+ })
370
+ .map((dd) => {
371
+ return {
372
+ key: dd.id,
373
+ name: dd.name,
374
+ type: 'pos',
375
+ custom: true,
376
+ img: html `<i class="fa-regular fa-puzzle-piece-simple fs-4"></i>`,
377
+ };
378
+ }),
379
+ ];
380
+ const deleteEvent = (key) => gvc.event(() => {
381
+ dialog.checkYesOrNot({
382
+ text: '是否確認刪除此金流?',
383
+ callback: (response) => __awaiter(this, void 0, void 0, function* () {
384
+ if (response) {
385
+ const data = yield saasConfig.api.getPrivateConfig(saasConfig.config.appName, 'glitter_finance');
386
+ if (data.response.result[0]) {
387
+ const keyData = data.response.result[0].value;
388
+ keyData.payment_info_custom = keyData.payment_info_custom.filter((d1) => {
389
+ return key !== d1.id;
390
+ });
391
+ dialog.dataLoading({ visible: true });
392
+ saasConfig.api.setPrivateConfig(saasConfig.config.appName, 'glitter_finance', keyData);
393
+ dialog.dataLoading({ visible: false });
394
+ this.refresh();
395
+ }
396
+ }
397
+ }),
398
+ });
399
+ });
400
+ return html `<div class="px-md-0 px-2 mb-2">${BgWidget.normalInsignia('設定實體店面所需串接的付款方式')}</div>
401
+ <div class="row m-0">
402
+ ${posCashflow
403
+ .map(dd => {
404
+ var _b;
405
+ keyData[dd.key] = (_b = keyData[dd.key]) !== null && _b !== void 0 ? _b : {};
406
+ const data = structuredClone(keyData[dd.key]);
407
+ const button_action = (() => {
408
+ if (dd.custom) {
409
+ return posCustomFinance({
410
+ function: 'replace',
411
+ data: keyData.payment_info_custom.find((d1) => dd.key === d1.id),
412
+ }).map(item => {
413
+ return BgWidget.customButton(item);
414
+ });
415
+ }
416
+ if (dd.key === 'line_pay_scan') {
417
+ return this.linePayScan(gvc, dd.key, data);
418
+ }
419
+ if (dd.key === 'ut_credit_card') {
420
+ return this.utCreditCard(gvc, dd.key, data);
421
+ }
422
+ return [];
423
+ })();
424
+ return this.card({
425
+ title: dd.name,
426
+ img: dd.img.includes('fa-puzzle-piece') ? dd.img : html `<img src="${dd.img || BgWidget.noImageURL}" />`,
427
+ toggle: keyData[dd.key].toggle,
428
+ toggleEvent: gvc.event(() => {
429
+ keyData[dd.key].toggle = !keyData[dd.key].toggle;
430
+ saveData();
431
+ }),
432
+ buttonAction: button_action,
433
+ deleteEvent: dd.custom ? deleteEvent(dd.key) : undefined,
434
+ });
435
+ })
436
+ .join('')}
437
+ ${this.addCard('新增自訂付款', posCustomFinance({ function: 'plus' })[0].event)}
438
+ </div>`;
439
+ }
887
440
  static tabView(gvc, viewList) {
888
- var _a;
441
+ var _b;
889
442
  const vm = {
890
443
  id: gvc.glitter.getUUID(),
891
- key: ((_a = viewList[0].key) !== null && _a !== void 0 ? _a : ''),
444
+ key: ((_b = viewList[0].key) !== null && _b !== void 0 ? _b : ''),
892
445
  };
893
446
  return gvc.bindView({
894
447
  bind: vm.id,
895
448
  view: () => {
896
- var _a, _b;
897
- const page = (_b = (_a = viewList.find(view => view.key === vm.key)) === null || _a === void 0 ? void 0 : _a.html) !== null && _b !== void 0 ? _b : '';
449
+ var _b, _c;
450
+ const page = (_c = (_b = viewList.find(view => view.key === vm.key)) === null || _b === void 0 ? void 0 : _b.html) !== null && _c !== void 0 ? _c : '';
898
451
  return [
899
452
  BgWidget.tab(viewList, gvc, vm.key, res => {
900
453
  vm.key = res;
@@ -905,15 +458,53 @@ export class ShoppingFinanceSetting {
905
458
  },
906
459
  });
907
460
  }
461
+ static settingDialog(gvc, title, innerHTML, footerHTML, closeCallback) {
462
+ return BgWidget.settingDialog({
463
+ gvc,
464
+ title,
465
+ innerHTML: gvc => innerHTML(gvc),
466
+ footer_html: gvc => footerHTML(gvc),
467
+ closeCallback: closeCallback,
468
+ });
469
+ }
470
+ static buttonListView(gvc, key, keyData, viewList) {
471
+ return viewList.map(item => {
472
+ return BgWidget.customButton({
473
+ button: { color: 'gray', size: 'sm' },
474
+ text: { name: item.title },
475
+ event: gvc.event(() => __awaiter(this, void 0, void 0, function* () {
476
+ this.settingDialog(gvc, item.title, gvc => html `<div>${item.html(gvc)}</div>`, gvc => {
477
+ return [
478
+ BgWidget.cancel(gvc.event(() => this.refresh(gvc))),
479
+ BgWidget.save(gvc.event(() => __awaiter(this, void 0, void 0, function* () {
480
+ try {
481
+ const saasConfig = this.saasConfig;
482
+ const data = yield saasConfig.api.getPrivateConfig(saasConfig.config.appName, 'glitter_finance');
483
+ data.response.result[0].value[key] = keyData;
484
+ saasConfig.api
485
+ .setPrivateConfig(saasConfig.config.appName, 'glitter_finance', data.response.result[0].value)
486
+ .then(() => this.refresh(gvc));
487
+ }
488
+ catch (error) {
489
+ console.error(error);
490
+ gvc.closeDialog();
491
+ }
492
+ }))),
493
+ ].join('');
494
+ }, () => this.refresh(gvc));
495
+ })),
496
+ });
497
+ });
498
+ }
908
499
  static setShipmentSupport(gvc, data) {
909
500
  return __awaiter(this, void 0, void 0, function* () {
910
501
  const id = gvc.glitter.getUUID();
911
- const saasConfig = window.parent.saasConfig;
502
+ const saasConfig = this.saasConfig;
912
503
  const logiData = yield saasConfig.api.getPrivateConfig(saasConfig.config.appName, 'logistics_setting');
913
504
  const custom_delivery = (() => {
914
- var _a, _b, _c;
505
+ var _b, _c, _d;
915
506
  try {
916
- return ((_c = (_b = (_a = logiData === null || logiData === void 0 ? void 0 : logiData.response) === null || _a === void 0 ? void 0 : _a.result[0]) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.custom_delivery) || [];
507
+ return ((_d = (_c = (_b = logiData === null || logiData === void 0 ? void 0 : logiData.response) === null || _b === void 0 ? void 0 : _b.result[0]) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.custom_delivery) || [];
917
508
  }
918
509
  catch (error) {
919
510
  console.error(error);
@@ -932,26 +523,16 @@ export class ShoppingFinanceSetting {
932
523
  return html `<div class="w-100">
933
524
  <div class="d-flex align-items-center mt-2 gap-2">
934
525
  ${BgWidget.customButton({
935
- button: {
936
- color: 'snow',
937
- size: 'sm',
938
- },
939
- text: {
940
- name: '全部開啟',
941
- },
526
+ button: { color: 'snow', size: 'sm' },
527
+ text: { name: '全部開啟' },
942
528
  event: gvc.event(() => {
943
529
  data.shipmentSupport = allDelivery.map(d => d.value);
944
530
  gvc.notifyDataChange(id);
945
531
  }),
946
532
  })}
947
533
  ${BgWidget.customButton({
948
- button: {
949
- color: 'snow',
950
- size: 'sm',
951
- },
952
- text: {
953
- name: '全部關閉',
954
- },
534
+ button: { color: 'snow', size: 'sm' },
535
+ text: { name: '全部關閉' },
955
536
  event: gvc.event(() => {
956
537
  data.shipmentSupport = [];
957
538
  gvc.notifyDataChange(id);
@@ -994,7 +575,7 @@ export class ShoppingFinanceSetting {
994
575
  style="flex-direction: column; justify-content: center; align-items: flex-start; gap: 4px; display: inline-flex"
995
576
  >
996
577
  <div class="tx_normal">${dd.title}</div>
997
- <div class="d-flex align-items-center" style="gap:4px;">
578
+ <div class="d-flex align-items-center" style="gap: 4px;">
998
579
  <div class="tx_normal">${trigger ? '開啟' : '關閉'}</div>
999
580
  <div class="cursor_pointer form-check form-switch" style="margin-top: 10px;">
1000
581
  <input
@@ -1035,11 +616,11 @@ export class ShoppingFinanceSetting {
1035
616
  });
1036
617
  }
1037
618
  static setCartSetting(gvc, data, type = 'cashflow') {
1038
- var _a;
619
+ var _b;
1039
620
  const id = gvc.glitter.getUUID();
1040
621
  const dialog = new ShareDialog(gvc.glitter);
1041
622
  const t = type === 'cashflow' ? '金' : '物';
1042
- data.cartSetting = Object.assign({ minimumTotal: 0, maximumTotal: 0, freeShipmnetTarget: 0, orderFormula: [] }, ((_a = data.cartSetting) !== null && _a !== void 0 ? _a : {}));
623
+ data.cartSetting = Object.assign({ minimumTotal: 0, maximumTotal: 0, freeShipmnetTarget: 0, orderFormula: [] }, ((_b = data.cartSetting) !== null && _b !== void 0 ? _b : {}));
1043
624
  function questionDialog(text) {
1044
625
  return BgWidget.questionButton(gvc.event(() => {
1045
626
  BgWidget.quesDialog({
@@ -1080,44 +661,48 @@ export class ShoppingFinanceSetting {
1080
661
  bind: id,
1081
662
  view: () => {
1082
663
  return [
1083
- html `<div class="d-flex align-items-center mt-2 gap-2 mb-2">
1084
- <div class="tx_700">是否啟用此${t}流的計算公式包含</div>
1085
- ${questionDialog(html `<div style="white-space: normal;">
1086
- 訂單總金額的公式為:<br />
1087
- 「總金額(T) = 所有商品小計(A) - 購物金折抵(B) - 優惠券折抵(C) + 運費(D)」
1088
- </div>
1089
- ${BgWidget.mbContainer(12)}
1090
- <div style="white-space: normal;">勾選的項目會列為「限制使用此${t}流」的公式判斷</div>
1091
- ${BgWidget.mbContainer(12)}
1092
- <div style="white-space: normal;">
1093
- 範例:僅勾選「運費」,顧客購物車消費的總金額依然是 A-B-C+D<br />
1094
- 但此${t}流是否能使用的公式會是 A+D
1095
- </div>
1096
- ${BgWidget.mbContainer(12)}
1097
- <div style="white-space: normal;">
1098
- A+D 有在最低和最高消費金額的區間內<br />
1099
- 則顧客可以使用此${t}流進行結帳
1100
- </div>`)}
1101
- </div>`,
1102
- BgWidget.multiCheckboxContainer(gvc, [
1103
- {
1104
- key: 'use_rebate',
1105
- name: '購物金折抵',
1106
- },
1107
- {
1108
- key: 'discount',
1109
- name: '優惠券折抵',
1110
- },
1111
- {
1112
- key: 'shipment_fee',
1113
- name: '運費',
1114
- },
1115
- ], data.cartSetting.orderFormula, result => {
1116
- data.cartSetting.orderFormula = result;
1117
- }, { single: false }),
664
+ [
665
+ html `<div class="d-flex align-items-center gap-2">
666
+ <div class="tx_700">金額計算規則</div>
667
+ ${questionDialog(html `<div style="white-space: normal;">
668
+ 訂單總金額的公式為:<br />
669
+ 「總金額(T) = 所有商品小計(A) - 購物金折抵(B) - 優惠券折抵(C) + 運費(D)」
670
+ </div>
671
+ ${BgWidget.mbContainer(12)}
672
+ <div style="white-space: normal;">勾選的項目會列為「限制使用此${t}流」的公式判斷</div>
673
+ ${BgWidget.mbContainer(12)}
674
+ <div style="white-space: normal;">
675
+ 範例:僅勾選「運費」,顧客購物車消費的總金額依然是 A-B-C+D<br />
676
+ 但此${t}流是否能使用的公式會是 A+D
677
+ </div>
678
+ ${BgWidget.mbContainer(12)}
679
+ <div style="white-space: normal;">
680
+ 若 A+D 有在最低和最高消費金額的區間內<br />
681
+ 則顧客可以使用此${t}流進行結帳
682
+ </div>`)}
683
+ </div>`,
684
+ BgWidget.grayNote('系統會依據您選擇的規則計算訂單金額,再判斷是否達到以下門檻'),
685
+ BgWidget.mbContainer(8),
686
+ BgWidget.multiCheckboxContainer(gvc, [
687
+ {
688
+ key: 'use_rebate',
689
+ name: '含購物金折抵',
690
+ },
691
+ {
692
+ key: 'discount',
693
+ name: '含優惠券折抵',
694
+ },
695
+ {
696
+ key: 'shipment_fee',
697
+ name: '含運費',
698
+ },
699
+ ], data.cartSetting.orderFormula, result => {
700
+ data.cartSetting.orderFormula = result;
701
+ }, { single: false }),
702
+ ].join(''),
1118
703
  BgWidget.editeInput({
1119
704
  gvc: gvc,
1120
- title: html `<div class="d-flex align-items-center mt-3 gap-2">最低消費金額(輸入 0 則沒有限制)</div>
705
+ title: html `<div class="tx_700">最低消費門檻 (輸入 0 則沒有限制)</div>
1121
706
  ${BgWidget.grayNote(`購物車需達到此金額,才可使用此${t}流`)}`,
1122
707
  default: `${data.cartSetting.minimumTotal}`,
1123
708
  type: 'number',
@@ -1128,7 +713,7 @@ export class ShoppingFinanceSetting {
1128
713
  }),
1129
714
  BgWidget.editeInput({
1130
715
  gvc: gvc,
1131
- title: html `<div class="d-flex align-items-center mt-3 gap-2">最高消費金額(輸入 0 則沒有限制)</div>
716
+ title: html `<div class="tx_700">最高消費門檻 (輸入 0 則沒有限制)</div>
1132
717
  ${BgWidget.grayNote(`購物車需低於此金額,才可使用此${t}流`)}`,
1133
718
  default: `${data.cartSetting.maximumTotal}`,
1134
719
  type: 'number',
@@ -1140,7 +725,7 @@ export class ShoppingFinanceSetting {
1140
725
  BgWidget.horizontalLine({ margin: 1.5 }),
1141
726
  BgWidget.editeInput({
1142
727
  gvc: gvc,
1143
- title: html `<div class="mt-3" style="white-space: break-spaces;">滿額免運(輸入 0 則不啟用)</div>
728
+ title: html `<div class="tx_700">滿額免運 (輸入 0 則不啟用)</div>
1144
729
  ${BgWidget.grayNote('購物車達到此金額即享有免運優惠')}`,
1145
730
  default: `${data.cartSetting.freeShipmnetTarget}`,
1146
731
  type: 'number',
@@ -1149,103 +734,418 @@ export class ShoppingFinanceSetting {
1149
734
  },
1150
735
  placeHolder: '請輸入金額',
1151
736
  }),
1152
- ].join('');
737
+ ].join(BgWidget.mbContainer(18));
738
+ },
739
+ });
740
+ }
741
+ static ePayForm(gvc, key_d, brand) {
742
+ return [
743
+ BgWidget.inlineCheckBox({
744
+ title: '串接路徑',
745
+ gvc: gvc,
746
+ def: key_d.ActionURL,
747
+ array: (() => {
748
+ if (brand === 'newWebPay') {
749
+ return [
750
+ {
751
+ title: '正式站',
752
+ value: 'https://core.newebpay.com/MPG/mpg_gateway',
753
+ },
754
+ {
755
+ title: '測試站',
756
+ value: 'https://ccore.newebpay.com/MPG/mpg_gateway',
757
+ },
758
+ ];
759
+ }
760
+ else {
761
+ return [
762
+ {
763
+ title: '正式站',
764
+ value: 'https://payment.ecpay.com.tw/Cashier/AioCheckOut/V5',
765
+ },
766
+ {
767
+ title: '測試站',
768
+ value: 'https://payment-stage.ecpay.com.tw/Cashier/AioCheckOut/V5',
769
+ },
770
+ ];
771
+ }
772
+ })(),
773
+ callback: (text) => {
774
+ key_d.ActionURL = text;
775
+ },
776
+ }),
777
+ BgWidget.inlineCheckBox({
778
+ title: '開通付款方式',
779
+ gvc: gvc,
780
+ def: ['credit', 'atm', 'web_atm', 'c_code', 'c_bar_code'].filter(dd => {
781
+ return key_d[dd];
782
+ }),
783
+ array: [
784
+ {
785
+ title: '信用卡',
786
+ value: 'credit',
787
+ },
788
+ {
789
+ title: '一般 ATM',
790
+ value: 'atm',
791
+ },
792
+ {
793
+ title: '網路 ATM',
794
+ value: 'web_atm',
795
+ },
796
+ {
797
+ title: '超商代碼',
798
+ value: 'c_code',
799
+ },
800
+ {
801
+ title: '超商條碼',
802
+ value: 'c_bar_code',
803
+ },
804
+ ],
805
+ callback: (array) => {
806
+ ['credit', 'atm', 'web_atm', 'c_code', 'c_bar_code'].map(dd => {
807
+ key_d[dd] = !!array.find((d1) => {
808
+ return d1 === dd;
809
+ });
810
+ });
811
+ },
812
+ type: 'multiple',
813
+ }),
814
+ BgWidget.editeInput({
815
+ gvc: gvc,
816
+ title: '商店代號',
817
+ default: key_d.MERCHANT_ID,
818
+ callback: text => {
819
+ key_d.MERCHANT_ID = text;
820
+ },
821
+ placeHolder: '請輸入商店代號',
822
+ }),
823
+ BgWidget.editeInput({
824
+ gvc: gvc,
825
+ title: 'HASH_KEY',
826
+ default: key_d.HASH_KEY,
827
+ callback: text => {
828
+ key_d.HASH_KEY = text;
829
+ },
830
+ placeHolder: '請輸入HASH_KEY',
831
+ }),
832
+ BgWidget.editeInput({
833
+ gvc: gvc,
834
+ title: 'HASH_IV',
835
+ default: key_d.HASH_IV,
836
+ callback: text => {
837
+ key_d.HASH_IV = text;
838
+ },
839
+ placeHolder: '請輸入HASH_IV',
840
+ }),
841
+ BgWidget.editeInput({
842
+ gvc: gvc,
843
+ title: '信用卡授權檢查碼',
844
+ default: key_d.CreditCheckCode,
845
+ callback: text => {
846
+ key_d.CreditCheckCode = text;
847
+ },
848
+ placeHolder: '請輸入信用卡檢查碼',
849
+ }),
850
+ ].join('');
851
+ }
852
+ static paypalForm(gvc, key_d) {
853
+ return [
854
+ BgWidget.inlineCheckBox({
855
+ title: '串接路徑',
856
+ gvc: gvc,
857
+ def: `${key_d.BETA}`,
858
+ array: [
859
+ {
860
+ title: '正式站',
861
+ value: `false`,
862
+ },
863
+ {
864
+ title: '測試站',
865
+ value: `true`,
866
+ },
867
+ ],
868
+ callback: (text) => {
869
+ key_d.BETA = text;
870
+ },
871
+ }),
872
+ BgWidget.editeInput({
873
+ gvc: gvc,
874
+ title: 'CLIENT_ID',
875
+ default: key_d.PAYPAL_CLIENT_ID,
876
+ callback: text => {
877
+ key_d.PAYPAL_CLIENT_ID = text;
878
+ },
879
+ placeHolder: '請輸入CLIENT_ID',
880
+ }),
881
+ BgWidget.editeInput({
882
+ gvc: gvc,
883
+ title: 'SECRET',
884
+ default: key_d.PAYPAL_SECRET,
885
+ callback: text => {
886
+ key_d.PAYPAL_SECRET = text;
887
+ },
888
+ placeHolder: '請輸入SECRET',
889
+ }),
890
+ ].join('');
891
+ }
892
+ static linepayForm(gvc, key_d) {
893
+ return [
894
+ BgWidget.inlineCheckBox({
895
+ title: '串接路徑',
896
+ gvc: gvc,
897
+ def: `${key_d.BETA}`,
898
+ array: [
899
+ {
900
+ title: '正式站',
901
+ value: `false`,
902
+ },
903
+ {
904
+ title: '測試站',
905
+ value: `true`,
906
+ },
907
+ ],
908
+ callback: (text) => {
909
+ key_d.BETA = text;
910
+ },
911
+ }),
912
+ BgWidget.editeInput({
913
+ gvc: gvc,
914
+ title: 'CLIENT_ID',
915
+ default: key_d.CLIENT_ID,
916
+ callback: text => {
917
+ key_d.CLIENT_ID = text;
918
+ },
919
+ placeHolder: '請輸入CLIENT_ID',
920
+ }),
921
+ BgWidget.editeInput({
922
+ gvc: gvc,
923
+ title: 'SECRET',
924
+ default: key_d.SECRET,
925
+ callback: text => {
926
+ key_d.SECRET = text;
927
+ },
928
+ placeHolder: '請輸入SECRET',
929
+ }),
930
+ ].join('');
931
+ }
932
+ static jkopayForm(gvc, key_d) {
933
+ return [
934
+ BgWidget.editeInput({
935
+ gvc: gvc,
936
+ title: 'STORE_ID',
937
+ default: key_d.STORE_ID,
938
+ callback: text => {
939
+ key_d.STORE_ID = text;
940
+ },
941
+ placeHolder: '請輸入STORE_ID',
942
+ }),
943
+ ].join('');
944
+ }
945
+ static paynowForm(gvc, key_d) {
946
+ return [
947
+ BgWidget.inlineCheckBox({
948
+ title: '串接路徑',
949
+ gvc: gvc,
950
+ def: `${key_d.BETA}`,
951
+ array: [
952
+ {
953
+ title: '正式站',
954
+ value: `false`,
955
+ },
956
+ {
957
+ title: '測試站',
958
+ value: `true`,
959
+ },
960
+ ],
961
+ callback: (text) => {
962
+ key_d.BETA = text;
963
+ },
964
+ }),
965
+ BgWidget.editeInput({
966
+ gvc: gvc,
967
+ title: '串接帳號',
968
+ default: key_d.account,
969
+ callback: text => {
970
+ key_d.account = text;
971
+ },
972
+ placeHolder: '請輸入串接帳號',
973
+ }),
974
+ BgWidget.editeInput({
975
+ gvc: gvc,
976
+ title: '串接密碼',
977
+ default: key_d.pwd,
978
+ callback: text => {
979
+ key_d.pwd = text;
980
+ },
981
+ placeHolder: '請輸入串接密碼',
982
+ }),
983
+ ].join('');
984
+ }
985
+ static formatOnlinePayList(gvc, key, key_d) {
986
+ const setting = {
987
+ key: 'setting',
988
+ title: '基本設定',
989
+ html: (gvc) => {
990
+ return html ` ${BgWidget.editeInput({
991
+ gvc: gvc,
992
+ title: html `<div>自訂金流名稱 ${BgWidget.grayNote('未輸入則參照預設')}</div>`,
993
+ default: key_d.custome_name,
994
+ callback: text => {
995
+ key_d.custome_name = text;
996
+ },
997
+ placeHolder: '請輸入自訂顯示名稱',
998
+ global_language: true,
999
+ })}
1000
+ <div style="margin-top: 8px;">
1001
+ ${(() => {
1002
+ switch (key) {
1003
+ case 'newWebPay':
1004
+ case 'ecPay':
1005
+ return this.ePayForm(gvc, key_d, key);
1006
+ case 'paypal':
1007
+ return this.paypalForm(gvc, key_d);
1008
+ case 'line_pay':
1009
+ return this.linepayForm(gvc, key_d);
1010
+ case 'jkopay':
1011
+ return this.jkopayForm(gvc, key_d);
1012
+ case 'paynow':
1013
+ return this.paynowForm(gvc, key_d);
1014
+ }
1015
+ return '';
1016
+ })()}
1017
+ </div>`;
1153
1018
  },
1154
- });
1019
+ };
1020
+ const shipment = {
1021
+ key: 'shipment',
1022
+ title: '指定物流',
1023
+ html: (gvc) => {
1024
+ return gvc.bindView({
1025
+ bind: gvc.glitter.getUUID(),
1026
+ view: () => ShoppingFinanceSetting.setShipmentSupport(gvc, key_d),
1027
+ });
1028
+ },
1029
+ };
1030
+ const cartSetting = {
1031
+ key: 'cartSetting',
1032
+ title: '購物車設定',
1033
+ html: (gvc) => {
1034
+ return gvc.bindView({
1035
+ bind: gvc.glitter.getUUID(),
1036
+ view: () => ShoppingFinanceSetting.setCartSetting(gvc, key_d),
1037
+ });
1038
+ },
1039
+ };
1040
+ return this.buttonListView(gvc, key, key_d, [setting, shipment, cartSetting]);
1155
1041
  }
1156
- static cashOnDelivery(gvc, keyData) {
1157
- var _a;
1158
- keyData.cash_on_delivery = (_a = keyData.cash_on_delivery) !== null && _a !== void 0 ? _a : { shipmentSupport: [] };
1042
+ static cashOnDelivery(gvc, key, keyData) {
1043
+ var _b;
1044
+ keyData.cash_on_delivery = (_b = keyData.cash_on_delivery) !== null && _b !== void 0 ? _b : { shipmentSupport: [] };
1159
1045
  const shipment = {
1160
1046
  key: 'shipment',
1161
1047
  title: '指定物流',
1162
- html: gvc.bindView({
1163
- bind: gvc.glitter.getUUID(),
1164
- view: () => ShoppingFinanceSetting.setShipmentSupport(gvc, keyData.cash_on_delivery),
1165
- }),
1048
+ html: (gvc) => {
1049
+ return gvc.bindView({
1050
+ bind: gvc.glitter.getUUID(),
1051
+ view: () => ShoppingFinanceSetting.setShipmentSupport(gvc, keyData.cash_on_delivery),
1052
+ });
1053
+ },
1166
1054
  };
1167
1055
  const cartSetting = {
1168
1056
  key: 'cartSetting',
1169
1057
  title: '購物車設定',
1170
- html: gvc.bindView({
1171
- bind: gvc.glitter.getUUID(),
1172
- view: () => ShoppingFinanceSetting.setCartSetting(gvc, keyData.cash_on_delivery),
1173
- }),
1058
+ html: (gvc) => {
1059
+ return gvc.bindView({
1060
+ bind: gvc.glitter.getUUID(),
1061
+ view: () => ShoppingFinanceSetting.setCartSetting(gvc, keyData.cash_on_delivery),
1062
+ });
1063
+ },
1174
1064
  };
1175
- return this.tabView(gvc, [shipment, cartSetting]);
1065
+ return this.buttonListView(gvc, 'cash_on_delivery', keyData.cash_on_delivery, [shipment, cartSetting]);
1176
1066
  }
1177
- static lineIPassMoney(gvc, keyData) {
1178
- var _a;
1179
- keyData.payment_info_line_pay = (_a = keyData.payment_info_line_pay) !== null && _a !== void 0 ? _a : { text: '' };
1067
+ static lineIPassMoney(gvc, key, keyData) {
1068
+ var _b;
1069
+ keyData.payment_info_line_pay = (_b = keyData.payment_info_line_pay) !== null && _b !== void 0 ? _b : { text: '' };
1180
1070
  const cashflow = {
1181
1071
  key: 'cashflow',
1182
1072
  title: '基本設定',
1183
- html: (() => {
1184
- const id = gvc.glitter.getUUID();
1185
- const defText = html `<p>
1186
- 您選擇了線下Line
1187
- Pay付款。請完成付款後,提供證明截圖(圖一),或是照著(圖二)的流程擷取『付款詳細資訊』並上傳,以便我們核款。&nbsp;
1188
- </p>
1189
- <p>
1190
- <br /><img
1191
- src="https://d3jnmi1tfjgtti.cloudfront.net/file/234285319/1722924978722-Frame%205078.png"
1192
- class="fr-fic fr-dii"
1193
- style="width: 215px;"
1194
- />&nbsp;<img
1195
- src="https://d3jnmi1tfjgtti.cloudfront.net/file/234285319/1722924973580-Frame%205058.png"
1196
- class="fr-fic fr-dii"
1197
- style="width: 545px;"
1198
- />
1199
- </p>
1200
- <p>
1201
- <br />
1202
- </p>`;
1203
- return gvc.bindView({
1204
- bind: id,
1205
- view: () => {
1206
- var _a;
1207
- return [
1208
- html ` <div class="d-flex justify-content-between mb-3">
1209
- <div class="tx_normal">付款說明</div>
1210
- ${BgWidget.blueNote('返回預設', gvc.event(() => {
1211
- keyData.payment_info_line_pay.text = defText;
1212
- gvc.notifyDataChange(id);
1213
- }))}
1214
- </div>`,
1215
- BgWidget.richTextEditor({
1216
- gvc: gvc,
1217
- content: (_a = keyData.payment_info_line_pay.text) !== null && _a !== void 0 ? _a : '',
1218
- callback: content => {
1219
- keyData.payment_info_line_pay.text = content;
1220
- },
1221
- title: '付款說明',
1222
- }),
1223
- ].join('');
1224
- },
1225
- });
1226
- })(),
1073
+ html: (gvc) => {
1074
+ return (() => {
1075
+ const id = gvc.glitter.getUUID();
1076
+ const defText = html `<p>
1077
+ 您選擇了線下Line
1078
+ Pay付款。請完成付款後,提供證明截圖(圖一),或是照著(圖二)的流程擷取『付款詳細資訊』並上傳,以便我們核款。&nbsp;
1079
+ </p>
1080
+ <p>
1081
+ <br /><img
1082
+ src="https://d3jnmi1tfjgtti.cloudfront.net/file/234285319/1722924978722-Frame%205078.png"
1083
+ class="fr-fic fr-dii"
1084
+ style="width: 215px;"
1085
+ />&nbsp;<img
1086
+ src="https://d3jnmi1tfjgtti.cloudfront.net/file/234285319/1722924973580-Frame%205058.png"
1087
+ class="fr-fic fr-dii"
1088
+ style="width: 545px;"
1089
+ />
1090
+ </p>
1091
+ <p>
1092
+ <br />
1093
+ </p>`;
1094
+ return gvc.bindView({
1095
+ bind: id,
1096
+ view: () => {
1097
+ var _b;
1098
+ return [
1099
+ html ` <div class="d-flex justify-content-between mb-3">
1100
+ <div class="tx_normal">付款說明</div>
1101
+ ${BgWidget.blueNote('返回預設', gvc.event(() => {
1102
+ keyData.payment_info_line_pay.text = defText;
1103
+ gvc.notifyDataChange(id);
1104
+ }))}
1105
+ </div>`,
1106
+ BgWidget.richTextEditor({
1107
+ gvc: gvc,
1108
+ content: (_b = keyData.payment_info_line_pay.text) !== null && _b !== void 0 ? _b : '',
1109
+ callback: content => {
1110
+ keyData.payment_info_line_pay.text = content;
1111
+ },
1112
+ title: '付款說明',
1113
+ }),
1114
+ ].join('');
1115
+ },
1116
+ });
1117
+ })();
1118
+ },
1227
1119
  };
1228
1120
  const shipment = {
1229
1121
  key: 'shipment',
1230
1122
  title: '指定物流',
1231
- html: gvc.bindView({
1232
- bind: gvc.glitter.getUUID(),
1233
- view: () => ShoppingFinanceSetting.setShipmentSupport(gvc, keyData.payment_info_line_pay),
1234
- }),
1123
+ html: (gvc) => {
1124
+ return gvc.bindView({
1125
+ bind: gvc.glitter.getUUID(),
1126
+ view: () => ShoppingFinanceSetting.setShipmentSupport(gvc, keyData.payment_info_line_pay),
1127
+ });
1128
+ },
1235
1129
  };
1236
1130
  const cartSetting = {
1237
1131
  key: 'cartSetting',
1238
1132
  title: '購物車設定',
1239
- html: gvc.bindView({
1240
- bind: gvc.glitter.getUUID(),
1241
- view: () => ShoppingFinanceSetting.setCartSetting(gvc, keyData.payment_info_line_pay),
1242
- }),
1133
+ html: (gvc) => {
1134
+ return gvc.bindView({
1135
+ bind: gvc.glitter.getUUID(),
1136
+ view: () => ShoppingFinanceSetting.setCartSetting(gvc, keyData.payment_info_line_pay),
1137
+ });
1138
+ },
1243
1139
  };
1244
- return this.tabView(gvc, [cashflow, shipment, cartSetting]);
1140
+ return this.buttonListView(gvc, 'payment_info_line_pay', keyData.payment_info_line_pay, [
1141
+ cashflow,
1142
+ shipment,
1143
+ cartSetting,
1144
+ ]);
1245
1145
  }
1246
- static atm(gvc, keyData) {
1247
- var _a;
1248
- keyData.payment_info_atm = (_a = keyData.payment_info_atm) !== null && _a !== void 0 ? _a : {
1146
+ static atm(gvc, key, keyData) {
1147
+ var _b;
1148
+ keyData.payment_info_atm = (_b = keyData.payment_info_atm) !== null && _b !== void 0 ? _b : {
1249
1149
  bank_account: '',
1250
1150
  bank_code: '',
1251
1151
  bank_name: '',
@@ -1254,224 +1154,248 @@ export class ShoppingFinanceSetting {
1254
1154
  const cashflow = {
1255
1155
  key: 'cashflow',
1256
1156
  title: '基本設定',
1257
- html: (() => {
1258
- const id = gvc.glitter.getUUID();
1259
- const defText = html `<p>當日下單匯款,隔日出貨,後天到貨。</p>
1260
- <p>若有需要統一編號 請提早告知</p>
1261
- <p>------------------------------------------------------------------</p>
1262
- <p>*採臨櫃匯款者,電匯單上匯款人姓名與聯絡電話請務必填寫。</p> `;
1263
- return gvc.bindView({
1264
- bind: id,
1265
- view: () => {
1266
- var _a, _b;
1267
- return [
1268
- html ` <div class="row w-100">
1269
- ${[
1270
- {
1271
- key: 'bank_code',
1272
- title: '銀行代號',
1273
- },
1274
- {
1275
- key: 'bank_name',
1276
- title: '銀行名稱',
1277
- },
1278
- {
1279
- key: 'bank_user',
1280
- title: '銀行戶名',
1281
- },
1282
- {
1283
- key: 'bank_account',
1284
- title: '銀行帳號',
1285
- },
1286
- ]
1287
- .map(dd => {
1288
- return html ` <div class="col-12 col-md-6 mb-2 pe-0 pe-md-2">
1289
- <div class="w-100 mb-1">
1290
- <span
1291
- style="color: #393939; font-size: 16px; font-family: Noto Sans; font-weight: 400; word-wrap: break-word"
1292
- >${dd.title}</span
1293
- >
1294
- <span
1295
- style="color: #E80000; font-size: 16px; font-family: Noto Sans; font-weight: 400; word-wrap: break-word"
1296
- >*</span
1297
- >
1298
- </div>
1299
- <input
1300
- class="form-control w-100"
1301
- placeholder="請輸入${dd.title}"
1302
- value="${keyData.payment_info_atm[dd.key]}"
1303
- onchange="${gvc.event(e => {
1304
- keyData.payment_info_atm[dd.key] = e.value;
1305
- })}"
1306
- />
1307
- </div>`;
1308
- })
1309
- .join('')}
1310
- </div>`,
1311
- html ` <div class="my-2 px-1" style="display:flex;justify-content: space-between;">
1312
- <div class="tx_normal">付款說明</div>
1313
- ${BgWidget.blueNote('返回預設', gvc.event(() => {
1314
- keyData.payment_info_atm.text = defText;
1315
- gvc.notifyDataChange(id);
1316
- }))}
1317
- </div>`,
1318
- BgWidget.richTextEditor({
1319
- gvc: gvc,
1320
- content: (_b = (_a = keyData.payment_info_atm) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : '',
1321
- callback: content => {
1322
- keyData.payment_info_atm.text = content;
1157
+ html: (gvc) => {
1158
+ return (() => {
1159
+ const id = gvc.glitter.getUUID();
1160
+ const defText = html `<p>當日下單匯款,隔日出貨,後天到貨。</p>
1161
+ <p>若有需要統一編號 請提早告知</p>
1162
+ <p>------------------------------------------------------------------</p>
1163
+ <p>*採臨櫃匯款者,電匯單上匯款人姓名與聯絡電話請務必填寫。</p> `;
1164
+ return gvc.bindView({
1165
+ bind: id,
1166
+ view: () => {
1167
+ var _b, _c;
1168
+ return [
1169
+ html ` <div class="row w-100">
1170
+ ${[
1171
+ {
1172
+ key: 'bank_code',
1173
+ title: '銀行代號',
1174
+ },
1175
+ {
1176
+ key: 'bank_name',
1177
+ title: '銀行名稱',
1178
+ },
1179
+ {
1180
+ key: 'bank_user',
1181
+ title: '銀行戶名',
1182
+ },
1183
+ {
1184
+ key: 'bank_account',
1185
+ title: '銀行帳號',
1186
+ },
1187
+ ]
1188
+ .map(dd => {
1189
+ return html ` <div class="col-12 col-md-6 mb-2 pe-0 pe-md-2">
1190
+ <div class="w-100 mb-1">
1191
+ <span
1192
+ style="color: #393939; font-size: 16px; font-family: Noto Sans; font-weight: 400; word-wrap: break-word"
1193
+ >${dd.title}</span
1194
+ >
1195
+ <span
1196
+ style="color: #E80000; font-size: 16px; font-family: Noto Sans; font-weight: 400; word-wrap: break-word"
1197
+ >*</span
1198
+ >
1199
+ </div>
1200
+ <input
1201
+ class="form-control w-100"
1202
+ placeholder="請輸入${dd.title}"
1203
+ value="${keyData.payment_info_atm[dd.key]}"
1204
+ onchange="${gvc.event(e => {
1205
+ keyData.payment_info_atm[dd.key] = e.value;
1206
+ })}"
1207
+ />
1208
+ </div>`;
1209
+ })
1210
+ .join('')}
1211
+ </div>`,
1212
+ html ` <div class="my-2 px-1" style="display:flex;justify-content: space-between;">
1213
+ <div class="tx_normal">付款說明</div>
1214
+ ${BgWidget.blueNote('返回預設', gvc.event(() => {
1215
+ keyData.payment_info_atm.text = defText;
1323
1216
  gvc.notifyDataChange(id);
1324
- },
1325
- title: '付款說明',
1326
- }),
1327
- ].join('');
1328
- },
1329
- divCreate: { class: 'guide2-5' },
1330
- });
1331
- })(),
1217
+ }))}
1218
+ </div>`,
1219
+ BgWidget.richTextEditor({
1220
+ gvc: gvc,
1221
+ content: (_c = (_b = keyData.payment_info_atm) === null || _b === void 0 ? void 0 : _b.text) !== null && _c !== void 0 ? _c : '',
1222
+ callback: content => {
1223
+ keyData.payment_info_atm.text = content;
1224
+ gvc.notifyDataChange(id);
1225
+ },
1226
+ title: '付款說明',
1227
+ }),
1228
+ ].join('');
1229
+ },
1230
+ divCreate: { class: 'guide2-5' },
1231
+ });
1232
+ })();
1233
+ },
1332
1234
  };
1333
1235
  const shipment = {
1334
1236
  key: 'shipment',
1335
1237
  title: '指定物流',
1336
- html: gvc.bindView({
1337
- bind: gvc.glitter.getUUID(),
1338
- view: () => ShoppingFinanceSetting.setShipmentSupport(gvc, keyData.payment_info_atm),
1339
- }),
1238
+ html: (gvc) => {
1239
+ return gvc.bindView({
1240
+ bind: gvc.glitter.getUUID(),
1241
+ view: () => ShoppingFinanceSetting.setShipmentSupport(gvc, keyData.payment_info_atm),
1242
+ });
1243
+ },
1340
1244
  };
1341
1245
  const cartSetting = {
1342
1246
  key: 'cartSetting',
1343
1247
  title: '購物車設定',
1344
- html: gvc.bindView({
1345
- bind: gvc.glitter.getUUID(),
1346
- view: () => ShoppingFinanceSetting.setCartSetting(gvc, keyData.payment_info_atm),
1347
- }),
1248
+ html: (gvc) => {
1249
+ return gvc.bindView({
1250
+ bind: gvc.glitter.getUUID(),
1251
+ view: () => ShoppingFinanceSetting.setCartSetting(gvc, keyData.payment_info_atm),
1252
+ });
1253
+ },
1348
1254
  };
1349
- return this.tabView(gvc, [cashflow, shipment, cartSetting]);
1255
+ return this.buttonListView(gvc, 'payment_info_atm', keyData.payment_info_atm, [cashflow, shipment, cartSetting]);
1350
1256
  }
1351
- static linePayScan(gvc, data) {
1257
+ static linePayScan(gvc, key, data) {
1352
1258
  const cashflow = {
1353
1259
  key: 'cashflow',
1354
1260
  title: '基本設定',
1355
- html: html ` ${[
1356
- BgWidget.inlineCheckBox({
1357
- title: '串接路徑',
1358
- gvc: gvc,
1359
- def: `${data.BETA}`,
1360
- array: [
1361
- {
1362
- title: '正式站',
1363
- value: `false`,
1261
+ html: (gvc) => {
1262
+ return [
1263
+ BgWidget.inlineCheckBox({
1264
+ title: '串接路徑',
1265
+ gvc: gvc,
1266
+ def: `${data.BETA}`,
1267
+ array: [
1268
+ {
1269
+ title: '正式站',
1270
+ value: `false`,
1271
+ },
1272
+ {
1273
+ title: '測試站',
1274
+ value: `true`,
1275
+ },
1276
+ ],
1277
+ callback: (text) => {
1278
+ data.BETA = text;
1364
1279
  },
1365
- {
1366
- title: '測試站',
1367
- value: `true`,
1280
+ }),
1281
+ BgWidget.editeInput({
1282
+ gvc: gvc,
1283
+ title: 'CLIENT_ID',
1284
+ default: data.CLIENT_ID,
1285
+ callback: text => {
1286
+ data.CLIENT_ID = text;
1368
1287
  },
1369
- ],
1370
- callback: (text) => {
1371
- data.BETA = text;
1372
- },
1373
- }),
1374
- BgWidget.editeInput({
1375
- gvc: gvc,
1376
- title: 'CLIENT_ID',
1377
- default: data.CLIENT_ID,
1378
- callback: text => {
1379
- data.CLIENT_ID = text;
1380
- },
1381
- placeHolder: '請輸入CLIENT_ID',
1382
- }),
1383
- BgWidget.editeInput({
1384
- gvc: gvc,
1385
- title: 'SECRET',
1386
- default: data.SECRET,
1387
- callback: text => {
1388
- data.SECRET = text;
1389
- },
1390
- placeHolder: '請輸入SECRET',
1391
- }),
1392
- ].join('')}`,
1288
+ placeHolder: '請輸入CLIENT_ID',
1289
+ }),
1290
+ BgWidget.editeInput({
1291
+ gvc: gvc,
1292
+ title: 'SECRET',
1293
+ default: data.SECRET,
1294
+ callback: text => {
1295
+ data.SECRET = text;
1296
+ },
1297
+ placeHolder: '請輸入SECRET',
1298
+ }),
1299
+ ].join('');
1300
+ },
1393
1301
  };
1394
1302
  const shipment = {
1395
1303
  key: 'shipment',
1396
1304
  title: '指定物流',
1397
- html: gvc.bindView({
1398
- bind: gvc.glitter.getUUID(),
1399
- view: () => ShoppingFinanceSetting.setShipmentSupport(gvc, data),
1400
- }),
1305
+ html: (gvc) => {
1306
+ return gvc.bindView({
1307
+ bind: gvc.glitter.getUUID(),
1308
+ view: () => ShoppingFinanceSetting.setShipmentSupport(gvc, data),
1309
+ });
1310
+ },
1401
1311
  };
1402
1312
  const cartSetting = {
1403
1313
  key: 'cartSetting',
1404
1314
  title: '購物車設定',
1405
- html: gvc.bindView({
1406
- bind: gvc.glitter.getUUID(),
1407
- view: () => ShoppingFinanceSetting.setCartSetting(gvc, data),
1408
- }),
1315
+ html: (gvc) => {
1316
+ return gvc.bindView({
1317
+ bind: gvc.glitter.getUUID(),
1318
+ view: () => ShoppingFinanceSetting.setCartSetting(gvc, data),
1319
+ });
1320
+ },
1409
1321
  };
1410
- return this.tabView(gvc, [cashflow, shipment, cartSetting]);
1322
+ return this.buttonListView(gvc, key, data, [cashflow, shipment, cartSetting]);
1411
1323
  }
1412
- static utCreditCard(gvc, data) {
1324
+ static utCreditCard(gvc, key, data) {
1413
1325
  const cashflow = {
1414
1326
  key: 'cashflow',
1415
1327
  title: '基本設定',
1416
- html: BgWidget.editeInput({
1417
- gvc: gvc,
1418
- title: '商家ID',
1419
- default: data.pwd,
1420
- callback: text => {
1421
- data.pwd = text;
1422
- },
1423
- placeHolder: '請輸入商家ID',
1424
- }),
1328
+ html: (gvc) => {
1329
+ return BgWidget.editeInput({
1330
+ gvc: gvc,
1331
+ title: '商家ID',
1332
+ default: data.pwd,
1333
+ callback: text => {
1334
+ data.pwd = text;
1335
+ },
1336
+ placeHolder: '請輸入商家ID',
1337
+ });
1338
+ },
1425
1339
  };
1426
1340
  const shipment = {
1427
1341
  key: 'shipment',
1428
1342
  title: '指定物流',
1429
- html: gvc.bindView({
1430
- bind: gvc.glitter.getUUID(),
1431
- view: () => ShoppingFinanceSetting.setShipmentSupport(gvc, data),
1432
- }),
1343
+ html: (gvc) => {
1344
+ return gvc.bindView({
1345
+ bind: gvc.glitter.getUUID(),
1346
+ view: () => ShoppingFinanceSetting.setShipmentSupport(gvc, data),
1347
+ });
1348
+ },
1433
1349
  };
1434
1350
  const cartSetting = {
1435
1351
  key: 'cartSetting',
1436
1352
  title: '購物車設定',
1437
- html: gvc.bindView({
1438
- bind: gvc.glitter.getUUID(),
1439
- view: () => ShoppingFinanceSetting.setCartSetting(gvc, data),
1440
- }),
1353
+ html: (gvc) => {
1354
+ return gvc.bindView({
1355
+ bind: gvc.glitter.getUUID(),
1356
+ view: () => ShoppingFinanceSetting.setCartSetting(gvc, data),
1357
+ });
1358
+ },
1441
1359
  };
1442
- return this.tabView(gvc, [cashflow, shipment, cartSetting]);
1360
+ return this.buttonListView(gvc, key, data, [cashflow, shipment, cartSetting]);
1443
1361
  }
1444
1362
  static myPayPos(gvc, data) {
1445
1363
  const cashflow = {
1446
1364
  key: 'cashflow',
1447
1365
  title: '基本設定',
1448
- html: BgWidget.editeInput({
1449
- gvc: gvc,
1450
- title: '刷卡機密碼',
1451
- default: data.pwd,
1452
- callback: text => {
1453
- data.pwd = text;
1454
- },
1455
- placeHolder: '請輸入刷卡機密碼',
1456
- }),
1366
+ html: (gvc) => {
1367
+ return BgWidget.editeInput({
1368
+ gvc: gvc,
1369
+ title: '刷卡機密碼',
1370
+ default: data.pwd,
1371
+ callback: text => {
1372
+ data.pwd = text;
1373
+ },
1374
+ placeHolder: '請輸入刷卡機密碼',
1375
+ });
1376
+ },
1457
1377
  };
1458
1378
  const shipment = {
1459
1379
  key: 'shipment',
1460
1380
  title: '指定物流',
1461
- html: gvc.bindView({
1462
- bind: gvc.glitter.getUUID(),
1463
- view: () => ShoppingFinanceSetting.setShipmentSupport(gvc, data),
1464
- }),
1381
+ html: (gvc) => {
1382
+ return gvc.bindView({
1383
+ bind: gvc.glitter.getUUID(),
1384
+ view: () => ShoppingFinanceSetting.setShipmentSupport(gvc, data),
1385
+ });
1386
+ },
1465
1387
  };
1466
1388
  const cartSetting = {
1467
1389
  key: 'cartSetting',
1468
1390
  title: '購物車設定',
1469
- html: gvc.bindView({
1470
- bind: gvc.glitter.getUUID(),
1471
- view: () => ShoppingFinanceSetting.setCartSetting(gvc, data),
1472
- }),
1391
+ html: (gvc) => {
1392
+ return gvc.bindView({
1393
+ bind: gvc.glitter.getUUID(),
1394
+ view: () => ShoppingFinanceSetting.setCartSetting(gvc, data),
1395
+ });
1396
+ },
1473
1397
  };
1474
- return this.tabView(gvc, [cashflow, shipment, cartSetting]);
1398
+ return this.buttonListView(gvc, 'my_pay', data, [cashflow, shipment, cartSetting]);
1475
1399
  }
1476
1400
  static customerText(gvc, keyData, id) {
1477
1401
  const fi_ = keyData.payment_info_custom.find((id_) => id_ === id);
@@ -1498,12 +1422,71 @@ export class ShoppingFinanceSetting {
1498
1422
  };
1499
1423
  });
1500
1424
  }
1425
+ static card(obj) {
1426
+ return html `<div class="col-12 col-lg-4 col-md-6 p-0 p-md-2">
1427
+ <div
1428
+ class="w-100 position-relative main-card"
1429
+ style="padding: 20px 12px; background: white; overflow: hidden; flex-direction: column; justify-content: flex-start; align-items: flex-start; gap: 18px; display: inline-flex;"
1430
+ >
1431
+ <div
1432
+ style="padding: 9px 12px;align-self: stretch; justify-content: flex-start; align-items: center; gap: 28px; display: inline-flex;"
1433
+ >
1434
+ ${obj.deleteEvent
1435
+ ? html `<div style="position: absolute; top: 10px; right: 20px; font-size: 18px; cursor: pointer;">
1436
+ <i class="fa-regular fa-trash" onclick="${obj.deleteEvent}"></i>
1437
+ </div>`
1438
+ : ''}
1439
+ <div style="min-width: 46px;max-width: 46px; text-align: center;">${obj.img}</div>
1440
+ <div
1441
+ style="flex-direction: column; justify-content: center; align-items: flex-start; gap: 4px; display: inline-flex"
1442
+ >
1443
+ <div class="tx_normal">${obj.title}</div>
1444
+ <div class="d-flex align-items-center" style="gap: 4px;">
1445
+ <div class="tx_normal">${obj.toggle ? '開啟' : '關閉'}</div>
1446
+ <div class="cursor_pointer form-check form-switch" style="margin-top: 10px;">
1447
+ <input
1448
+ class="form-check-input"
1449
+ type="checkbox"
1450
+ onchange="${obj.toggleEvent}"
1451
+ ${obj.toggle ? 'checked' : ''}
1452
+ />
1453
+ </div>
1454
+ </div>
1455
+ </div>
1456
+ </div>
1457
+ <div class="w-100 border-top pt-3 mt-n2">
1458
+ <div class="d-flex flex-wrap justify-content-end gap-1 cursor_pointer">
1459
+ <div class="flex-fill"></div>
1460
+ ${obj.buttonAction.join('')}
1461
+ </div>
1462
+ </div>
1463
+ </div>
1464
+ </div>
1465
+ ${document.body.clientWidth > 768 ? '' : BgWidget.mbContainer(8)}`;
1466
+ }
1467
+ static addCard(title, event) {
1468
+ return html `<div class="col-12 col-lg-4 col-md-6 p-0 p-md-2" style="cursor: pointer;" onclick="${event}">
1469
+ <div
1470
+ class="w-100 main-card"
1471
+ style="min-height:183.59px;padding: 24px; background: white; overflow: hidden; flex-direction: column; justify-content: center; align-items: center; gap: 18px; display: inline-flex"
1472
+ >
1473
+ <div
1474
+ class="fw-bold"
1475
+ style="align-self: stretch; justify-content: center; align-items: center; gap: 14px; display: inline-flex;color:#4D86DB;"
1476
+ >
1477
+ <i class="fa-regular fa-circle-plus fs-5"></i>
1478
+ <div class="fs-5">${title}</div>
1479
+ </div>
1480
+ </div>
1481
+ </div>`;
1482
+ }
1501
1483
  static logistics_setting(gvc, widget) {
1484
+ this.id = 'shopping-logistics-setting-main';
1485
+ this.loading = true;
1486
+ this.gvc = gvc;
1502
1487
  const dialog = new ShareDialog(gvc.glitter);
1503
- const saasConfig = window.parent.saasConfig;
1488
+ const saasConfig = this.saasConfig;
1504
1489
  const vm = {
1505
- id: gvc.glitter.getUUID(),
1506
- loading: true,
1507
1490
  data: {},
1508
1491
  delivery: {
1509
1492
  ec_pay: {
@@ -1526,34 +1509,18 @@ export class ShoppingFinanceSetting {
1526
1509
  language: window.parent.store_info.language_setting.def,
1527
1510
  page: 'delivery_setting',
1528
1511
  };
1529
- saasConfig.api
1530
- .getPrivateConfig(saasConfig.config.appName, 'logistics_setting')
1531
- .then((r) => {
1532
- if (r.response.result[0]) {
1533
- vm.data = r.response.result[0].value;
1534
- }
1535
- vm.loading = false;
1536
- if (!vm.data.language_data) {
1537
- vm.data.language_data = {
1538
- 'en-US': { info: '' },
1539
- 'zh-CN': { info: '' },
1540
- 'zh-TW': { info: vm.data.info || '' },
1541
- };
1542
- }
1543
- gvc.notifyDataChange(vm.id);
1544
- });
1545
- function save() {
1512
+ const save = () => {
1546
1513
  saasConfig.api.setPrivateConfig(saasConfig.config.appName, 'logistics_setting', vm.data);
1547
- }
1514
+ };
1548
1515
  return gvc.bindView(() => {
1549
1516
  return {
1550
- bind: vm.id,
1517
+ bind: this.id,
1551
1518
  view: () => {
1552
- if (vm.loading) {
1519
+ if (this.loading) {
1553
1520
  return BgWidget.spinner();
1554
1521
  }
1555
- vm.data.support = vm.data.support || [];
1556
1522
  const language_data = vm.data.language_data[vm.language];
1523
+ vm.data.support = vm.data.support || [];
1557
1524
  vm.data.info = vm.data.info || '';
1558
1525
  vm.data.form = vm.data.form || [];
1559
1526
  let view = [
@@ -1568,7 +1535,7 @@ export class ShoppingFinanceSetting {
1568
1535
  { title: '配送備註', key: 'delivery_note' },
1569
1536
  ], gvc, vm.page, text => {
1570
1537
  vm.page = text;
1571
- gvc.notifyDataChange(vm.id);
1538
+ gvc.notifyDataChange(this.id);
1572
1539
  }, 'margin-bottom:0px;'),
1573
1540
  ];
1574
1541
  if (vm.page === 'delivery_setting') {
@@ -1578,9 +1545,6 @@ export class ShoppingFinanceSetting {
1578
1545
  </div>`,
1579
1546
  gvc.bindView(() => {
1580
1547
  const id = gvc.glitter.getUUID();
1581
- function refresh() {
1582
- gvc.notifyDataChange(id);
1583
- }
1584
1548
  function updateCustomShipment(obj) {
1585
1549
  const custom_delivery = JSON.parse(JSON.stringify(obj.data || {
1586
1550
  name: '',
@@ -1589,7 +1553,7 @@ export class ShoppingFinanceSetting {
1589
1553
  let form = undefined;
1590
1554
  BgWidget.settingDialog({
1591
1555
  gvc: gvc,
1592
- title: custom_delivery.name ? `「${custom_delivery.name}」自訂表單設定` : '新增自訂物流',
1556
+ title: custom_delivery.name ? `「${custom_delivery.name}」表單設定` : '新增自訂物流',
1593
1557
  innerHTML: gvc => {
1594
1558
  form = BgWidget.customForm(gvc, [
1595
1559
  {
@@ -1605,9 +1569,9 @@ export class ShoppingFinanceSetting {
1605
1569
  },
1606
1570
  ]);
1607
1571
  return gvc.bindView((() => {
1608
- var _a;
1572
+ var _b;
1609
1573
  const id = gvc.glitter.getUUID();
1610
- custom_delivery.system_form = (_a = custom_delivery.system_form) !== null && _a !== void 0 ? _a : [];
1574
+ custom_delivery.system_form = (_b = custom_delivery.system_form) !== null && _b !== void 0 ? _b : [];
1611
1575
  return {
1612
1576
  bind: id,
1613
1577
  view: () => {
@@ -1652,373 +1616,294 @@ export class ShoppingFinanceSetting {
1652
1616
  })());
1653
1617
  },
1654
1618
  footer_html: gvc => {
1655
- let array = [
1656
- BgWidget.save(gvc.event(() => {
1657
- return new Promise(() => __awaiter(this, void 0, void 0, function* () {
1658
- var _a;
1659
- if (!custom_delivery.name) {
1660
- dialog.errorMessage({ text: `請輸入物流名稱` });
1661
- return;
1662
- }
1663
- vm.data.custom_delivery = (_a = vm.data.custom_delivery) !== null && _a !== void 0 ? _a : [];
1664
- if (obj.function === 'plus') {
1665
- vm.data.custom_delivery.push(custom_delivery);
1666
- }
1667
- else {
1668
- vm.data.custom_delivery[vm.data.custom_delivery.findIndex((d1) => {
1669
- return d1.id === custom_delivery.id;
1670
- })] = custom_delivery;
1671
- }
1672
- dialog.dataLoading({ visible: true });
1673
- yield form.save();
1674
- yield saasConfig.api.setPrivateConfig(saasConfig.config.appName, 'logistics_setting', vm.data);
1675
- dialog.dataLoading({ visible: false });
1676
- dialog.successMessage({ text: '設定成功' });
1677
- gvc.closeDialog();
1678
- refresh();
1679
- }));
1680
- })),
1681
- ];
1682
- if (obj.function === 'replace') {
1683
- array = [
1684
- BgWidget.danger(gvc.event(() => {
1685
- dialog.checkYesOrNot({
1686
- text: '是否確認刪除?',
1687
- callback: (response) => __awaiter(this, void 0, void 0, function* () {
1688
- if (response) {
1689
- vm.data.custom_delivery = vm.data.custom_delivery.filter((d1) => {
1690
- return obj.data.id !== d1.id;
1691
- });
1692
- dialog.dataLoading({ visible: true });
1693
- yield saasConfig.api.setPrivateConfig(saasConfig.config.appName, 'logistics_setting', vm.data);
1694
- dialog.dataLoading({ visible: false });
1695
- refresh();
1696
- gvc.closeDialog();
1619
+ return BgWidget.save(gvc.event(() => {
1620
+ return new Promise(() => __awaiter(this, void 0, void 0, function* () {
1621
+ var _b;
1622
+ if (!custom_delivery.name) {
1623
+ dialog.errorMessage({ text: `請輸入物流名稱` });
1624
+ return;
1625
+ }
1626
+ vm.data.custom_delivery = (_b = vm.data.custom_delivery) !== null && _b !== void 0 ? _b : [];
1627
+ if (obj.function === 'plus') {
1628
+ vm.data.custom_delivery.push(custom_delivery);
1629
+ }
1630
+ else {
1631
+ vm.data.custom_delivery[vm.data.custom_delivery.findIndex((d1) => {
1632
+ return d1.id === custom_delivery.id;
1633
+ })] = custom_delivery;
1634
+ }
1635
+ dialog.dataLoading({ visible: true });
1636
+ yield form.save();
1637
+ yield saasConfig.api.setPrivateConfig(saasConfig.config.appName, 'logistics_setting', vm.data);
1638
+ dialog.dataLoading({ visible: false });
1639
+ dialog.successMessage({ text: '設定成功' });
1640
+ ShoppingFinanceSetting.refresh(gvc);
1641
+ }));
1642
+ }));
1643
+ },
1644
+ });
1645
+ }
1646
+ return {
1647
+ bind: id,
1648
+ view: () => {
1649
+ var _b;
1650
+ return ShipmentConfig.list
1651
+ .concat(((_b = vm.data.custom_delivery) !== null && _b !== void 0 ? _b : []).map((dd) => {
1652
+ return {
1653
+ title: Language.getLanguageCustomText(dd.name),
1654
+ value: dd.id,
1655
+ custom: true,
1656
+ type: 'font_awesome',
1657
+ src: html `<i class="fa-regular fa-puzzle-piece-simple fs-4"></i>`,
1658
+ };
1659
+ }))
1660
+ .map(dd => {
1661
+ let button_action = [
1662
+ BgWidget.customButton({
1663
+ button: {
1664
+ color: 'gray',
1665
+ size: 'sm',
1666
+ },
1667
+ text: {
1668
+ name: '配送設定',
1669
+ },
1670
+ event: gvc.event(() => __awaiter(this, void 0, void 0, function* () {
1671
+ const log_config = (yield ApiUser.getPublicConfig('shipment_config_' + dd.value, 'manager', saasConfig.config.appName)).response.value;
1672
+ BgWidget.settingDialog({
1673
+ gvc: gvc,
1674
+ title: `「${dd.title}」配送設定`,
1675
+ innerHTML: gvc => {
1676
+ var _b;
1677
+ const view = [];
1678
+ if (['UNIMARTC2C', 'UNIMARTFREEZE', 'FAMIC2C', 'FAMIC2CFREEZE'].includes(dd.value)) {
1679
+ view.push(html `<div class="d-flex flex-column w-100">
1680
+ ${[
1681
+ html `<div
1682
+ style="flex-direction: column; justify-content: center; align-items: flex-start; gap: 4px; display: inline-flex"
1683
+ >
1684
+ <div class="tx_normal">大宗配送</div>
1685
+ <div class="d-flex align-items-center" style="gap: 4px;">
1686
+ <div class="tx_normal">${log_config.bulk ? '開啟' : '關閉'}</div>
1687
+ <div
1688
+ class="cursor_pointer form-check form-switch"
1689
+ style="margin-top: 10px;"
1690
+ >
1691
+ <input
1692
+ class="form-check-input"
1693
+ type="checkbox"
1694
+ onchange="${gvc.event(() => {
1695
+ log_config.bulk = !log_config.bulk;
1696
+ gvc.recreateView();
1697
+ })}"
1698
+ ${log_config.bulk ? `checked` : ''}
1699
+ />
1700
+ </div>
1701
+ </div>
1702
+ </div> `,
1703
+ ].join('')}
1704
+ </div>`);
1697
1705
  }
1698
- }),
1706
+ view.push(html ` <div class="d-flex flex-column" style="gap: 4px;">
1707
+ ${[
1708
+ html `<div class="tx_normal">物流配送說明</div>`,
1709
+ BgWidget.richTextEditor({
1710
+ gvc: gvc,
1711
+ content: (_b = log_config.content) !== null && _b !== void 0 ? _b : '',
1712
+ callback: data => {
1713
+ log_config.content = data;
1714
+ },
1715
+ title: '物流配送說明',
1716
+ }),
1717
+ ].join('')}
1718
+ </div>`);
1719
+ return html `<div class="w-100 d-flex flex-column" style="gap: 4px;">
1720
+ ${view.join(html `<div class="w-100 border-bottom my-2"></div>`)}
1721
+ </div>`;
1722
+ },
1723
+ footer_html: gvc => {
1724
+ let array = [
1725
+ BgWidget.cancel(gvc.event(() => {
1726
+ gvc.closeDialog();
1727
+ })),
1728
+ BgWidget.save(gvc.event(() => {
1729
+ dialog.dataLoading({ visible: true });
1730
+ ApiUser.setPublicConfig({
1731
+ user_id: 'manager',
1732
+ key: 'shipment_config_' + dd.value,
1733
+ value: log_config,
1734
+ }).then(() => {
1735
+ dialog.dataLoading({ visible: false });
1736
+ dialog.successMessage({ text: '設定成功' });
1737
+ gvc.closeDialog();
1738
+ });
1739
+ })),
1740
+ ];
1741
+ return array.join('');
1742
+ },
1699
1743
  });
1700
1744
  })),
1701
- ].concat(array);
1702
- }
1703
- return array.join('');
1704
- },
1705
- });
1706
- }
1707
- return {
1708
- bind: id,
1709
- view: () => {
1710
- var _a;
1711
- return ShipmentConfig.list
1712
- .concat(((_a = vm.data.custom_delivery) !== null && _a !== void 0 ? _a : []).map((dd) => {
1713
- return {
1714
- title: Language.getLanguageCustomText(dd.name),
1715
- value: dd.id,
1716
- custom: true,
1717
- type: 'font_awesome',
1718
- src: html `<i class="fa-regular fa-puzzle-piece-simple fs-4"></i>`,
1719
- };
1720
- }))
1721
- .map(dd => {
1722
- return html `
1723
- <div class="col-12 col-lg-4 col-md-6 p-0 p-md-2">
1724
- <div
1725
- class="w-100 position-relative main-card"
1726
- style="padding: 24px; background: white; overflow: hidden; flex-direction: column; justify-content: flex-start; align-items: flex-start; gap: 18px; display: inline-flex;"
1727
- >
1728
- <div
1729
- style="align-self: stretch; justify-content: flex-start; align-items: center; gap: 28px; display: inline-flex;"
1730
- >
1731
- <div style="min-width: 46px;max-width: 46px;">
1732
- ${dd.type === 'font_awesome' ? dd.src : html ` <img src="${dd.src}" />`}
1733
- </div>
1734
- <div
1735
- style="flex-direction: column; justify-content: center; align-items: flex-start; gap: 4px; display: inline-flex"
1736
- >
1737
- <div class="tx_normal">${dd.title}</div>
1738
- <div class="d-flex align-items-center" style="gap:4px;">
1739
- <div class="tx_normal">
1740
- ${vm.data.support.find((d1) => dd.value === d1) ? `開啟` : `關閉`}
1741
- </div>
1742
- <div class="cursor_pointer form-check form-switch" style="margin-top: 10px;">
1743
- <input
1744
- class="form-check-input"
1745
- type="checkbox"
1746
- onchange="${gvc.event(() => {
1747
- if (vm.data.support.find((d1) => {
1748
- return dd.value === d1;
1749
- })) {
1750
- vm.data.support = vm.data.support.filter((d1) => {
1751
- return dd.value !== d1;
1752
- });
1753
- }
1754
- else {
1755
- vm.data.support.push(dd.value);
1756
- }
1757
- save();
1758
- gvc.notifyDataChange(id);
1759
- })}"
1760
- ${vm.data.support.find((d1) => {
1761
- return dd.value === d1;
1762
- })
1763
- ? `checked`
1764
- : ''}
1765
- />
1766
- </div>
1767
- </div>
1768
- </div>
1769
- </div>
1770
- <div class="w-100 border-top pt-3 mt-n2">
1771
- ${(() => {
1772
- let button_action = [
1773
- BgWidget.customButton({
1774
- button: {
1775
- color: 'gray',
1776
- size: 'sm',
1777
- },
1778
- text: {
1779
- name: html `<i class="fa-regular fa-gear me-1"></i>配送`,
1780
- },
1781
- event: gvc.event(() => __awaiter(this, void 0, void 0, function* () {
1782
- const log_config = (yield ApiUser.getPublicConfig('shipment_config_' + dd.value, 'manager', saasConfig.config.appName)).response.value;
1783
- BgWidget.settingDialog({
1784
- gvc: gvc,
1785
- title: `「${dd.title}」配送設定`,
1786
- innerHTML: gvc => {
1787
- var _a;
1788
- const view = [];
1789
- if (['UNIMARTC2C', 'UNIMARTFREEZE', 'FAMIC2C', 'FAMIC2CFREEZE'].includes(dd.value)) {
1790
- view.push(html `<div class="d-flex flex-column w-100">
1791
- ${[
1792
- html `<div
1793
- style="flex-direction: column; justify-content: center; align-items: flex-start; gap: 4px; display: inline-flex"
1794
- >
1795
- <div class="tx_normal">大宗配送</div>
1796
- <div class="d-flex align-items-center" style="gap:4px;">
1797
- <div class="tx_normal">
1798
- ${log_config.bulk ? `開啟` : `關閉`}
1799
- </div>
1800
- <div
1801
- class="cursor_pointer form-check form-switch"
1802
- style="margin-top: 10px;"
1803
- >
1804
- <input
1805
- class="form-check-input"
1806
- type="checkbox"
1807
- onchange="${gvc.event(() => {
1808
- log_config.bulk = !log_config.bulk;
1809
- gvc.recreateView();
1810
- })}"
1811
- ${log_config.bulk ? `checked` : ''}
1812
- />
1813
- </div>
1814
- </div>
1815
- </div> `,
1816
- ].join('')}
1817
- </div>`);
1818
- }
1819
- view.push(html ` <div class="d-flex flex-column" style="gap:5px;">
1820
- ${[
1821
- html `<div class="tx_normal">物流配送說明</div>`,
1822
- BgWidget.richTextEditor({
1823
- gvc: gvc,
1824
- content: (_a = log_config.content) !== null && _a !== void 0 ? _a : '',
1825
- callback: data => {
1826
- log_config.content = data;
1827
- },
1828
- title: '物流配送說明',
1829
- }),
1830
- ].join('')}
1831
- </div>`);
1832
- return html `<div class="w-100 d-flex flex-column" style="gap:5px;">
1833
- ${view.join(html `<div class="w-100 border-bottom my-2"></div>`)}
1834
- </div>`;
1835
- },
1836
- footer_html: gvc => {
1837
- let array = [
1838
- BgWidget.cancel(gvc.event(() => {
1745
+ }),
1746
+ BgWidget.customButton({
1747
+ button: {
1748
+ color: 'gray',
1749
+ size: 'sm',
1750
+ },
1751
+ text: {
1752
+ name: '購物車設定',
1753
+ },
1754
+ event: gvc.event(() => __awaiter(this, void 0, void 0, function* () {
1755
+ const vm = {
1756
+ id: gvc.glitter.getUUID(),
1757
+ loading: true,
1758
+ config: {},
1759
+ };
1760
+ BgWidget.settingDialog({
1761
+ gvc: gvc,
1762
+ title: `「${dd.title}」購物車設定`,
1763
+ innerHTML: gvc => {
1764
+ return gvc.bindView({
1765
+ bind: id,
1766
+ view: () => {
1767
+ if (vm.loading) {
1768
+ return BgWidget.spinner();
1769
+ }
1770
+ else {
1771
+ return ShoppingFinanceSetting.setCartSetting(gvc, vm.config, 'shipment');
1772
+ }
1773
+ },
1774
+ onCreate: () => __awaiter(this, void 0, void 0, function* () {
1775
+ if (vm.loading) {
1776
+ const r = yield ApiUser.getPublicConfig('shipment_config_' + dd.value, 'manager', saasConfig.config.appName);
1777
+ vm.config = r.response.value;
1778
+ vm.loading = false;
1779
+ gvc.notifyDataChange(id);
1780
+ }
1781
+ }),
1782
+ });
1783
+ },
1784
+ footer_html: gvc => {
1785
+ return [
1786
+ BgWidget.cancel(gvc.event(() => {
1787
+ gvc.closeDialog();
1788
+ })),
1789
+ BgWidget.save(gvc.event(() => {
1790
+ dialog.dataLoading({ visible: true });
1791
+ ApiUser.setPublicConfig({
1792
+ user_id: 'manager',
1793
+ key: 'shipment_config_' + dd.value,
1794
+ value: vm.config,
1795
+ }).then(() => {
1796
+ dialog.dataLoading({ visible: false });
1797
+ dialog.successMessage({ text: '設定成功' });
1839
1798
  gvc.closeDialog();
1840
- })),
1841
- BgWidget.save(gvc.event(() => {
1842
- dialog.dataLoading({ visible: true });
1843
- ApiUser.setPublicConfig({
1844
- user_id: 'manager',
1845
- key: 'shipment_config_' + dd.value,
1846
- value: log_config,
1847
- }).then(() => {
1848
- dialog.dataLoading({ visible: false });
1849
- dialog.successMessage({ text: '設定成功' });
1850
- gvc.closeDialog();
1851
- });
1852
- })),
1853
- ];
1854
- return array.join('');
1855
- },
1856
- });
1857
- })),
1799
+ });
1800
+ })),
1801
+ ].join('');
1802
+ },
1803
+ });
1804
+ })),
1805
+ }),
1806
+ BgWidget.customButton({
1807
+ button: {
1808
+ color: 'gray',
1809
+ size: 'sm',
1810
+ },
1811
+ text: {
1812
+ name: '運費設定',
1813
+ },
1814
+ event: gvc.event(() => {
1815
+ const vm = {
1816
+ gvc: gvc,
1817
+ key: dd.value,
1818
+ save_event: () => {
1819
+ return new Promise(resolve => resolve(true));
1820
+ },
1821
+ };
1822
+ BgWidget.settingDialog({
1823
+ gvc: gvc,
1824
+ width: 1200,
1825
+ height: document.body.clientHeight - 100,
1826
+ title: `「${dd.title}」運費設定`,
1827
+ d_main_style: document.body.clientWidth < 768 ? 'padding:0px !important;' : '',
1828
+ innerHTML: (gvc) => {
1829
+ vm.gvc = gvc;
1830
+ return ShoppingShipmentSetting.main(vm);
1831
+ },
1832
+ footer_html: gvc => {
1833
+ return [
1834
+ BgWidget.cancel(gvc.event(() => {
1835
+ gvc.closeDialog();
1836
+ })),
1837
+ BgWidget.save(gvc.event(() => {
1838
+ vm.save_event().then(() => { });
1839
+ })),
1840
+ ].join('');
1841
+ },
1842
+ });
1858
1843
  }),
1844
+ }),
1845
+ ];
1846
+ if (dd.custom) {
1847
+ button_action = [
1859
1848
  BgWidget.customButton({
1860
1849
  button: {
1861
1850
  color: 'gray',
1862
1851
  size: 'sm',
1863
1852
  },
1864
1853
  text: {
1865
- name: html `<i class="fa-regular fa-gear me-1"></i>購物車`,
1866
- },
1867
- event: gvc.event(() => __awaiter(this, void 0, void 0, function* () {
1868
- const vm = {
1869
- id: gvc.glitter.getUUID(),
1870
- loading: true,
1871
- config: {},
1872
- };
1873
- BgWidget.settingDialog({
1874
- gvc: gvc,
1875
- title: `「${dd.title}」購物車設定`,
1876
- innerHTML: gvc => {
1877
- return gvc.bindView({
1878
- bind: id,
1879
- view: () => {
1880
- if (vm.loading) {
1881
- return BgWidget.spinner();
1882
- }
1883
- else {
1884
- return ShoppingFinanceSetting.setCartSetting(gvc, vm.config, 'shipment');
1885
- }
1886
- },
1887
- onCreate: () => __awaiter(this, void 0, void 0, function* () {
1888
- if (vm.loading) {
1889
- const r = yield ApiUser.getPublicConfig('shipment_config_' + dd.value, 'manager', saasConfig.config.appName);
1890
- vm.config = r.response.value;
1891
- vm.loading = false;
1892
- gvc.notifyDataChange(id);
1893
- }
1894
- }),
1895
- });
1896
- },
1897
- footer_html: gvc => {
1898
- return [
1899
- BgWidget.cancel(gvc.event(() => {
1900
- gvc.closeDialog();
1901
- })),
1902
- BgWidget.save(gvc.event(() => {
1903
- dialog.dataLoading({ visible: true });
1904
- ApiUser.setPublicConfig({
1905
- user_id: 'manager',
1906
- key: 'shipment_config_' + dd.value,
1907
- value: vm.config,
1908
- }).then(() => {
1909
- dialog.dataLoading({ visible: false });
1910
- dialog.successMessage({ text: '設定成功' });
1911
- gvc.closeDialog();
1912
- });
1913
- })),
1914
- ].join('');
1915
- },
1916
- });
1917
- })),
1918
- }),
1919
- ];
1920
- const shipment_fee = () => {
1921
- return BgWidget.customButton({
1922
- button: {
1923
- color: 'gray',
1924
- size: 'sm',
1925
- },
1926
- text: {
1927
- name: html `<i class="fa-regular fa-gear me-1"></i>運費`,
1854
+ name: '表單設定',
1928
1855
  },
1929
1856
  event: gvc.event(() => {
1930
- const vm = {
1931
- gvc: gvc,
1932
- key: dd.value,
1933
- save_event: () => {
1934
- return new Promise(resolve => resolve(true));
1935
- },
1936
- };
1937
- BgWidget.settingDialog({
1938
- gvc: gvc,
1939
- width: 1200,
1940
- height: document.body.clientHeight - 100,
1941
- title: `「${dd.title}」運費設定`,
1942
- d_main_style: document.body.clientWidth < 768 ? 'padding:0px !important;' : '',
1943
- innerHTML: (gvc) => {
1944
- vm.gvc = gvc;
1945
- return ShoppingShipmentSetting.main(vm);
1946
- },
1947
- footer_html: gvc => {
1948
- return [
1949
- BgWidget.cancel(gvc.event(() => {
1950
- gvc.closeDialog();
1951
- })),
1952
- BgWidget.save(gvc.event(() => {
1953
- vm.save_event().then(() => { });
1954
- })),
1955
- ].join('');
1956
- },
1857
+ updateCustomShipment({
1858
+ function: 'replace',
1859
+ data: vm.data.custom_delivery.find((d1) => dd.value === d1.id),
1957
1860
  });
1958
1861
  }),
1959
- });
1960
- };
1961
- if (dd.custom) {
1962
- button_action = button_action.concat([
1963
- shipment_fee(),
1964
- BgWidget.customButton({
1965
- button: {
1966
- color: 'gray',
1967
- size: 'sm',
1968
- },
1969
- text: {
1970
- name: html `<i class="fa-regular fa-gear me-1"></i>自訂表單`,
1971
- },
1972
- event: gvc.event(() => {
1973
- updateCustomShipment({
1974
- function: 'replace',
1975
- data: vm.data.custom_delivery.find((d1) => dd.value === d1.id),
1976
- });
1862
+ }),
1863
+ ...button_action,
1864
+ ];
1865
+ }
1866
+ return this.card({
1867
+ title: dd.title,
1868
+ img: dd.type === 'font_awesome' ? dd.src : html ` <img src="${dd.src}" />`,
1869
+ toggle: vm.data.support.some((d1) => dd.value === d1),
1870
+ toggleEvent: gvc.event(() => {
1871
+ if (vm.data.support.find((d1) => dd.value === d1)) {
1872
+ vm.data.support = vm.data.support.filter((d1) => dd.value !== d1);
1873
+ }
1874
+ else {
1875
+ vm.data.support.push(dd.value);
1876
+ }
1877
+ save();
1878
+ gvc.notifyDataChange(id);
1879
+ }),
1880
+ buttonAction: button_action,
1881
+ deleteEvent: dd.custom
1882
+ ? gvc.event(() => {
1883
+ dialog.checkYesOrNot({
1884
+ text: '是否確認刪除此物流?',
1885
+ callback: (response) => __awaiter(this, void 0, void 0, function* () {
1886
+ if (response) {
1887
+ const data = yield saasConfig.api.getPrivateConfig(saasConfig.config.appName, 'logistics_setting');
1888
+ if (data.response.result[0]) {
1889
+ const keyData = data.response.result[0].value;
1890
+ keyData.custom_delivery = keyData.custom_delivery.filter((d1) => {
1891
+ return dd.value !== d1.id;
1892
+ });
1893
+ dialog.dataLoading({ visible: true });
1894
+ saasConfig.api.setPrivateConfig(saasConfig.config.appName, 'logistics_setting', keyData);
1895
+ dialog.dataLoading({ visible: false });
1896
+ this.refresh();
1897
+ }
1898
+ }
1977
1899
  }),
1978
- }),
1979
- ]);
1980
- return html `
1981
- <div class="d-flex flex-wrap justify-content-end gap-1 cursor_pointer">
1982
- <div class="flex-fill"></div>
1983
- ${button_action.join('')}
1984
- </div>
1985
- `;
1986
- }
1987
- else {
1988
- button_action = button_action.concat([shipment_fee()]);
1989
- return html ` <div class="d-flex flex-wrap justify-content-end gap-1 cursor_pointer">
1990
- <div class="flex-fill"></div>
1991
- ${button_action.join('')}
1992
- </div>`;
1993
- }
1994
- })()}
1995
- </div>
1996
- </div>
1997
- </div>
1998
- ${document.body.clientWidth > 768 ? '' : BgWidget.mbContainer(8)}
1999
- `;
1900
+ });
1901
+ })
1902
+ : undefined,
1903
+ });
2000
1904
  })
2001
1905
  .concat([
2002
- html ` <div
2003
- class="col-12 col-lg-4 col-md-6 p-0 p-md-2"
2004
- style="cursor: pointer;"
2005
- onclick="${gvc.event(() => {
2006
- updateCustomShipment({ function: 'plus' });
2007
- })}"
2008
- >
2009
- <div
2010
- class="w-100 main-card"
2011
- style="min-height:173.59px;padding: 24px; background: white; overflow: hidden; flex-direction: column; justify-content: center; align-items: center; gap: 18px; display: inline-flex"
2012
- >
2013
- <div
2014
- class="fw-bold"
2015
- style="align-self: stretch; justify-content: center; align-items: center; gap: 14px; display: inline-flex;color:#4D86DB;"
2016
- >
2017
- <i class="fa-regular fa-circle-plus fs-5"></i>
2018
- <div class="fs-5">新增自訂物流</div>
2019
- </div>
2020
- </div>
2021
- </div>`,
1906
+ this.addCard('新增自訂物流', gvc.event(() => updateCustomShipment({ function: 'plus' }))),
2022
1907
  ])
2023
1908
  .join('');
2024
1909
  },
@@ -2046,7 +1931,7 @@ export class ShoppingFinanceSetting {
2046
1931
  language: vm.language,
2047
1932
  callback: language => {
2048
1933
  vm.language = language;
2049
- gvc.notifyDataChange(vm.id);
1934
+ gvc.notifyDataChange(this.id);
2050
1935
  },
2051
1936
  })}
2052
1937
  </div>`,
@@ -2066,7 +1951,7 @@ export class ShoppingFinanceSetting {
2066
1951
  BgWidget.fullDialog({
2067
1952
  gvc: gvc,
2068
1953
  title: gvc2 => {
2069
- return html `<div class="d-flex align-items-center" style="gap:10px;">
1954
+ return html `<div class="d-flex align-items-center" style="gap: 10px;">
2070
1955
  ${'配送資訊' +
2071
1956
  BgWidget.aiChatButton({
2072
1957
  gvc: gvc2,
@@ -2074,7 +1959,7 @@ export class ShoppingFinanceSetting {
2074
1959
  click: () => {
2075
1960
  ProductAi.generateRichText(gvc, text => {
2076
1961
  language_data.info += text;
2077
- gvc.notifyDataChange(vm.id);
1962
+ gvc.notifyDataChange(this.id);
2078
1963
  gvc2.recreateView();
2079
1964
  });
2080
1965
  },
@@ -2213,44 +2098,42 @@ export class ShoppingFinanceSetting {
2213
2098
  },
2214
2099
  ]
2215
2100
  .map(dd => {
2216
- return html `
2217
- <div class="col-12 col-lg-3 col-md-4 p-0 p-md-2">
2218
- <div
2219
- class="w-100 position-relative main-card"
2220
- style="padding: 24px 32px; background: white; overflow: hidden; flex-direction: column; justify-content: flex-start; align-items: flex-start; gap: 18px; display: inline-flex;"
2221
- >
2222
- ${(() => {
2223
- return html ` <div
2224
- class="position-absolute fw-500"
2225
- style="cursor:pointer;right:15px;top:15px;"
2226
- >
2227
- ${BgWidget.customButton({
2228
- button: {
2229
- color: 'gray',
2230
- size: 'sm',
2231
- },
2232
- text: {
2233
- name: `串接設定`,
2234
- },
2235
- event: gvc.event(() => {
2236
- if (dd.value === 'ec_pay') {
2237
- BgWidget.dialog({
2238
- gvc: gvc,
2239
- title: '物流追蹤設定',
2240
- innerHTML: (gvc) => {
2241
- return gvc.bindView((() => {
2101
+ return this.card({
2102
+ title: dd.title,
2103
+ img: html `<img src="${dd.src || BgWidget.noImageURL}" />`,
2104
+ toggle: vm.delivery[dd.value].toggle,
2105
+ toggleEvent: gvc.event(() => {
2106
+ vm.delivery[dd.value].toggle = !vm.delivery[dd.value].toggle;
2107
+ saveDelivery();
2108
+ gvc.notifyDataChange(id);
2109
+ }),
2110
+ buttonAction: [
2111
+ BgWidget.customButton({
2112
+ button: {
2113
+ color: 'gray',
2114
+ size: 'sm',
2115
+ },
2116
+ text: {
2117
+ name: `串接設定`,
2118
+ },
2119
+ event: gvc.event(() => {
2120
+ if (dd.value === 'ec_pay') {
2121
+ BgWidget.dialog({
2122
+ gvc: gvc,
2123
+ title: '物流追蹤設定',
2124
+ innerHTML: (gvc) => {
2242
2125
  const id = gvc.glitter.getUUID();
2243
- return {
2126
+ return gvc.bindView({
2244
2127
  bind: id,
2245
2128
  view: () => {
2246
2129
  return [
2247
2130
  ...(() => {
2248
- var _a, _b, _c, _d, _e, _f, _g;
2131
+ var _b, _c, _d, _e, _f, _g, _h;
2249
2132
  let array = [
2250
2133
  BgWidget.inlineCheckBox({
2251
2134
  title: '串接路徑',
2252
2135
  gvc: gvc,
2253
- def: (_a = vm.delivery[dd.value].Action) !== null && _a !== void 0 ? _a : 'test',
2136
+ def: (_b = vm.delivery[dd.value].Action) !== null && _b !== void 0 ? _b : 'test',
2254
2137
  array: [
2255
2138
  {
2256
2139
  title: '正式站',
@@ -2269,7 +2152,7 @@ export class ShoppingFinanceSetting {
2269
2152
  BgWidget.editeInput({
2270
2153
  gvc: gvc,
2271
2154
  title: '寄件人名稱',
2272
- default: (_b = vm.delivery[dd.value].SenderName) !== null && _b !== void 0 ? _b : '',
2155
+ default: (_c = vm.delivery[dd.value].SenderName) !== null && _c !== void 0 ? _c : '',
2273
2156
  callback: text => {
2274
2157
  vm.delivery[dd.value].SenderName = text;
2275
2158
  },
@@ -2278,7 +2161,7 @@ export class ShoppingFinanceSetting {
2278
2161
  BgWidget.editeInput({
2279
2162
  gvc: gvc,
2280
2163
  title: '寄件人手機',
2281
- default: (_c = vm.delivery[dd.value].SenderCellPhone) !== null && _c !== void 0 ? _c : '',
2164
+ default: (_d = vm.delivery[dd.value].SenderCellPhone) !== null && _d !== void 0 ? _d : '',
2282
2165
  callback: text => {
2283
2166
  vm.delivery[dd.value].SenderCellPhone = text;
2284
2167
  },
@@ -2287,7 +2170,7 @@ export class ShoppingFinanceSetting {
2287
2170
  BgWidget.editeInput({
2288
2171
  gvc: gvc,
2289
2172
  title: '寄件人地址',
2290
- default: (_d = vm.delivery[dd.value].SenderAddress) !== null && _d !== void 0 ? _d : '',
2173
+ default: (_e = vm.delivery[dd.value].SenderAddress) !== null && _e !== void 0 ? _e : '',
2291
2174
  callback: text => {
2292
2175
  vm.delivery[dd.value].SenderAddress = text;
2293
2176
  },
@@ -2295,17 +2178,17 @@ export class ShoppingFinanceSetting {
2295
2178
  }),
2296
2179
  BgWidget.editeInput({
2297
2180
  gvc: gvc,
2298
- title: '特店編號',
2299
- default: (_e = vm.delivery[dd.value].MERCHANT_ID) !== null && _e !== void 0 ? _e : '',
2181
+ title: '商店代號',
2182
+ default: (_f = vm.delivery[dd.value].MERCHANT_ID) !== null && _f !== void 0 ? _f : '',
2300
2183
  callback: text => {
2301
2184
  vm.delivery[dd.value].MERCHANT_ID = text;
2302
2185
  },
2303
- placeHolder: '請輸入特店編號',
2186
+ placeHolder: '請輸入商店代號',
2304
2187
  }),
2305
2188
  BgWidget.editeInput({
2306
2189
  gvc: gvc,
2307
2190
  title: 'HASH KEY',
2308
- default: (_f = vm.delivery[dd.value].HASH_KEY) !== null && _f !== void 0 ? _f : '',
2191
+ default: (_g = vm.delivery[dd.value].HASH_KEY) !== null && _g !== void 0 ? _g : '',
2309
2192
  callback: text => {
2310
2193
  vm.delivery[dd.value].HASH_KEY = text;
2311
2194
  },
@@ -2314,7 +2197,7 @@ export class ShoppingFinanceSetting {
2314
2197
  BgWidget.editeInput({
2315
2198
  gvc: gvc,
2316
2199
  title: 'HASH IV',
2317
- default: (_g = vm.delivery[dd.value].HASH_IV) !== null && _g !== void 0 ? _g : '',
2200
+ default: (_h = vm.delivery[dd.value].HASH_IV) !== null && _h !== void 0 ? _h : '',
2318
2201
  callback: text => {
2319
2202
  vm.delivery[dd.value].HASH_IV = text;
2320
2203
  },
@@ -2325,79 +2208,82 @@ export class ShoppingFinanceSetting {
2325
2208
  })(),
2326
2209
  ].join(BgWidget.mbContainer(12));
2327
2210
  },
2328
- };
2329
- })());
2330
- },
2331
- save: {
2332
- text: '儲存',
2333
- event: () => {
2334
- return new Promise(resolve => {
2335
- function checkSenderPattern(input) {
2336
- const senderPattern = /^[\u4e00-\u9fa5]{2,5}|[a-zA-Z]{4,10}$/;
2337
- return senderPattern.test(input);
2338
- }
2339
- function checkPhonePattern(input) {
2340
- const phonePattern = /^09\d{8}$/;
2341
- return phonePattern.test(input);
2342
- }
2343
- function checkAddressPattern(input) {
2344
- const addressPattern = /^.{6,60}$/;
2345
- return addressPattern.test(input);
2346
- }
2347
- if (CheckInput.isEmpty(vm.delivery[dd.value].SenderName) ||
2348
- !checkSenderPattern(vm.delivery[dd.value].SenderName)) {
2349
- dialog.infoMessage({
2350
- text: html ` <div class="text-center">
2351
- 寄件人名稱請設定最多10字元<br />(中文5個字, 英文10個字,<br />不得含指定特殊符號)
2352
- </div>`,
2353
- });
2354
- resolve(false);
2355
- return;
2356
- }
2357
- if (CheckInput.isEmpty(vm.delivery[dd.value].SenderCellPhone) ||
2358
- !checkPhonePattern(vm.delivery[dd.value].SenderCellPhone)) {
2359
- dialog.infoMessage({ text: '寄件人手機應為09開頭的手機格式' });
2360
- resolve(false);
2361
- return;
2362
- }
2363
- if (!vm.delivery[dd.value].SenderAddress ||
2364
- !checkAddressPattern(vm.delivery[dd.value].SenderAddress)) {
2365
- dialog.infoMessage({
2366
- text: html ` <div class="text-center">
2367
- 請輸入正確的寄件人地址<br />(中文6~60個字)
2368
- </div>`,
2369
- });
2370
- resolve(false);
2371
- return;
2372
- }
2373
- ApiPageConfig.setPrivateConfigV2({
2374
- key: 'glitter_delivery',
2375
- value: JSON.stringify(vm.delivery),
2376
- appName: saasConfig.config.appName,
2377
- }).then((r) => {
2378
- dialog.dataLoading({ visible: false });
2379
- if (r.response) {
2380
- dialog.successMessage({ text: '設定成功' });
2211
+ });
2212
+ },
2213
+ save: {
2214
+ text: '儲存',
2215
+ event: gvc => {
2216
+ return new Promise(resolve => {
2217
+ function checkSenderPattern(input) {
2218
+ const senderPattern = /^[\u4e00-\u9fa5]{2,5}|[a-zA-Z]{4,10}$/;
2219
+ return senderPattern.test(input);
2381
2220
  }
2382
- else {
2383
- dialog.errorMessage({ text: '設定失敗' });
2221
+ function checkPhonePattern(input) {
2222
+ const phonePattern = /^09\d{8}$/;
2223
+ return phonePattern.test(input);
2384
2224
  }
2385
- resolve(true);
2225
+ function checkAddressPattern(input) {
2226
+ const addressPattern = /^.{6,60}$/;
2227
+ return addressPattern.test(input);
2228
+ }
2229
+ if (CheckInput.isEmpty(vm.delivery[dd.value].SenderName) ||
2230
+ !checkSenderPattern(vm.delivery[dd.value].SenderName)) {
2231
+ dialog.infoMessage({
2232
+ text: html ` <div class="text-center">
2233
+ 寄件人名稱請設定最多10字元<br />(中文5個字, 英文10個字,<br />不得含指定特殊符號)
2234
+ </div>`,
2235
+ });
2236
+ resolve(false);
2237
+ return;
2238
+ }
2239
+ if (CheckInput.isEmpty(vm.delivery[dd.value].SenderCellPhone) ||
2240
+ !checkPhonePattern(vm.delivery[dd.value].SenderCellPhone)) {
2241
+ dialog.infoMessage({ text: '寄件人手機應為09開頭的手機格式' });
2242
+ resolve(false);
2243
+ return;
2244
+ }
2245
+ if (!vm.delivery[dd.value].SenderAddress ||
2246
+ !checkAddressPattern(vm.delivery[dd.value].SenderAddress)) {
2247
+ dialog.infoMessage({
2248
+ text: html ` <div class="text-center">
2249
+ 請輸入正確的寄件人地址<br />(中文6~60個字)
2250
+ </div>`,
2251
+ });
2252
+ resolve(false);
2253
+ return;
2254
+ }
2255
+ ApiPageConfig.setPrivateConfigV2({
2256
+ key: 'glitter_delivery',
2257
+ value: JSON.stringify(vm.delivery),
2258
+ appName: saasConfig.config.appName,
2259
+ }).then((r) => {
2260
+ dialog.dataLoading({ visible: false });
2261
+ if (r.response) {
2262
+ dialog.successMessage({ text: '設定成功' });
2263
+ }
2264
+ else {
2265
+ dialog.errorMessage({ text: '設定失敗' });
2266
+ }
2267
+ this.refresh(gvc);
2268
+ resolve(true);
2269
+ });
2386
2270
  });
2387
- });
2271
+ },
2388
2272
  },
2389
- },
2390
- cancel: {},
2391
- });
2392
- }
2393
- else if (dd.value === 'pay_now') {
2394
- BgWidget.dialog({
2395
- gvc: gvc,
2396
- title: '物流追蹤設定',
2397
- innerHTML: (gvc) => {
2398
- return gvc.bindView((() => {
2273
+ cancel: {
2274
+ text: '取消',
2275
+ event: gvc => new Promise(() => this.refresh(gvc)),
2276
+ },
2277
+ xmark: gvc => new Promise(() => this.refresh(gvc)),
2278
+ });
2279
+ }
2280
+ else if (dd.value === 'pay_now') {
2281
+ BgWidget.dialog({
2282
+ gvc: gvc,
2283
+ title: '物流追蹤設定',
2284
+ innerHTML: (gvc) => {
2399
2285
  const id = gvc.glitter.getUUID();
2400
- return {
2286
+ return gvc.bindView({
2401
2287
  bind: id,
2402
2288
  view: () => {
2403
2289
  return [
@@ -2405,25 +2291,22 @@ export class ShoppingFinanceSetting {
2405
2291
  gvc,
2406
2292
  tag: 'delivery_alert_info',
2407
2293
  title: '注意事項',
2408
- insideHTML: html ` <div
2409
- class="mt-2"
2410
- style="white-space: normal;"
2411
- >
2412
- ${BgWidget.alertInfo('', [
2294
+ insideHTML: html ` <div class="mt-2" style="white-space: normal;">
2295
+ ${BgWidget.alertInfo('', [
2413
2296
  '1. 支援四大超商(7-ELEVEN、全家、萊爾富、OK超商)與黑貓',
2414
2297
  '2. 寄件人名稱請設定最多10字元(中文5個字, 英文10個字, 不得含指定特殊符號)',
2415
2298
  '3. 寄件人手機應為09開頭的格式',
2416
2299
  ])}
2417
- </div>`,
2300
+ </div>`,
2418
2301
  height: document.body.clientWidth > 768 ? 300 : 385,
2419
2302
  }),
2420
2303
  ...(() => {
2421
- var _a, _b, _c, _d, _e, _f, _g;
2304
+ var _b, _c, _d, _e, _f, _g, _h;
2422
2305
  let array = [
2423
2306
  BgWidget.inlineCheckBox({
2424
2307
  title: '串接路徑',
2425
2308
  gvc: gvc,
2426
- def: (_a = vm.delivery[dd.value].Action) !== null && _a !== void 0 ? _a : 'test',
2309
+ def: (_b = vm.delivery[dd.value].Action) !== null && _b !== void 0 ? _b : 'test',
2427
2310
  array: [
2428
2311
  {
2429
2312
  title: '正式站',
@@ -2440,32 +2323,29 @@ export class ShoppingFinanceSetting {
2440
2323
  type: 'single',
2441
2324
  }),
2442
2325
  html ` <div
2443
- onclick="${gvc.event(() => {
2326
+ onclick="${gvc.event(() => {
2444
2327
  window.parent.navigator.clipboard.writeText(window.parent.saasConfig.config.url +
2445
2328
  `/api-public/v1/delivery/notify?g-app=${window.parent.appName}`);
2446
2329
  dialog.successMessage({ text: '已複製至剪貼簿' });
2447
2330
  })}"
2448
- >
2449
- ${BgWidget.editeInput({
2331
+ >
2332
+ ${BgWidget.editeInput({
2450
2333
  readonly: true,
2451
2334
  gvc: gvc,
2452
- title: html ` <div
2453
- class="d-flex flex-column"
2454
- style="gap:5px;"
2455
- >
2456
- 物流追蹤通知
2457
- ${BgWidget.grayNote('點擊複製此連結至PAYNOW後台的貨態回傳網址')}
2458
- </div>`,
2335
+ title: html ` <div class="d-flex flex-column" style="gap: 4px;">
2336
+ 物流追蹤通知
2337
+ ${BgWidget.grayNote('點擊複製此連結至PAYNOW後台的貨態回傳網址')}
2338
+ </div>`,
2459
2339
  default: window.parent.saasConfig.config.url +
2460
2340
  `/api-public/v1/delivery/notify?g-app=${window.parent.appName}`,
2461
2341
  placeHolder: '',
2462
2342
  callback: text => { },
2463
2343
  })}
2464
- </div>`,
2344
+ </div>`,
2465
2345
  BgWidget.editeInput({
2466
2346
  gvc: gvc,
2467
2347
  title: '串接帳號',
2468
- default: (_b = vm.delivery[dd.value].account) !== null && _b !== void 0 ? _b : '',
2348
+ default: (_c = vm.delivery[dd.value].account) !== null && _c !== void 0 ? _c : '',
2469
2349
  callback: text => {
2470
2350
  vm.delivery[dd.value].account = text;
2471
2351
  },
@@ -2474,7 +2354,7 @@ export class ShoppingFinanceSetting {
2474
2354
  BgWidget.editeInput({
2475
2355
  gvc: gvc,
2476
2356
  title: '串接密碼',
2477
- default: (_c = vm.delivery[dd.value].pwd) !== null && _c !== void 0 ? _c : '',
2357
+ default: (_d = vm.delivery[dd.value].pwd) !== null && _d !== void 0 ? _d : '',
2478
2358
  callback: text => {
2479
2359
  vm.delivery[dd.value].pwd = text;
2480
2360
  },
@@ -2483,7 +2363,7 @@ export class ShoppingFinanceSetting {
2483
2363
  BgWidget.editeInput({
2484
2364
  gvc: gvc,
2485
2365
  title: '寄件人名稱',
2486
- default: (_d = vm.delivery[dd.value].SenderName) !== null && _d !== void 0 ? _d : '',
2366
+ default: (_e = vm.delivery[dd.value].SenderName) !== null && _e !== void 0 ? _e : '',
2487
2367
  callback: text => {
2488
2368
  vm.delivery[dd.value].SenderName = text;
2489
2369
  },
@@ -2492,7 +2372,7 @@ export class ShoppingFinanceSetting {
2492
2372
  BgWidget.editeInput({
2493
2373
  gvc: gvc,
2494
2374
  title: '寄件人手機',
2495
- default: (_e = vm.delivery[dd.value].SenderCellPhone) !== null && _e !== void 0 ? _e : '',
2375
+ default: (_f = vm.delivery[dd.value].SenderCellPhone) !== null && _f !== void 0 ? _f : '',
2496
2376
  callback: text => {
2497
2377
  vm.delivery[dd.value].SenderCellPhone = text;
2498
2378
  },
@@ -2501,7 +2381,7 @@ export class ShoppingFinanceSetting {
2501
2381
  BgWidget.editeInput({
2502
2382
  gvc: gvc,
2503
2383
  title: '寄件人地址',
2504
- default: (_f = vm.delivery[dd.value].SenderAddress) !== null && _f !== void 0 ? _f : '',
2384
+ default: (_g = vm.delivery[dd.value].SenderAddress) !== null && _g !== void 0 ? _g : '',
2505
2385
  callback: text => {
2506
2386
  vm.delivery[dd.value].SenderAddress = text;
2507
2387
  },
@@ -2510,7 +2390,7 @@ export class ShoppingFinanceSetting {
2510
2390
  BgWidget.editeInput({
2511
2391
  gvc: gvc,
2512
2392
  title: '寄件人信箱',
2513
- default: (_g = vm.delivery[dd.value].SenderEmail) !== null && _g !== void 0 ? _g : '',
2393
+ default: (_h = vm.delivery[dd.value].SenderEmail) !== null && _h !== void 0 ? _h : '',
2514
2394
  callback: text => {
2515
2395
  vm.delivery[dd.value].SenderEmail = text;
2516
2396
  },
@@ -2521,68 +2401,41 @@ export class ShoppingFinanceSetting {
2521
2401
  })(),
2522
2402
  ].join(BgWidget.mbContainer(12));
2523
2403
  },
2524
- };
2525
- })());
2526
- },
2527
- save: {
2528
- text: '儲存',
2529
- event: () => {
2530
- return new Promise(resolve => {
2531
- ApiPageConfig.setPrivateConfigV2({
2532
- key: 'glitter_delivery',
2533
- value: JSON.stringify(vm.delivery),
2534
- appName: saasConfig.config.appName,
2535
- }).then((r) => {
2536
- dialog.dataLoading({ visible: false });
2537
- if (r.response) {
2538
- dialog.successMessage({ text: '設定成功' });
2539
- }
2540
- else {
2541
- dialog.errorMessage({ text: '設定失敗' });
2542
- }
2543
- resolve(true);
2544
- });
2545
2404
  });
2546
2405
  },
2547
- },
2548
- cancel: {},
2549
- });
2550
- }
2406
+ save: {
2407
+ text: '儲存',
2408
+ event: gvc => {
2409
+ return new Promise(resolve => {
2410
+ ApiPageConfig.setPrivateConfigV2({
2411
+ key: 'glitter_delivery',
2412
+ value: JSON.stringify(vm.delivery),
2413
+ appName: saasConfig.config.appName,
2414
+ }).then((r) => {
2415
+ dialog.dataLoading({ visible: false });
2416
+ if (r.response) {
2417
+ dialog.successMessage({ text: '設定成功' });
2418
+ }
2419
+ else {
2420
+ dialog.errorMessage({ text: '設定失敗' });
2421
+ }
2422
+ this.refresh(gvc);
2423
+ resolve(true);
2424
+ });
2425
+ });
2426
+ },
2427
+ },
2428
+ cancel: {
2429
+ text: '取消',
2430
+ event: gvc => new Promise(() => this.refresh(gvc)),
2431
+ },
2432
+ xmark: gvc => new Promise(() => this.refresh(gvc)),
2433
+ });
2434
+ }
2435
+ }),
2551
2436
  }),
2552
- })}
2553
- </div>`;
2554
- })()}
2555
- <div
2556
- style="align-self: stretch; justify-content: flex-start; align-items: center; gap: 28px; display: inline-flex"
2557
- >
2558
- <div style="min-width: 46px;max-width: 46px;">
2559
- <img src="${dd.src}" />
2560
- </div>
2561
- <div
2562
- style="flex-direction: column; justify-content: center; align-items: flex-start; gap: 4px; display: inline-flex"
2563
- >
2564
- <div class="tx_normal">${dd.title}</div>
2565
- <div class="d-flex align-items-center" style="gap:4px;">
2566
- <div class="tx_normal">${vm.delivery[dd.value].toggle ? `開啟` : `關閉`}</div>
2567
- <div class="cursor_pointer form-check form-switch" style="margin-top: 10px;">
2568
- <input
2569
- class="form-check-input"
2570
- type="checkbox"
2571
- onchange="${gvc.event((e, event) => {
2572
- vm.delivery[dd.value].toggle = !vm.delivery[dd.value].toggle;
2573
- saveDelivery();
2574
- gvc.notifyDataChange(id);
2575
- })}"
2576
- ${vm.delivery[dd.value].toggle ? `checked` : ''}
2577
- />
2578
- </div>
2579
- </div>
2580
- </div>
2581
- </div>
2582
- </div>
2583
- </div>
2584
- ${document.body.clientWidth > 768 ? '' : BgWidget.mbContainer(8)}
2585
- `;
2437
+ ],
2438
+ });
2586
2439
  })
2587
2440
  .join('');
2588
2441
  },
@@ -2662,7 +2515,7 @@ export class ShoppingFinanceSetting {
2662
2515
  onCreate: () => {
2663
2516
  if (loading) {
2664
2517
  ApiPageConfig.getPrivateConfig(window.parent.appName, 'logistics_setting').then((dd) => {
2665
- var _a;
2518
+ var _b;
2666
2519
  if (dd.result && dd.response.result[0]) {
2667
2520
  const shipment_setting = dd.response.result[0].value;
2668
2521
  const combinedList = [
@@ -2670,7 +2523,7 @@ export class ShoppingFinanceSetting {
2670
2523
  name: dd.title,
2671
2524
  value: dd.value,
2672
2525
  })),
2673
- ...((_a = shipment_setting.custom_delivery) !== null && _a !== void 0 ? _a : []).map((dd) => ({
2526
+ ...((_b = shipment_setting.custom_delivery) !== null && _b !== void 0 ? _b : []).map((dd) => ({
2674
2527
  form: dd.form,
2675
2528
  name: dd.name,
2676
2529
  value: dd.id,
@@ -2816,9 +2669,9 @@ export class ShoppingFinanceSetting {
2816
2669
  onCreate: () => {
2817
2670
  if (dvm.loading) {
2818
2671
  ApiUser.getPublicConfig('logistics_group', 'manager').then(r => {
2819
- var _a;
2672
+ var _b;
2820
2673
  if (r.result) {
2821
- dvm.dataList = (_a = r.response.value) !== null && _a !== void 0 ? _a : [];
2674
+ dvm.dataList = (_b = r.response.value) !== null && _b !== void 0 ? _b : [];
2822
2675
  }
2823
2676
  setTimeout(() => {
2824
2677
  dvm.loading = false;
@@ -2837,13 +2690,33 @@ export class ShoppingFinanceSetting {
2837
2690
  divCreate: {
2838
2691
  class: `d-flex justify-content-center w-100 flex-column align-items-center `,
2839
2692
  },
2693
+ onCreate: () => {
2694
+ if (this.loading) {
2695
+ saasConfig.api
2696
+ .getPrivateConfig(saasConfig.config.appName, 'logistics_setting')
2697
+ .then((r) => {
2698
+ if (r.response.result[0]) {
2699
+ vm.data = r.response.result[0].value;
2700
+ }
2701
+ if (!vm.data.language_data) {
2702
+ vm.data.language_data = {
2703
+ 'en-US': { info: '' },
2704
+ 'zh-CN': { info: '' },
2705
+ 'zh-TW': { info: vm.data.info || '' },
2706
+ };
2707
+ }
2708
+ this.loading = false;
2709
+ gvc.notifyDataChange(this.id);
2710
+ });
2711
+ }
2712
+ },
2840
2713
  };
2841
2714
  });
2842
2715
  }
2843
2716
  static invoice_setting_v2(gvc, widget) {
2844
2717
  const dialog = new ShareDialog(gvc.glitter);
2845
- const saasConfig = window.parent.saasConfig;
2846
2718
  const glitter = window.glitter;
2719
+ const saasConfig = this.saasConfig;
2847
2720
  const vm = {
2848
2721
  id: glitter.getUUID(),
2849
2722
  loading: true,
@@ -2880,25 +2753,25 @@ export class ShoppingFinanceSetting {
2880
2753
  bind: id,
2881
2754
  view: () => {
2882
2755
  return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
2883
- var _a, _b;
2756
+ var _b, _c;
2884
2757
  const data = yield saasConfig.api.getPrivateConfig(saasConfig.config.appName, `invoice_setting`);
2885
2758
  if (data.response.result[0]) {
2886
2759
  vm.data = data.response.result[0].value;
2887
2760
  }
2888
2761
  if (vm.data.point === 'beta') {
2889
- vm.data.whiteList = (_a = vm.data.whiteList) !== null && _a !== void 0 ? _a : [];
2890
- vm.data.whiteListExpand = (_b = vm.data.whiteListExpand) !== null && _b !== void 0 ? _b : {};
2762
+ vm.data.whiteList = (_b = vm.data.whiteList) !== null && _b !== void 0 ? _b : [];
2763
+ vm.data.whiteListExpand = (_c = vm.data.whiteListExpand) !== null && _c !== void 0 ? _c : {};
2891
2764
  }
2892
2765
  resolve(gvc.bindView(() => {
2893
- var _a, _b;
2894
- vm.data.fincial = (_a = vm.data.fincial) !== null && _a !== void 0 ? _a : 'ezpay';
2895
- vm.data.point = (_b = vm.data.point) !== null && _b !== void 0 ? _b : 'beta';
2766
+ var _b, _c;
2767
+ vm.data.fincial = (_b = vm.data.fincial) !== null && _b !== void 0 ? _b : 'ezpay';
2768
+ vm.data.point = (_c = vm.data.point) !== null && _c !== void 0 ? _c : 'beta';
2896
2769
  const id = gvc.glitter.getUUID();
2897
2770
  return {
2898
2771
  bind: id,
2899
2772
  view: () => {
2900
2773
  return html `
2901
- <div class="d-flex flex-column" style="gap:18px;">
2774
+ <div class="d-flex flex-column" style="gap: 18px;">
2902
2775
  <div class="tx_normal fw-bold">服務商選擇</div>
2903
2776
  ${[
2904
2777
  {
@@ -2934,7 +2807,7 @@ export class ShoppingFinanceSetting {
2934
2807
  ${[
2935
2808
  html ` <div
2936
2809
  class="d-flex align-items-center cursor_pointer"
2937
- style="gap:8px;"
2810
+ style="gap: 8px;"
2938
2811
  onclick="${gvc.event(() => {
2939
2812
  vm.data.fincial = dd.value;
2940
2813
  gvc.notifyDataChange(id);
@@ -2950,9 +2823,9 @@ export class ShoppingFinanceSetting {
2950
2823
  class="ms-2 border-end position-absolute h-100"
2951
2824
  style="left: 0px;"
2952
2825
  ></div>
2953
- <div class="flex-fill" style="margin-left:30px;max-width: 518px;">
2826
+ <div class="flex-fill" style="margin-left: 30px;max-width: 518px;">
2954
2827
  ${(() => {
2955
- var _a, _b, _c;
2828
+ var _b, _c, _d;
2956
2829
  if (vm.data.fincial === 'nouse' ||
2957
2830
  vm.data.fincial === 'off_line' ||
2958
2831
  vm.data.fincial !== dd.value) {
@@ -2989,10 +2862,10 @@ export class ShoppingFinanceSetting {
2989
2862
  }),
2990
2863
  BgWidget.editeInput({
2991
2864
  gvc: gvc,
2992
- title: '特店編號',
2993
- default: (_a = vm.data.merchNO) !== null && _a !== void 0 ? _a : '',
2865
+ title: '商店代號',
2866
+ default: (_b = vm.data.merchNO) !== null && _b !== void 0 ? _b : '',
2994
2867
  type: 'text',
2995
- placeHolder: '請輸入特店編號',
2868
+ placeHolder: '請輸入商店代號',
2996
2869
  callback: text => {
2997
2870
  vm.data.merchNO = text;
2998
2871
  },
@@ -3000,7 +2873,7 @@ export class ShoppingFinanceSetting {
3000
2873
  BgWidget.editeInput({
3001
2874
  gvc: gvc,
3002
2875
  title: 'HashKey',
3003
- default: (_b = vm.data.hashkey) !== null && _b !== void 0 ? _b : '',
2876
+ default: (_c = vm.data.hashkey) !== null && _c !== void 0 ? _c : '',
3004
2877
  type: 'text',
3005
2878
  placeHolder: '請輸入HashKey',
3006
2879
  callback: text => {
@@ -3016,7 +2889,7 @@ export class ShoppingFinanceSetting {
3016
2889
  BgWidget.editeInput({
3017
2890
  gvc: gvc,
3018
2891
  title: 'HashIV',
3019
- default: (_c = vm.data.hashiv) !== null && _c !== void 0 ? _c : '',
2892
+ default: (_d = vm.data.hashiv) !== null && _d !== void 0 ? _d : '',
3020
2893
  type: 'text',
3021
2894
  placeHolder: '請輸入HashIV',
3022
2895
  callback: text => {
@@ -3050,16 +2923,14 @@ export class ShoppingFinanceSetting {
3050
2923
  },
3051
2924
  divCreate: {
3052
2925
  class: 'd-flex flex-column flex-column-reverse flex-md-row px-0',
3053
- style: 'gap:10px;',
2926
+ style: 'gap: 10px;',
3054
2927
  },
3055
2928
  };
3056
2929
  })),
3057
2930
  BgWidget.mbContainer(240),
3058
2931
  html ` <div class="update-bar-container">
3059
2932
  ${BgWidget.save(gvc.event(() => {
3060
- save(() => {
3061
- dialog.successMessage({ text: '設定成功' });
3062
- });
2933
+ save(() => dialog.successMessage({ text: '設定成功' }));
3063
2934
  }))}
3064
2935
  </div>`,
3065
2936
  ].join(''))}
@@ -3068,4 +2939,22 @@ export class ShoppingFinanceSetting {
3068
2939
  });
3069
2940
  }
3070
2941
  }
2942
+ _a = ShoppingFinanceSetting;
2943
+ ShoppingFinanceSetting.gvc = null;
2944
+ ShoppingFinanceSetting.id = '';
2945
+ ShoppingFinanceSetting.loading = true;
2946
+ ShoppingFinanceSetting.saasConfig = window.parent.saasConfig;
2947
+ ShoppingFinanceSetting.refresh = (dialogGVC) => {
2948
+ _a.loading = true;
2949
+ if (dialogGVC) {
2950
+ dialogGVC.closeDialog();
2951
+ }
2952
+ if (_a.gvc === null) {
2953
+ console.error('Refresh GVC 並不存在');
2954
+ return;
2955
+ }
2956
+ const pageGVC = _a.gvc;
2957
+ pageGVC.closeDialog();
2958
+ setTimeout(() => pageGVC.notifyDataChange(_a.id), 300);
2959
+ };
3071
2960
  window.glitter.setModule(import.meta.url, ShoppingFinanceSetting);