ts-glitter 21.7.7 → 21.7.8
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.
- package/lowcode/Entry.js +1 -1
- package/lowcode/Entry.ts +1 -1
- package/lowcode/backend-manager/bg-blog.js +1 -6
- package/lowcode/backend-manager/bg-blog.ts +1 -11
- package/lowcode/backend-manager/bg-dialog.js +176 -0
- package/lowcode/backend-manager/bg-dialog.ts +230 -0
- package/lowcode/backend-manager/bg-product.js +1 -3
- package/lowcode/backend-manager/bg-product.ts +1 -5
- package/lowcode/cms-plugin/module/delivery-html.js +56 -5
- package/lowcode/cms-plugin/module/delivery-html.ts +69 -14
- package/lowcode/cms-plugin/shopping-discount-setting.js +234 -1468
- package/lowcode/cms-plugin/shopping-discount-setting.ts +302 -1732
- package/lowcode/jslib/lottie-player.js +143 -39
- package/lowcode/public-components/product/pd-card-01.js +1 -1
- package/lowcode/public-components/product/pd-card-01.ts +5 -8
- package/lowcode/public-components/product/pd-card-02.js +3 -2
- package/lowcode/public-components/product/pd-card-02.ts +7 -10
- package/lowcode/public-components/product/pd-card-03.js +3 -2
- package/lowcode/public-components/product/pd-card-03.ts +7 -9
- package/package.json +1 -1
- package/src/api-public/services/checkout-event.js +17 -7
- package/src/api-public/services/checkout-event.js.map +5 -1
- package/src/api-public/services/financial-serviceV2.js +17 -7
- package/src/api-public/services/financial-serviceV2.js.map +1 -1
- package/src/api-public/services/monitor.d.ts +0 -1
- package/src/api-public/services/shopee.js +17 -7
- package/src/api-public/services/shopee.js.map +1 -1
- package/src/api-public/services/shopping.js +3 -3
- package/src/api-public/services/shopping.js.map +1 -1
- package/src/api-public/services/shopping.ts +3 -5
- package/src/api-public/services/user.js +17 -7
- package/src/api-public/services/user.js.map +5 -1
- package/src/app-project/serverless/src/index.js +17 -7
- package/src/app-project/serverless/src/index.js.map +1 -1
- package/src/app-project/serverless/src/modules/CryptoJS.js +17 -7
- package/src/app-project/serverless/src/modules/CryptoJS.js.map +1 -1
- package/src/app-project/serverless/src/modules/ssh.js +17 -7
- package/src/app-project/serverless/src/modules/ssh.js.map +1 -1
- package/src/index.js +3 -3
- package/src/modules/CryptoJS.js +17 -7
- package/src/modules/CryptoJS.js.map +1 -1
- package/src/modules/database.d.ts +1 -1
- package/src/modules/ssh.js +17 -7
- package/src/modules/ssh.js.map +1 -1
- package/src/modules/tool.d.ts +4 -4
- package/src/modules/tool.js +1 -2
- package/src/modules/tool.js.map +1 -1
- package/src/services/app.js +17 -7
- package/src/services/app.js.map +1 -1
|
@@ -17,19 +17,9 @@ import { ShareDialog } from '../glitterBundle/dialog/ShareDialog.js';
|
|
|
17
17
|
import { FilterOptions } from './filter-options.js';
|
|
18
18
|
import { Tool } from '../modules/tool.js';
|
|
19
19
|
import { ShipmentConfig } from '../glitter-base/global/shipment-config.js';
|
|
20
|
+
import { BgDialog } from '../backend-manager/bg-dialog.js';
|
|
20
21
|
const html = String.raw;
|
|
21
22
|
export class ShoppingDiscountSetting {
|
|
22
|
-
static getLabel(voucher_type) {
|
|
23
|
-
var _b;
|
|
24
|
-
const labels = {
|
|
25
|
-
giveaway: '贈品活動',
|
|
26
|
-
add_on_items: '加價購活動',
|
|
27
|
-
discount: '折扣活動',
|
|
28
|
-
rebate: '回饋金活動',
|
|
29
|
-
shipment_free: '免運費活動',
|
|
30
|
-
};
|
|
31
|
-
return (_b = labels[voucher_type]) !== null && _b !== void 0 ? _b : '未知活動';
|
|
32
|
-
}
|
|
33
23
|
static main(gvc, voucher_type) {
|
|
34
24
|
const glitter = gvc.glitter;
|
|
35
25
|
const dialog = new ShareDialog(glitter);
|
|
@@ -185,6 +175,17 @@ export class ShoppingDiscountSetting {
|
|
|
185
175
|
};
|
|
186
176
|
});
|
|
187
177
|
}
|
|
178
|
+
static getLabel(voucher_type) {
|
|
179
|
+
var _b;
|
|
180
|
+
const labels = {
|
|
181
|
+
giveaway: '贈品活動',
|
|
182
|
+
add_on_items: '加價購活動',
|
|
183
|
+
discount: '折扣活動',
|
|
184
|
+
rebate: '回饋金活動',
|
|
185
|
+
shipment_free: '免運費活動',
|
|
186
|
+
};
|
|
187
|
+
return (_b = labels[voucher_type]) !== null && _b !== void 0 ? _b : '未知活動';
|
|
188
|
+
}
|
|
188
189
|
static summaryTextList(voucherData) {
|
|
189
190
|
var _b, _c;
|
|
190
191
|
return [
|
|
@@ -257,1440 +258,6 @@ export class ShoppingDiscountSetting {
|
|
|
257
258
|
})()}`,
|
|
258
259
|
];
|
|
259
260
|
}
|
|
260
|
-
static voucherEditor(obj) {
|
|
261
|
-
const gvc = obj.gvc;
|
|
262
|
-
const glitter = gvc.glitter;
|
|
263
|
-
const vm = obj.vm;
|
|
264
|
-
const dialog = new ShareDialog(glitter);
|
|
265
|
-
const pageVM = {
|
|
266
|
-
viewID: gvc.glitter.getUUID(),
|
|
267
|
-
conditionID: gvc.glitter.getUUID(),
|
|
268
|
-
countingID: gvc.glitter.getUUID(),
|
|
269
|
-
productOffID: gvc.glitter.getUUID(),
|
|
270
|
-
};
|
|
271
|
-
const voucherData = Object.assign({ title: '', code: '', trigger: 'auto', method: 'fixed', value: '0', for: 'all', forKey: [], device: ['normal'], rule: 'min_price', ruleValue: 1000, startDate: this.getDateTime().date, startTime: this.getDateTime().time, endDate: undefined, endTime: undefined, status: 1, type: 'voucher', overlay: false, start_ISO_Date: '', end_ISO_Date: '', reBackType: obj.reBackType, rebateEndDay: '30', target: 'all', targetList: [], macroLimited: 0, microLimited: 0, counting: 'single', conditionType: 'order', includeDiscount: 'before', productOffStart: 'price_desc', selectShipment: { type: 'all', list: [] } }, vm.data);
|
|
272
|
-
function summaryTextList() {
|
|
273
|
-
var _b, _c;
|
|
274
|
-
return [
|
|
275
|
-
`活動標題:${voucherData.title && voucherData.title.length > 0 ? voucherData.title : '尚無標題'}`,
|
|
276
|
-
`適用商品:${(() => {
|
|
277
|
-
const forData = ShoppingDiscountSetting.productForList.find(item => item.value === voucherData.for);
|
|
278
|
-
return forData ? forData.title : '';
|
|
279
|
-
})()}`,
|
|
280
|
-
`活動方式:${(() => {
|
|
281
|
-
var _b;
|
|
282
|
-
if (voucherData.trigger === 'auto')
|
|
283
|
-
return '自動折扣';
|
|
284
|
-
if (voucherData.trigger === 'distribution')
|
|
285
|
-
return '分銷連結';
|
|
286
|
-
if (voucherData.trigger === 'code')
|
|
287
|
-
return `優惠代碼「${(_b = voucherData.code) !== null && _b !== void 0 ? _b : ''}」`;
|
|
288
|
-
return '';
|
|
289
|
-
})()}`,
|
|
290
|
-
`活動對象:${(() => {
|
|
291
|
-
const targetMapping = {
|
|
292
|
-
customer: '特定顧客',
|
|
293
|
-
levels: '會員等級',
|
|
294
|
-
group: '顧客分群',
|
|
295
|
-
all: '所有顧客',
|
|
296
|
-
};
|
|
297
|
-
return targetMapping[voucherData.target] || targetMapping.all;
|
|
298
|
-
})()}`,
|
|
299
|
-
'',
|
|
300
|
-
`消費條件:${(() => {
|
|
301
|
-
if (voucherData.rule === 'min_price')
|
|
302
|
-
return '最少消費金額';
|
|
303
|
-
if (voucherData.rule === 'min_count')
|
|
304
|
-
return '最少購買數量';
|
|
305
|
-
return '';
|
|
306
|
-
})()}`,
|
|
307
|
-
`條件值:${(() => {
|
|
308
|
-
if (voucherData.rule === 'min_price')
|
|
309
|
-
return voucherData.ruleValue + ' 元';
|
|
310
|
-
if (voucherData.rule === 'min_count')
|
|
311
|
-
return voucherData.ruleValue + ' 個';
|
|
312
|
-
return '';
|
|
313
|
-
})()}`,
|
|
314
|
-
`折扣優惠:${(() => {
|
|
315
|
-
const voucherMessages = {
|
|
316
|
-
rebate: (method, value) => method === 'fixed' ? `${value} 點購物金` : `符合條件商品總額的 ${value} %作為購物金`,
|
|
317
|
-
discount: (method, value) => (method === 'fixed' ? `折扣 ${value} 元` : `符合條件商品折扣 ${value} %`),
|
|
318
|
-
shipment_free: () => '免運費',
|
|
319
|
-
};
|
|
320
|
-
const messageFunction = voucherMessages[voucherData.reBackType];
|
|
321
|
-
return messageFunction ? messageFunction(voucherData.method, voucherData.value) : '';
|
|
322
|
-
})()}`,
|
|
323
|
-
`將此優惠套用至:${(() => {
|
|
324
|
-
var _b, _c;
|
|
325
|
-
const length = (_c = (_b = voucherData.forKey) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
|
|
326
|
-
const forMaps = {
|
|
327
|
-
collection: `指定 ${length} 種商品分類`,
|
|
328
|
-
product: `指定 ${length} 個商品`,
|
|
329
|
-
all: '所有商品',
|
|
330
|
-
};
|
|
331
|
-
return forMaps[voucherData.for] || forMaps.all;
|
|
332
|
-
})()}`,
|
|
333
|
-
'',
|
|
334
|
-
voucherData.overlay ? '可以疊加,套用最大優惠' : '不可疊加',
|
|
335
|
-
`啟用時間:${(_b = voucherData.startDate) !== null && _b !== void 0 ? _b : '未設定日期'} ${(_c = voucherData.startTime) !== null && _c !== void 0 ? _c : '尚未設定時間'}`,
|
|
336
|
-
`結束時間:${(() => {
|
|
337
|
-
var _b, _c;
|
|
338
|
-
if (!voucherData.endDate)
|
|
339
|
-
return '無期限';
|
|
340
|
-
return `${(_b = voucherData.endDate) !== null && _b !== void 0 ? _b : '未設定日期'} ${(_c = voucherData.endTime) !== null && _c !== void 0 ? _c : '尚未設定時間'}`;
|
|
341
|
-
})()}`,
|
|
342
|
-
];
|
|
343
|
-
}
|
|
344
|
-
function title() {
|
|
345
|
-
return html ` <div class="tx_700">活動標題</div>
|
|
346
|
-
${BgWidget.mbContainer(18)}
|
|
347
|
-
${BgWidget.editeInput({
|
|
348
|
-
gvc: gvc,
|
|
349
|
-
title: '',
|
|
350
|
-
default: voucherData.title,
|
|
351
|
-
placeHolder: '請輸入活動標題',
|
|
352
|
-
callback: text => {
|
|
353
|
-
voucherData.title = text;
|
|
354
|
-
},
|
|
355
|
-
})}
|
|
356
|
-
${BgWidget.grayNote('顧客將會在「購物車」與「結帳」看見此標題', 'margin-left: 4px;')}`;
|
|
357
|
-
}
|
|
358
|
-
function status() {
|
|
359
|
-
return html ` <div class="tx_700">活動狀態</div>
|
|
360
|
-
${BgWidget.mbContainer(12)}
|
|
361
|
-
${BgWidget.switchTextButton(gvc, voucherData.status === 1, {
|
|
362
|
-
left: '關閉',
|
|
363
|
-
right: '啟用',
|
|
364
|
-
}, bool => {
|
|
365
|
-
voucherData.status = bool ? 1 : 0;
|
|
366
|
-
})}`;
|
|
367
|
-
}
|
|
368
|
-
function trigger() {
|
|
369
|
-
return html ` <div class="tx_700">活動方式</div>
|
|
370
|
-
${BgWidget.mbContainer(18)}
|
|
371
|
-
${BgWidget.multiCheckboxContainer(gvc, [
|
|
372
|
-
{
|
|
373
|
-
key: 'auto',
|
|
374
|
-
name: '自動折扣',
|
|
375
|
-
innerHtml: BgWidget.grayNote('顧客將在結帳時,自動獲得折扣'),
|
|
376
|
-
},
|
|
377
|
-
{
|
|
378
|
-
key: 'code',
|
|
379
|
-
name: '優惠代碼',
|
|
380
|
-
innerHtml: (() => {
|
|
381
|
-
const id = glitter.getUUID();
|
|
382
|
-
return gvc.bindView({
|
|
383
|
-
bind: id,
|
|
384
|
-
view: () => {
|
|
385
|
-
var _b;
|
|
386
|
-
return gvc.map([
|
|
387
|
-
BgWidget.grayNote('顧客可在結帳時輸入優惠代碼,來獲得折扣'),
|
|
388
|
-
BgWidget.editeInput({
|
|
389
|
-
gvc: gvc,
|
|
390
|
-
title: '',
|
|
391
|
-
default: (_b = voucherData.code) !== null && _b !== void 0 ? _b : '',
|
|
392
|
-
placeHolder: '請輸入優惠券代碼',
|
|
393
|
-
callback: text => {
|
|
394
|
-
voucherData.code = text.toUpperCase();
|
|
395
|
-
},
|
|
396
|
-
endText: html ` <div class="d-flex justify-content-end">
|
|
397
|
-
${BgWidget.mbContainer(8)}
|
|
398
|
-
${BgWidget.blueNote(document.body.clientWidth > 768 ? '隨機產生優惠代碼' : '隨機產生', gvc.event(() => {
|
|
399
|
-
voucherData.code = Tool.randomString(6).toUpperCase();
|
|
400
|
-
gvc.notifyDataChange(id);
|
|
401
|
-
}))}
|
|
402
|
-
</div>`,
|
|
403
|
-
}),
|
|
404
|
-
]);
|
|
405
|
-
},
|
|
406
|
-
});
|
|
407
|
-
})(),
|
|
408
|
-
},
|
|
409
|
-
{
|
|
410
|
-
key: 'distribution',
|
|
411
|
-
name: '供分銷連結或一頁式網頁使用',
|
|
412
|
-
},
|
|
413
|
-
], [voucherData.trigger], text => {
|
|
414
|
-
if (text[0] === 'auto') {
|
|
415
|
-
voucherData.code = undefined;
|
|
416
|
-
}
|
|
417
|
-
if (text[0] === 'distribution') {
|
|
418
|
-
voucherData.for = 'all';
|
|
419
|
-
}
|
|
420
|
-
voucherData.trigger = text[0];
|
|
421
|
-
gvc.notifyDataChange(pageVM.viewID);
|
|
422
|
-
}, { single: true })}`;
|
|
423
|
-
}
|
|
424
|
-
function target() {
|
|
425
|
-
return html ` <div class="tx_700">活動對象</div>
|
|
426
|
-
${BgWidget.mbContainer(18)}
|
|
427
|
-
${gvc.bindView(() => {
|
|
428
|
-
const id = gvc.glitter.getUUID();
|
|
429
|
-
return {
|
|
430
|
-
bind: id,
|
|
431
|
-
view: () => {
|
|
432
|
-
var _b;
|
|
433
|
-
return html `
|
|
434
|
-
<div style="display: flex; flex-direction: column; gap: 8px;">
|
|
435
|
-
${BgWidget.selectFilter({
|
|
436
|
-
gvc: gvc,
|
|
437
|
-
callback: text => {
|
|
438
|
-
voucherData.target = text;
|
|
439
|
-
gvc.notifyDataChange(id);
|
|
440
|
-
},
|
|
441
|
-
default: (_b = voucherData.target) !== null && _b !== void 0 ? _b : 'all',
|
|
442
|
-
options: [
|
|
443
|
-
{
|
|
444
|
-
key: 'all',
|
|
445
|
-
value: '所有顧客',
|
|
446
|
-
},
|
|
447
|
-
{
|
|
448
|
-
key: 'customer',
|
|
449
|
-
value: '特定顧客',
|
|
450
|
-
},
|
|
451
|
-
{
|
|
452
|
-
key: 'levels',
|
|
453
|
-
value: '會員等級',
|
|
454
|
-
},
|
|
455
|
-
],
|
|
456
|
-
style: 'width: 100%;',
|
|
457
|
-
})}
|
|
458
|
-
<div>
|
|
459
|
-
${(() => {
|
|
460
|
-
switch (voucherData.target) {
|
|
461
|
-
case 'all':
|
|
462
|
-
return '';
|
|
463
|
-
case 'customer':
|
|
464
|
-
return gvc.bindView(() => {
|
|
465
|
-
const customVM = {
|
|
466
|
-
id: gvc.glitter.getUUID(),
|
|
467
|
-
loading: true,
|
|
468
|
-
dataList: [],
|
|
469
|
-
};
|
|
470
|
-
return {
|
|
471
|
-
bind: customVM.id,
|
|
472
|
-
view: () => {
|
|
473
|
-
if (customVM.loading) {
|
|
474
|
-
return BgWidget.spinner();
|
|
475
|
-
}
|
|
476
|
-
return html `
|
|
477
|
-
<div class="d-flex flex-column p-2" style="gap: 18px;">
|
|
478
|
-
<div
|
|
479
|
-
class="d-flex align-items-center gray-bottom-line-18"
|
|
480
|
-
style="justify-content: space-between;"
|
|
481
|
-
>
|
|
482
|
-
<div class="form-check-label c_updown_label">
|
|
483
|
-
<div class="tx_normal">顧客名稱</div>
|
|
484
|
-
</div>
|
|
485
|
-
${BgWidget.grayButton('查看全部', gvc.event(() => {
|
|
486
|
-
var _b;
|
|
487
|
-
BgWidget.selectDropDialog({
|
|
488
|
-
gvc: gvc,
|
|
489
|
-
title: '搜尋特定顧客',
|
|
490
|
-
tag: 'select_users',
|
|
491
|
-
updownOptions: FilterOptions.userOrderBy,
|
|
492
|
-
callback: value => {
|
|
493
|
-
voucherData.targetList = value;
|
|
494
|
-
customVM.loading = true;
|
|
495
|
-
gvc.notifyDataChange(customVM.id);
|
|
496
|
-
},
|
|
497
|
-
default: ((_b = voucherData.targetList) !== null && _b !== void 0 ? _b : []).map(id => id.toString()),
|
|
498
|
-
api: (data) => {
|
|
499
|
-
return new Promise(resolve => {
|
|
500
|
-
ApiUser.getUserListOrders({
|
|
501
|
-
page: 0,
|
|
502
|
-
limit: 99999,
|
|
503
|
-
search: data.query,
|
|
504
|
-
orderString: data.orderString,
|
|
505
|
-
only_id: true,
|
|
506
|
-
}).then(dd => {
|
|
507
|
-
if (dd.response.data) {
|
|
508
|
-
resolve(dd.response.data.map((item) => {
|
|
509
|
-
var _b;
|
|
510
|
-
return {
|
|
511
|
-
key: item.userID,
|
|
512
|
-
value: (_b = item.userData.name) !== null && _b !== void 0 ? _b : '(尚無姓名)',
|
|
513
|
-
note: item.userData.email,
|
|
514
|
-
};
|
|
515
|
-
}));
|
|
516
|
-
}
|
|
517
|
-
});
|
|
518
|
-
});
|
|
519
|
-
},
|
|
520
|
-
style: 'width: 100%;',
|
|
521
|
-
});
|
|
522
|
-
}), { textStyle: 'font-weight: 400;' })}
|
|
523
|
-
</div>
|
|
524
|
-
${obj.gvc.map(customVM.dataList.map((opt, index) => {
|
|
525
|
-
return html ` <div class="form-check-label c_updown_label">
|
|
526
|
-
<span class="tx_normal">${index + 1}. ${opt.value}</span>
|
|
527
|
-
${opt.note ? html ` <span class="tx_gray_12 ms-2">${opt.note}</span> ` : ''}
|
|
528
|
-
</div>`;
|
|
529
|
-
}))}
|
|
530
|
-
</div>
|
|
531
|
-
`;
|
|
532
|
-
},
|
|
533
|
-
onCreate: () => {
|
|
534
|
-
if (customVM.loading) {
|
|
535
|
-
if (voucherData.targetList.length === 0) {
|
|
536
|
-
setTimeout(() => {
|
|
537
|
-
customVM.dataList = [];
|
|
538
|
-
customVM.loading = false;
|
|
539
|
-
gvc.notifyDataChange(customVM.id);
|
|
540
|
-
}, 200);
|
|
541
|
-
}
|
|
542
|
-
else {
|
|
543
|
-
ApiUser.getUserList({
|
|
544
|
-
page: 0,
|
|
545
|
-
limit: 99999,
|
|
546
|
-
id: voucherData.targetList.join(','),
|
|
547
|
-
only_id: true,
|
|
548
|
-
}).then(dd => {
|
|
549
|
-
if (dd.response.data) {
|
|
550
|
-
customVM.dataList = dd.response.data.map((item) => {
|
|
551
|
-
return {
|
|
552
|
-
key: item.userID,
|
|
553
|
-
value: item.userData.name,
|
|
554
|
-
note: item.userData.email,
|
|
555
|
-
};
|
|
556
|
-
});
|
|
557
|
-
}
|
|
558
|
-
customVM.loading = false;
|
|
559
|
-
gvc.notifyDataChange(customVM.id);
|
|
560
|
-
});
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
},
|
|
564
|
-
};
|
|
565
|
-
});
|
|
566
|
-
case 'levels':
|
|
567
|
-
return (() => {
|
|
568
|
-
const levelVM = {
|
|
569
|
-
id: gvc.glitter.getUUID(),
|
|
570
|
-
loading: true,
|
|
571
|
-
dataList: [],
|
|
572
|
-
};
|
|
573
|
-
return gvc.bindView({
|
|
574
|
-
bind: levelVM.id,
|
|
575
|
-
view: () => {
|
|
576
|
-
var _b;
|
|
577
|
-
if (levelVM.loading) {
|
|
578
|
-
return BgWidget.spinner({ text: { visible: false } });
|
|
579
|
-
}
|
|
580
|
-
else {
|
|
581
|
-
return BgWidget.selectDropList({
|
|
582
|
-
gvc: gvc,
|
|
583
|
-
callback: value => {
|
|
584
|
-
voucherData.targetList = value;
|
|
585
|
-
gvc.notifyDataChange(id);
|
|
586
|
-
},
|
|
587
|
-
default: ((_b = voucherData.targetList) !== null && _b !== void 0 ? _b : []).map(id => id.toString()),
|
|
588
|
-
options: levelVM.dataList,
|
|
589
|
-
style: 'width: 100%;',
|
|
590
|
-
});
|
|
591
|
-
}
|
|
592
|
-
},
|
|
593
|
-
divCreate: {
|
|
594
|
-
style: 'width: 100%;',
|
|
595
|
-
},
|
|
596
|
-
onCreate: () => {
|
|
597
|
-
if (levelVM.loading) {
|
|
598
|
-
ApiUser.getPublicConfig('member_level_config', 'manager').then((dd) => {
|
|
599
|
-
if (dd.result && dd.response.value) {
|
|
600
|
-
levelVM.dataList = dd.response.value.levels.map((item) => {
|
|
601
|
-
return {
|
|
602
|
-
key: item.id,
|
|
603
|
-
value: item.tag_name,
|
|
604
|
-
};
|
|
605
|
-
});
|
|
606
|
-
levelVM.loading = false;
|
|
607
|
-
gvc.notifyDataChange(levelVM.id);
|
|
608
|
-
}
|
|
609
|
-
});
|
|
610
|
-
}
|
|
611
|
-
},
|
|
612
|
-
});
|
|
613
|
-
})();
|
|
614
|
-
case 'group':
|
|
615
|
-
return (() => {
|
|
616
|
-
const levelVM = {
|
|
617
|
-
id: gvc.glitter.getUUID(),
|
|
618
|
-
loading: true,
|
|
619
|
-
dataList: [],
|
|
620
|
-
};
|
|
621
|
-
return gvc.bindView({
|
|
622
|
-
bind: levelVM.id,
|
|
623
|
-
view: () => {
|
|
624
|
-
var _b;
|
|
625
|
-
if (levelVM.loading) {
|
|
626
|
-
return BgWidget.spinner({ text: { visible: false } });
|
|
627
|
-
}
|
|
628
|
-
else {
|
|
629
|
-
return BgWidget.selectDropList({
|
|
630
|
-
gvc: gvc,
|
|
631
|
-
callback: (value) => {
|
|
632
|
-
voucherData.targetList = value;
|
|
633
|
-
gvc.notifyDataChange(id);
|
|
634
|
-
},
|
|
635
|
-
default: ((_b = voucherData.targetList) !== null && _b !== void 0 ? _b : []).map(id => id.toString()),
|
|
636
|
-
options: levelVM.dataList,
|
|
637
|
-
style: 'width: 100%;',
|
|
638
|
-
});
|
|
639
|
-
}
|
|
640
|
-
},
|
|
641
|
-
divCreate: {
|
|
642
|
-
style: 'width: 100%;',
|
|
643
|
-
},
|
|
644
|
-
onCreate: () => {
|
|
645
|
-
if (levelVM.loading) {
|
|
646
|
-
ApiUser.getUserGroupList().then((dd) => {
|
|
647
|
-
if (dd.result && dd.response.data) {
|
|
648
|
-
levelVM.dataList = dd.response.data
|
|
649
|
-
.filter((item) => {
|
|
650
|
-
return item.type !== 'level';
|
|
651
|
-
})
|
|
652
|
-
.map((item) => {
|
|
653
|
-
return {
|
|
654
|
-
key: item.type,
|
|
655
|
-
value: item.title,
|
|
656
|
-
};
|
|
657
|
-
});
|
|
658
|
-
levelVM.loading = false;
|
|
659
|
-
gvc.notifyDataChange(levelVM.id);
|
|
660
|
-
}
|
|
661
|
-
});
|
|
662
|
-
}
|
|
663
|
-
},
|
|
664
|
-
});
|
|
665
|
-
})();
|
|
666
|
-
default:
|
|
667
|
-
return '';
|
|
668
|
-
}
|
|
669
|
-
})()}
|
|
670
|
-
</div>
|
|
671
|
-
</div>
|
|
672
|
-
`;
|
|
673
|
-
},
|
|
674
|
-
};
|
|
675
|
-
})}`;
|
|
676
|
-
}
|
|
677
|
-
function device() {
|
|
678
|
-
var _b;
|
|
679
|
-
return html ` <div class="tx_700">可使用訂單來源</div>
|
|
680
|
-
${BgWidget.mbContainer(18)}
|
|
681
|
-
${BgWidget.multiCheckboxContainer(gvc, [
|
|
682
|
-
{ key: 'normal', name: 'APP & 官網' },
|
|
683
|
-
{ key: 'pos', name: 'POS' },
|
|
684
|
-
], (_b = voucherData.device) !== null && _b !== void 0 ? _b : ['normal'], text => {
|
|
685
|
-
voucherData.device = text;
|
|
686
|
-
gvc.notifyDataChange(pageVM.viewID);
|
|
687
|
-
}, { single: false })}`;
|
|
688
|
-
}
|
|
689
|
-
function selectShipment() {
|
|
690
|
-
const id = glitter.getUUID();
|
|
691
|
-
return gvc.bindView({
|
|
692
|
-
bind: id,
|
|
693
|
-
view: () => {
|
|
694
|
-
var _b;
|
|
695
|
-
return html ` <div class="tx_700">可使用物流</div>
|
|
696
|
-
${BgWidget.mbContainer(18)}
|
|
697
|
-
${[
|
|
698
|
-
BgWidget.select({
|
|
699
|
-
gvc,
|
|
700
|
-
callback: value => {
|
|
701
|
-
voucherData.selectShipment.type = value;
|
|
702
|
-
gvc.notifyDataChange(id);
|
|
703
|
-
},
|
|
704
|
-
default: voucherData.selectShipment.type,
|
|
705
|
-
options: [
|
|
706
|
-
{ key: 'all', value: '所有物流' },
|
|
707
|
-
{ key: 'select', value: '指定物流' },
|
|
708
|
-
],
|
|
709
|
-
}),
|
|
710
|
-
voucherData.selectShipment.type === 'all'
|
|
711
|
-
? ''
|
|
712
|
-
: BgWidget.selectDropList({
|
|
713
|
-
gvc: gvc,
|
|
714
|
-
callback: value => {
|
|
715
|
-
voucherData.selectShipment.list = value;
|
|
716
|
-
},
|
|
717
|
-
default: (_b = voucherData.selectShipment.list) !== null && _b !== void 0 ? _b : [],
|
|
718
|
-
options: ShipmentConfig.list.map(item => {
|
|
719
|
-
return {
|
|
720
|
-
key: item.value,
|
|
721
|
-
value: item.title,
|
|
722
|
-
};
|
|
723
|
-
}),
|
|
724
|
-
style: 'width: 100%;',
|
|
725
|
-
}),
|
|
726
|
-
]
|
|
727
|
-
.filter(Boolean)
|
|
728
|
-
.join(BgWidget.mbContainer(8))}`;
|
|
729
|
-
},
|
|
730
|
-
});
|
|
731
|
-
}
|
|
732
|
-
function rebackProduct() {
|
|
733
|
-
return gvc.bindView(() => {
|
|
734
|
-
const vm = {
|
|
735
|
-
id: gvc.glitter.getUUID(),
|
|
736
|
-
};
|
|
737
|
-
if (!Array.isArray(voucherData.add_on_products)) {
|
|
738
|
-
voucherData.add_on_products = [];
|
|
739
|
-
}
|
|
740
|
-
return {
|
|
741
|
-
bind: vm.id,
|
|
742
|
-
view: () => {
|
|
743
|
-
return html `
|
|
744
|
-
<div class="tx_700">${voucherData.reBackType === 'add_on_items' ? `加購品項` : `贈品品項`}</div>
|
|
745
|
-
${BgWidget.mbContainer(18)}
|
|
746
|
-
${obj.gvc.bindView(() => {
|
|
747
|
-
const id = gvc.glitter.getUUID();
|
|
748
|
-
return {
|
|
749
|
-
bind: id,
|
|
750
|
-
view: () => {
|
|
751
|
-
try {
|
|
752
|
-
return html `
|
|
753
|
-
<div
|
|
754
|
-
class="d-flex align-items-center gray-bottom-line-18"
|
|
755
|
-
style="gap: 24px; justify-content: space-between;"
|
|
756
|
-
>
|
|
757
|
-
<div class="form-check-label c_updown_label">
|
|
758
|
-
<div class="tx_normal">商品列表</div>
|
|
759
|
-
</div>
|
|
760
|
-
${BgWidget.grayButton('選擇商品', gvc.event(() => {
|
|
761
|
-
var _b;
|
|
762
|
-
BgProduct.productsDialog({
|
|
763
|
-
gvc: gvc,
|
|
764
|
-
default: (_b = voucherData.add_on_products) !== null && _b !== void 0 ? _b : [],
|
|
765
|
-
callback: (value) => __awaiter(this, void 0, void 0, function* () {
|
|
766
|
-
voucherData.add_on_products = value;
|
|
767
|
-
gvc.notifyDataChange(id);
|
|
768
|
-
}),
|
|
769
|
-
filter: dd => {
|
|
770
|
-
return true;
|
|
771
|
-
},
|
|
772
|
-
productType: voucherData.reBackType === 'add_on_items' ? 'addProduct' : 'giveaway',
|
|
773
|
-
});
|
|
774
|
-
}), { textStyle: 'font-weight: 400;' })}
|
|
775
|
-
</div>
|
|
776
|
-
${gvc.bindView(() => {
|
|
777
|
-
const vm = {
|
|
778
|
-
id: gvc.glitter.getUUID(),
|
|
779
|
-
loading: true,
|
|
780
|
-
data: [],
|
|
781
|
-
};
|
|
782
|
-
BgProduct.getProductOpts(voucherData.add_on_products, voucherData.reBackType === 'add_on_items' ? 'addProduct' : 'giveaway').then(res => {
|
|
783
|
-
vm.data = res;
|
|
784
|
-
vm.loading = false;
|
|
785
|
-
gvc.notifyDataChange(vm.id);
|
|
786
|
-
});
|
|
787
|
-
return {
|
|
788
|
-
bind: vm.id,
|
|
789
|
-
view: () => __awaiter(this, void 0, void 0, function* () {
|
|
790
|
-
if (vm.loading) {
|
|
791
|
-
return BgWidget.spinner();
|
|
792
|
-
}
|
|
793
|
-
return vm.data
|
|
794
|
-
.map((opt, index) => {
|
|
795
|
-
return html ` <div
|
|
796
|
-
class="d-flex align-items-center form-check-label c_updown_label gap-3"
|
|
797
|
-
>
|
|
798
|
-
<span class="tx_normal">${index + 1}.</span>
|
|
799
|
-
${BgWidget.validImageBox({
|
|
800
|
-
gvc: gvc,
|
|
801
|
-
image: opt.image,
|
|
802
|
-
width: 40,
|
|
803
|
-
})}
|
|
804
|
-
<div class="tx_normal ${opt.note ? 'mb-1' : ''}">${opt.value}</div>
|
|
805
|
-
${opt.note ? html ` <div class="tx_gray_12">${opt.note}</div> ` : ''}
|
|
806
|
-
</div>`;
|
|
807
|
-
})
|
|
808
|
-
.join('');
|
|
809
|
-
}),
|
|
810
|
-
divCreate: {
|
|
811
|
-
class: `d-flex py-2 flex-column`,
|
|
812
|
-
style: `gap:10px;`,
|
|
813
|
-
},
|
|
814
|
-
};
|
|
815
|
-
})}
|
|
816
|
-
`;
|
|
817
|
-
}
|
|
818
|
-
catch (e) {
|
|
819
|
-
console.error(e);
|
|
820
|
-
return '';
|
|
821
|
-
}
|
|
822
|
-
},
|
|
823
|
-
divCreate: {
|
|
824
|
-
class: `w-100`,
|
|
825
|
-
},
|
|
826
|
-
};
|
|
827
|
-
})}
|
|
828
|
-
`;
|
|
829
|
-
},
|
|
830
|
-
};
|
|
831
|
-
});
|
|
832
|
-
}
|
|
833
|
-
return gvc.bindView(() => {
|
|
834
|
-
return {
|
|
835
|
-
bind: pageVM.viewID,
|
|
836
|
-
view: () => {
|
|
837
|
-
return BgWidget.container([
|
|
838
|
-
html ` <div class="title-container">
|
|
839
|
-
${BgWidget.goBack(gvc.event(() => {
|
|
840
|
-
vm.type = 'list';
|
|
841
|
-
}))}
|
|
842
|
-
${BgWidget.title(`${obj.type === 'add' ? '新增' : '編輯'}${ShoppingDiscountSetting.getLabel(obj.reBackType)}`)}
|
|
843
|
-
</div>`,
|
|
844
|
-
BgWidget.container1x2({
|
|
845
|
-
html: [
|
|
846
|
-
BgWidget.mainCard([title(), status()].join(BgWidget.horizontalLine())),
|
|
847
|
-
BgWidget.mainCard([
|
|
848
|
-
trigger(),
|
|
849
|
-
target(),
|
|
850
|
-
device(),
|
|
851
|
-
voucherData.reBackType === 'shipment_free' ? selectShipment() : '',
|
|
852
|
-
]
|
|
853
|
-
.filter(Boolean)
|
|
854
|
-
.map(str => html ` <div>${str}</div>`)
|
|
855
|
-
.join(BgWidget.horizontalLine())),
|
|
856
|
-
...(['shipment_free', 'add_on_items', 'giveaway'].includes(voucherData.reBackType)
|
|
857
|
-
? []
|
|
858
|
-
: [
|
|
859
|
-
BgWidget.mainCard(gvc.bindView(() => {
|
|
860
|
-
var _b;
|
|
861
|
-
const id = glitter.getUUID();
|
|
862
|
-
const originForType = String(voucherData.for);
|
|
863
|
-
voucherData.forKey = (_b = voucherData.forKey) !== null && _b !== void 0 ? _b : [];
|
|
864
|
-
let defKeys = {
|
|
865
|
-
collection: JSON.parse(JSON.stringify(voucherData.forKey)),
|
|
866
|
-
product: JSON.parse(JSON.stringify(voucherData.forKey)),
|
|
867
|
-
manager_tag: JSON.parse(JSON.stringify(voucherData.forKey)),
|
|
868
|
-
};
|
|
869
|
-
return {
|
|
870
|
-
bind: id,
|
|
871
|
-
dataList: [
|
|
872
|
-
{ obj: voucherData, key: 'method' },
|
|
873
|
-
{ obj: voucherData, key: 'reBackType' },
|
|
874
|
-
],
|
|
875
|
-
view: () => {
|
|
876
|
-
return [
|
|
877
|
-
...(() => {
|
|
878
|
-
if (['shipment_free', 'add_on_items', 'giveaway'].includes(voucherData.reBackType)) {
|
|
879
|
-
return [];
|
|
880
|
-
}
|
|
881
|
-
const valueInput = (obj) => {
|
|
882
|
-
return BgWidget.editeInput({
|
|
883
|
-
gvc: gvc,
|
|
884
|
-
type: 'number',
|
|
885
|
-
divStyle: 'width:150px;',
|
|
886
|
-
title: '',
|
|
887
|
-
default: voucherData.value,
|
|
888
|
-
placeHolder: '',
|
|
889
|
-
callback: text => {
|
|
890
|
-
const texInt = parseInt(text, 10);
|
|
891
|
-
if (voucherData.method === 'percent' && (texInt > 100 || texInt < 0)) {
|
|
892
|
-
dialog.infoMessage({ text: '數值需介於0~100' });
|
|
893
|
-
gvc.notifyDataChange(id);
|
|
894
|
-
gvc.notifyDataChange(pageVM.countingID);
|
|
895
|
-
}
|
|
896
|
-
else {
|
|
897
|
-
voucherData.value = text;
|
|
898
|
-
}
|
|
899
|
-
},
|
|
900
|
-
startText: obj.startText,
|
|
901
|
-
endText: obj.endText,
|
|
902
|
-
});
|
|
903
|
-
};
|
|
904
|
-
return [
|
|
905
|
-
html ` <div>
|
|
906
|
-
<div class="tx_700">折扣金額</div>
|
|
907
|
-
${BgWidget.mbContainer(18)}
|
|
908
|
-
${BgWidget.multiCheckboxContainer(gvc, [
|
|
909
|
-
{
|
|
910
|
-
key: 'fixed',
|
|
911
|
-
name: '固定金額',
|
|
912
|
-
innerHtml: valueInput({ startText: '$' }),
|
|
913
|
-
},
|
|
914
|
-
{
|
|
915
|
-
key: 'percent',
|
|
916
|
-
name: '百分比',
|
|
917
|
-
innerHtml: valueInput({ endText: '%' }),
|
|
918
|
-
},
|
|
919
|
-
], [voucherData.method], text => {
|
|
920
|
-
voucherData.value = '0';
|
|
921
|
-
voucherData.method = text[0];
|
|
922
|
-
gvc.notifyDataChange(pageVM.conditionID);
|
|
923
|
-
}, { single: true })}
|
|
924
|
-
</div>`,
|
|
925
|
-
];
|
|
926
|
-
})(),
|
|
927
|
-
...(() => {
|
|
928
|
-
var _b;
|
|
929
|
-
if (voucherData.trigger === 'distribution') {
|
|
930
|
-
return [];
|
|
931
|
-
}
|
|
932
|
-
return [
|
|
933
|
-
html `
|
|
934
|
-
<div class="tx_700">套用至</div>
|
|
935
|
-
${BgWidget.mbContainer(18)}
|
|
936
|
-
${EditorElem.radio({
|
|
937
|
-
gvc: gvc,
|
|
938
|
-
title: '',
|
|
939
|
-
def: (_b = voucherData.for) !== null && _b !== void 0 ? _b : 'all',
|
|
940
|
-
array: ShoppingDiscountSetting.productForList,
|
|
941
|
-
callback: text => {
|
|
942
|
-
voucherData.forKey = defKeys[text];
|
|
943
|
-
voucherData.for = text;
|
|
944
|
-
gvc.notifyDataChange(id);
|
|
945
|
-
},
|
|
946
|
-
oneLine: true,
|
|
947
|
-
})}
|
|
948
|
-
${BgWidget.mbContainer(8)}
|
|
949
|
-
${(() => {
|
|
950
|
-
switch (voucherData.for) {
|
|
951
|
-
case 'manager_tag':
|
|
952
|
-
return gvc.bindView(() => {
|
|
953
|
-
const subVM = {
|
|
954
|
-
id: gvc.glitter.getUUID(),
|
|
955
|
-
dataList: originForType === 'manager_tag' ? [...defKeys.manager_tag] : [],
|
|
956
|
-
};
|
|
957
|
-
return {
|
|
958
|
-
bind: subVM.id,
|
|
959
|
-
view: () => {
|
|
960
|
-
return html `
|
|
961
|
-
<div class="d-flex flex-column p-2" style="gap: 18px;">
|
|
962
|
-
<div
|
|
963
|
-
class="d-flex align-items-center gray-bottom-line-18"
|
|
964
|
-
style="gap: 24px; justify-content: space-between;"
|
|
965
|
-
>
|
|
966
|
-
<div class="form-check-label c_updown_label">
|
|
967
|
-
<div class="tx_normal">標籤列表</div>
|
|
968
|
-
</div>
|
|
969
|
-
${BgWidget.grayButton('選擇標籤', gvc.event(() => {
|
|
970
|
-
BgProduct.useProductTags({
|
|
971
|
-
gvc,
|
|
972
|
-
config_key: 'product_manager_tags',
|
|
973
|
-
def: originForType === 'manager_tag' &&
|
|
974
|
-
voucherData.forKey
|
|
975
|
-
? voucherData.forKey.map(item => `${item}`)
|
|
976
|
-
: [],
|
|
977
|
-
callback: (value) => __awaiter(this, void 0, void 0, function* () {
|
|
978
|
-
voucherData.forKey = value;
|
|
979
|
-
defKeys.manager_tag = value;
|
|
980
|
-
subVM.dataList = value;
|
|
981
|
-
gvc.notifyDataChange(subVM.id);
|
|
982
|
-
}),
|
|
983
|
-
});
|
|
984
|
-
}), { textStyle: 'font-weight: 400;' })}
|
|
985
|
-
</div>
|
|
986
|
-
${obj.gvc.map(subVM.dataList.map((opt, index) => {
|
|
987
|
-
return html ` <div
|
|
988
|
-
class="d-flex align-items-center form-check-label c_updown_label gap-3"
|
|
989
|
-
>
|
|
990
|
-
<span class="tx_normal">${index + 1}. #${opt}</span>
|
|
991
|
-
</div>`;
|
|
992
|
-
}))}
|
|
993
|
-
</div>
|
|
994
|
-
`;
|
|
995
|
-
},
|
|
996
|
-
};
|
|
997
|
-
});
|
|
998
|
-
case 'collection':
|
|
999
|
-
return gvc.bindView(() => {
|
|
1000
|
-
const subVM = {
|
|
1001
|
-
id: gvc.glitter.getUUID(),
|
|
1002
|
-
loading: true,
|
|
1003
|
-
dataList: [],
|
|
1004
|
-
};
|
|
1005
|
-
return {
|
|
1006
|
-
bind: subVM.id,
|
|
1007
|
-
view: () => {
|
|
1008
|
-
if (subVM.loading) {
|
|
1009
|
-
return BgWidget.spinner();
|
|
1010
|
-
}
|
|
1011
|
-
return html `
|
|
1012
|
-
<div class="d-flex flex-column p-2" style="gap: 18px;">
|
|
1013
|
-
<div
|
|
1014
|
-
class="d-flex align-items-center gray-bottom-line-18"
|
|
1015
|
-
style="gap: 24px; justify-content: space-between;"
|
|
1016
|
-
>
|
|
1017
|
-
<div class="form-check-label c_updown_label">
|
|
1018
|
-
<div class="tx_normal">分類列表</div>
|
|
1019
|
-
</div>
|
|
1020
|
-
${BgWidget.grayButton('選擇分類', gvc.event(() => {
|
|
1021
|
-
var _b;
|
|
1022
|
-
BgProduct.collectionsDialog({
|
|
1023
|
-
gvc: gvc,
|
|
1024
|
-
default: (_b = voucherData.forKey) !== null && _b !== void 0 ? _b : [],
|
|
1025
|
-
callback: (value) => __awaiter(this, void 0, void 0, function* () {
|
|
1026
|
-
voucherData.forKey = value;
|
|
1027
|
-
defKeys.collection = value;
|
|
1028
|
-
subVM.dataList =
|
|
1029
|
-
yield BgProduct.getCollectiosOpts(value);
|
|
1030
|
-
subVM.loading = true;
|
|
1031
|
-
gvc.notifyDataChange(subVM.id);
|
|
1032
|
-
}),
|
|
1033
|
-
});
|
|
1034
|
-
}), { textStyle: 'font-weight: 400;' })}
|
|
1035
|
-
</div>
|
|
1036
|
-
${obj.gvc.map(subVM.dataList.map((opt, index) => {
|
|
1037
|
-
return html ` <div
|
|
1038
|
-
class="d-flex align-items-center form-check-label c_updown_label gap-3"
|
|
1039
|
-
>
|
|
1040
|
-
<span class="tx_normal"
|
|
1041
|
-
>${index + 1}. ${opt.value}</span
|
|
1042
|
-
>
|
|
1043
|
-
${opt.note
|
|
1044
|
-
? html `
|
|
1045
|
-
<span class="tx_gray_12 ms-2">${opt.note}</span>
|
|
1046
|
-
`
|
|
1047
|
-
: ''}
|
|
1048
|
-
</div>`;
|
|
1049
|
-
}))}
|
|
1050
|
-
</div>
|
|
1051
|
-
`;
|
|
1052
|
-
},
|
|
1053
|
-
onCreate: () => {
|
|
1054
|
-
if (subVM.loading) {
|
|
1055
|
-
if (voucherData.forKey.length === 0) {
|
|
1056
|
-
setTimeout(() => {
|
|
1057
|
-
subVM.dataList = [];
|
|
1058
|
-
subVM.loading = false;
|
|
1059
|
-
gvc.notifyDataChange(subVM.id);
|
|
1060
|
-
}, 200);
|
|
1061
|
-
}
|
|
1062
|
-
else {
|
|
1063
|
-
new Promise(resolve => {
|
|
1064
|
-
resolve(BgProduct.getCollectiosOpts(voucherData.forKey));
|
|
1065
|
-
}).then(data => {
|
|
1066
|
-
subVM.dataList = data;
|
|
1067
|
-
subVM.loading = false;
|
|
1068
|
-
gvc.notifyDataChange(subVM.id);
|
|
1069
|
-
});
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1072
|
-
},
|
|
1073
|
-
};
|
|
1074
|
-
});
|
|
1075
|
-
case 'product':
|
|
1076
|
-
return gvc.bindView(() => {
|
|
1077
|
-
const subVM = {
|
|
1078
|
-
id: gvc.glitter.getUUID(),
|
|
1079
|
-
loading: true,
|
|
1080
|
-
dataList: [],
|
|
1081
|
-
};
|
|
1082
|
-
return {
|
|
1083
|
-
bind: subVM.id,
|
|
1084
|
-
view: () => {
|
|
1085
|
-
if (subVM.loading) {
|
|
1086
|
-
return BgWidget.spinner();
|
|
1087
|
-
}
|
|
1088
|
-
return html `
|
|
1089
|
-
<div class="d-flex flex-column p-2" style="gap: 18px;">
|
|
1090
|
-
<div
|
|
1091
|
-
class="d-flex align-items-center gray-bottom-line-18"
|
|
1092
|
-
style="gap: 24px; justify-content: space-between;"
|
|
1093
|
-
>
|
|
1094
|
-
<div class="form-check-label c_updown_label">
|
|
1095
|
-
<div class="tx_normal">商品列表</div>
|
|
1096
|
-
</div>
|
|
1097
|
-
${BgWidget.grayButton('選擇商品', gvc.event(() => {
|
|
1098
|
-
var _b;
|
|
1099
|
-
BgProduct.productsDialog({
|
|
1100
|
-
gvc: gvc,
|
|
1101
|
-
default: (_b = voucherData.forKey) !== null && _b !== void 0 ? _b : [],
|
|
1102
|
-
callback: (value) => __awaiter(this, void 0, void 0, function* () {
|
|
1103
|
-
voucherData.forKey = value;
|
|
1104
|
-
defKeys.product = value;
|
|
1105
|
-
subVM.dataList = yield BgProduct.getProductOpts(voucherData.forKey);
|
|
1106
|
-
subVM.loading = true;
|
|
1107
|
-
gvc.notifyDataChange(subVM.id);
|
|
1108
|
-
}),
|
|
1109
|
-
});
|
|
1110
|
-
}), { textStyle: 'font-weight: 400;' })}
|
|
1111
|
-
</div>
|
|
1112
|
-
${subVM.dataList
|
|
1113
|
-
.map((opt, index) => {
|
|
1114
|
-
return html ` <div
|
|
1115
|
-
class="d-flex align-items-center form-check-label c_updown_label gap-3"
|
|
1116
|
-
>
|
|
1117
|
-
<span class="tx_normal">${index + 1}.</span>
|
|
1118
|
-
${BgWidget.validImageBox({
|
|
1119
|
-
gvc: gvc,
|
|
1120
|
-
image: opt.image,
|
|
1121
|
-
width: 40,
|
|
1122
|
-
})}
|
|
1123
|
-
<div class="tx_normal ${opt.note ? 'mb-1' : ''}">
|
|
1124
|
-
${opt.value}
|
|
1125
|
-
</div>
|
|
1126
|
-
${opt.note
|
|
1127
|
-
? html ` <div class="tx_gray_12">${opt.note}</div> `
|
|
1128
|
-
: ''}
|
|
1129
|
-
</div>`;
|
|
1130
|
-
})
|
|
1131
|
-
.join(``)}
|
|
1132
|
-
</div>
|
|
1133
|
-
`;
|
|
1134
|
-
},
|
|
1135
|
-
onCreate: () => {
|
|
1136
|
-
if (subVM.loading) {
|
|
1137
|
-
if (voucherData.forKey.length === 0) {
|
|
1138
|
-
setTimeout(() => {
|
|
1139
|
-
subVM.dataList = [];
|
|
1140
|
-
subVM.loading = false;
|
|
1141
|
-
gvc.notifyDataChange(subVM.id);
|
|
1142
|
-
}, 200);
|
|
1143
|
-
}
|
|
1144
|
-
else {
|
|
1145
|
-
new Promise(resolve => {
|
|
1146
|
-
resolve(BgProduct.getProductOpts(voucherData.forKey));
|
|
1147
|
-
}).then(data => {
|
|
1148
|
-
subVM.dataList = data;
|
|
1149
|
-
subVM.loading = false;
|
|
1150
|
-
gvc.notifyDataChange(subVM.id);
|
|
1151
|
-
});
|
|
1152
|
-
}
|
|
1153
|
-
}
|
|
1154
|
-
},
|
|
1155
|
-
};
|
|
1156
|
-
});
|
|
1157
|
-
case 'all':
|
|
1158
|
-
default:
|
|
1159
|
-
return '';
|
|
1160
|
-
}
|
|
1161
|
-
})()}
|
|
1162
|
-
`,
|
|
1163
|
-
];
|
|
1164
|
-
})(),
|
|
1165
|
-
].join(BgWidget.horizontalLine());
|
|
1166
|
-
},
|
|
1167
|
-
};
|
|
1168
|
-
})),
|
|
1169
|
-
]),
|
|
1170
|
-
['giveaway', 'add_on_items'].includes(voucherData.reBackType)
|
|
1171
|
-
? BgWidget.mainCard(rebackProduct())
|
|
1172
|
-
: '',
|
|
1173
|
-
BgWidget.mainCard(gvc.bindView(() => {
|
|
1174
|
-
return {
|
|
1175
|
-
bind: pageVM.conditionID,
|
|
1176
|
-
view: () => {
|
|
1177
|
-
const conditionInput = (text) => {
|
|
1178
|
-
var _b;
|
|
1179
|
-
return BgWidget.editeInput({
|
|
1180
|
-
gvc: gvc,
|
|
1181
|
-
title: '',
|
|
1182
|
-
divStyle: 'width:150px;',
|
|
1183
|
-
default: `${(_b = voucherData.ruleValue) !== null && _b !== void 0 ? _b : 0}`,
|
|
1184
|
-
placeHolder: '',
|
|
1185
|
-
callback: value => {
|
|
1186
|
-
voucherData.ruleValue = parseInt(value, 10);
|
|
1187
|
-
gvc.notifyDataChange(pageVM.conditionID);
|
|
1188
|
-
},
|
|
1189
|
-
endText: text,
|
|
1190
|
-
});
|
|
1191
|
-
};
|
|
1192
|
-
const n = voucherData.ruleValue;
|
|
1193
|
-
const floor = Math.floor(n / 2);
|
|
1194
|
-
const ruleText = (sum) => {
|
|
1195
|
-
return `${sum}${voucherData.rule === 'min_count' ? '個' : '元'}`;
|
|
1196
|
-
};
|
|
1197
|
-
voucherData.counting =
|
|
1198
|
-
voucherData.method === 'percent' || voucherData.reBackType === 'shipment_free'
|
|
1199
|
-
? 'single'
|
|
1200
|
-
: voucherData.counting;
|
|
1201
|
-
voucherData.conditionType =
|
|
1202
|
-
voucherData.reBackType === 'shipment_free' ? 'order' : voucherData.conditionType;
|
|
1203
|
-
return [
|
|
1204
|
-
html ` <div class="tx_700">消費條件</div>
|
|
1205
|
-
${BgWidget.mbContainer(18)}
|
|
1206
|
-
${BgWidget.multiCheckboxContainer(gvc, [
|
|
1207
|
-
{
|
|
1208
|
-
key: 'min_price',
|
|
1209
|
-
name: '最低消費金額',
|
|
1210
|
-
innerHtml: conditionInput('元'),
|
|
1211
|
-
},
|
|
1212
|
-
{
|
|
1213
|
-
key: 'min_count',
|
|
1214
|
-
name: '最少購買數量',
|
|
1215
|
-
innerHtml: conditionInput('個'),
|
|
1216
|
-
},
|
|
1217
|
-
], [voucherData.rule], text => {
|
|
1218
|
-
voucherData.ruleValue = 0;
|
|
1219
|
-
voucherData.rule = text[0];
|
|
1220
|
-
gvc.notifyDataChange(pageVM.conditionID);
|
|
1221
|
-
}, { single: true })}`,
|
|
1222
|
-
html ` ${BgWidget.horizontalLine()}
|
|
1223
|
-
<div class="tx_700">計算單位</div>
|
|
1224
|
-
${BgWidget.mbContainer(18)}
|
|
1225
|
-
${BgWidget.multiCheckboxContainer(gvc, [
|
|
1226
|
-
{
|
|
1227
|
-
key: 'order',
|
|
1228
|
-
name: '以整份訂單計算',
|
|
1229
|
-
innerHtml: BgWidget.grayNote((() => {
|
|
1230
|
-
if (voucherData.reBackType === 'shipment_free') {
|
|
1231
|
-
return '優惠條件為整份訂單免運費';
|
|
1232
|
-
}
|
|
1233
|
-
return `若商品A購買${ruleText(floor)},加上商品B購買${ruleText(n - floor)},可觸發優惠`;
|
|
1234
|
-
})()),
|
|
1235
|
-
},
|
|
1236
|
-
{
|
|
1237
|
-
key: 'item',
|
|
1238
|
-
name: '以商品計算',
|
|
1239
|
-
innerHtml: BgWidget.grayNote(`需要商品A購買滿${ruleText(n)},或商品B購買滿${ruleText(n)},即可觸發優惠<br/>若商品A購買${ruleText(floor)},加上商品B購買${ruleText(n - floor)},無法觸發優惠`),
|
|
1240
|
-
},
|
|
1241
|
-
], [voucherData.conditionType], text => {
|
|
1242
|
-
voucherData.conditionType = text[0];
|
|
1243
|
-
gvc.notifyDataChange(pageVM.conditionID);
|
|
1244
|
-
}, {
|
|
1245
|
-
single: true,
|
|
1246
|
-
readonly: voucherData.reBackType === 'shipment_free',
|
|
1247
|
-
})}`,
|
|
1248
|
-
gvc.bindView({
|
|
1249
|
-
bind: pageVM.countingID,
|
|
1250
|
-
view: () => {
|
|
1251
|
-
if (voucherData.method === 'percent' || voucherData.reBackType === 'shipment_free') {
|
|
1252
|
-
return '';
|
|
1253
|
-
}
|
|
1254
|
-
return html ` ${BgWidget.horizontalLine()}
|
|
1255
|
-
<div class="tx_700">重複觸發</div>
|
|
1256
|
-
${BgWidget.mbContainer(18)}
|
|
1257
|
-
${BgWidget.multiCheckboxContainer(gvc, [
|
|
1258
|
-
{
|
|
1259
|
-
key: 'single',
|
|
1260
|
-
name: '不重複',
|
|
1261
|
-
innerHtml: BgWidget.grayNote(`購買${ruleText(n)}折Y元,額外購買至${ruleText(n * 2)}或${ruleText(n * 3)}依然是折Y元`),
|
|
1262
|
-
},
|
|
1263
|
-
{
|
|
1264
|
-
key: 'each',
|
|
1265
|
-
name: '重複',
|
|
1266
|
-
innerHtml: BgWidget.grayNote(`購買${ruleText(n)}折Y元,購買${ruleText(n * 2)}則折Y * 2元,購買${ruleText(n * 3)}則折Y * 3元,以此類推`),
|
|
1267
|
-
},
|
|
1268
|
-
], [voucherData.counting], text => {
|
|
1269
|
-
voucherData.counting = text[0];
|
|
1270
|
-
gvc.notifyDataChange(pageVM.conditionID);
|
|
1271
|
-
}, {
|
|
1272
|
-
single: true,
|
|
1273
|
-
})}`;
|
|
1274
|
-
},
|
|
1275
|
-
}),
|
|
1276
|
-
gvc.bindView({
|
|
1277
|
-
bind: pageVM.productOffID,
|
|
1278
|
-
view: () => {
|
|
1279
|
-
if (!(voucherData.method === 'percent' &&
|
|
1280
|
-
voucherData.conditionType === 'order' &&
|
|
1281
|
-
voucherData.rule === 'min_count' &&
|
|
1282
|
-
voucherData.reBackType === 'discount')) {
|
|
1283
|
-
return '';
|
|
1284
|
-
}
|
|
1285
|
-
return html ` ${BgWidget.horizontalLine()}
|
|
1286
|
-
<div class="tx_700">打折範圍</div>
|
|
1287
|
-
${BgWidget.mbContainer(18)}
|
|
1288
|
-
${BgWidget.multiCheckboxContainer(gvc, [
|
|
1289
|
-
{
|
|
1290
|
-
key: 'price_desc',
|
|
1291
|
-
name: '從最高價的商品打折',
|
|
1292
|
-
innerHtml: BgWidget.grayNote(`購物車訂單將會從最高價且符合優惠的${ruleText(n)}商品進行打折`),
|
|
1293
|
-
},
|
|
1294
|
-
{
|
|
1295
|
-
key: 'price_asc',
|
|
1296
|
-
name: '從最低價的商品打折',
|
|
1297
|
-
innerHtml: BgWidget.grayNote(`購物車訂單將會從最低價且符合優惠的${ruleText(n)}商品進行打折`),
|
|
1298
|
-
},
|
|
1299
|
-
{
|
|
1300
|
-
key: 'price_all',
|
|
1301
|
-
name: '符合優惠的商品全部打折',
|
|
1302
|
-
innerHtml: BgWidget.grayNote(`購物車訂單符合優惠的商品進行打折`),
|
|
1303
|
-
},
|
|
1304
|
-
], [voucherData.productOffStart], text => {
|
|
1305
|
-
voucherData.productOffStart = text[0];
|
|
1306
|
-
gvc.notifyDataChange(pageVM.productOffID);
|
|
1307
|
-
}, {
|
|
1308
|
-
single: true,
|
|
1309
|
-
})}`;
|
|
1310
|
-
},
|
|
1311
|
-
}),
|
|
1312
|
-
].join('');
|
|
1313
|
-
},
|
|
1314
|
-
};
|
|
1315
|
-
})),
|
|
1316
|
-
BgWidget.mainCard(gvc.bindView(() => {
|
|
1317
|
-
const id = glitter.getUUID();
|
|
1318
|
-
return {
|
|
1319
|
-
bind: id,
|
|
1320
|
-
view: () => {
|
|
1321
|
-
function overlay() {
|
|
1322
|
-
return html ` <div class="tx_700">是否與其他優惠券疊加使用</div>
|
|
1323
|
-
${BgWidget.mbContainer(18)}
|
|
1324
|
-
${BgWidget.multiCheckboxContainer(gvc, [
|
|
1325
|
-
{
|
|
1326
|
-
key: 'false',
|
|
1327
|
-
name: '不可疊加',
|
|
1328
|
-
innerHtml: BgWidget.grayNote('系統將以最大優惠排序進行判定'),
|
|
1329
|
-
},
|
|
1330
|
-
{
|
|
1331
|
-
key: 'true',
|
|
1332
|
-
name: '可以疊加',
|
|
1333
|
-
},
|
|
1334
|
-
], [voucherData.overlay ? 'true' : 'false'], text => {
|
|
1335
|
-
voucherData.overlay = text[0] === 'true';
|
|
1336
|
-
gvc.notifyDataChange(id);
|
|
1337
|
-
}, { single: true })}`;
|
|
1338
|
-
}
|
|
1339
|
-
function isIncludeDiscount() {
|
|
1340
|
-
return html ` <div class="tx_700">消費金額於其他折扣觸發時機</div>
|
|
1341
|
-
${BgWidget.mbContainer(18)}
|
|
1342
|
-
${BgWidget.multiCheckboxContainer(gvc, [
|
|
1343
|
-
{
|
|
1344
|
-
key: 'before',
|
|
1345
|
-
name: '觸發前',
|
|
1346
|
-
innerHtml: BgWidget.grayNote('在其他折扣觸發前,訂單的消費金額將做為達成消費條件的金額,來判斷是否可使用此優惠券'),
|
|
1347
|
-
},
|
|
1348
|
-
{
|
|
1349
|
-
key: 'after',
|
|
1350
|
-
name: '觸發後',
|
|
1351
|
-
innerHtml: BgWidget.grayNote('將訂單的消費金額包含其他折扣後,做為達成消費條件的金額,來判斷是否可使用此優惠券'),
|
|
1352
|
-
},
|
|
1353
|
-
], [voucherData.includeDiscount], text => {
|
|
1354
|
-
voucherData.includeDiscount = text[0];
|
|
1355
|
-
gvc.notifyDataChange(pageVM.conditionID);
|
|
1356
|
-
}, {
|
|
1357
|
-
single: true,
|
|
1358
|
-
})}`;
|
|
1359
|
-
}
|
|
1360
|
-
return [overlay(), voucherData.overlay ? isIncludeDiscount() : '']
|
|
1361
|
-
.filter(Boolean)
|
|
1362
|
-
.join(BgWidget.horizontalLine());
|
|
1363
|
-
},
|
|
1364
|
-
};
|
|
1365
|
-
})),
|
|
1366
|
-
BgWidget.mainCard(gvc.bindView(() => {
|
|
1367
|
-
const id = glitter.getUUID();
|
|
1368
|
-
const inputStyle = 'display: block; width: 200px;';
|
|
1369
|
-
return {
|
|
1370
|
-
bind: id,
|
|
1371
|
-
view: () => {
|
|
1372
|
-
function storeUseTimeLimit() {
|
|
1373
|
-
var _b;
|
|
1374
|
-
return html ` <div class="tx_700">全館總使用次數</div>
|
|
1375
|
-
${BgWidget.mbContainer(18)}
|
|
1376
|
-
${BgWidget.multiCheckboxContainer(gvc, [
|
|
1377
|
-
{
|
|
1378
|
-
key: 'noLimited',
|
|
1379
|
-
name: '無限制',
|
|
1380
|
-
},
|
|
1381
|
-
{
|
|
1382
|
-
key: 'hasLimited',
|
|
1383
|
-
name: '限制次數',
|
|
1384
|
-
innerHtml: html ` <div class="d-flex align-items-center">
|
|
1385
|
-
<span class="tx_normal me-2">可使用次數</span>
|
|
1386
|
-
${BgWidget.editeInput({
|
|
1387
|
-
gvc: gvc,
|
|
1388
|
-
title: '',
|
|
1389
|
-
type: 'number',
|
|
1390
|
-
divStyle: 'width: 150px;',
|
|
1391
|
-
default: `${(_b = voucherData.macroLimited) !== null && _b !== void 0 ? _b : 0}`,
|
|
1392
|
-
placeHolder: '',
|
|
1393
|
-
callback: text => {
|
|
1394
|
-
voucherData.macroLimited = parseInt(text, 10);
|
|
1395
|
-
},
|
|
1396
|
-
endText: '次',
|
|
1397
|
-
})}
|
|
1398
|
-
</div>`,
|
|
1399
|
-
},
|
|
1400
|
-
], [voucherData.macroLimited === 0 ? 'noLimited' : 'hasLimited'], text => {
|
|
1401
|
-
if (text[0] === 'noLimited') {
|
|
1402
|
-
voucherData.macroLimited = 0;
|
|
1403
|
-
}
|
|
1404
|
-
}, { single: true })}`;
|
|
1405
|
-
}
|
|
1406
|
-
function memberUseTimeLimit() {
|
|
1407
|
-
var _b;
|
|
1408
|
-
return html ` <div class="tx_700">個人總使用次數</div>
|
|
1409
|
-
${BgWidget.mbContainer(18)}
|
|
1410
|
-
${BgWidget.multiCheckboxContainer(gvc, [
|
|
1411
|
-
{
|
|
1412
|
-
key: 'noLimited',
|
|
1413
|
-
name: '無限制',
|
|
1414
|
-
},
|
|
1415
|
-
{
|
|
1416
|
-
key: 'hasLimited',
|
|
1417
|
-
name: '限制次數',
|
|
1418
|
-
innerHtml: html ` <div class="d-flex align-items-center">
|
|
1419
|
-
<span class="tx_normal me-2">可使用次數</span>
|
|
1420
|
-
${BgWidget.editeInput({
|
|
1421
|
-
gvc: gvc,
|
|
1422
|
-
title: '',
|
|
1423
|
-
type: 'number',
|
|
1424
|
-
divStyle: 'width: 150px;',
|
|
1425
|
-
default: `${(_b = voucherData.microLimited) !== null && _b !== void 0 ? _b : 0}`,
|
|
1426
|
-
placeHolder: '',
|
|
1427
|
-
callback: text => {
|
|
1428
|
-
voucherData.microLimited = parseInt(text, 10);
|
|
1429
|
-
},
|
|
1430
|
-
endText: '次',
|
|
1431
|
-
})}
|
|
1432
|
-
</div>`,
|
|
1433
|
-
},
|
|
1434
|
-
], [voucherData.microLimited === 0 ? 'noLimited' : 'hasLimited'], text => {
|
|
1435
|
-
if (text[0] === 'noLimited') {
|
|
1436
|
-
voucherData.microLimited = 0;
|
|
1437
|
-
}
|
|
1438
|
-
}, { single: true })}`;
|
|
1439
|
-
}
|
|
1440
|
-
function startDateTime() {
|
|
1441
|
-
return html ` <div class="tx_700">優惠券有效日期</div>
|
|
1442
|
-
<div
|
|
1443
|
-
class="d-flex mb-3 ${document.body.clientWidth < 768 ? 'flex-column' : ''}"
|
|
1444
|
-
style="gap: 12px"
|
|
1445
|
-
>
|
|
1446
|
-
<div class="d-flex align-items-center">
|
|
1447
|
-
<span class="tx_normal me-2">開始日期</span>
|
|
1448
|
-
${BgWidget.editeInput({
|
|
1449
|
-
gvc: gvc,
|
|
1450
|
-
title: '',
|
|
1451
|
-
type: 'date',
|
|
1452
|
-
style: inputStyle,
|
|
1453
|
-
default: `${voucherData.startDate}`,
|
|
1454
|
-
placeHolder: '',
|
|
1455
|
-
callback: text => {
|
|
1456
|
-
voucherData.startDate = text;
|
|
1457
|
-
},
|
|
1458
|
-
})}
|
|
1459
|
-
</div>
|
|
1460
|
-
<div class="d-flex align-items-center">
|
|
1461
|
-
<span class="tx_normal me-2">開始時間</span>
|
|
1462
|
-
${BgWidget.editeInput({
|
|
1463
|
-
gvc: gvc,
|
|
1464
|
-
title: '',
|
|
1465
|
-
type: 'time',
|
|
1466
|
-
style: inputStyle,
|
|
1467
|
-
default: `${voucherData.startTime}`,
|
|
1468
|
-
placeHolder: '',
|
|
1469
|
-
callback: text => {
|
|
1470
|
-
voucherData.startTime = text;
|
|
1471
|
-
},
|
|
1472
|
-
})}
|
|
1473
|
-
</div>
|
|
1474
|
-
</div>
|
|
1475
|
-
${BgWidget.multiCheckboxContainer(gvc, [
|
|
1476
|
-
{
|
|
1477
|
-
key: 'noEnd',
|
|
1478
|
-
name: '無期限',
|
|
1479
|
-
},
|
|
1480
|
-
{
|
|
1481
|
-
key: 'withEnd',
|
|
1482
|
-
name: '有效期限',
|
|
1483
|
-
innerHtml: html ` <div
|
|
1484
|
-
class="d-flex mt-0 mt-md-3 ${document.body.clientWidth < 768
|
|
1485
|
-
? 'flex-column'
|
|
1486
|
-
: ''}"
|
|
1487
|
-
style="gap: 12px"
|
|
1488
|
-
>
|
|
1489
|
-
<div class="d-flex align-items-center">
|
|
1490
|
-
<span class="tx_normal me-2">結束日期</span>
|
|
1491
|
-
${BgWidget.editeInput({
|
|
1492
|
-
gvc: gvc,
|
|
1493
|
-
title: '',
|
|
1494
|
-
type: 'date',
|
|
1495
|
-
style: inputStyle,
|
|
1496
|
-
default: `${voucherData.endDate}`,
|
|
1497
|
-
placeHolder: '',
|
|
1498
|
-
callback: text => {
|
|
1499
|
-
voucherData.endDate = text;
|
|
1500
|
-
},
|
|
1501
|
-
})}
|
|
1502
|
-
</div>
|
|
1503
|
-
<div class="d-flex align-items-center">
|
|
1504
|
-
<span class="tx_normal me-2">結束時間</span>
|
|
1505
|
-
${BgWidget.editeInput({
|
|
1506
|
-
gvc: gvc,
|
|
1507
|
-
title: '',
|
|
1508
|
-
type: 'time',
|
|
1509
|
-
style: inputStyle,
|
|
1510
|
-
default: `${voucherData.endTime}`,
|
|
1511
|
-
placeHolder: '',
|
|
1512
|
-
callback: text => {
|
|
1513
|
-
voucherData.endTime = text;
|
|
1514
|
-
},
|
|
1515
|
-
})}
|
|
1516
|
-
</div>
|
|
1517
|
-
</div>`,
|
|
1518
|
-
},
|
|
1519
|
-
], [voucherData.endDate ? `withEnd` : `noEnd`], text => {
|
|
1520
|
-
if (text[0] === 'noEnd') {
|
|
1521
|
-
voucherData.endDate = undefined;
|
|
1522
|
-
voucherData.endTime = undefined;
|
|
1523
|
-
}
|
|
1524
|
-
}, { single: true })}`;
|
|
1525
|
-
}
|
|
1526
|
-
function rebateEndDay() {
|
|
1527
|
-
var _b, _c;
|
|
1528
|
-
return [
|
|
1529
|
-
html ` <div class="tx_700">購物金有效天數</div>`,
|
|
1530
|
-
BgWidget.multiCheckboxContainer(gvc, [
|
|
1531
|
-
{
|
|
1532
|
-
key: 'noEnd',
|
|
1533
|
-
name: '無期限',
|
|
1534
|
-
},
|
|
1535
|
-
{
|
|
1536
|
-
key: 'withEnd',
|
|
1537
|
-
name: '有效期限',
|
|
1538
|
-
innerHtml: html ` <div
|
|
1539
|
-
class="d-flex mt-0 mt-md-3 ${document.body.clientWidth < 768
|
|
1540
|
-
? 'flex-column'
|
|
1541
|
-
: ''}"
|
|
1542
|
-
style="gap: 12px"
|
|
1543
|
-
>
|
|
1544
|
-
<div class="d-flex align-items-center" style="gap:10px;">
|
|
1545
|
-
${BgWidget.editeInput({
|
|
1546
|
-
gvc: gvc,
|
|
1547
|
-
title: '',
|
|
1548
|
-
type: 'number',
|
|
1549
|
-
style: inputStyle,
|
|
1550
|
-
default: `${(_b = voucherData.rebateEndDay) !== null && _b !== void 0 ? _b : ''}`,
|
|
1551
|
-
placeHolder: '0則為無期限',
|
|
1552
|
-
callback: text => {
|
|
1553
|
-
voucherData.rebateEndDay = text;
|
|
1554
|
-
gvc.notifyDataChange(id);
|
|
1555
|
-
},
|
|
1556
|
-
})}
|
|
1557
|
-
<span class="tx_normal me-2">天</span>
|
|
1558
|
-
</div>
|
|
1559
|
-
</div>`,
|
|
1560
|
-
},
|
|
1561
|
-
], [parseInt((_c = voucherData.rebateEndDay) !== null && _c !== void 0 ? _c : '0', 10) ? `withEnd` : `noEnd`], text => {
|
|
1562
|
-
if (text[0] === 'noEnd') {
|
|
1563
|
-
voucherData.rebateEndDay = '0';
|
|
1564
|
-
}
|
|
1565
|
-
}, { single: true }),
|
|
1566
|
-
].join(html ` <div class="my-2"></div>`);
|
|
1567
|
-
}
|
|
1568
|
-
return [
|
|
1569
|
-
storeUseTimeLimit(),
|
|
1570
|
-
memberUseTimeLimit(),
|
|
1571
|
-
voucherData.reBackType === 'rebate' ? rebateEndDay() : '',
|
|
1572
|
-
startDateTime(),
|
|
1573
|
-
]
|
|
1574
|
-
.filter(Boolean)
|
|
1575
|
-
.join(BgWidget.horizontalLine());
|
|
1576
|
-
},
|
|
1577
|
-
};
|
|
1578
|
-
})),
|
|
1579
|
-
]
|
|
1580
|
-
.filter(Boolean)
|
|
1581
|
-
.join(BgWidget.mbContainer(24)),
|
|
1582
|
-
ratio: 68,
|
|
1583
|
-
}, {
|
|
1584
|
-
html: gvc.bindView(() => {
|
|
1585
|
-
const id = gvc.glitter.getUUID();
|
|
1586
|
-
return {
|
|
1587
|
-
bind: id,
|
|
1588
|
-
dataList: Object.keys(voucherData).map(key => {
|
|
1589
|
-
return { obj: voucherData, key };
|
|
1590
|
-
}),
|
|
1591
|
-
view: () => {
|
|
1592
|
-
return BgWidget.mainCard(html `
|
|
1593
|
-
<div class="tx_700">摘要</div>
|
|
1594
|
-
${BgWidget.mbContainer(18)}
|
|
1595
|
-
<div style="display: flex; gap: 12px; flex-direction: column;">
|
|
1596
|
-
${summaryTextList()
|
|
1597
|
-
.map(text => {
|
|
1598
|
-
return html ` <div class="${text.length > 0 ? 'tx_normal' : 'gray-top-bottom-line-6'}">
|
|
1599
|
-
${text}
|
|
1600
|
-
</div>`;
|
|
1601
|
-
})
|
|
1602
|
-
.join('')}
|
|
1603
|
-
</div>
|
|
1604
|
-
`);
|
|
1605
|
-
},
|
|
1606
|
-
divCreate: {
|
|
1607
|
-
class: 'summary-card p-0',
|
|
1608
|
-
},
|
|
1609
|
-
};
|
|
1610
|
-
}),
|
|
1611
|
-
ratio: 32,
|
|
1612
|
-
}),
|
|
1613
|
-
BgWidget.mbContainer(240),
|
|
1614
|
-
html ` <div class="update-bar-container">
|
|
1615
|
-
${obj.type === 'replace'
|
|
1616
|
-
? BgWidget.cancel(gvc.event(() => {
|
|
1617
|
-
const dialog = new ShareDialog(obj.gvc.glitter);
|
|
1618
|
-
dialog.checkYesOrNot({
|
|
1619
|
-
text: '是否確認刪除優惠券?',
|
|
1620
|
-
callback: response => {
|
|
1621
|
-
if (response) {
|
|
1622
|
-
dialog.dataLoading({ visible: true });
|
|
1623
|
-
ApiShop.deleteVoucher({
|
|
1624
|
-
id: voucherData.id,
|
|
1625
|
-
}).then(res => {
|
|
1626
|
-
dialog.dataLoading({ visible: false });
|
|
1627
|
-
if (res.result) {
|
|
1628
|
-
vm.type = 'list';
|
|
1629
|
-
}
|
|
1630
|
-
else {
|
|
1631
|
-
dialog.errorMessage({ text: '刪除失敗' });
|
|
1632
|
-
}
|
|
1633
|
-
});
|
|
1634
|
-
}
|
|
1635
|
-
},
|
|
1636
|
-
});
|
|
1637
|
-
}), '刪除優惠券')
|
|
1638
|
-
: ''}
|
|
1639
|
-
${BgWidget.cancel(gvc.event(() => {
|
|
1640
|
-
vm.type = 'list';
|
|
1641
|
-
}))}
|
|
1642
|
-
${BgWidget.save(gvc.event(() => {
|
|
1643
|
-
voucherData.start_ISO_Date = '';
|
|
1644
|
-
voucherData.end_ISO_Date = '';
|
|
1645
|
-
glitter.ut.tryMethod([
|
|
1646
|
-
() => {
|
|
1647
|
-
voucherData.start_ISO_Date = new Date(`${voucherData.startDate} ${voucherData.startTime}`).toISOString();
|
|
1648
|
-
},
|
|
1649
|
-
() => {
|
|
1650
|
-
voucherData.end_ISO_Date = new Date(`${voucherData.endDate} ${voucherData.endTime}`).toISOString();
|
|
1651
|
-
},
|
|
1652
|
-
]);
|
|
1653
|
-
if (obj.type === 'replace') {
|
|
1654
|
-
dialog.dataLoading({ text: '正在更新優惠券', visible: true });
|
|
1655
|
-
ApiShop.putVoucher({
|
|
1656
|
-
postData: voucherData,
|
|
1657
|
-
token: window.parent.saasConfig.config.token,
|
|
1658
|
-
type: 'manager',
|
|
1659
|
-
}).then(re => {
|
|
1660
|
-
dialog.dataLoading({ visible: false });
|
|
1661
|
-
if (re.result) {
|
|
1662
|
-
vm.type = 'list';
|
|
1663
|
-
dialog.successMessage({ text: '上傳成功' });
|
|
1664
|
-
}
|
|
1665
|
-
else {
|
|
1666
|
-
dialog.errorMessage({ text: '上傳失敗' });
|
|
1667
|
-
}
|
|
1668
|
-
});
|
|
1669
|
-
}
|
|
1670
|
-
else {
|
|
1671
|
-
dialog.dataLoading({ text: '正在新增優惠券', visible: true });
|
|
1672
|
-
ApiShop.postVoucher({
|
|
1673
|
-
postData: voucherData,
|
|
1674
|
-
token: window.parent.saasConfig.config.token,
|
|
1675
|
-
type: 'manager',
|
|
1676
|
-
}).then(re => {
|
|
1677
|
-
dialog.dataLoading({ visible: false });
|
|
1678
|
-
if (re.result) {
|
|
1679
|
-
vm.type = 'list';
|
|
1680
|
-
dialog.successMessage({ text: `上傳成功` });
|
|
1681
|
-
}
|
|
1682
|
-
else {
|
|
1683
|
-
dialog.errorMessage({ text: `上傳失敗` });
|
|
1684
|
-
}
|
|
1685
|
-
});
|
|
1686
|
-
}
|
|
1687
|
-
}))}
|
|
1688
|
-
</div>`,
|
|
1689
|
-
].join(BgWidget.mbContainer(24)));
|
|
1690
|
-
},
|
|
1691
|
-
};
|
|
1692
|
-
});
|
|
1693
|
-
}
|
|
1694
261
|
static voucherEditorV2(obj) {
|
|
1695
262
|
const gvc = obj.gvc;
|
|
1696
263
|
const vm = obj.vm;
|
|
@@ -1702,7 +269,13 @@ export class ShoppingDiscountSetting {
|
|
|
1702
269
|
};
|
|
1703
270
|
const voucherData = Object.assign(Object.assign({}, this.emptyVoucher(obj.reBackType)), vm.data);
|
|
1704
271
|
const cloneForKey = (key) => JSON.parse(JSON.stringify(key));
|
|
1705
|
-
const setTitle = (title) =>
|
|
272
|
+
const setTitle = (title, button) => {
|
|
273
|
+
return html `<div class="title-container">
|
|
274
|
+
<div class="tx_700">${title}</div>
|
|
275
|
+
<div class="flex-fill"></div>
|
|
276
|
+
${button !== null && button !== void 0 ? button : ''}
|
|
277
|
+
</div>`;
|
|
278
|
+
};
|
|
1706
279
|
const voucherSettingCard = (array) => BgWidget.mainCard(array
|
|
1707
280
|
.map(stringArray => stringArray.filter(Boolean))
|
|
1708
281
|
.filter(stringArray => stringArray.length > 0)
|
|
@@ -1742,7 +315,7 @@ export class ShoppingDiscountSetting {
|
|
|
1742
315
|
</div>`;
|
|
1743
316
|
}
|
|
1744
317
|
function title() {
|
|
1745
|
-
return html ` <div class="tx_normal"
|
|
318
|
+
return html ` <div class="tx_normal">活動標題${BgWidget.requiredStar()}</div>
|
|
1746
319
|
${BgWidget.mbContainer(8)}
|
|
1747
320
|
${BgWidget.editeInput({
|
|
1748
321
|
gvc: gvc,
|
|
@@ -2062,6 +635,10 @@ export class ShoppingDiscountSetting {
|
|
|
2062
635
|
}
|
|
2063
636
|
function device() {
|
|
2064
637
|
var _b;
|
|
638
|
+
if (voucherData.trigger === 'distribution') {
|
|
639
|
+
voucherData.device = ['normal'];
|
|
640
|
+
return '';
|
|
641
|
+
}
|
|
2065
642
|
return BgWidget.multiCheckboxContainer(gvc, [
|
|
2066
643
|
{ key: 'normal', name: '官網 & APP 訂單' },
|
|
2067
644
|
{ key: 'pos', name: 'POS 訂單' },
|
|
@@ -2116,7 +693,8 @@ export class ShoppingDiscountSetting {
|
|
|
2116
693
|
}
|
|
2117
694
|
function setVoucherFor() {
|
|
2118
695
|
var _b;
|
|
2119
|
-
let view = [
|
|
696
|
+
let view = [
|
|
697
|
+
EditorElem.radio({
|
|
2120
698
|
gvc: gvc,
|
|
2121
699
|
title: '',
|
|
2122
700
|
def: (_b = voucherData.for) !== null && _b !== void 0 ? _b : 'all',
|
|
@@ -2127,7 +705,8 @@ export class ShoppingDiscountSetting {
|
|
|
2127
705
|
gvc.notifyDataChange(pageVM.viewID);
|
|
2128
706
|
},
|
|
2129
707
|
oneLine: true,
|
|
2130
|
-
})
|
|
708
|
+
}),
|
|
709
|
+
];
|
|
2131
710
|
if (['add_on_items', 'giveaway', 'shipment_free'].includes(voucherData.reBackType)) {
|
|
2132
711
|
view.push(`<div class="mx-n2">${selectProduct()}</div>`);
|
|
2133
712
|
}
|
|
@@ -2655,19 +1234,20 @@ export class ShoppingDiscountSetting {
|
|
|
2655
1234
|
});
|
|
2656
1235
|
}
|
|
2657
1236
|
function isIncludeDiscount() {
|
|
2658
|
-
if (!voucherData.overlay) {
|
|
1237
|
+
if (!voucherData.overlay || voucherData.rule === 'min_count') {
|
|
1238
|
+
voucherData.includeDiscount = 'before';
|
|
2659
1239
|
return '';
|
|
2660
1240
|
}
|
|
2661
1241
|
return BgWidget.multiCheckboxContainer(gvc, [
|
|
2662
1242
|
{
|
|
2663
1243
|
key: 'before',
|
|
2664
|
-
name: '
|
|
2665
|
-
innerHtml: BgWidget.grayNote('
|
|
1244
|
+
name: '折扣前金額',
|
|
1245
|
+
innerHtml: BgWidget.grayNote('以未套用其他優惠前的商品原始金額,來判斷是否達成此優惠券的使用門檻'),
|
|
2666
1246
|
},
|
|
2667
1247
|
{
|
|
2668
1248
|
key: 'after',
|
|
2669
|
-
name: '
|
|
2670
|
-
innerHtml: BgWidget.grayNote('
|
|
1249
|
+
name: '折扣後金額',
|
|
1250
|
+
innerHtml: BgWidget.grayNote('使用已套用其他優惠後的實際結帳,來判斷是否達成此優惠券的使用門檻'),
|
|
2671
1251
|
},
|
|
2672
1252
|
], [voucherData.includeDiscount], text => {
|
|
2673
1253
|
voucherData.includeDiscount = text[0];
|
|
@@ -2684,12 +1264,12 @@ export class ShoppingDiscountSetting {
|
|
|
2684
1264
|
{
|
|
2685
1265
|
key: 'single',
|
|
2686
1266
|
name: '不重複',
|
|
2687
|
-
innerHtml: BgWidget.grayNote(
|
|
1267
|
+
innerHtml: BgWidget.grayNote(`購買 ${ruleText(ruleValue)}折 Y 元,額外購買至 ${ruleText(ruleValue * 2)}或 ${ruleText(ruleValue * 3)}依然是折 Y 元`),
|
|
2688
1268
|
},
|
|
2689
1269
|
{
|
|
2690
1270
|
key: 'each',
|
|
2691
1271
|
name: '重複',
|
|
2692
|
-
innerHtml: BgWidget.grayNote(
|
|
1272
|
+
innerHtml: BgWidget.grayNote(`購買 ${ruleText(ruleValue)}折 Y 元,購買 ${ruleText(ruleValue * 2)}則折 Y * 2 元,購買 ${ruleText(ruleValue * 3)}則折 Y * 3 元,以此類推`),
|
|
2693
1273
|
},
|
|
2694
1274
|
], [voucherData.counting], text => {
|
|
2695
1275
|
voucherData.counting = text[0];
|
|
@@ -2707,13 +1287,13 @@ export class ShoppingDiscountSetting {
|
|
|
2707
1287
|
if (voucherData.reBackType === 'shipment_free') {
|
|
2708
1288
|
return '優惠條件為整份訂單免運費';
|
|
2709
1289
|
}
|
|
2710
|
-
return `若商品A
|
|
1290
|
+
return `若商品 A 購買 ${ruleText(floor)} + 商品 B 購買 ${ruleText(ruleValue - floor)},可觸發優惠`;
|
|
2711
1291
|
})()),
|
|
2712
1292
|
},
|
|
2713
1293
|
{
|
|
2714
1294
|
key: 'item',
|
|
2715
1295
|
name: '以商品計算',
|
|
2716
|
-
innerHtml: BgWidget.grayNote(
|
|
1296
|
+
innerHtml: BgWidget.grayNote(`商品 A 及 商品 B 需各滿 ${ruleText(ruleValue)},才可觸發優惠`),
|
|
2717
1297
|
},
|
|
2718
1298
|
], [voucherData.conditionType], text => {
|
|
2719
1299
|
voucherData.conditionType = text[0];
|
|
@@ -2778,7 +1358,7 @@ export class ShoppingDiscountSetting {
|
|
|
2778
1358
|
}, { single: true });
|
|
2779
1359
|
}
|
|
2780
1360
|
function ruleText(sum) {
|
|
2781
|
-
return `${sum}${voucherData.rule === 'min_count' ? '個' : '元'}`;
|
|
1361
|
+
return `${sum} ${voucherData.rule === 'min_count' ? '個' : '元'}`;
|
|
2782
1362
|
}
|
|
2783
1363
|
function valueInput(obj) {
|
|
2784
1364
|
return BgWidget.editeInput({
|
|
@@ -2802,6 +1382,181 @@ export class ShoppingDiscountSetting {
|
|
|
2802
1382
|
endText: obj.endText,
|
|
2803
1383
|
});
|
|
2804
1384
|
}
|
|
1385
|
+
function applyShop() {
|
|
1386
|
+
if (voucherData.trigger !== 'distribution') {
|
|
1387
|
+
return '';
|
|
1388
|
+
}
|
|
1389
|
+
const prefix = Tool.randomString(6);
|
|
1390
|
+
const shopTypeRecord = {
|
|
1391
|
+
group: {
|
|
1392
|
+
icon: html `<i class="fa-regular fa-puzzle-piece ${prefix}_icon"></i>`,
|
|
1393
|
+
title: '拼團賣場',
|
|
1394
|
+
},
|
|
1395
|
+
recommend: {
|
|
1396
|
+
icon: html `<i class="fa-regular fa-share-nodes ${prefix}_icon"></i>`,
|
|
1397
|
+
title: '分銷連結',
|
|
1398
|
+
},
|
|
1399
|
+
hidden: {
|
|
1400
|
+
icon: html `<i class="fa-solid fa-face-dotted ${prefix}_icon"></i>`,
|
|
1401
|
+
title: '隱形賣場',
|
|
1402
|
+
},
|
|
1403
|
+
onepage: {
|
|
1404
|
+
icon: html `<i class="fa-regular fa-file ${prefix}_icon"></i>`,
|
|
1405
|
+
title: '一頁商店',
|
|
1406
|
+
},
|
|
1407
|
+
};
|
|
1408
|
+
gvc.addStyle(`
|
|
1409
|
+
.${prefix}_container {
|
|
1410
|
+
max-width: 800px;
|
|
1411
|
+
margin: 0 auto;
|
|
1412
|
+
background-color: #fff;
|
|
1413
|
+
border-radius: 8px;
|
|
1414
|
+
overflow: hidden;
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
.${prefix}_table {
|
|
1418
|
+
width: 100%;
|
|
1419
|
+
border-collapse: collapse;
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
.${prefix}_thead {
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
.${prefix}_th {
|
|
1426
|
+
padding: 8px 16px;
|
|
1427
|
+
text-align: left;
|
|
1428
|
+
font-size: 16px;
|
|
1429
|
+
font-weight: normal;
|
|
1430
|
+
text-transform: uppercase;
|
|
1431
|
+
letter-spacing: 0.05em;
|
|
1432
|
+
border-bottom: 1px solid #e5e7eb;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
.${prefix}_td {
|
|
1436
|
+
padding: 8px 16px;
|
|
1437
|
+
font-size: 16px;
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
.${prefix}_tr:hover {
|
|
1441
|
+
background-color: #f9fafb;
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
.${prefix}_type_cell {
|
|
1445
|
+
display: flex;
|
|
1446
|
+
align-items: center;
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
.${prefix}_icon {
|
|
1450
|
+
width: 16px;
|
|
1451
|
+
height: 16px;
|
|
1452
|
+
margin-right: 8px;
|
|
1453
|
+
text-align: center;
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
.${prefix}_empty_referrer {
|
|
1457
|
+
color: #9ca3af;
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
.${prefix}_expend {
|
|
1461
|
+
display: flex;
|
|
1462
|
+
height: 34px;
|
|
1463
|
+
padding: 6px 0px;
|
|
1464
|
+
justify-content: center;
|
|
1465
|
+
align-items: center;
|
|
1466
|
+
gap: 8px;
|
|
1467
|
+
border-radius: 10px;
|
|
1468
|
+
border: 1px solid #ddd;
|
|
1469
|
+
background: #fff;
|
|
1470
|
+
margin-top: 18px;
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
.${prefix}_expend:hover {
|
|
1474
|
+
background-color: #f9fafb;
|
|
1475
|
+
}
|
|
1476
|
+
`);
|
|
1477
|
+
return gvc.bindView({
|
|
1478
|
+
bind: 'idnnn',
|
|
1479
|
+
view: () => {
|
|
1480
|
+
return html `<div class="${prefix}_container">
|
|
1481
|
+
<table id="beauty-salon-table" class="${prefix}_table">
|
|
1482
|
+
<thead class="${prefix}_thead">
|
|
1483
|
+
<tr class="${prefix}_tr">
|
|
1484
|
+
<th class="${prefix}_th">賣場類型</th>
|
|
1485
|
+
<th class="${prefix}_th">賣場名稱</th>
|
|
1486
|
+
<th class="${prefix}_th">推薦人</th>
|
|
1487
|
+
</tr>
|
|
1488
|
+
</thead>
|
|
1489
|
+
<tbody>
|
|
1490
|
+
<!-- 資料將由 JavaScript 動態填入 -->
|
|
1491
|
+
</tbody>
|
|
1492
|
+
</table>
|
|
1493
|
+
<div id="beauty-salon-div">
|
|
1494
|
+
<!-- 資料將由 JavaScript 動態填入 -->
|
|
1495
|
+
</div>
|
|
1496
|
+
</div>`;
|
|
1497
|
+
},
|
|
1498
|
+
divCreate: {},
|
|
1499
|
+
onCreate: () => {
|
|
1500
|
+
const salons = [
|
|
1501
|
+
{
|
|
1502
|
+
type: 'group',
|
|
1503
|
+
name: 'SPA 梳毛刷現實揪團中!人越多越便宜!',
|
|
1504
|
+
referrer: '-',
|
|
1505
|
+
},
|
|
1506
|
+
{
|
|
1507
|
+
type: 'recommend',
|
|
1508
|
+
name: '與Sandy的貓跳台合作,給貓咪最好的跳台!',
|
|
1509
|
+
referrer: 'YT貓皇',
|
|
1510
|
+
},
|
|
1511
|
+
{
|
|
1512
|
+
type: 'hidden',
|
|
1513
|
+
name: '毛孩防寒任三件8折,一起溫暖過冬!',
|
|
1514
|
+
referrer: 'Sandy',
|
|
1515
|
+
},
|
|
1516
|
+
{
|
|
1517
|
+
type: 'onepage',
|
|
1518
|
+
name: '毛孩玩具聯名,買三件折扣8折!',
|
|
1519
|
+
referrer: '-',
|
|
1520
|
+
},
|
|
1521
|
+
];
|
|
1522
|
+
const tableBody = document.querySelector('#beauty-salon-table tbody');
|
|
1523
|
+
const tableDiv = document.querySelector('#beauty-salon-div');
|
|
1524
|
+
if (!tableBody || !tableDiv) {
|
|
1525
|
+
return;
|
|
1526
|
+
}
|
|
1527
|
+
salons.forEach(salon => {
|
|
1528
|
+
const data = shopTypeRecord[salon.type];
|
|
1529
|
+
const row = document.createElement('tr');
|
|
1530
|
+
row.className = `${prefix}_tr`;
|
|
1531
|
+
const typeCell = document.createElement('td');
|
|
1532
|
+
typeCell.className = `${prefix}_td ${prefix}_type_cell`;
|
|
1533
|
+
typeCell.innerHTML = `${data.icon} ${data.title}`;
|
|
1534
|
+
row.appendChild(typeCell);
|
|
1535
|
+
const nameCell = document.createElement('td');
|
|
1536
|
+
nameCell.className = `${prefix}_td`;
|
|
1537
|
+
nameCell.textContent = salon.name;
|
|
1538
|
+
row.appendChild(nameCell);
|
|
1539
|
+
const referrerCell = document.createElement('td');
|
|
1540
|
+
referrerCell.className = `${prefix}_td`;
|
|
1541
|
+
if (salon.referrer) {
|
|
1542
|
+
referrerCell.textContent = salon.referrer;
|
|
1543
|
+
}
|
|
1544
|
+
else {
|
|
1545
|
+
referrerCell.textContent = '-';
|
|
1546
|
+
referrerCell.classList.add(`${prefix}_empty_referrer`);
|
|
1547
|
+
}
|
|
1548
|
+
row.appendChild(referrerCell);
|
|
1549
|
+
tableBody.appendChild(row);
|
|
1550
|
+
});
|
|
1551
|
+
const expendMore = document.createElement('div');
|
|
1552
|
+
expendMore.className = `${prefix}_expend`;
|
|
1553
|
+
const moreText = html `<span>展開更多</span>`;
|
|
1554
|
+
const chevronDown = html `<i class="fa-solid fa-chevron-dow ms-1"></i>`;
|
|
1555
|
+
expendMore.innerHTML = `${moreText} ${chevronDown}`;
|
|
1556
|
+
tableDiv.appendChild(expendMore);
|
|
1557
|
+
},
|
|
1558
|
+
});
|
|
1559
|
+
}
|
|
2805
1560
|
const reBackProductView = {
|
|
2806
1561
|
rebate: { title: '活動商品', html: voucherData.for === 'all' ? '' : selectProduct() },
|
|
2807
1562
|
discount: { title: '活動商品', html: voucherData.for === 'all' ? '' : selectProduct() },
|
|
@@ -2809,6 +1564,14 @@ export class ShoppingDiscountSetting {
|
|
|
2809
1564
|
add_on_items: { title: '加購品項', html: [addProductView()].join('') },
|
|
2810
1565
|
giveaway: { title: '贈品品項', html: [addProductView()].join('') },
|
|
2811
1566
|
};
|
|
1567
|
+
const applyShopButton = BgWidget.customButton({
|
|
1568
|
+
button: { color: 'gray', size: 'md' },
|
|
1569
|
+
text: { name: '選擇賣場' },
|
|
1570
|
+
event: gvc.event(() => {
|
|
1571
|
+
const bgDialog = new BgDialog(gvc);
|
|
1572
|
+
bgDialog.marketShop();
|
|
1573
|
+
}),
|
|
1574
|
+
});
|
|
2812
1575
|
const viewList = [
|
|
2813
1576
|
[
|
|
2814
1577
|
{ title: '活動設定', html: [status(), title()] },
|
|
@@ -2830,7 +1593,7 @@ export class ShoppingDiscountSetting {
|
|
|
2830
1593
|
{ title: '打折範圍', html: offStart() },
|
|
2831
1594
|
{ title: '重複觸發', html: countingBoolean() },
|
|
2832
1595
|
{ title: '是否與其他優惠券疊加使用', html: overlay() },
|
|
2833
|
-
{ title: '
|
|
1596
|
+
{ title: '優惠門檻判斷依據', html: isIncludeDiscount() },
|
|
2834
1597
|
],
|
|
2835
1598
|
[
|
|
2836
1599
|
{ title: '全館總使用次數', html: storeUseTimeLimit() },
|
|
@@ -2851,15 +1614,18 @@ export class ShoppingDiscountSetting {
|
|
|
2851
1614
|
BgWidget.container1x2({
|
|
2852
1615
|
html: viewList
|
|
2853
1616
|
.map(viewData => {
|
|
1617
|
+
if (viewData.length === 0 || viewData.every(view => !view.html)) {
|
|
1618
|
+
return '';
|
|
1619
|
+
}
|
|
2854
1620
|
return voucherSettingCard(viewData.map(view => {
|
|
2855
1621
|
if (!view.html) {
|
|
2856
1622
|
return [];
|
|
2857
1623
|
}
|
|
2858
1624
|
else if (Array.isArray(view.html)) {
|
|
2859
|
-
return [setTitle(view.title), ...view.html];
|
|
1625
|
+
return [setTitle(view.title, view.button), ...view.html];
|
|
2860
1626
|
}
|
|
2861
1627
|
else {
|
|
2862
|
-
return [setTitle(view.title), view.html];
|
|
1628
|
+
return [setTitle(view.title, view.button), view.html];
|
|
2863
1629
|
}
|
|
2864
1630
|
}));
|
|
2865
1631
|
})
|
|
@@ -2957,6 +1723,12 @@ export class ShoppingDiscountSetting {
|
|
|
2957
1723
|
}
|
|
2958
1724
|
}
|
|
2959
1725
|
_a = ShoppingDiscountSetting;
|
|
1726
|
+
ShoppingDiscountSetting.productForList = [
|
|
1727
|
+
{ title: '所有商品', value: 'all' },
|
|
1728
|
+
{ title: '商品分類', value: 'collection' },
|
|
1729
|
+
{ title: '管理員標籤', value: 'manager_tag' },
|
|
1730
|
+
{ title: '特定商品', value: 'product' },
|
|
1731
|
+
];
|
|
2960
1732
|
ShoppingDiscountSetting.getDateTime = (n = 0) => {
|
|
2961
1733
|
const now = new Date();
|
|
2962
1734
|
now.setDate(now.getDate() + n);
|
|
@@ -2968,12 +1740,6 @@ ShoppingDiscountSetting.getDateTime = (n = 0) => {
|
|
|
2968
1740
|
const timeStr = `${hours}:00`;
|
|
2969
1741
|
return { date: dateStr, time: timeStr };
|
|
2970
1742
|
};
|
|
2971
|
-
ShoppingDiscountSetting.productForList = [
|
|
2972
|
-
{ title: '所有商品', value: 'all' },
|
|
2973
|
-
{ title: '商品分類', value: 'collection' },
|
|
2974
|
-
{ title: '管理員標籤', value: 'manager_tag' },
|
|
2975
|
-
{ title: '特定商品', value: 'product' },
|
|
2976
|
-
];
|
|
2977
1743
|
ShoppingDiscountSetting.emptyVoucher = (reBackType) => {
|
|
2978
1744
|
return {
|
|
2979
1745
|
title: '',
|