ts-glitter 21.8.3 → 21.8.6
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-dialog.js +342 -100
- package/lowcode/backend-manager/bg-dialog.ts +432 -145
- package/lowcode/backend-manager/bg-widget.js +4 -4
- package/lowcode/backend-manager/bg-widget.ts +5 -5
- package/lowcode/cms-plugin/POS-setting.js +18 -6
- package/lowcode/cms-plugin/POS-setting.ts +22 -10
- package/lowcode/cms-plugin/pos-pages/payment-page.js +9 -2
- package/lowcode/cms-plugin/pos-pages/payment-page.ts +11 -3
- package/lowcode/cms-plugin/shopping-discount-setting.js +148 -92
- package/lowcode/cms-plugin/shopping-discount-setting.ts +162 -111
- package/lowcode/cms-plugin/shopping-product-stock.js +58 -45
- package/lowcode/cms-plugin/shopping-product-stock.ts +66 -49
- package/lowcode/cms-plugin/stock-stores.js +55 -0
- package/lowcode/cms-plugin/stock-stores.ts +59 -0
- package/lowcode/css/editor.css +8 -9
- package/lowcode/editor/basic-component.js +0 -10
- package/lowcode/editor/basic-component.ts +1 -11
- package/lowcode/glitter-base/route/article.js +50 -51
- package/lowcode/glitter-base/route/article.ts +102 -103
- package/lowcode/glitter-base/route/recommend.js +1 -0
- package/lowcode/glitter-base/route/recommend.ts +141 -123
- package/lowcode/glitterBundle/plugins/html-render.js +2 -0
- package/lowcode/glitterBundle/plugins/html-render.ts +1 -0
- package/lowcode/jspage/function-page/setting_editor.js +1 -1
- package/lowcode/jspage/function-page/setting_editor.ts +1 -1
- package/lowcode/jspage/function-page/tool-setting.js +0 -1
- package/lowcode/jspage/function-page/tool-setting.ts +0 -1
- package/lowcode/jspage/main.js +6 -1
- package/lowcode/jspage/main.ts +6 -1
- package/lowcode/modules/image-library-clone.ts +2 -0
- package/lowcode/modules/image-library.js +118 -155
- package/lowcode/modules/image-library.ts +134 -197
- package/lowcode/official_view_component/official/component.js +1 -1
- package/lowcode/official_view_component/official/component.ts +1 -1
- package/lowcode/public-components/banner/first-banner.js +85 -50
- package/lowcode/public-components/banner/first-banner.ts +96 -59
- package/lowcode/public-components/layout-plugin/social-links-01.js +19 -19
- package/lowcode/public-components/layout-plugin/social-links-01.ts +35 -35
- package/package.json +1 -1
- package/src/api-public/controllers/article.js +11 -0
- package/src/api-public/controllers/article.js.map +1 -1
- package/src/api-public/controllers/article.ts +13 -0
- package/src/api-public/controllers/recommend.js +1 -0
- package/src/api-public/controllers/recommend.js.map +1 -1
- package/src/api-public/controllers/recommend.ts +99 -89
- package/src/api-public/services/checkout-event.js +81 -43
- package/src/api-public/services/checkout-event.js.map +1 -1
- package/src/api-public/services/checkout-event.ts +93 -38
- package/src/api-public/services/post.js +7 -17
- package/src/api-public/services/post.js.map +1 -1
- package/src/api-public/services/recommend.d.ts +1 -0
- package/src/api-public/services/recommend.js +12 -2
- package/src/api-public/services/recommend.js.map +1 -1
- package/src/api-public/services/recommend.ts +375 -354
- package/src/api-public/services/shopping.d.ts +1 -0
- package/src/api-public/services/shopping.js +4 -2
- package/src/api-public/services/shopping.js.map +1 -1
- package/src/api-public/services/shopping.ts +7 -2
- package/src/services/saas-table-check.js +1 -1
- package/src/services/saas-table-check.js.map +1 -1
- package/src/services/saas-table-check.ts +1 -1
|
@@ -1023,7 +1023,7 @@ ${obj.default ?? ''}</textarea
|
|
|
1023
1023
|
</div>`;
|
|
1024
1024
|
}
|
|
1025
1025
|
|
|
1026
|
-
static searchPlace(event: string,
|
|
1026
|
+
static searchPlace(event: string, value: string, placeholder: string, margin?: string, padding?: string) {
|
|
1027
1027
|
const defMargin = document.body.clientWidth > 768 ? '16px 0' : '8px 0';
|
|
1028
1028
|
const defPadding = document.body.clientWidth > 768 ? '0 16px' : '0';
|
|
1029
1029
|
return html`
|
|
@@ -1039,7 +1039,7 @@ ${obj.default ?? ''}</textarea
|
|
|
1039
1039
|
style="border-radius: 10px; border: 1px solid #DDD; padding-left: 50px;"
|
|
1040
1040
|
placeholder="${placeholder}"
|
|
1041
1041
|
onchange="${event}"
|
|
1042
|
-
value="${
|
|
1042
|
+
value="${value}"
|
|
1043
1043
|
/>
|
|
1044
1044
|
</div>
|
|
1045
1045
|
</div>
|
|
@@ -2088,7 +2088,7 @@ ${obj.default ?? ''}</textarea
|
|
|
2088
2088
|
gvc: GVC;
|
|
2089
2089
|
filter: TableV3Filter[]; // 批量編輯與刪除物件陣列
|
|
2090
2090
|
getData: (vm: TableV3) => void; // 非同步取得資料陣列事件
|
|
2091
|
-
rowClick: (data: any, index: number) => void; // row 點擊事件
|
|
2091
|
+
rowClick: (data: any, index: number, element: any, event: any) => void; // row 點擊事件
|
|
2092
2092
|
hiddenPageSplit?: boolean; // 表格頁面導覽列
|
|
2093
2093
|
defPage?: number; // 預設顯示第幾頁
|
|
2094
2094
|
itemSelect?: () => void;
|
|
@@ -2451,8 +2451,8 @@ ${obj.default ?? ''}</textarea
|
|
|
2451
2451
|
class="${trIndex === 0 ? ids.tr : ''} ${dd.find(d3 => d3.tooltip)
|
|
2452
2452
|
? 'tr-tooltip-container'
|
|
2453
2453
|
: ''}"
|
|
2454
|
-
onclick="${gvc.event(() => {
|
|
2455
|
-
obj.rowClick && obj.rowClick(dd, trIndex);
|
|
2454
|
+
onclick="${gvc.event((e, event) => {
|
|
2455
|
+
obj.rowClick && obj.rowClick(dd, trIndex, e, event);
|
|
2456
2456
|
})}"
|
|
2457
2457
|
onmouseover="${gvc.event(() => {
|
|
2458
2458
|
$(`#${ids.pencil}${trIndex}`).removeClass('d-none');
|
|
@@ -347,6 +347,13 @@ export class POSSetting {
|
|
|
347
347
|
});
|
|
348
348
|
return product.content.variants.find((variant) => arraysEqual(variant.spec, emptyArray));
|
|
349
349
|
}
|
|
350
|
+
data.content.specs.map((dd, index) => {
|
|
351
|
+
dd.option.map((d1, index) => {
|
|
352
|
+
d1.select = index === 0;
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
selectVariant = changeSelectVariant(data);
|
|
356
|
+
obj.callback(selectVariant);
|
|
350
357
|
gvc.glitter.innerDialog(gvc => {
|
|
351
358
|
return gvc.bindView({
|
|
352
359
|
bind: 'productDialog',
|
|
@@ -354,10 +361,14 @@ export class POSSetting {
|
|
|
354
361
|
var _a;
|
|
355
362
|
try {
|
|
356
363
|
selectVariant.preview_image = selectVariant.preview_image || [];
|
|
357
|
-
selectVariant.stock =
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
364
|
+
selectVariant.stock = gvc.glitter.share.store_list.filter((dd) => {
|
|
365
|
+
var _a;
|
|
366
|
+
return (dd.id === POSSetting.config.where_store) || ((_a = gvc.glitter.share.store_list.find((dd) => {
|
|
367
|
+
return dd.id === POSSetting.config.where_store;
|
|
368
|
+
}).support_store) !== null && _a !== void 0 ? _a : []).includes(dd.id);
|
|
369
|
+
}).map((d1) => {
|
|
370
|
+
return selectVariant.stockList[d1.id].count;
|
|
371
|
+
}).reduce((acc, val) => acc + val, 0);
|
|
361
372
|
return html ` <div
|
|
362
373
|
class="w-100 h-100 d-flex align-items-center justify-content-center"
|
|
363
374
|
onclick="${gvc.event(() => gvc.glitter.closeDiaLog())}"
|
|
@@ -507,7 +518,7 @@ export class POSSetting {
|
|
|
507
518
|
</div>
|
|
508
519
|
${selectVariant.show_understocking === 'false'
|
|
509
520
|
? ''
|
|
510
|
-
: BgWidget.blueNote('
|
|
521
|
+
: BgWidget.blueNote('查看各庫存點數量', gvc.event(() => {
|
|
511
522
|
BgWidget.settingDialog({
|
|
512
523
|
gvc,
|
|
513
524
|
title: '其他庫存點',
|
|
@@ -528,7 +539,7 @@ export class POSSetting {
|
|
|
528
539
|
return dataList.map((dd) => {
|
|
529
540
|
return [
|
|
530
541
|
{
|
|
531
|
-
key: '
|
|
542
|
+
key: '門市/庫存點',
|
|
532
543
|
value: `<span class="fs-7">${dd.name}</span>`,
|
|
533
544
|
},
|
|
534
545
|
{
|
|
@@ -540,6 +551,7 @@ export class POSSetting {
|
|
|
540
551
|
}
|
|
541
552
|
ApiUser.getPublicConfig('store_manager', 'manager').then((dd) => {
|
|
542
553
|
var _a;
|
|
554
|
+
console.log(`selectVariant===>`, selectVariant);
|
|
543
555
|
if (dd.result && Array.isArray((_a = dd.response.value) === null || _a === void 0 ? void 0 : _a.list)) {
|
|
544
556
|
dd.response.value.list.map((store) => {
|
|
545
557
|
var _a, _b, _c;
|
|
@@ -385,6 +385,7 @@ export class POSSetting {
|
|
|
385
385
|
const data = obj.defaultData;
|
|
386
386
|
const orderDetail = obj.orderDetail;
|
|
387
387
|
let selectVariant = obj.selectVariant;
|
|
388
|
+
|
|
388
389
|
let count = 1;
|
|
389
390
|
|
|
390
391
|
function arraysEqual(arr1: any[], arr2: any[]) {
|
|
@@ -399,7 +400,13 @@ export class POSSetting {
|
|
|
399
400
|
});
|
|
400
401
|
return product.content.variants.find((variant: any) => arraysEqual(variant.spec, emptyArray));
|
|
401
402
|
}
|
|
402
|
-
|
|
403
|
+
data.content.specs.map((dd:any,index:number)=>{
|
|
404
|
+
dd.option.map((d1:any,index:number)=>{
|
|
405
|
+
d1.select = index===0;
|
|
406
|
+
})
|
|
407
|
+
});
|
|
408
|
+
selectVariant = changeSelectVariant(data);
|
|
409
|
+
obj.callback(selectVariant);
|
|
403
410
|
gvc.glitter.innerDialog(
|
|
404
411
|
gvc => {
|
|
405
412
|
return gvc.bindView({
|
|
@@ -407,10 +414,16 @@ export class POSSetting {
|
|
|
407
414
|
view: () => {
|
|
408
415
|
try {
|
|
409
416
|
selectVariant.preview_image = selectVariant.preview_image || [];
|
|
410
|
-
selectVariant.stock =
|
|
411
|
-
(
|
|
412
|
-
|
|
413
|
-
|
|
417
|
+
selectVariant.stock = gvc.glitter.share.store_list.filter((dd:any)=>{
|
|
418
|
+
return (dd.id===POSSetting.config.where_store) || (
|
|
419
|
+
gvc.glitter.share.store_list.find((dd:any)=>{
|
|
420
|
+
return dd.id === POSSetting.config.where_store;
|
|
421
|
+
}).support_store ?? []
|
|
422
|
+
).includes(dd.id);
|
|
423
|
+
}).map((d1:any)=>{
|
|
424
|
+
return selectVariant.stockList[d1.id].count
|
|
425
|
+
}).reduce((acc: any, val: any) => acc + val,0)
|
|
426
|
+
|
|
414
427
|
|
|
415
428
|
return html` <div
|
|
416
429
|
class="w-100 h-100 d-flex align-items-center justify-content-center"
|
|
@@ -453,7 +466,7 @@ export class POSSetting {
|
|
|
453
466
|
'zh-TW': string;
|
|
454
467
|
};
|
|
455
468
|
}[] = data.content.specs;
|
|
456
|
-
|
|
469
|
+
|
|
457
470
|
return productSpecs
|
|
458
471
|
.map((spec, index1) => {
|
|
459
472
|
return html` <div>
|
|
@@ -577,7 +590,7 @@ export class POSSetting {
|
|
|
577
590
|
${selectVariant.show_understocking === 'false'
|
|
578
591
|
? ''
|
|
579
592
|
: BgWidget.blueNote(
|
|
580
|
-
'
|
|
593
|
+
'查看各庫存點數量',
|
|
581
594
|
gvc.event(() => {
|
|
582
595
|
BgWidget.settingDialog({
|
|
583
596
|
gvc,
|
|
@@ -588,7 +601,6 @@ export class POSSetting {
|
|
|
588
601
|
filter: [],
|
|
589
602
|
getData: vmi => {
|
|
590
603
|
const dataList: { name: string; count: number }[] = [];
|
|
591
|
-
|
|
592
604
|
function callback() {
|
|
593
605
|
vmi.pageSize = 1;
|
|
594
606
|
vmi.originalData = dataList;
|
|
@@ -596,12 +608,11 @@ export class POSSetting {
|
|
|
596
608
|
vmi.loading = false;
|
|
597
609
|
vmi.callback();
|
|
598
610
|
}
|
|
599
|
-
|
|
600
611
|
function getDatalist() {
|
|
601
612
|
return dataList.map((dd: any) => {
|
|
602
613
|
return [
|
|
603
614
|
{
|
|
604
|
-
key: '
|
|
615
|
+
key: '門市/庫存點',
|
|
605
616
|
value: `<span class="fs-7">${dd.name}</span>`,
|
|
606
617
|
},
|
|
607
618
|
{
|
|
@@ -613,6 +624,7 @@ export class POSSetting {
|
|
|
613
624
|
}
|
|
614
625
|
|
|
615
626
|
ApiUser.getPublicConfig('store_manager', 'manager').then((dd: any) => {
|
|
627
|
+
console.log(`selectVariant===>`,selectVariant)
|
|
616
628
|
if (dd.result && Array.isArray(dd.response.value?.list)) {
|
|
617
629
|
dd.response.value.list.map((store: any) => {
|
|
618
630
|
const n = selectVariant.stockList?.[store.id]?.count ?? 0;
|
|
@@ -228,8 +228,15 @@ export class PaymentPage {
|
|
|
228
228
|
if (`${data.show_understocking}` === 'false') {
|
|
229
229
|
return '不追蹤庫存';
|
|
230
230
|
}
|
|
231
|
-
const stock =
|
|
232
|
-
|
|
231
|
+
const stock = gvc.glitter.share.store_list.filter((dd) => {
|
|
232
|
+
var _a;
|
|
233
|
+
return (dd.id === POSSetting.config.where_store) || ((_a = gvc.glitter.share.store_list.find((dd) => {
|
|
234
|
+
return dd.id === POSSetting.config.where_store;
|
|
235
|
+
}).support_store) !== null && _a !== void 0 ? _a : []).includes(dd.id);
|
|
236
|
+
}).map((d1) => {
|
|
237
|
+
return data.stockList[d1.id].count;
|
|
238
|
+
}).reduce((acc, val) => acc + val, 0);
|
|
239
|
+
return `庫存: ${stock || 0}`;
|
|
233
240
|
})()}
|
|
234
241
|
</div>
|
|
235
242
|
</div>
|
|
@@ -265,9 +265,17 @@ export class PaymentPage {
|
|
|
265
265
|
if (`${data.show_understocking}` === 'false') {
|
|
266
266
|
return '不追蹤庫存';
|
|
267
267
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
268
|
+
const stock = gvc.glitter.share.store_list.filter((dd:any)=>{
|
|
269
|
+
return (dd.id===POSSetting.config.where_store) || (
|
|
270
|
+
gvc.glitter.share.store_list.find((dd:any)=>{
|
|
271
|
+
return dd.id === POSSetting.config.where_store;
|
|
272
|
+
}).support_store ?? []
|
|
273
|
+
).includes(dd.id);
|
|
274
|
+
}).map((d1:any)=>{
|
|
275
|
+
return data.stockList[d1.id].count
|
|
276
|
+
}).reduce((acc: any, val: any) => acc + val,0)
|
|
277
|
+
|
|
278
|
+
return `庫存: ${stock || 0}`;
|
|
271
279
|
})()}
|
|
272
280
|
</div>
|
|
273
281
|
</div>
|
|
@@ -18,6 +18,8 @@ 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
20
|
import { BgDialog } from '../backend-manager/bg-dialog.js';
|
|
21
|
+
import { Article } from '../glitter-base/route/article.js';
|
|
22
|
+
import { ApiRecommend } from '../glitter-base/route/recommend.js';
|
|
21
23
|
const html = String.raw;
|
|
22
24
|
export class ShoppingDiscountSetting {
|
|
23
25
|
static main(gvc, voucher_type) {
|
|
@@ -63,7 +65,7 @@ export class ShoppingDiscountSetting {
|
|
|
63
65
|
const triggerLabels = {
|
|
64
66
|
auto: '自動',
|
|
65
67
|
code: '輸入代碼',
|
|
66
|
-
distribution: '
|
|
68
|
+
distribution: '特定賣場',
|
|
67
69
|
};
|
|
68
70
|
function getDatalist() {
|
|
69
71
|
return data.response.data.map((dd) => {
|
|
@@ -199,7 +201,7 @@ export class ShoppingDiscountSetting {
|
|
|
199
201
|
if (voucherData.trigger === 'auto')
|
|
200
202
|
return '自動折扣';
|
|
201
203
|
if (voucherData.trigger === 'distribution')
|
|
202
|
-
return '
|
|
204
|
+
return '特定賣場使用';
|
|
203
205
|
if (voucherData.trigger === 'code')
|
|
204
206
|
return `優惠代碼「${(_b = voucherData.code) !== null && _b !== void 0 ? _b : ''}」`;
|
|
205
207
|
return '';
|
|
@@ -263,6 +265,7 @@ export class ShoppingDiscountSetting {
|
|
|
263
265
|
const vm = obj.vm;
|
|
264
266
|
const glitter = gvc.glitter;
|
|
265
267
|
const dialog = new ShareDialog(glitter);
|
|
268
|
+
const bgDialog = new BgDialog(gvc);
|
|
266
269
|
const getUUID = glitter.getUUID;
|
|
267
270
|
const pageVM = {
|
|
268
271
|
viewID: getUUID(),
|
|
@@ -369,7 +372,7 @@ export class ShoppingDiscountSetting {
|
|
|
369
372
|
{
|
|
370
373
|
key: 'distribution',
|
|
371
374
|
name: '供特定賣場優惠使用',
|
|
372
|
-
innerHtml: BgWidget.grayNote('僅限於隱形賣場 / 一頁商店 /
|
|
375
|
+
innerHtml: BgWidget.grayNote('僅限於隱形賣場 / 一頁商店 / 分銷連結使用'),
|
|
373
376
|
},
|
|
374
377
|
], [voucherData.trigger], text => {
|
|
375
378
|
if (text[0] === 'auto') {
|
|
@@ -1386,28 +1389,12 @@ export class ShoppingDiscountSetting {
|
|
|
1386
1389
|
if (voucherData.trigger !== 'distribution') {
|
|
1387
1390
|
return '';
|
|
1388
1391
|
}
|
|
1392
|
+
const id = 'apply_shop_view';
|
|
1389
1393
|
const prefix = Tool.randomString(6);
|
|
1390
|
-
|
|
1391
|
-
|
|
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
|
-
};
|
|
1394
|
+
let loading = true;
|
|
1395
|
+
let dataList = [];
|
|
1408
1396
|
gvc.addStyle(`
|
|
1409
1397
|
.${prefix}_container {
|
|
1410
|
-
max-width: 800px;
|
|
1411
1398
|
margin: 0 auto;
|
|
1412
1399
|
background-color: #fff;
|
|
1413
1400
|
border-radius: 8px;
|
|
@@ -1417,9 +1404,9 @@ export class ShoppingDiscountSetting {
|
|
|
1417
1404
|
.${prefix}_table {
|
|
1418
1405
|
width: 100%;
|
|
1419
1406
|
border-collapse: collapse;
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1407
|
+
overflow-x: auto;
|
|
1408
|
+
white-space: nowrap;
|
|
1409
|
+
${bgDialog.isMobile ? 'display: block;' : ''}
|
|
1423
1410
|
}
|
|
1424
1411
|
|
|
1425
1412
|
.${prefix}_th {
|
|
@@ -1473,13 +1460,21 @@ export class ShoppingDiscountSetting {
|
|
|
1473
1460
|
.${prefix}_expend:hover {
|
|
1474
1461
|
background-color: #f9fafb;
|
|
1475
1462
|
}
|
|
1463
|
+
|
|
1464
|
+
.${prefix}_none_text {
|
|
1465
|
+
text-align: center;
|
|
1466
|
+
padding: 18px 0;
|
|
1467
|
+
}
|
|
1476
1468
|
`);
|
|
1477
1469
|
return gvc.bindView({
|
|
1478
|
-
bind:
|
|
1470
|
+
bind: id,
|
|
1479
1471
|
view: () => {
|
|
1472
|
+
if (loading) {
|
|
1473
|
+
return BgWidget.spinner();
|
|
1474
|
+
}
|
|
1480
1475
|
return html `<div class="${prefix}_container">
|
|
1481
|
-
<table id="
|
|
1482
|
-
<thead
|
|
1476
|
+
<table id="apply-shop-table" class="${prefix}_table">
|
|
1477
|
+
<thead>
|
|
1483
1478
|
<tr class="${prefix}_tr">
|
|
1484
1479
|
<th class="${prefix}_th">賣場類型</th>
|
|
1485
1480
|
<th class="${prefix}_th">賣場名稱</th>
|
|
@@ -1490,86 +1485,139 @@ export class ShoppingDiscountSetting {
|
|
|
1490
1485
|
<!-- 資料將由 JavaScript 動態填入 -->
|
|
1491
1486
|
</tbody>
|
|
1492
1487
|
</table>
|
|
1493
|
-
<div id="
|
|
1488
|
+
<div id="apply-shop-div">
|
|
1494
1489
|
<!-- 資料將由 JavaScript 動態填入 -->
|
|
1495
1490
|
</div>
|
|
1496
1491
|
</div>`;
|
|
1497
1492
|
},
|
|
1498
|
-
divCreate: {},
|
|
1499
1493
|
onCreate: () => {
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
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;
|
|
1494
|
+
function render() {
|
|
1495
|
+
const tableBody = document.querySelector('#apply-shop-table tbody');
|
|
1496
|
+
const tableDiv = document.querySelector('#apply-shop-div');
|
|
1497
|
+
if (!tableBody || !tableDiv) {
|
|
1498
|
+
return;
|
|
1543
1499
|
}
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1500
|
+
tableBody.innerHTML = '';
|
|
1501
|
+
if (voucherData.distribution_shop.length === 0) {
|
|
1502
|
+
const row = document.createElement('tr');
|
|
1503
|
+
row.className = `${prefix}_tr`;
|
|
1504
|
+
row.innerHTML = html `<td colspan="3" class="${prefix}_none_text">尚未選擇賣場</td>`;
|
|
1505
|
+
tableBody.appendChild(row);
|
|
1506
|
+
return;
|
|
1547
1507
|
}
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1508
|
+
const shopTypeRecord = bgDialog.shopTypeRecord();
|
|
1509
|
+
dataList.forEach(data => {
|
|
1510
|
+
const shopData = shopTypeRecord[data.type];
|
|
1511
|
+
const row = document.createElement('tr');
|
|
1512
|
+
row.className = `${prefix}_tr`;
|
|
1513
|
+
const referrerText = data.referrer ? data.referrer : '-';
|
|
1514
|
+
const referrerClass = data.referrer ? '' : `${prefix}_empty_referrer`;
|
|
1515
|
+
row.innerHTML = html `
|
|
1516
|
+
<td class="${prefix}_td ${prefix}_type_cell">${shopData.icon} ${shopData.title}</td>
|
|
1517
|
+
<td class="${prefix}_td">${data.name}</td>
|
|
1518
|
+
<td class="${prefix}_td ${referrerClass}">${referrerText}</td>
|
|
1519
|
+
`;
|
|
1520
|
+
tableBody.appendChild(row);
|
|
1521
|
+
});
|
|
1522
|
+
}
|
|
1523
|
+
if (loading) {
|
|
1524
|
+
if (voucherData.distribution_shop.length === 0) {
|
|
1525
|
+
loading = false;
|
|
1526
|
+
setTimeout(() => gvc.notifyDataChange(id), 100);
|
|
1527
|
+
return;
|
|
1528
|
+
}
|
|
1529
|
+
dataList = [];
|
|
1530
|
+
const articleIds = [];
|
|
1531
|
+
const recommendIds = [];
|
|
1532
|
+
voucherData.distribution_shop.map(item => {
|
|
1533
|
+
const [pageType, id] = item.split('-');
|
|
1534
|
+
pageType === 'recommend' ? recommendIds.push(id) : articleIds.push(id);
|
|
1535
|
+
});
|
|
1536
|
+
Promise.all([
|
|
1537
|
+
articleIds.length > 0
|
|
1538
|
+
? Article.get({
|
|
1539
|
+
page: 0,
|
|
1540
|
+
limit: 9999,
|
|
1541
|
+
search: vm.search || undefined,
|
|
1542
|
+
status: '0,1',
|
|
1543
|
+
id_list: articleIds.join(','),
|
|
1544
|
+
}).then(data => {
|
|
1545
|
+
var _b;
|
|
1546
|
+
return Array.isArray((_b = data.response) === null || _b === void 0 ? void 0 : _b.data) ? data.response.data : [];
|
|
1547
|
+
})
|
|
1548
|
+
: [],
|
|
1549
|
+
recommendIds.length > 0
|
|
1550
|
+
? ApiRecommend.getList({
|
|
1551
|
+
data: {},
|
|
1552
|
+
limit: 9999,
|
|
1553
|
+
page: 0,
|
|
1554
|
+
token: window.parent.config.token,
|
|
1555
|
+
id_list: recommendIds.join(','),
|
|
1556
|
+
}).then(data => {
|
|
1557
|
+
var _b;
|
|
1558
|
+
return Array.isArray((_b = data.response) === null || _b === void 0 ? void 0 : _b.data) ? data.response.data : [];
|
|
1559
|
+
})
|
|
1560
|
+
: [],
|
|
1561
|
+
]).then(dataArray => {
|
|
1562
|
+
const [article, recommend] = dataArray;
|
|
1563
|
+
article.map((item) => {
|
|
1564
|
+
dataList.push({
|
|
1565
|
+
type: item.content.page_type === 'hidden' ? 'hidden' : 'onepage',
|
|
1566
|
+
name: item.content.name,
|
|
1567
|
+
referrer: '-',
|
|
1568
|
+
});
|
|
1569
|
+
});
|
|
1570
|
+
recommend.map((item) => {
|
|
1571
|
+
var _b, _c;
|
|
1572
|
+
dataList.push({
|
|
1573
|
+
type: 'recommend',
|
|
1574
|
+
name: item.content.title,
|
|
1575
|
+
referrer: (_c = (_b = item.content.recommend_user) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : '-',
|
|
1576
|
+
});
|
|
1577
|
+
});
|
|
1578
|
+
loading = false;
|
|
1579
|
+
gvc.notifyDataChange(id);
|
|
1580
|
+
});
|
|
1581
|
+
}
|
|
1582
|
+
else {
|
|
1583
|
+
render();
|
|
1584
|
+
}
|
|
1557
1585
|
},
|
|
1558
1586
|
});
|
|
1559
1587
|
}
|
|
1560
1588
|
const reBackProductView = {
|
|
1561
|
-
rebate: {
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1589
|
+
rebate: {
|
|
1590
|
+
title: '活動商品',
|
|
1591
|
+
html: voucherData.for === 'all' ? '' : selectProduct(),
|
|
1592
|
+
},
|
|
1593
|
+
discount: {
|
|
1594
|
+
title: '活動商品',
|
|
1595
|
+
html: voucherData.for === 'all' ? '' : selectProduct(),
|
|
1596
|
+
},
|
|
1597
|
+
shipment_free: {
|
|
1598
|
+
title: '活動商品',
|
|
1599
|
+
html: '',
|
|
1600
|
+
},
|
|
1601
|
+
add_on_items: {
|
|
1602
|
+
title: '加購品項',
|
|
1603
|
+
html: [addProductView()].join(''),
|
|
1604
|
+
},
|
|
1605
|
+
giveaway: {
|
|
1606
|
+
title: '贈品品項',
|
|
1607
|
+
html: [addProductView()].join(''),
|
|
1608
|
+
},
|
|
1566
1609
|
};
|
|
1567
1610
|
const applyShopButton = BgWidget.customButton({
|
|
1568
1611
|
button: { color: 'gray', size: 'md' },
|
|
1569
1612
|
text: { name: '選擇賣場' },
|
|
1570
1613
|
event: gvc.event(() => {
|
|
1571
|
-
|
|
1572
|
-
|
|
1614
|
+
bgDialog.marketShop({
|
|
1615
|
+
def: voucherData.distribution_shop.slice(),
|
|
1616
|
+
callback: postData => {
|
|
1617
|
+
voucherData.distribution_shop = postData;
|
|
1618
|
+
gvc.notifyDataChange(pageVM.viewID);
|
|
1619
|
+
},
|
|
1620
|
+
});
|
|
1573
1621
|
}),
|
|
1574
1622
|
});
|
|
1575
1623
|
const viewList = [
|
|
@@ -1578,6 +1626,13 @@ export class ShoppingDiscountSetting {
|
|
|
1578
1626
|
{ title: '折扣方式', html: trigger() },
|
|
1579
1627
|
{ title: '適用訂單類型', html: device() },
|
|
1580
1628
|
],
|
|
1629
|
+
[
|
|
1630
|
+
{
|
|
1631
|
+
title: '套用賣場',
|
|
1632
|
+
button: applyShopButton,
|
|
1633
|
+
html: applyShop(),
|
|
1634
|
+
},
|
|
1635
|
+
],
|
|
1581
1636
|
[
|
|
1582
1637
|
{ title: '折扣設定', html: method() },
|
|
1583
1638
|
{ title: '使用條件', html: rule() },
|
|
@@ -1772,6 +1827,7 @@ ShoppingDiscountSetting.emptyVoucher = (reBackType) => {
|
|
|
1772
1827
|
includeDiscount: 'before',
|
|
1773
1828
|
productOffStart: 'price_desc',
|
|
1774
1829
|
selectShipment: { type: 'all', list: [] },
|
|
1830
|
+
distribution_shop: [],
|
|
1775
1831
|
};
|
|
1776
1832
|
};
|
|
1777
1833
|
window.glitter.setModule(import.meta.url, ShoppingDiscountSetting);
|