ts-glitter 21.3.1 → 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 +4 -2
- package/lowcode/backend-manager/bg-customer-message.ts +4 -2
- 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/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
|
@@ -44,6 +44,8 @@ export interface RowInitData {
|
|
|
44
44
|
save_stock: string;
|
|
45
45
|
barcode: string;
|
|
46
46
|
sub_title: string;
|
|
47
|
+
product_general_tag: string;
|
|
48
|
+
product_customize_tag: string;
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
export interface RowInitKitchen {
|
|
@@ -84,13 +86,17 @@ export class ProductExcel {
|
|
|
84
86
|
}
|
|
85
87
|
|
|
86
88
|
checkString(value: any): string {
|
|
87
|
-
|
|
89
|
+
try {
|
|
90
|
+
if (CheckInput.isEmpty(value)) {
|
|
91
|
+
return '';
|
|
92
|
+
}
|
|
93
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
94
|
+
return `${value}`;
|
|
95
|
+
}
|
|
96
|
+
return '';
|
|
97
|
+
} catch (error) {
|
|
88
98
|
return '';
|
|
89
99
|
}
|
|
90
|
-
if (typeof value === 'string' || typeof value === 'number') {
|
|
91
|
-
return `${value}`;
|
|
92
|
-
}
|
|
93
|
-
return '';
|
|
94
100
|
}
|
|
95
101
|
|
|
96
102
|
checkNumber(value: any) {
|
|
@@ -298,6 +304,8 @@ export class ProductExcel {
|
|
|
298
304
|
'安全庫存數量',
|
|
299
305
|
'商品條碼',
|
|
300
306
|
'商品簡述',
|
|
307
|
+
'商品標籤',
|
|
308
|
+
'管理員標籤',
|
|
301
309
|
];
|
|
302
310
|
}
|
|
303
311
|
|
|
@@ -359,6 +367,9 @@ export class ProductExcel {
|
|
|
359
367
|
'100',
|
|
360
368
|
'10',
|
|
361
369
|
'CODE1230',
|
|
370
|
+
'簡述內容',
|
|
371
|
+
'標籤A,標籤B',
|
|
372
|
+
'標籤C,標籤D',
|
|
362
373
|
],
|
|
363
374
|
[
|
|
364
375
|
'',
|
|
@@ -549,37 +560,39 @@ export class ProductExcel {
|
|
|
549
560
|
];
|
|
550
561
|
}
|
|
551
562
|
|
|
552
|
-
static getInitData = () =>
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
563
|
+
static getInitData = () => {
|
|
564
|
+
return {
|
|
565
|
+
name: '',
|
|
566
|
+
status: '',
|
|
567
|
+
category: '',
|
|
568
|
+
productType: '',
|
|
569
|
+
img: '',
|
|
570
|
+
SEO_domain: '',
|
|
571
|
+
SEO_title: '',
|
|
572
|
+
SEO_desc: '',
|
|
573
|
+
spec1: '',
|
|
574
|
+
spec1Value: '',
|
|
575
|
+
spec2: '',
|
|
576
|
+
spec2Value: '',
|
|
577
|
+
spec3: '',
|
|
578
|
+
spec3Value: '',
|
|
579
|
+
sku: '',
|
|
580
|
+
cost: '',
|
|
581
|
+
sale_price: '',
|
|
582
|
+
compare_price: '',
|
|
583
|
+
benefit: '',
|
|
584
|
+
shipment_type: '',
|
|
585
|
+
length: '',
|
|
586
|
+
width: '',
|
|
587
|
+
height: '',
|
|
588
|
+
weight: '',
|
|
589
|
+
weightUnit: '',
|
|
590
|
+
stockPolicy: '',
|
|
591
|
+
stock: '',
|
|
592
|
+
save_stock: '',
|
|
593
|
+
barcode: '',
|
|
594
|
+
};
|
|
595
|
+
};
|
|
583
596
|
|
|
584
597
|
static getProductTypeString(product: any) {
|
|
585
598
|
product.productType = product.productType ?? {
|
|
@@ -627,95 +640,55 @@ export class ProductExcel {
|
|
|
627
640
|
this.saveAsExcelFile(buffer, `${name}.xlsx`);
|
|
628
641
|
}
|
|
629
642
|
|
|
643
|
+
static rowDataKeys: (keyof RowInitData)[] = [
|
|
644
|
+
'name',
|
|
645
|
+
'status',
|
|
646
|
+
'category',
|
|
647
|
+
'productType',
|
|
648
|
+
'img',
|
|
649
|
+
'SEO_domain',
|
|
650
|
+
'SEO_title',
|
|
651
|
+
'SEO_desc',
|
|
652
|
+
'spec1',
|
|
653
|
+
'spec1Value',
|
|
654
|
+
'spec2',
|
|
655
|
+
'spec2Value',
|
|
656
|
+
'spec3',
|
|
657
|
+
'spec3Value',
|
|
658
|
+
'sku',
|
|
659
|
+
'cost',
|
|
660
|
+
'sale_price',
|
|
661
|
+
'compare_price',
|
|
662
|
+
'benefit',
|
|
663
|
+
'shipment_type',
|
|
664
|
+
'length',
|
|
665
|
+
'width',
|
|
666
|
+
'height',
|
|
667
|
+
'weight',
|
|
668
|
+
'weightUnit',
|
|
669
|
+
'stockPolicy',
|
|
670
|
+
'stock',
|
|
671
|
+
'save_stock',
|
|
672
|
+
'barcode',
|
|
673
|
+
'sub_title',
|
|
674
|
+
'product_general_tag',
|
|
675
|
+
'product_customize_tag',
|
|
676
|
+
];
|
|
677
|
+
|
|
630
678
|
// 匯出零售商品
|
|
631
679
|
static exportCommodity(gvc: GVC, getFormData: any) {
|
|
632
|
-
const
|
|
633
|
-
|
|
634
|
-
status: '',
|
|
635
|
-
category: '',
|
|
636
|
-
productType: '',
|
|
637
|
-
img: '',
|
|
638
|
-
SEO_domain: '',
|
|
639
|
-
SEO_title: '',
|
|
640
|
-
SEO_desc: '',
|
|
641
|
-
spec1: '',
|
|
642
|
-
spec1Value: '',
|
|
643
|
-
spec2: '',
|
|
644
|
-
spec2Value: '',
|
|
645
|
-
spec3: '',
|
|
646
|
-
spec3Value: '',
|
|
647
|
-
sku: '',
|
|
648
|
-
cost: '',
|
|
649
|
-
sale_price: '',
|
|
650
|
-
compare_price: '',
|
|
651
|
-
benefit: '',
|
|
652
|
-
shipment_type: '',
|
|
653
|
-
length: '',
|
|
654
|
-
width: '',
|
|
655
|
-
height: '',
|
|
656
|
-
weight: '',
|
|
657
|
-
weightUnit: '',
|
|
658
|
-
stockPolicy: '',
|
|
659
|
-
stock: '',
|
|
660
|
-
save_stock: '',
|
|
661
|
-
barcode: '',
|
|
662
|
-
sub_title: '',
|
|
663
|
-
};
|
|
680
|
+
const rowInitDataKeys = this.rowDataKeys;
|
|
681
|
+
|
|
664
682
|
const dialog = new ShareDialog(gvc.glitter);
|
|
665
683
|
dialog.dataLoading({ visible: true });
|
|
684
|
+
|
|
666
685
|
ApiShop.getProduct(getFormData).then(response => {
|
|
667
|
-
const
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
const
|
|
672
|
-
|
|
673
|
-
name: index === 0 ? productData.content.title || '未命名商品' : '',
|
|
674
|
-
status:
|
|
675
|
-
index === 0
|
|
676
|
-
? (() => {
|
|
677
|
-
switch (productData.content?.status) {
|
|
678
|
-
case 'draft':
|
|
679
|
-
return '草稿';
|
|
680
|
-
case 'schedule':
|
|
681
|
-
return '期間限定';
|
|
682
|
-
default:
|
|
683
|
-
return '啟用';
|
|
684
|
-
}
|
|
685
|
-
})()
|
|
686
|
-
: '',
|
|
687
|
-
category: index === 0 ? expo.checkString(productData.content.collection.join(' , ')) : '',
|
|
688
|
-
productType: index === 0 ? expo.checkString(this.getProductTypeString(productData.content)) : '',
|
|
689
|
-
img: expo.checkString(
|
|
690
|
-
(productData.content.variants[index] && productData.content.variants[index].preview_image) ||
|
|
691
|
-
productData.content.preview_image[0]
|
|
692
|
-
),
|
|
693
|
-
SEO_domain: index === 0 ? expo.checkString(productData.content?.seo?.domain) : '',
|
|
694
|
-
SEO_title: index === 0 ? expo.checkString(productData.content?.seo?.title) : '',
|
|
695
|
-
SEO_desc: index === 0 ? expo.checkString(productData.content?.seo?.content) : '',
|
|
696
|
-
spec1: index === 0 ? expo.checkString(productData.content?.specs[0]?.title) : '',
|
|
697
|
-
spec1Value: expo.checkString(productData.content.variants[index]?.spec[0]),
|
|
698
|
-
spec2: index === 0 ? expo.checkString(productData.content?.specs[1]?.title) : '',
|
|
699
|
-
spec2Value: expo.checkString(productData.content.variants[index]?.spec[1]),
|
|
700
|
-
spec3: index === 0 ? expo.checkString(productData.content?.specs[2]?.title) : '',
|
|
701
|
-
spec3Value: expo.checkString(productData.content.variants[index]?.spec[2]),
|
|
702
|
-
sku: expo.checkString(productData.content.variants[index]?.sku),
|
|
703
|
-
cost: expo.checkNumber(productData.content.variants[index]?.cost),
|
|
704
|
-
sale_price: expo.checkNumber(productData.content.variants[index]?.sale_price),
|
|
705
|
-
compare_price: expo.checkNumber(productData.content.variants[index]?.compare_price),
|
|
706
|
-
benefit: expo.checkNumber(productData.content.variants[index]?.profit),
|
|
707
|
-
shipment_type: getShipmentType(productData.content.variants[index]?.shipment_type),
|
|
708
|
-
length: expo.checkNumber(productData.content.variants[index]?.v_length || 0),
|
|
709
|
-
width: expo.checkNumber(productData.content.variants[index]?.v_width || 0),
|
|
710
|
-
height: expo.checkNumber(productData.content.variants[index]?.v_height || 0),
|
|
711
|
-
weight: expo.checkNumber(productData.content.variants[index]?.weight || 0),
|
|
712
|
-
weightUnit: expo.checkString(productData.content.variants[index]?.weightUnit || 'KG'),
|
|
713
|
-
stockPolicy: productData.content.variants[index]?.show_understocking === 'true' ? '追蹤' : '不追蹤',
|
|
714
|
-
stock: expo.checkNumber(productData.content.variants[index]?.stock),
|
|
715
|
-
save_stock: expo.checkNumber(productData.content.variants[index]?.save_stock),
|
|
716
|
-
barcode: expo.checkString(productData.content.variants[index]?.barcode),
|
|
717
|
-
sub_title: expo.checkString(productData.content.language_data[Language.getLanguage()].sub_title as string),
|
|
718
|
-
});
|
|
686
|
+
const products = response.response.data;
|
|
687
|
+
const exporter = new ProductExcel(gvc, ProductExcel.exampleHeader(), rowInitDataKeys);
|
|
688
|
+
|
|
689
|
+
const exportData = products.flatMap((productData: any) => {
|
|
690
|
+
const product = productData.content;
|
|
691
|
+
const lang = Language.getLanguage();
|
|
719
692
|
|
|
720
693
|
const getShipmentType = (type: string) => {
|
|
721
694
|
switch (type) {
|
|
@@ -728,13 +701,63 @@ export class ProductExcel {
|
|
|
728
701
|
}
|
|
729
702
|
};
|
|
730
703
|
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
704
|
+
const getProductStatus = (status: string) => {
|
|
705
|
+
switch (status) {
|
|
706
|
+
case 'draft':
|
|
707
|
+
return '草稿';
|
|
708
|
+
case 'schedule':
|
|
709
|
+
return '期間限定';
|
|
710
|
+
default:
|
|
711
|
+
return '啟用';
|
|
712
|
+
}
|
|
713
|
+
};
|
|
714
|
+
|
|
715
|
+
const getBaseRowData = (variant: any, index: number): RowInitData => {
|
|
716
|
+
return {
|
|
717
|
+
id: index === 0 ? product.id || '' : '',
|
|
718
|
+
name: index === 0 ? product.title || '未命名商品' : '',
|
|
719
|
+
status: index === 0 ? getProductStatus(product.status) : '',
|
|
720
|
+
category: index === 0 ? exporter.checkString(product.collection?.filter(Boolean).join(', ')) : '',
|
|
721
|
+
productType: index === 0 ? exporter.checkString(this.getProductTypeString(product)) : '',
|
|
722
|
+
img: exporter.checkString(variant?.preview_image || product.preview_image?.[0]),
|
|
723
|
+
SEO_domain: index === 0 ? exporter.checkString(product.seo?.domain) : '',
|
|
724
|
+
SEO_title: index === 0 ? exporter.checkString(product.seo?.title) : '',
|
|
725
|
+
SEO_desc: index === 0 ? exporter.checkString(product.seo?.content) : '',
|
|
726
|
+
spec1: index === 0 ? exporter.checkString(product.specs?.[0]?.title) : '',
|
|
727
|
+
spec1Value: exporter.checkString(variant?.spec?.[0]),
|
|
728
|
+
spec2: index === 0 ? exporter.checkString(product.specs?.[1]?.title) : '',
|
|
729
|
+
spec2Value: exporter.checkString(variant?.spec?.[1]),
|
|
730
|
+
spec3: index === 0 ? exporter.checkString(product.specs?.[2]?.title) : '',
|
|
731
|
+
spec3Value: exporter.checkString(variant?.spec?.[2]),
|
|
732
|
+
sku: exporter.checkString(variant?.sku),
|
|
733
|
+
cost: exporter.checkNumber(variant?.cost),
|
|
734
|
+
sale_price: exporter.checkNumber(variant?.sale_price),
|
|
735
|
+
compare_price: exporter.checkNumber(variant?.compare_price),
|
|
736
|
+
benefit: exporter.checkNumber(variant?.profit),
|
|
737
|
+
shipment_type: getShipmentType(variant?.shipment_type),
|
|
738
|
+
length: exporter.checkNumber(variant?.v_length || 0),
|
|
739
|
+
width: exporter.checkNumber(variant?.v_width || 0),
|
|
740
|
+
height: exporter.checkNumber(variant?.v_height || 0),
|
|
741
|
+
weight: exporter.checkNumber(variant?.weight || 0),
|
|
742
|
+
weightUnit: exporter.checkString(variant?.weightUnit || 'KG'),
|
|
743
|
+
stockPolicy: variant?.show_understocking === 'true' ? '追蹤' : '不追蹤',
|
|
744
|
+
stock: exporter.checkNumber(variant?.stock),
|
|
745
|
+
save_stock: exporter.checkNumber(variant?.save_stock),
|
|
746
|
+
barcode: exporter.checkString(variant?.barcode),
|
|
747
|
+
sub_title: index === 0 ? exporter.checkString(product.language_data?.[lang]?.sub_title || '') : '',
|
|
748
|
+
product_general_tag:
|
|
749
|
+
index === 0
|
|
750
|
+
? exporter.checkString(product.product_tag?.language?.[lang]?.filter(Boolean).join(', ') || '')
|
|
751
|
+
: '',
|
|
752
|
+
product_customize_tag:
|
|
753
|
+
index === 0 ? exporter.checkString(product.product_customize_tag?.filter(Boolean).join(', ') || '') : '',
|
|
754
|
+
};
|
|
755
|
+
};
|
|
756
|
+
|
|
757
|
+
return product.variants.map((variant: any, index: number) => getBaseRowData(variant, index));
|
|
735
758
|
});
|
|
736
759
|
|
|
737
|
-
|
|
760
|
+
exporter.export(exportData, `商品列表_${gvc.glitter.ut.dateFormat(new Date(), 'yyyyMMddhhmmss')}`);
|
|
738
761
|
dialog.dataLoading({ visible: false });
|
|
739
762
|
});
|
|
740
763
|
}
|
|
@@ -797,7 +820,7 @@ export class ProductExcel {
|
|
|
797
820
|
}
|
|
798
821
|
})()
|
|
799
822
|
: '',
|
|
800
|
-
category: index === 0 ? expo.checkString(productData.content.collection.join('
|
|
823
|
+
category: index === 0 ? expo.checkString(productData.content.collection.filter(Boolean).join(', ')) : '',
|
|
801
824
|
productType: index === 0 ? expo.checkString(this.getProductTypeString(productData.content)) : '',
|
|
802
825
|
img: expo.checkString(productData.content.preview_image[0]),
|
|
803
826
|
SEO_domain: index === 0 ? expo.checkString(productData.content?.seo?.domain) : '',
|
|
@@ -838,7 +861,7 @@ export class ProductExcel {
|
|
|
838
861
|
}
|
|
839
862
|
})()
|
|
840
863
|
: '',
|
|
841
|
-
category: index === 0 ? expo.checkString(productData.content.collection.join('
|
|
864
|
+
category: index === 0 ? expo.checkString(productData.content.collection.filter(Boolean).join(', ')) : '',
|
|
842
865
|
productType: index === 0 ? expo.checkString(this.getProductTypeString(productData.content)) : '',
|
|
843
866
|
img: expo.checkString(
|
|
844
867
|
(productData.content.variants[index] && productData.content.variants[index].preview_image) ||
|
|
@@ -978,7 +1001,10 @@ export class ProductExcel {
|
|
|
978
1001
|
},
|
|
979
1002
|
checked: {
|
|
980
1003
|
...baseFormData,
|
|
981
|
-
id_list: dataArray
|
|
1004
|
+
id_list: dataArray
|
|
1005
|
+
.map((item: { id: number }) => item.id)
|
|
1006
|
+
.filter(Boolean)
|
|
1007
|
+
.join(','),
|
|
982
1008
|
},
|
|
983
1009
|
all: baseFormData,
|
|
984
1010
|
};
|
|
@@ -1300,14 +1326,16 @@ export class ProductExcel {
|
|
|
1300
1326
|
keywords: '',
|
|
1301
1327
|
},
|
|
1302
1328
|
template: '',
|
|
1329
|
+
product_tag: {
|
|
1330
|
+
language: {},
|
|
1331
|
+
},
|
|
1303
1332
|
};
|
|
1304
1333
|
productData.id = id_list[postMD.length];
|
|
1305
1334
|
productData.title = this.checkString(row[0]);
|
|
1306
|
-
productData.sub_title = this.checkString(row[29]);
|
|
1307
1335
|
productData.status = row[1] == '啟用' ? 'active' : 'draft';
|
|
1308
1336
|
productData.collection = row[2].split(',') ?? [];
|
|
1309
1337
|
// 去除多餘空白
|
|
1310
|
-
productData.collection = productData.collection.map((item: string) => item.replace(/\s+/g, ''));
|
|
1338
|
+
productData.collection = productData.collection.map((item: string) => item.trim().replace(/\s+/g, ''));
|
|
1311
1339
|
productData.collection.forEach((row: any) => {
|
|
1312
1340
|
let collection = row.replace(/\s+/g, '');
|
|
1313
1341
|
// if (regex.test(collection)) {
|
|
@@ -1361,6 +1389,7 @@ export class ProductExcel {
|
|
|
1361
1389
|
productData.seo.domain = this.checkString(row[5]);
|
|
1362
1390
|
productData.seo.title = this.checkString(row[6]);
|
|
1363
1391
|
productData.seo.content = this.checkString(row[7]);
|
|
1392
|
+
productData.product_category = product_category;
|
|
1364
1393
|
// spec值 merge
|
|
1365
1394
|
let indices = [8, 10, 12];
|
|
1366
1395
|
indices.forEach(index => {
|
|
@@ -1371,6 +1400,21 @@ export class ProductExcel {
|
|
|
1371
1400
|
});
|
|
1372
1401
|
}
|
|
1373
1402
|
});
|
|
1403
|
+
productData.sub_title = this.checkString(row[29]);
|
|
1404
|
+
productData.product_tag.language[Language.getLanguage()] = (() => {
|
|
1405
|
+
try {
|
|
1406
|
+
return row[30].split(',').map((item: string) => item.trim().replace(/\s+/g, '')) ?? [];
|
|
1407
|
+
} catch (error) {
|
|
1408
|
+
return [];
|
|
1409
|
+
}
|
|
1410
|
+
})();
|
|
1411
|
+
productData.product_customize_tag = (() => {
|
|
1412
|
+
try {
|
|
1413
|
+
return row[31].split(',').map((item: string) => item.trim().replace(/\s+/g, '')) ?? [];
|
|
1414
|
+
} catch (error) {
|
|
1415
|
+
return [];
|
|
1416
|
+
}
|
|
1417
|
+
})();
|
|
1374
1418
|
}
|
|
1375
1419
|
let indices = [9, 11, 13];
|
|
1376
1420
|
indices.forEach((rowindex, key) => {
|