ts-glitter 21.3.0 → 21.3.3
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-customer-message.js +662 -566
- package/lowcode/backend-manager/bg-customer-message.ts +1740 -1580
- package/lowcode/cms-plugin/customer-message-user.ts +2 -0
- package/lowcode/cms-plugin/module/product-excel.js +169 -129
- package/lowcode/cms-plugin/module/product-excel.ts +174 -130
- package/lowcode/cms-plugin/shopping-discount-setting.js +640 -600
- package/lowcode/cms-plugin/shopping-discount-setting.ts +782 -716
- package/lowcode/cms-plugin/shopping-finance-setting.js +372 -407
- package/lowcode/cms-plugin/shopping-finance-setting.ts +918 -968
- package/lowcode/cms-plugin/shopping-setting-advance.js +1 -1
- package/lowcode/cms-plugin/shopping-setting-advance.ts +1 -1
- package/lowcode/glitter-base/global/language.js +12 -0
- package/lowcode/glitter-base/global/language.ts +12 -0
- package/lowcode/glitter-base/route/api-track.js +2 -2
- package/lowcode/glitter-base/route/api-track.ts +20 -20
- package/lowcode/public-components/checkout/index.js +27 -5
- package/lowcode/public-components/checkout/index.ts +34 -6
- package/lowcode/public-components/headers/header-class.js +13 -18
- package/lowcode/public-components/headers/header-class.ts +16 -20
- package/lowcode/public-components/modules/cart-module.js +6 -0
- package/lowcode/public-components/modules/cart-module.ts +6 -0
- package/lowcode/public-components/product/pd-class.js +1 -3
- package/lowcode/public-components/product/pd-class.ts +1 -3
- package/omr85cp878.json +1 -0
- package/package.json +1 -1
- package/src/api-public/services/checkout-event.js +26 -12
- package/src/api-public/services/checkout-event.js.map +1 -1
- package/src/api-public/services/checkout-event.ts +34 -12
- package/src/api-public/services/data-analyze.d.ts +1 -1
- package/src/api-public/services/post.js +7 -17
- package/src/api-public/services/post.js.map +1 -1
- package/src/api-public/services/shopee.js +7 -17
- package/src/api-public/services/shopee.js.map +1 -1
- package/src/api-public/services/shopping.d.ts +44 -27
- package/src/api-public/services/shopping.js +56 -11
- package/src/api-public/services/shopping.js.map +1 -1
- package/src/api-public/services/shopping.ts +125 -58
- package/src/index.js +7 -17
- package/src/index.js.map +1 -1
|
@@ -15,6 +15,8 @@ import { EditorElem } from '../glitterBundle/plugins/editor-elem.js';
|
|
|
15
15
|
import { ShareDialog } from '../glitterBundle/dialog/ShareDialog.js';
|
|
16
16
|
import { FilterOptions } from './filter-options.js';
|
|
17
17
|
import { Tool } from '../modules/tool.js';
|
|
18
|
+
import { ShipmentConfig } from '../glitter-base/global/shipment-config.js';
|
|
19
|
+
const html = String.raw;
|
|
18
20
|
export class ShoppingDiscountSetting {
|
|
19
21
|
static getLabel(voucher_type) {
|
|
20
22
|
var _a;
|
|
@@ -29,13 +31,13 @@ export class ShoppingDiscountSetting {
|
|
|
29
31
|
}
|
|
30
32
|
static main(gvc, voucher_type) {
|
|
31
33
|
const glitter = gvc.glitter;
|
|
34
|
+
const dialog = new ShareDialog(glitter);
|
|
32
35
|
const vm = {
|
|
33
36
|
type: 'list',
|
|
34
37
|
data: undefined,
|
|
35
38
|
dataList: undefined,
|
|
36
39
|
query: undefined,
|
|
37
40
|
};
|
|
38
|
-
const html = String.raw;
|
|
39
41
|
return gvc.bindView(() => {
|
|
40
42
|
const id = glitter.getUUID();
|
|
41
43
|
return {
|
|
@@ -127,7 +129,6 @@ export class ShoppingDiscountSetting {
|
|
|
127
129
|
{
|
|
128
130
|
name: '批量移除',
|
|
129
131
|
event: () => {
|
|
130
|
-
const dialog = new ShareDialog(gvc.glitter);
|
|
131
132
|
dialog.checkYesOrNot({
|
|
132
133
|
text: '是否確認刪除所選項目?',
|
|
133
134
|
callback: response => {
|
|
@@ -187,9 +188,15 @@ export class ShoppingDiscountSetting {
|
|
|
187
188
|
const gvc = obj.gvc;
|
|
188
189
|
const glitter = gvc.glitter;
|
|
189
190
|
const vm = obj.vm;
|
|
190
|
-
const
|
|
191
|
-
const
|
|
192
|
-
|
|
191
|
+
const dialog = new ShareDialog(glitter);
|
|
192
|
+
const pageVM = {
|
|
193
|
+
viewID: gvc.glitter.getUUID(),
|
|
194
|
+
conditionID: gvc.glitter.getUUID(),
|
|
195
|
+
countingID: gvc.glitter.getUUID(),
|
|
196
|
+
productOffID: gvc.glitter.getUUID(),
|
|
197
|
+
};
|
|
198
|
+
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);
|
|
199
|
+
function summaryTextList() {
|
|
193
200
|
var _a, _b;
|
|
194
201
|
return [
|
|
195
202
|
`活動標題:${voucherData.title && voucherData.title.length > 0 ? voucherData.title : '尚無標題'}`,
|
|
@@ -261,369 +268,515 @@ export class ShoppingDiscountSetting {
|
|
|
261
268
|
})()}`,
|
|
262
269
|
];
|
|
263
270
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
271
|
+
function title() {
|
|
272
|
+
return html ` <div class="tx_700">活動標題</div>
|
|
273
|
+
${BgWidget.mbContainer(18)}
|
|
274
|
+
${BgWidget.editeInput({
|
|
275
|
+
gvc: gvc,
|
|
276
|
+
title: '',
|
|
277
|
+
default: voucherData.title,
|
|
278
|
+
placeHolder: '請輸入活動標題',
|
|
279
|
+
callback: text => {
|
|
280
|
+
voucherData.title = text;
|
|
281
|
+
},
|
|
282
|
+
})}
|
|
283
|
+
${BgWidget.grayNote('顧客將會在「購物車」與「結帳」看見此標題', 'margin-left: 4px;')}`;
|
|
284
|
+
}
|
|
285
|
+
function status() {
|
|
286
|
+
return html ` <div class="tx_700">活動狀態</div>
|
|
287
|
+
${BgWidget.mbContainer(12)}
|
|
288
|
+
${BgWidget.switchTextButton(gvc, voucherData.status === 1, {
|
|
289
|
+
left: '關閉',
|
|
290
|
+
right: '啟用',
|
|
291
|
+
}, bool => {
|
|
292
|
+
voucherData.status = bool ? 1 : 0;
|
|
293
|
+
})}`;
|
|
294
|
+
}
|
|
295
|
+
function trigger() {
|
|
296
|
+
return html ` <div class="tx_700">活動方式</div>
|
|
297
|
+
${BgWidget.mbContainer(18)}
|
|
298
|
+
${BgWidget.multiCheckboxContainer(gvc, [
|
|
299
|
+
{
|
|
300
|
+
key: 'auto',
|
|
301
|
+
name: '自動折扣',
|
|
302
|
+
innerHtml: BgWidget.grayNote('顧客將在結帳時,自動獲得折扣'),
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
key: 'code',
|
|
306
|
+
name: '優惠代碼',
|
|
307
|
+
innerHtml: (() => {
|
|
308
|
+
const id = glitter.getUUID();
|
|
309
|
+
return gvc.bindView({
|
|
310
|
+
bind: id,
|
|
311
|
+
view: () => {
|
|
312
|
+
var _a;
|
|
313
|
+
return gvc.map([
|
|
314
|
+
BgWidget.grayNote('顧客可在結帳時輸入優惠代碼,來獲得折扣'),
|
|
315
|
+
BgWidget.editeInput({
|
|
290
316
|
gvc: gvc,
|
|
291
317
|
title: '',
|
|
292
|
-
default: voucherData.
|
|
293
|
-
placeHolder: '
|
|
318
|
+
default: (_a = voucherData.code) !== null && _a !== void 0 ? _a : '',
|
|
319
|
+
placeHolder: '請輸入優惠券代碼',
|
|
294
320
|
callback: text => {
|
|
295
|
-
voucherData.
|
|
296
|
-
},
|
|
297
|
-
})}
|
|
298
|
-
${BgWidget.grayNote('顧客將會在「購物車」與「結帳」看見此標題', 'margin-left: 4px;')}`,
|
|
299
|
-
html ` <div class="tx_700">活動狀態</div>
|
|
300
|
-
${BgWidget.mbContainer(12)}
|
|
301
|
-
${BgWidget.switchTextButton(gvc, voucherData.status === 1, {
|
|
302
|
-
left: '關閉',
|
|
303
|
-
right: '啟用',
|
|
304
|
-
}, bool => {
|
|
305
|
-
voucherData.status = bool ? 1 : 0;
|
|
306
|
-
})}`,
|
|
307
|
-
].join(BgWidget.horizontalLine())),
|
|
308
|
-
BgWidget.mainCard([
|
|
309
|
-
html ` <div class="tx_700">活動方式</div>
|
|
310
|
-
${BgWidget.mbContainer(18)}
|
|
311
|
-
${BgWidget.multiCheckboxContainer(gvc, [
|
|
312
|
-
{
|
|
313
|
-
key: 'auto',
|
|
314
|
-
name: '自動折扣',
|
|
315
|
-
innerHtml: BgWidget.grayNote('顧客將在結帳時,自動獲得折扣'),
|
|
316
|
-
},
|
|
317
|
-
{
|
|
318
|
-
key: 'code',
|
|
319
|
-
name: '優惠代碼',
|
|
320
|
-
innerHtml: (() => {
|
|
321
|
-
const id = glitter.getUUID();
|
|
322
|
-
return gvc.bindView({
|
|
323
|
-
bind: id,
|
|
324
|
-
view: () => {
|
|
325
|
-
var _a;
|
|
326
|
-
return gvc.map([
|
|
327
|
-
BgWidget.grayNote('顧客可在結帳時輸入優惠代碼,來獲得折扣'),
|
|
328
|
-
BgWidget.editeInput({
|
|
329
|
-
gvc: gvc,
|
|
330
|
-
title: '',
|
|
331
|
-
default: (_a = voucherData.code) !== null && _a !== void 0 ? _a : '',
|
|
332
|
-
placeHolder: '請輸入優惠券代碼',
|
|
333
|
-
callback: text => {
|
|
334
|
-
voucherData.code = text.toUpperCase();
|
|
335
|
-
},
|
|
336
|
-
endText: html ` <div class="d-flex justify-content-end">
|
|
337
|
-
${BgWidget.mbContainer(8)}
|
|
338
|
-
${BgWidget.blueNote(document.body.clientWidth > 768 ? '隨機產生優惠代碼' : '隨機產生', gvc.event(() => {
|
|
339
|
-
voucherData.code = Tool.randomString(6).toUpperCase();
|
|
340
|
-
gvc.notifyDataChange(id);
|
|
341
|
-
}))}
|
|
342
|
-
</div>`,
|
|
343
|
-
}),
|
|
344
|
-
]);
|
|
345
|
-
},
|
|
346
|
-
});
|
|
347
|
-
})(),
|
|
321
|
+
voucherData.code = text.toUpperCase();
|
|
348
322
|
},
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
323
|
+
endText: html ` <div class="d-flex justify-content-end">
|
|
324
|
+
${BgWidget.mbContainer(8)}
|
|
325
|
+
${BgWidget.blueNote(document.body.clientWidth > 768 ? '隨機產生優惠代碼' : '隨機產生', gvc.event(() => {
|
|
326
|
+
voucherData.code = Tool.randomString(6).toUpperCase();
|
|
327
|
+
gvc.notifyDataChange(id);
|
|
328
|
+
}))}
|
|
329
|
+
</div>`,
|
|
330
|
+
}),
|
|
331
|
+
]);
|
|
332
|
+
},
|
|
333
|
+
});
|
|
334
|
+
})(),
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
key: 'distribution',
|
|
338
|
+
name: '供分銷連結或一頁式網頁使用',
|
|
339
|
+
},
|
|
340
|
+
], [voucherData.trigger], text => {
|
|
341
|
+
if (text[0] === 'auto') {
|
|
342
|
+
voucherData.code = undefined;
|
|
343
|
+
}
|
|
344
|
+
if (text[0] === 'distribution') {
|
|
345
|
+
voucherData.for = 'all';
|
|
346
|
+
}
|
|
347
|
+
voucherData.trigger = text[0];
|
|
348
|
+
gvc.notifyDataChange(pageVM.viewID);
|
|
349
|
+
}, { single: true })}`;
|
|
350
|
+
}
|
|
351
|
+
function target() {
|
|
352
|
+
return html ` <div class="tx_700">活動對象</div>
|
|
353
|
+
${BgWidget.mbContainer(18)}
|
|
354
|
+
${gvc.bindView(() => {
|
|
355
|
+
const id = gvc.glitter.getUUID();
|
|
356
|
+
return {
|
|
357
|
+
bind: id,
|
|
358
|
+
view: () => {
|
|
359
|
+
var _a;
|
|
360
|
+
return html `
|
|
361
|
+
<div style="display: flex; flex-direction: column; gap: 8px;">
|
|
362
|
+
${BgWidget.selectFilter({
|
|
363
|
+
gvc: gvc,
|
|
364
|
+
callback: text => {
|
|
365
|
+
voucherData.target = text;
|
|
366
|
+
gvc.notifyDataChange(id);
|
|
367
|
+
},
|
|
368
|
+
default: (_a = voucherData.target) !== null && _a !== void 0 ? _a : 'all',
|
|
369
|
+
options: [
|
|
370
|
+
{
|
|
371
|
+
key: 'all',
|
|
372
|
+
value: '所有顧客',
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
key: 'customer',
|
|
376
|
+
value: '特定顧客',
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
key: 'levels',
|
|
380
|
+
value: '會員等級',
|
|
381
|
+
},
|
|
382
|
+
],
|
|
383
|
+
style: 'width: 100%;',
|
|
384
|
+
})}
|
|
385
|
+
<div>
|
|
386
|
+
${(() => {
|
|
387
|
+
switch (voucherData.target) {
|
|
388
|
+
case 'all':
|
|
389
|
+
return '';
|
|
390
|
+
case 'customer':
|
|
391
|
+
return gvc.bindView(() => {
|
|
392
|
+
const customVM = {
|
|
393
|
+
id: gvc.glitter.getUUID(),
|
|
394
|
+
loading: true,
|
|
395
|
+
dataList: [],
|
|
396
|
+
};
|
|
367
397
|
return {
|
|
368
|
-
bind: id,
|
|
398
|
+
bind: customVM.id,
|
|
369
399
|
view: () => {
|
|
370
|
-
|
|
400
|
+
if (customVM.loading) {
|
|
401
|
+
return BgWidget.spinner();
|
|
402
|
+
}
|
|
371
403
|
return html `
|
|
372
|
-
<div
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
value: '會員等級',
|
|
404
|
+
<div class="d-flex flex-column p-2" style="gap: 18px;">
|
|
405
|
+
<div
|
|
406
|
+
class="d-flex align-items-center gray-bottom-line-18"
|
|
407
|
+
style="justify-content: space-between;"
|
|
408
|
+
>
|
|
409
|
+
<div class="form-check-label c_updown_label">
|
|
410
|
+
<div class="tx_normal">顧客名稱</div>
|
|
411
|
+
</div>
|
|
412
|
+
${BgWidget.grayButton('查看全部', gvc.event(() => {
|
|
413
|
+
var _a;
|
|
414
|
+
BgWidget.selectDropDialog({
|
|
415
|
+
gvc: gvc,
|
|
416
|
+
title: '搜尋特定顧客',
|
|
417
|
+
tag: 'select_users',
|
|
418
|
+
updownOptions: FilterOptions.userOrderBy,
|
|
419
|
+
callback: value => {
|
|
420
|
+
voucherData.targetList = value;
|
|
421
|
+
customVM.loading = true;
|
|
422
|
+
gvc.notifyDataChange(customVM.id);
|
|
392
423
|
},
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
id: gvc.glitter.getUUID(),
|
|
405
|
-
loading: true,
|
|
406
|
-
dataList: [],
|
|
407
|
-
};
|
|
408
|
-
return {
|
|
409
|
-
bind: customVM.id,
|
|
410
|
-
view: () => {
|
|
411
|
-
if (customVM.loading) {
|
|
412
|
-
return BgWidget.spinner();
|
|
413
|
-
}
|
|
414
|
-
return html `
|
|
415
|
-
<div class="d-flex flex-column p-2" style="gap: 18px;">
|
|
416
|
-
<div
|
|
417
|
-
class="d-flex align-items-center gray-bottom-line-18"
|
|
418
|
-
style="justify-content: space-between;"
|
|
419
|
-
>
|
|
420
|
-
<div class="form-check-label c_updown_label">
|
|
421
|
-
<div class="tx_normal">顧客名稱</div>
|
|
422
|
-
</div>
|
|
423
|
-
${BgWidget.grayButton('查看全部', gvc.event(() => {
|
|
424
|
+
default: ((_a = voucherData.targetList) !== null && _a !== void 0 ? _a : []).map(id => id.toString()),
|
|
425
|
+
api: (data) => {
|
|
426
|
+
return new Promise(resolve => {
|
|
427
|
+
ApiUser.getUserListOrders({
|
|
428
|
+
page: 0,
|
|
429
|
+
limit: 99999,
|
|
430
|
+
search: data.query,
|
|
431
|
+
orderString: data.orderString,
|
|
432
|
+
}).then(dd => {
|
|
433
|
+
if (dd.response.data) {
|
|
434
|
+
resolve(dd.response.data.map((item) => {
|
|
424
435
|
var _a;
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
customVM.loading = true;
|
|
433
|
-
gvc.notifyDataChange(customVM.id);
|
|
434
|
-
},
|
|
435
|
-
default: (_a = voucherData.targetList) !== null && _a !== void 0 ? _a : [],
|
|
436
|
-
api: (data) => {
|
|
437
|
-
return new Promise(resolve => {
|
|
438
|
-
ApiUser.getUserListOrders({
|
|
439
|
-
page: 0,
|
|
440
|
-
limit: 99999,
|
|
441
|
-
search: data.query,
|
|
442
|
-
orderString: data.orderString,
|
|
443
|
-
}).then(dd => {
|
|
444
|
-
if (dd.response.data) {
|
|
445
|
-
resolve(dd.response.data.map((item) => {
|
|
446
|
-
var _a;
|
|
447
|
-
return {
|
|
448
|
-
key: item.userID,
|
|
449
|
-
value: (_a = item.userData.name) !== null && _a !== void 0 ? _a : '(尚無姓名)',
|
|
450
|
-
note: item.userData.email,
|
|
451
|
-
};
|
|
452
|
-
}));
|
|
453
|
-
}
|
|
454
|
-
});
|
|
455
|
-
});
|
|
456
|
-
},
|
|
457
|
-
style: 'width: 100%;',
|
|
458
|
-
});
|
|
459
|
-
}), { textStyle: 'font-weight: 400;' })}
|
|
460
|
-
</div>
|
|
461
|
-
${obj.gvc.map(customVM.dataList.map((opt, index) => {
|
|
462
|
-
return html ` <div class="form-check-label c_updown_label">
|
|
463
|
-
<span class="tx_normal">${index + 1}. ${opt.value}</span>
|
|
464
|
-
${opt.note
|
|
465
|
-
? html ` <span class="tx_gray_12 ms-2">${opt.note}</span> `
|
|
466
|
-
: ''}
|
|
467
|
-
</div>`;
|
|
468
|
-
}))}
|
|
469
|
-
</div>
|
|
470
|
-
`;
|
|
471
|
-
},
|
|
472
|
-
onCreate: () => {
|
|
473
|
-
if (customVM.loading) {
|
|
474
|
-
if (voucherData.targetList.length === 0) {
|
|
475
|
-
setTimeout(() => {
|
|
476
|
-
customVM.dataList = [];
|
|
477
|
-
customVM.loading = false;
|
|
478
|
-
gvc.notifyDataChange(customVM.id);
|
|
479
|
-
}, 200);
|
|
480
|
-
}
|
|
481
|
-
else {
|
|
482
|
-
ApiUser.getUserList({
|
|
483
|
-
page: 0,
|
|
484
|
-
limit: 99999,
|
|
485
|
-
id: voucherData.targetList.join(','),
|
|
486
|
-
}).then(dd => {
|
|
487
|
-
if (dd.response.data) {
|
|
488
|
-
customVM.dataList = dd.response.data.map((item) => {
|
|
489
|
-
return {
|
|
490
|
-
key: item.userID,
|
|
491
|
-
value: item.userData.name,
|
|
492
|
-
note: item.userData.email,
|
|
493
|
-
};
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
customVM.loading = false;
|
|
497
|
-
gvc.notifyDataChange(customVM.id);
|
|
498
|
-
});
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
},
|
|
502
|
-
};
|
|
503
|
-
});
|
|
504
|
-
case 'levels':
|
|
505
|
-
return (() => {
|
|
506
|
-
const levelVM = {
|
|
507
|
-
id: gvc.glitter.getUUID(),
|
|
508
|
-
loading: true,
|
|
509
|
-
dataList: [],
|
|
510
|
-
};
|
|
511
|
-
return gvc.bindView({
|
|
512
|
-
bind: levelVM.id,
|
|
513
|
-
view: () => {
|
|
514
|
-
var _a;
|
|
515
|
-
if (levelVM.loading) {
|
|
516
|
-
return BgWidget.spinner({ text: { visible: false } });
|
|
517
|
-
}
|
|
518
|
-
else {
|
|
519
|
-
return BgWidget.selectDropList({
|
|
520
|
-
gvc: gvc,
|
|
521
|
-
callback: (value) => {
|
|
522
|
-
voucherData.targetList = value;
|
|
523
|
-
gvc.notifyDataChange(id);
|
|
524
|
-
},
|
|
525
|
-
default: (_a = voucherData.targetList) !== null && _a !== void 0 ? _a : [],
|
|
526
|
-
options: levelVM.dataList,
|
|
527
|
-
style: 'width: 100%;',
|
|
528
|
-
});
|
|
529
|
-
}
|
|
530
|
-
},
|
|
531
|
-
divCreate: {
|
|
532
|
-
style: 'width: 100%;',
|
|
533
|
-
},
|
|
534
|
-
onCreate: () => {
|
|
535
|
-
if (levelVM.loading) {
|
|
536
|
-
ApiUser.getPublicConfig('member_level_config', 'manager').then((dd) => {
|
|
537
|
-
if (dd.result && dd.response.value) {
|
|
538
|
-
levelVM.dataList = dd.response.value.levels.map((item) => {
|
|
539
|
-
return {
|
|
540
|
-
key: item.id,
|
|
541
|
-
value: item.tag_name,
|
|
542
|
-
};
|
|
543
|
-
});
|
|
544
|
-
levelVM.loading = false;
|
|
545
|
-
gvc.notifyDataChange(levelVM.id);
|
|
546
|
-
}
|
|
547
|
-
});
|
|
548
|
-
}
|
|
549
|
-
},
|
|
550
|
-
});
|
|
551
|
-
})();
|
|
552
|
-
case 'group':
|
|
553
|
-
return (() => {
|
|
554
|
-
const levelVM = {
|
|
555
|
-
id: gvc.glitter.getUUID(),
|
|
556
|
-
loading: true,
|
|
557
|
-
dataList: [],
|
|
558
|
-
};
|
|
559
|
-
return gvc.bindView({
|
|
560
|
-
bind: levelVM.id,
|
|
561
|
-
view: () => {
|
|
562
|
-
var _a;
|
|
563
|
-
if (levelVM.loading) {
|
|
564
|
-
return BgWidget.spinner({ text: { visible: false } });
|
|
565
|
-
}
|
|
566
|
-
else {
|
|
567
|
-
return BgWidget.selectDropList({
|
|
568
|
-
gvc: gvc,
|
|
569
|
-
callback: (value) => {
|
|
570
|
-
voucherData.targetList = value;
|
|
571
|
-
gvc.notifyDataChange(id);
|
|
572
|
-
},
|
|
573
|
-
default: (_a = voucherData.targetList) !== null && _a !== void 0 ? _a : [],
|
|
574
|
-
options: levelVM.dataList,
|
|
575
|
-
style: 'width: 100%;',
|
|
576
|
-
});
|
|
577
|
-
}
|
|
578
|
-
},
|
|
579
|
-
divCreate: {
|
|
580
|
-
style: 'width: 100%;',
|
|
581
|
-
},
|
|
582
|
-
onCreate: () => {
|
|
583
|
-
if (levelVM.loading) {
|
|
584
|
-
ApiUser.getUserGroupList().then((dd) => {
|
|
585
|
-
if (dd.result && dd.response.data) {
|
|
586
|
-
levelVM.dataList = dd.response.data
|
|
587
|
-
.filter((item) => {
|
|
588
|
-
return item.type !== 'level';
|
|
589
|
-
})
|
|
590
|
-
.map((item) => {
|
|
591
|
-
return {
|
|
592
|
-
key: item.type,
|
|
593
|
-
value: item.title,
|
|
594
|
-
};
|
|
595
|
-
});
|
|
596
|
-
levelVM.loading = false;
|
|
597
|
-
gvc.notifyDataChange(levelVM.id);
|
|
598
|
-
}
|
|
599
|
-
});
|
|
600
|
-
}
|
|
601
|
-
},
|
|
436
|
+
return {
|
|
437
|
+
key: item.userID,
|
|
438
|
+
value: (_a = item.userData.name) !== null && _a !== void 0 ? _a : '(尚無姓名)',
|
|
439
|
+
note: item.userData.email,
|
|
440
|
+
};
|
|
441
|
+
}));
|
|
442
|
+
}
|
|
602
443
|
});
|
|
603
|
-
})
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
}
|
|
607
|
-
})
|
|
444
|
+
});
|
|
445
|
+
},
|
|
446
|
+
style: 'width: 100%;',
|
|
447
|
+
});
|
|
448
|
+
}), { textStyle: 'font-weight: 400;' })}
|
|
608
449
|
</div>
|
|
450
|
+
${obj.gvc.map(customVM.dataList.map((opt, index) => {
|
|
451
|
+
return html ` <div class="form-check-label c_updown_label">
|
|
452
|
+
<span class="tx_normal">${index + 1}. ${opt.value}</span>
|
|
453
|
+
${opt.note ? html ` <span class="tx_gray_12 ms-2">${opt.note}</span> ` : ''}
|
|
454
|
+
</div>`;
|
|
455
|
+
}))}
|
|
609
456
|
</div>
|
|
610
457
|
`;
|
|
611
458
|
},
|
|
459
|
+
onCreate: () => {
|
|
460
|
+
if (customVM.loading) {
|
|
461
|
+
if (voucherData.targetList.length === 0) {
|
|
462
|
+
setTimeout(() => {
|
|
463
|
+
customVM.dataList = [];
|
|
464
|
+
customVM.loading = false;
|
|
465
|
+
gvc.notifyDataChange(customVM.id);
|
|
466
|
+
}, 200);
|
|
467
|
+
}
|
|
468
|
+
else {
|
|
469
|
+
ApiUser.getUserList({
|
|
470
|
+
page: 0,
|
|
471
|
+
limit: 99999,
|
|
472
|
+
id: voucherData.targetList.join(','),
|
|
473
|
+
}).then(dd => {
|
|
474
|
+
if (dd.response.data) {
|
|
475
|
+
customVM.dataList = dd.response.data.map((item) => {
|
|
476
|
+
return {
|
|
477
|
+
key: item.userID,
|
|
478
|
+
value: item.userData.name,
|
|
479
|
+
note: item.userData.email,
|
|
480
|
+
};
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
customVM.loading = false;
|
|
484
|
+
gvc.notifyDataChange(customVM.id);
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
},
|
|
612
489
|
};
|
|
613
|
-
})
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
gvc.
|
|
622
|
-
|
|
490
|
+
});
|
|
491
|
+
case 'levels':
|
|
492
|
+
return (() => {
|
|
493
|
+
const levelVM = {
|
|
494
|
+
id: gvc.glitter.getUUID(),
|
|
495
|
+
loading: true,
|
|
496
|
+
dataList: [],
|
|
497
|
+
};
|
|
498
|
+
return gvc.bindView({
|
|
499
|
+
bind: levelVM.id,
|
|
500
|
+
view: () => {
|
|
501
|
+
var _a;
|
|
502
|
+
if (levelVM.loading) {
|
|
503
|
+
return BgWidget.spinner({ text: { visible: false } });
|
|
504
|
+
}
|
|
505
|
+
else {
|
|
506
|
+
return BgWidget.selectDropList({
|
|
507
|
+
gvc: gvc,
|
|
508
|
+
callback: value => {
|
|
509
|
+
voucherData.targetList = value;
|
|
510
|
+
gvc.notifyDataChange(id);
|
|
511
|
+
},
|
|
512
|
+
default: ((_a = voucherData.targetList) !== null && _a !== void 0 ? _a : []).map(id => id.toString()),
|
|
513
|
+
options: levelVM.dataList,
|
|
514
|
+
style: 'width: 100%;',
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
},
|
|
518
|
+
divCreate: {
|
|
519
|
+
style: 'width: 100%;',
|
|
520
|
+
},
|
|
521
|
+
onCreate: () => {
|
|
522
|
+
if (levelVM.loading) {
|
|
523
|
+
ApiUser.getPublicConfig('member_level_config', 'manager').then((dd) => {
|
|
524
|
+
if (dd.result && dd.response.value) {
|
|
525
|
+
levelVM.dataList = dd.response.value.levels.map((item) => {
|
|
526
|
+
return {
|
|
527
|
+
key: item.id,
|
|
528
|
+
value: item.tag_name,
|
|
529
|
+
};
|
|
530
|
+
});
|
|
531
|
+
levelVM.loading = false;
|
|
532
|
+
gvc.notifyDataChange(levelVM.id);
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
},
|
|
537
|
+
});
|
|
538
|
+
})();
|
|
539
|
+
case 'group':
|
|
540
|
+
return (() => {
|
|
541
|
+
const levelVM = {
|
|
542
|
+
id: gvc.glitter.getUUID(),
|
|
543
|
+
loading: true,
|
|
544
|
+
dataList: [],
|
|
545
|
+
};
|
|
546
|
+
return gvc.bindView({
|
|
547
|
+
bind: levelVM.id,
|
|
548
|
+
view: () => {
|
|
549
|
+
var _a;
|
|
550
|
+
if (levelVM.loading) {
|
|
551
|
+
return BgWidget.spinner({ text: { visible: false } });
|
|
552
|
+
}
|
|
553
|
+
else {
|
|
554
|
+
return BgWidget.selectDropList({
|
|
555
|
+
gvc: gvc,
|
|
556
|
+
callback: (value) => {
|
|
557
|
+
voucherData.targetList = value;
|
|
558
|
+
gvc.notifyDataChange(id);
|
|
559
|
+
},
|
|
560
|
+
default: ((_a = voucherData.targetList) !== null && _a !== void 0 ? _a : []).map(id => id.toString()),
|
|
561
|
+
options: levelVM.dataList,
|
|
562
|
+
style: 'width: 100%;',
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
},
|
|
566
|
+
divCreate: {
|
|
567
|
+
style: 'width: 100%;',
|
|
568
|
+
},
|
|
569
|
+
onCreate: () => {
|
|
570
|
+
if (levelVM.loading) {
|
|
571
|
+
ApiUser.getUserGroupList().then((dd) => {
|
|
572
|
+
if (dd.result && dd.response.data) {
|
|
573
|
+
levelVM.dataList = dd.response.data
|
|
574
|
+
.filter((item) => {
|
|
575
|
+
return item.type !== 'level';
|
|
576
|
+
})
|
|
577
|
+
.map((item) => {
|
|
578
|
+
return {
|
|
579
|
+
key: item.type,
|
|
580
|
+
value: item.title,
|
|
581
|
+
};
|
|
582
|
+
});
|
|
583
|
+
levelVM.loading = false;
|
|
584
|
+
gvc.notifyDataChange(levelVM.id);
|
|
585
|
+
}
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
},
|
|
589
|
+
});
|
|
590
|
+
})();
|
|
591
|
+
default:
|
|
592
|
+
return '';
|
|
593
|
+
}
|
|
594
|
+
})()}
|
|
595
|
+
</div>
|
|
596
|
+
</div>
|
|
597
|
+
`;
|
|
598
|
+
},
|
|
599
|
+
};
|
|
600
|
+
})}`;
|
|
601
|
+
}
|
|
602
|
+
function device() {
|
|
603
|
+
var _a;
|
|
604
|
+
return html ` <div class="tx_700">可使用訂單來源</div>
|
|
605
|
+
${BgWidget.mbContainer(18)}
|
|
606
|
+
${BgWidget.multiCheckboxContainer(gvc, [
|
|
607
|
+
{ key: 'normal', name: 'APP & 官網' },
|
|
608
|
+
{ key: 'pos', name: 'POS' },
|
|
609
|
+
], (_a = voucherData.device) !== null && _a !== void 0 ? _a : ['normal'], text => {
|
|
610
|
+
voucherData.device = text;
|
|
611
|
+
gvc.notifyDataChange(pageVM.viewID);
|
|
612
|
+
}, { single: false })}`;
|
|
613
|
+
}
|
|
614
|
+
function selectShipment() {
|
|
615
|
+
const id = glitter.getUUID();
|
|
616
|
+
return gvc.bindView({
|
|
617
|
+
bind: id,
|
|
618
|
+
view: () => {
|
|
619
|
+
var _a;
|
|
620
|
+
return html ` <div class="tx_700">可使用物流</div>
|
|
621
|
+
${BgWidget.mbContainer(18)}
|
|
622
|
+
${[
|
|
623
|
+
BgWidget.select({
|
|
624
|
+
gvc,
|
|
625
|
+
callback: value => {
|
|
626
|
+
voucherData.selectShipment.type = value;
|
|
627
|
+
gvc.notifyDataChange(id);
|
|
628
|
+
},
|
|
629
|
+
default: voucherData.selectShipment.type,
|
|
630
|
+
options: [
|
|
631
|
+
{ key: 'all', value: '所有物流' },
|
|
632
|
+
{ key: 'select', value: '指定物流' },
|
|
633
|
+
],
|
|
634
|
+
}),
|
|
635
|
+
voucherData.selectShipment.type === 'all'
|
|
636
|
+
? ''
|
|
637
|
+
: BgWidget.selectDropList({
|
|
638
|
+
gvc: gvc,
|
|
639
|
+
callback: value => {
|
|
640
|
+
voucherData.selectShipment.list = value;
|
|
641
|
+
},
|
|
642
|
+
default: (_a = voucherData.selectShipment.list) !== null && _a !== void 0 ? _a : [],
|
|
643
|
+
options: ShipmentConfig.list.map(item => {
|
|
644
|
+
return {
|
|
645
|
+
key: item.value,
|
|
646
|
+
value: item.title,
|
|
647
|
+
};
|
|
648
|
+
}),
|
|
649
|
+
style: 'width: 100%;',
|
|
650
|
+
}),
|
|
651
|
+
]
|
|
652
|
+
.filter(Boolean)
|
|
653
|
+
.join(BgWidget.mbContainer(8))}`;
|
|
654
|
+
},
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
function rebackProduct() {
|
|
658
|
+
return gvc.bindView(() => {
|
|
659
|
+
const vm = {
|
|
660
|
+
id: gvc.glitter.getUUID(),
|
|
661
|
+
};
|
|
662
|
+
if (!Array.isArray(voucherData.add_on_products)) {
|
|
663
|
+
voucherData.add_on_products = [];
|
|
664
|
+
}
|
|
665
|
+
return {
|
|
666
|
+
bind: vm.id,
|
|
667
|
+
view: () => {
|
|
668
|
+
return html `
|
|
669
|
+
<div class="tx_700">${voucherData.reBackType === 'add_on_items' ? `加購品項` : `贈品品項`}</div>
|
|
670
|
+
${BgWidget.mbContainer(18)}
|
|
671
|
+
${obj.gvc.bindView(() => {
|
|
672
|
+
const id = gvc.glitter.getUUID();
|
|
673
|
+
return {
|
|
674
|
+
bind: id,
|
|
675
|
+
view: () => {
|
|
676
|
+
try {
|
|
677
|
+
return html `
|
|
678
|
+
<div
|
|
679
|
+
class="d-flex align-items-center gray-bottom-line-18"
|
|
680
|
+
style="gap: 24px; justify-content: space-between;"
|
|
681
|
+
>
|
|
682
|
+
<div class="form-check-label c_updown_label">
|
|
683
|
+
<div class="tx_normal">商品列表</div>
|
|
684
|
+
</div>
|
|
685
|
+
${BgWidget.grayButton('選擇商品', gvc.event(() => {
|
|
686
|
+
var _a;
|
|
687
|
+
BgProduct.productsDialog({
|
|
688
|
+
gvc: gvc,
|
|
689
|
+
default: (_a = voucherData.add_on_products) !== null && _a !== void 0 ? _a : [],
|
|
690
|
+
callback: (value) => __awaiter(this, void 0, void 0, function* () {
|
|
691
|
+
voucherData.add_on_products = value;
|
|
692
|
+
gvc.notifyDataChange(id);
|
|
693
|
+
}),
|
|
694
|
+
filter: dd => {
|
|
695
|
+
return true;
|
|
696
|
+
},
|
|
697
|
+
productType: voucherData.reBackType === 'add_on_items' ? 'addProduct' : 'giveaway',
|
|
698
|
+
});
|
|
699
|
+
}), { textStyle: 'font-weight: 400;' })}
|
|
700
|
+
</div>
|
|
701
|
+
${gvc.bindView(() => {
|
|
702
|
+
const vm = {
|
|
703
|
+
id: gvc.glitter.getUUID(),
|
|
704
|
+
loading: true,
|
|
705
|
+
data: [],
|
|
706
|
+
};
|
|
707
|
+
BgProduct.getProductOpts(voucherData.add_on_products, voucherData.reBackType === 'add_on_items' ? 'addProduct' : 'giveaway').then(res => {
|
|
708
|
+
vm.data = res;
|
|
709
|
+
vm.loading = false;
|
|
710
|
+
gvc.notifyDataChange(vm.id);
|
|
711
|
+
});
|
|
712
|
+
return {
|
|
713
|
+
bind: vm.id,
|
|
714
|
+
view: () => __awaiter(this, void 0, void 0, function* () {
|
|
715
|
+
if (vm.loading) {
|
|
716
|
+
return BgWidget.spinner();
|
|
717
|
+
}
|
|
718
|
+
return vm.data
|
|
719
|
+
.map((opt, index) => {
|
|
720
|
+
return html ` <div
|
|
721
|
+
class="d-flex align-items-center form-check-label c_updown_label gap-3"
|
|
722
|
+
>
|
|
723
|
+
<span class="tx_normal">${index + 1}.</span>
|
|
724
|
+
${BgWidget.validImageBox({
|
|
725
|
+
gvc: gvc,
|
|
726
|
+
image: opt.image,
|
|
727
|
+
width: 40,
|
|
728
|
+
})}
|
|
729
|
+
<div class="tx_normal ${opt.note ? 'mb-1' : ''}">${opt.value}</div>
|
|
730
|
+
${opt.note ? html ` <div class="tx_gray_12">${opt.note}</div> ` : ''}
|
|
731
|
+
</div>`;
|
|
732
|
+
})
|
|
733
|
+
.join('');
|
|
734
|
+
}),
|
|
735
|
+
divCreate: {
|
|
736
|
+
class: `d-flex py-2 flex-column`,
|
|
737
|
+
style: `gap:10px;`,
|
|
738
|
+
},
|
|
739
|
+
};
|
|
740
|
+
})}
|
|
741
|
+
`;
|
|
742
|
+
}
|
|
743
|
+
catch (e) {
|
|
744
|
+
console.error(e);
|
|
745
|
+
return '';
|
|
746
|
+
}
|
|
747
|
+
},
|
|
748
|
+
divCreate: {
|
|
749
|
+
class: `w-100`,
|
|
750
|
+
},
|
|
751
|
+
};
|
|
752
|
+
})}
|
|
753
|
+
`;
|
|
754
|
+
},
|
|
755
|
+
};
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
return gvc.bindView(() => {
|
|
759
|
+
return {
|
|
760
|
+
bind: pageVM.viewID,
|
|
761
|
+
view: () => {
|
|
762
|
+
return BgWidget.container([
|
|
763
|
+
html ` <div class="title-container">
|
|
764
|
+
${BgWidget.goBack(gvc.event(() => {
|
|
765
|
+
vm.type = 'list';
|
|
766
|
+
}))}
|
|
767
|
+
${BgWidget.title(`${obj.type === 'add' ? '新增' : '編輯'}${ShoppingDiscountSetting.getLabel(obj.reBackType)}`)}
|
|
768
|
+
</div>`,
|
|
769
|
+
BgWidget.container1x2({
|
|
770
|
+
html: [
|
|
771
|
+
BgWidget.mainCard([title(), status()].join(BgWidget.horizontalLine())),
|
|
772
|
+
BgWidget.mainCard([
|
|
773
|
+
trigger(),
|
|
774
|
+
target(),
|
|
775
|
+
device(),
|
|
776
|
+
voucherData.reBackType === 'shipment_free' ? selectShipment() : '',
|
|
623
777
|
]
|
|
624
|
-
.
|
|
625
|
-
|
|
626
|
-
})
|
|
778
|
+
.filter(Boolean)
|
|
779
|
+
.map(str => html `<div>${str}</div>`)
|
|
627
780
|
.join(BgWidget.horizontalLine())),
|
|
628
781
|
BgWidget.mainCard(gvc.bindView(() => {
|
|
629
782
|
var _a;
|
|
@@ -658,10 +811,9 @@ export class ShoppingDiscountSetting {
|
|
|
658
811
|
callback: text => {
|
|
659
812
|
const texInt = parseInt(text, 10);
|
|
660
813
|
if (voucherData.method === 'percent' && (texInt > 100 || texInt < 0)) {
|
|
661
|
-
const dialog = new ShareDialog(gvc.glitter);
|
|
662
814
|
dialog.infoMessage({ text: '數值需介於0~100' });
|
|
663
815
|
gvc.notifyDataChange(id);
|
|
664
|
-
gvc.notifyDataChange(pageVM.
|
|
816
|
+
gvc.notifyDataChange(pageVM.countingID);
|
|
665
817
|
}
|
|
666
818
|
else {
|
|
667
819
|
voucherData.value = text;
|
|
@@ -689,7 +841,7 @@ export class ShoppingDiscountSetting {
|
|
|
689
841
|
], [voucherData.method], text => {
|
|
690
842
|
voucherData.value = '0';
|
|
691
843
|
voucherData.method = text[0];
|
|
692
|
-
gvc.notifyDataChange(pageVM.
|
|
844
|
+
gvc.notifyDataChange(pageVM.conditionID);
|
|
693
845
|
}, { single: true })}
|
|
694
846
|
</div>`,
|
|
695
847
|
];
|
|
@@ -930,125 +1082,12 @@ export class ShoppingDiscountSetting {
|
|
|
930
1082
|
},
|
|
931
1083
|
};
|
|
932
1084
|
})),
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
BgWidget.mainCard(gvc.bindView(() => {
|
|
937
|
-
const vm = {
|
|
938
|
-
id: gvc.glitter.getUUID(),
|
|
939
|
-
};
|
|
940
|
-
if (!Array.isArray(voucherData.add_on_products)) {
|
|
941
|
-
voucherData.add_on_products = [];
|
|
942
|
-
}
|
|
943
|
-
return {
|
|
944
|
-
bind: vm.id,
|
|
945
|
-
view: () => {
|
|
946
|
-
return html `
|
|
947
|
-
<div class="tx_700">
|
|
948
|
-
${voucherData.reBackType === 'add_on_items' ? `加購品項` : `贈品品項`}
|
|
949
|
-
</div>
|
|
950
|
-
${BgWidget.mbContainer(18)}
|
|
951
|
-
${obj.gvc.bindView(() => {
|
|
952
|
-
const id = gvc.glitter.getUUID();
|
|
953
|
-
return {
|
|
954
|
-
bind: id,
|
|
955
|
-
view: () => {
|
|
956
|
-
try {
|
|
957
|
-
return html `
|
|
958
|
-
<div
|
|
959
|
-
class="d-flex align-items-center gray-bottom-line-18"
|
|
960
|
-
style="gap: 24px; justify-content: space-between;"
|
|
961
|
-
>
|
|
962
|
-
<div class="form-check-label c_updown_label">
|
|
963
|
-
<div class="tx_normal">商品列表</div>
|
|
964
|
-
</div>
|
|
965
|
-
${BgWidget.grayButton('選擇商品', gvc.event(() => {
|
|
966
|
-
var _a;
|
|
967
|
-
BgProduct.productsDialog({
|
|
968
|
-
gvc: gvc,
|
|
969
|
-
default: (_a = voucherData.add_on_products) !== null && _a !== void 0 ? _a : [],
|
|
970
|
-
callback: (value) => __awaiter(this, void 0, void 0, function* () {
|
|
971
|
-
voucherData.add_on_products = value;
|
|
972
|
-
gvc.notifyDataChange(id);
|
|
973
|
-
}),
|
|
974
|
-
filter: dd => {
|
|
975
|
-
return true;
|
|
976
|
-
},
|
|
977
|
-
productType: voucherData.reBackType === 'add_on_items'
|
|
978
|
-
? 'addProduct'
|
|
979
|
-
: 'giveaway',
|
|
980
|
-
});
|
|
981
|
-
}), { textStyle: 'font-weight: 400;' })}
|
|
982
|
-
</div>
|
|
983
|
-
${gvc.bindView(() => {
|
|
984
|
-
const vm = {
|
|
985
|
-
id: gvc.glitter.getUUID(),
|
|
986
|
-
loading: true,
|
|
987
|
-
data: [],
|
|
988
|
-
};
|
|
989
|
-
BgProduct.getProductOpts(voucherData.add_on_products, voucherData.reBackType === 'add_on_items' ? 'addProduct' : 'giveaway').then(res => {
|
|
990
|
-
vm.data = res;
|
|
991
|
-
vm.loading = false;
|
|
992
|
-
gvc.notifyDataChange(vm.id);
|
|
993
|
-
});
|
|
994
|
-
return {
|
|
995
|
-
bind: vm.id,
|
|
996
|
-
view: () => __awaiter(this, void 0, void 0, function* () {
|
|
997
|
-
if (vm.loading) {
|
|
998
|
-
return BgWidget.spinner();
|
|
999
|
-
}
|
|
1000
|
-
return vm.data
|
|
1001
|
-
.map((opt, index) => {
|
|
1002
|
-
return html ` <div
|
|
1003
|
-
class="d-flex align-items-center form-check-label c_updown_label gap-3"
|
|
1004
|
-
>
|
|
1005
|
-
<span class="tx_normal">${index + 1}.</span>
|
|
1006
|
-
${BgWidget.validImageBox({
|
|
1007
|
-
gvc: gvc,
|
|
1008
|
-
image: opt.image,
|
|
1009
|
-
width: 40,
|
|
1010
|
-
})}
|
|
1011
|
-
<div class="tx_normal ${opt.note ? 'mb-1' : ''}">
|
|
1012
|
-
${opt.value}
|
|
1013
|
-
</div>
|
|
1014
|
-
${opt.note
|
|
1015
|
-
? html ` <div class="tx_gray_12">${opt.note}</div> `
|
|
1016
|
-
: ''}
|
|
1017
|
-
</div>`;
|
|
1018
|
-
})
|
|
1019
|
-
.join('');
|
|
1020
|
-
}),
|
|
1021
|
-
divCreate: {
|
|
1022
|
-
class: `d-flex py-2 flex-column`,
|
|
1023
|
-
style: `gap:10px;`,
|
|
1024
|
-
},
|
|
1025
|
-
};
|
|
1026
|
-
})}
|
|
1027
|
-
`;
|
|
1028
|
-
}
|
|
1029
|
-
catch (e) {
|
|
1030
|
-
console.error(e);
|
|
1031
|
-
return '';
|
|
1032
|
-
}
|
|
1033
|
-
},
|
|
1034
|
-
divCreate: {
|
|
1035
|
-
class: `w-100`,
|
|
1036
|
-
},
|
|
1037
|
-
};
|
|
1038
|
-
})}
|
|
1039
|
-
`;
|
|
1040
|
-
},
|
|
1041
|
-
};
|
|
1042
|
-
})),
|
|
1043
|
-
];
|
|
1044
|
-
}
|
|
1045
|
-
else {
|
|
1046
|
-
return [];
|
|
1047
|
-
}
|
|
1048
|
-
})(),
|
|
1085
|
+
['giveaway', 'add_on_items'].includes(voucherData.reBackType)
|
|
1086
|
+
? BgWidget.mainCard(rebackProduct())
|
|
1087
|
+
: '',
|
|
1049
1088
|
BgWidget.mainCard(gvc.bindView(() => {
|
|
1050
1089
|
return {
|
|
1051
|
-
bind: pageVM.
|
|
1090
|
+
bind: pageVM.conditionID,
|
|
1052
1091
|
view: () => {
|
|
1053
1092
|
const conditionInput = (text) => {
|
|
1054
1093
|
var _a;
|
|
@@ -1060,7 +1099,7 @@ export class ShoppingDiscountSetting {
|
|
|
1060
1099
|
placeHolder: '',
|
|
1061
1100
|
callback: value => {
|
|
1062
1101
|
voucherData.ruleValue = parseInt(value, 10);
|
|
1063
|
-
gvc.notifyDataChange(pageVM.
|
|
1102
|
+
gvc.notifyDataChange(pageVM.conditionID);
|
|
1064
1103
|
},
|
|
1065
1104
|
endText: text,
|
|
1066
1105
|
});
|
|
@@ -1093,7 +1132,7 @@ export class ShoppingDiscountSetting {
|
|
|
1093
1132
|
], [voucherData.rule], text => {
|
|
1094
1133
|
voucherData.ruleValue = 0;
|
|
1095
1134
|
voucherData.rule = text[0];
|
|
1096
|
-
gvc.notifyDataChange(pageVM.
|
|
1135
|
+
gvc.notifyDataChange(pageVM.conditionID);
|
|
1097
1136
|
}, { single: true })}`,
|
|
1098
1137
|
html ` ${BgWidget.horizontalLine()}
|
|
1099
1138
|
<div class="tx_700">計算單位</div>
|
|
@@ -1116,33 +1155,13 @@ export class ShoppingDiscountSetting {
|
|
|
1116
1155
|
},
|
|
1117
1156
|
], [voucherData.conditionType], text => {
|
|
1118
1157
|
voucherData.conditionType = text[0];
|
|
1119
|
-
gvc.notifyDataChange(pageVM.
|
|
1158
|
+
gvc.notifyDataChange(pageVM.conditionID);
|
|
1120
1159
|
}, {
|
|
1121
1160
|
single: true,
|
|
1122
1161
|
readonly: voucherData.reBackType === 'shipment_free',
|
|
1123
1162
|
})}`,
|
|
1124
|
-
html ` ${BgWidget.horizontalLine()}
|
|
1125
|
-
<div class="tx_700">消費金額於其他折扣觸發時機</div>
|
|
1126
|
-
${BgWidget.mbContainer(18)}
|
|
1127
|
-
${BgWidget.multiCheckboxContainer(gvc, [
|
|
1128
|
-
{
|
|
1129
|
-
key: 'before',
|
|
1130
|
-
name: '觸發前',
|
|
1131
|
-
innerHtml: BgWidget.grayNote('在其他折扣觸發前,訂單的消費金額將做為達成消費條件的金額,來判斷是否可使用此優惠券'),
|
|
1132
|
-
},
|
|
1133
|
-
{
|
|
1134
|
-
key: 'after',
|
|
1135
|
-
name: '觸發後',
|
|
1136
|
-
innerHtml: BgWidget.grayNote('將訂單的消費金額包含其他折扣後,做為達成消費條件的金額,來判斷是否可使用此優惠券'),
|
|
1137
|
-
},
|
|
1138
|
-
], [voucherData.includeDiscount], text => {
|
|
1139
|
-
voucherData.includeDiscount = text[0];
|
|
1140
|
-
gvc.notifyDataChange(pageVM.conditionId);
|
|
1141
|
-
}, {
|
|
1142
|
-
single: true,
|
|
1143
|
-
})}`,
|
|
1144
1163
|
gvc.bindView({
|
|
1145
|
-
bind: pageVM.
|
|
1164
|
+
bind: pageVM.countingID,
|
|
1146
1165
|
view: () => {
|
|
1147
1166
|
if (voucherData.method === 'percent' || voucherData.reBackType === 'shipment_free') {
|
|
1148
1167
|
return '';
|
|
@@ -1163,14 +1182,14 @@ export class ShoppingDiscountSetting {
|
|
|
1163
1182
|
},
|
|
1164
1183
|
], [voucherData.counting], text => {
|
|
1165
1184
|
voucherData.counting = text[0];
|
|
1166
|
-
gvc.notifyDataChange(pageVM.
|
|
1185
|
+
gvc.notifyDataChange(pageVM.conditionID);
|
|
1167
1186
|
}, {
|
|
1168
1187
|
single: true,
|
|
1169
1188
|
})}`;
|
|
1170
1189
|
},
|
|
1171
1190
|
}),
|
|
1172
1191
|
gvc.bindView({
|
|
1173
|
-
bind: pageVM.
|
|
1192
|
+
bind: pageVM.productOffID,
|
|
1174
1193
|
view: () => {
|
|
1175
1194
|
if (!(voucherData.method === 'percent' &&
|
|
1176
1195
|
voucherData.conditionType === 'order' &&
|
|
@@ -1199,7 +1218,7 @@ export class ShoppingDiscountSetting {
|
|
|
1199
1218
|
},
|
|
1200
1219
|
], [voucherData.productOffStart], text => {
|
|
1201
1220
|
voucherData.productOffStart = text[0];
|
|
1202
|
-
gvc.notifyDataChange(pageVM.
|
|
1221
|
+
gvc.notifyDataChange(pageVM.productOffID);
|
|
1203
1222
|
}, {
|
|
1204
1223
|
single: true,
|
|
1205
1224
|
})}`;
|
|
@@ -1214,34 +1233,60 @@ export class ShoppingDiscountSetting {
|
|
|
1214
1233
|
return {
|
|
1215
1234
|
bind: id,
|
|
1216
1235
|
view: () => {
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
voucherData.overlay
|
|
1231
|
-
|
|
1232
|
-
|
|
1236
|
+
function overlay() {
|
|
1237
|
+
return html ` <div class="tx_700">是否與其他優惠券疊加使用</div>
|
|
1238
|
+
${BgWidget.mbContainer(18)}
|
|
1239
|
+
${BgWidget.multiCheckboxContainer(gvc, [
|
|
1240
|
+
{
|
|
1241
|
+
key: 'false',
|
|
1242
|
+
name: '不可疊加',
|
|
1243
|
+
innerHtml: BgWidget.grayNote('系統將以最大優惠排序進行判定'),
|
|
1244
|
+
},
|
|
1245
|
+
{
|
|
1246
|
+
key: 'true',
|
|
1247
|
+
name: '可以疊加',
|
|
1248
|
+
},
|
|
1249
|
+
], [voucherData.overlay ? 'true' : 'false'], text => {
|
|
1250
|
+
voucherData.overlay = text[0] === 'true';
|
|
1251
|
+
gvc.notifyDataChange(id);
|
|
1252
|
+
}, { single: true })}`;
|
|
1253
|
+
}
|
|
1254
|
+
function isIncludeDiscount() {
|
|
1255
|
+
return html ` <div class="tx_700">消費金額於其他折扣觸發時機</div>
|
|
1256
|
+
${BgWidget.mbContainer(18)}
|
|
1257
|
+
${BgWidget.multiCheckboxContainer(gvc, [
|
|
1258
|
+
{
|
|
1259
|
+
key: 'before',
|
|
1260
|
+
name: '觸發前',
|
|
1261
|
+
innerHtml: BgWidget.grayNote('在其他折扣觸發前,訂單的消費金額將做為達成消費條件的金額,來判斷是否可使用此優惠券'),
|
|
1262
|
+
},
|
|
1263
|
+
{
|
|
1264
|
+
key: 'after',
|
|
1265
|
+
name: '觸發後',
|
|
1266
|
+
innerHtml: BgWidget.grayNote('將訂單的消費金額包含其他折扣後,做為達成消費條件的金額,來判斷是否可使用此優惠券'),
|
|
1267
|
+
},
|
|
1268
|
+
], [voucherData.includeDiscount], text => {
|
|
1269
|
+
voucherData.includeDiscount = text[0];
|
|
1270
|
+
gvc.notifyDataChange(pageVM.conditionID);
|
|
1271
|
+
}, {
|
|
1272
|
+
single: true,
|
|
1273
|
+
})}`;
|
|
1274
|
+
}
|
|
1275
|
+
return [overlay(), voucherData.overlay ? isIncludeDiscount() : '']
|
|
1276
|
+
.filter(Boolean)
|
|
1277
|
+
.join(BgWidget.horizontalLine());
|
|
1233
1278
|
},
|
|
1234
1279
|
};
|
|
1235
1280
|
})),
|
|
1236
1281
|
BgWidget.mainCard(gvc.bindView(() => {
|
|
1237
1282
|
const id = glitter.getUUID();
|
|
1283
|
+
const inputStyle = 'display: block; width: 200px;';
|
|
1238
1284
|
return {
|
|
1239
1285
|
bind: id,
|
|
1240
1286
|
view: () => {
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
html ` <div class="tx_700">全館總使用次數</div>
|
|
1287
|
+
function storeUseTimeLimit() {
|
|
1288
|
+
var _a;
|
|
1289
|
+
return html ` <div class="tx_700">全館總使用次數</div>
|
|
1245
1290
|
${BgWidget.mbContainer(18)}
|
|
1246
1291
|
${BgWidget.multiCheckboxContainer(gvc, [
|
|
1247
1292
|
{
|
|
@@ -1271,8 +1316,11 @@ export class ShoppingDiscountSetting {
|
|
|
1271
1316
|
if (text[0] === 'noLimited') {
|
|
1272
1317
|
voucherData.macroLimited = 0;
|
|
1273
1318
|
}
|
|
1274
|
-
}, { single: true })}
|
|
1275
|
-
|
|
1319
|
+
}, { single: true })}`;
|
|
1320
|
+
}
|
|
1321
|
+
function memberUseTimeLimit() {
|
|
1322
|
+
var _a;
|
|
1323
|
+
return html ` <div class="tx_700">個人總使用次數</div>
|
|
1276
1324
|
${BgWidget.mbContainer(18)}
|
|
1277
1325
|
${BgWidget.multiCheckboxContainer(gvc, [
|
|
1278
1326
|
{
|
|
@@ -1289,7 +1337,7 @@ export class ShoppingDiscountSetting {
|
|
|
1289
1337
|
title: '',
|
|
1290
1338
|
type: 'number',
|
|
1291
1339
|
divStyle: 'width: 150px;',
|
|
1292
|
-
default: `${(
|
|
1340
|
+
default: `${(_a = voucherData.microLimited) !== null && _a !== void 0 ? _a : 0}`,
|
|
1293
1341
|
placeHolder: '',
|
|
1294
1342
|
callback: text => {
|
|
1295
1343
|
voucherData.microLimited = parseInt(text, 10);
|
|
@@ -1302,57 +1350,10 @@ export class ShoppingDiscountSetting {
|
|
|
1302
1350
|
if (text[0] === 'noLimited') {
|
|
1303
1351
|
voucherData.microLimited = 0;
|
|
1304
1352
|
}
|
|
1305
|
-
}, { single: true })}
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
return [
|
|
1310
|
-
[
|
|
1311
|
-
`<div class="tx_700">購物金有效天數</div>`,
|
|
1312
|
-
BgWidget.multiCheckboxContainer(gvc, [
|
|
1313
|
-
{
|
|
1314
|
-
key: 'noEnd',
|
|
1315
|
-
name: '無期限',
|
|
1316
|
-
},
|
|
1317
|
-
{
|
|
1318
|
-
key: 'withEnd',
|
|
1319
|
-
name: '有效期限',
|
|
1320
|
-
innerHtml: html ` <div
|
|
1321
|
-
class="d-flex mt-0 mt-md-3 ${document.body.clientWidth < 768
|
|
1322
|
-
? 'flex-column'
|
|
1323
|
-
: ''}"
|
|
1324
|
-
style="gap: 12px"
|
|
1325
|
-
>
|
|
1326
|
-
<div class="d-flex align-items-center" style="gap:10px;">
|
|
1327
|
-
${BgWidget.editeInput({
|
|
1328
|
-
gvc: gvc,
|
|
1329
|
-
title: '',
|
|
1330
|
-
type: 'number',
|
|
1331
|
-
style: inputStyle,
|
|
1332
|
-
default: `${(_a = voucherData.rebateEndDay) !== null && _a !== void 0 ? _a : ''}`,
|
|
1333
|
-
placeHolder: '0則為無期限',
|
|
1334
|
-
callback: text => {
|
|
1335
|
-
voucherData.rebateEndDay = text;
|
|
1336
|
-
gvc.notifyDataChange(id);
|
|
1337
|
-
},
|
|
1338
|
-
})}
|
|
1339
|
-
<span class="tx_normal me-2">天</span>
|
|
1340
|
-
</div>
|
|
1341
|
-
</div>`,
|
|
1342
|
-
},
|
|
1343
|
-
], [parseInt((_b = voucherData.rebateEndDay) !== null && _b !== void 0 ? _b : '0', 10) ? `withEnd` : `noEnd`], text => {
|
|
1344
|
-
if (text[0] === 'noEnd') {
|
|
1345
|
-
voucherData.rebateEndDay = '0';
|
|
1346
|
-
}
|
|
1347
|
-
}, { single: true }),
|
|
1348
|
-
].join('<div class="my-2"></div>'),
|
|
1349
|
-
];
|
|
1350
|
-
}
|
|
1351
|
-
else {
|
|
1352
|
-
return [];
|
|
1353
|
-
}
|
|
1354
|
-
})(),
|
|
1355
|
-
html ` <div class="tx_700">優惠券有效日期</div>
|
|
1353
|
+
}, { single: true })}`;
|
|
1354
|
+
}
|
|
1355
|
+
function startDateTime() {
|
|
1356
|
+
return html ` <div class="tx_700">優惠券有效日期</div>
|
|
1356
1357
|
<div
|
|
1357
1358
|
class="d-flex mb-3 ${document.body.clientWidth < 768 ? 'flex-column' : ''}"
|
|
1358
1359
|
style="gap: 12px"
|
|
@@ -1435,16 +1436,64 @@ export class ShoppingDiscountSetting {
|
|
|
1435
1436
|
voucherData.endDate = undefined;
|
|
1436
1437
|
voucherData.endTime = undefined;
|
|
1437
1438
|
}
|
|
1438
|
-
}, { single: true })}
|
|
1439
|
+
}, { single: true })}`;
|
|
1440
|
+
}
|
|
1441
|
+
function rebateEndDay() {
|
|
1442
|
+
var _a, _b;
|
|
1443
|
+
return [
|
|
1444
|
+
html `<div class="tx_700">購物金有效天數</div>`,
|
|
1445
|
+
BgWidget.multiCheckboxContainer(gvc, [
|
|
1446
|
+
{
|
|
1447
|
+
key: 'noEnd',
|
|
1448
|
+
name: '無期限',
|
|
1449
|
+
},
|
|
1450
|
+
{
|
|
1451
|
+
key: 'withEnd',
|
|
1452
|
+
name: '有效期限',
|
|
1453
|
+
innerHtml: html ` <div
|
|
1454
|
+
class="d-flex mt-0 mt-md-3 ${document.body.clientWidth < 768
|
|
1455
|
+
? 'flex-column'
|
|
1456
|
+
: ''}"
|
|
1457
|
+
style="gap: 12px"
|
|
1458
|
+
>
|
|
1459
|
+
<div class="d-flex align-items-center" style="gap:10px;">
|
|
1460
|
+
${BgWidget.editeInput({
|
|
1461
|
+
gvc: gvc,
|
|
1462
|
+
title: '',
|
|
1463
|
+
type: 'number',
|
|
1464
|
+
style: inputStyle,
|
|
1465
|
+
default: `${(_a = voucherData.rebateEndDay) !== null && _a !== void 0 ? _a : ''}`,
|
|
1466
|
+
placeHolder: '0則為無期限',
|
|
1467
|
+
callback: text => {
|
|
1468
|
+
voucherData.rebateEndDay = text;
|
|
1469
|
+
gvc.notifyDataChange(id);
|
|
1470
|
+
},
|
|
1471
|
+
})}
|
|
1472
|
+
<span class="tx_normal me-2">天</span>
|
|
1473
|
+
</div>
|
|
1474
|
+
</div>`,
|
|
1475
|
+
},
|
|
1476
|
+
], [parseInt((_b = voucherData.rebateEndDay) !== null && _b !== void 0 ? _b : '0', 10) ? `withEnd` : `noEnd`], text => {
|
|
1477
|
+
if (text[0] === 'noEnd') {
|
|
1478
|
+
voucherData.rebateEndDay = '0';
|
|
1479
|
+
}
|
|
1480
|
+
}, { single: true }),
|
|
1481
|
+
].join(html `<div class="my-2"></div>`);
|
|
1482
|
+
}
|
|
1483
|
+
return [
|
|
1484
|
+
storeUseTimeLimit(),
|
|
1485
|
+
memberUseTimeLimit(),
|
|
1486
|
+
voucherData.reBackType === 'rebate' ? rebateEndDay() : '',
|
|
1487
|
+
startDateTime(),
|
|
1439
1488
|
]
|
|
1440
|
-
.filter(
|
|
1441
|
-
return dd;
|
|
1442
|
-
})
|
|
1489
|
+
.filter(Boolean)
|
|
1443
1490
|
.join(BgWidget.horizontalLine());
|
|
1444
1491
|
},
|
|
1445
1492
|
};
|
|
1446
1493
|
})),
|
|
1447
|
-
]
|
|
1494
|
+
]
|
|
1495
|
+
.filter(Boolean)
|
|
1496
|
+
.join(BgWidget.mbContainer(24)),
|
|
1448
1497
|
ratio: 68,
|
|
1449
1498
|
}, {
|
|
1450
1499
|
html: gvc.bindView(() => {
|
|
@@ -1455,27 +1504,19 @@ export class ShoppingDiscountSetting {
|
|
|
1455
1504
|
return { obj: voucherData, key };
|
|
1456
1505
|
}),
|
|
1457
1506
|
view: () => {
|
|
1458
|
-
return BgWidget.mainCard(
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
${
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
${text}
|
|
1472
|
-
</div>`;
|
|
1473
|
-
}))}
|
|
1474
|
-
</div>
|
|
1475
|
-
`;
|
|
1476
|
-
},
|
|
1477
|
-
};
|
|
1478
|
-
}));
|
|
1507
|
+
return BgWidget.mainCard(html `
|
|
1508
|
+
<div class="tx_700">摘要</div>
|
|
1509
|
+
${BgWidget.mbContainer(18)}
|
|
1510
|
+
<div style="display: flex; gap: 12px; flex-direction: column;">
|
|
1511
|
+
${summaryTextList()
|
|
1512
|
+
.map(text => {
|
|
1513
|
+
return html ` <div class="${text.length > 0 ? 'tx_normal' : 'gray-top-bottom-line-6'}">
|
|
1514
|
+
${text}
|
|
1515
|
+
</div>`;
|
|
1516
|
+
})
|
|
1517
|
+
.join('')}
|
|
1518
|
+
</div>
|
|
1519
|
+
`);
|
|
1479
1520
|
},
|
|
1480
1521
|
divCreate: {
|
|
1481
1522
|
class: 'summary-card p-0',
|
|
@@ -1524,7 +1565,6 @@ export class ShoppingDiscountSetting {
|
|
|
1524
1565
|
voucherData.end_ISO_Date = new Date(`${voucherData.endDate} ${voucherData.endTime}`).toISOString();
|
|
1525
1566
|
},
|
|
1526
1567
|
]);
|
|
1527
|
-
const dialog = new ShareDialog(gvc.glitter);
|
|
1528
1568
|
if (obj.type === 'replace') {
|
|
1529
1569
|
dialog.dataLoading({ text: '正在更新優惠券', visible: true });
|
|
1530
1570
|
ApiShop.putVoucher({
|