ts-glitter 16.2.6 → 16.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -648,8 +648,10 @@ export class ProductList {
648
648
  if (!vm.collections || vm.collections.length === 0) {
649
649
  vm.title = all_text;
650
650
  } else {
651
- let collectionObj = vm.collections.find((item: { code: string }) => {
652
- return item.code === decodeURIComponent(extractCategoryTitleFromUrl(location.href)) ;
651
+ let collectionObj = vm.collections.find((item:any) => {
652
+ const language_data=item.language_data && item.language_data[Language.getLanguage()]
653
+ const code=((language_data && language_data.seo && language_data.seo.domain) || item.code) || (language_data && language_data.title) || item.title;
654
+ return (code) === decodeURIComponent(extractCategoryTitleFromUrl(location.href)) ;
653
655
  });
654
656
  try {
655
657
  if(!collectionObj){
@@ -658,63 +660,74 @@ export class ProductList {
658
660
  });
659
661
  }
660
662
  }catch (e){}
661
- vm.title = collectionObj ? collectionObj.title : all_text;
663
+ if(collectionObj){
664
+ const language_data=collectionObj.language_data
665
+ vm.title=(language_data && (language_data[Language.getLanguage()] && language_data[Language.getLanguage()].title)) || collectionObj.title;
666
+ }else{
667
+ vm.title=all_text
668
+ }
662
669
  }
663
670
  gvc.notifyDataChange(ids.pageTitle);
664
671
  }
665
672
 
666
673
  function setAdTag(data: any) {
667
- const path = location.pathname;
668
- const pathParts = path.split('/');
669
- const collectionIndex = pathParts.indexOf('collections');
670
- const index = collectionIndex + 1;
671
- const collection = pathParts[index];
672
- const collectionName = decodeURIComponent(collection);
673
-
674
- function findObjectByValue(arr: any, value: string): any {
675
- for (const item of arr) {
676
- if (item.code === value) {
677
- return item;
678
- }
679
- if (item.array.length > 0) {
680
- const found = findObjectByValue(item.array, value);
681
- if (found) {
682
- return found;
674
+ try {
675
+ const path = location.pathname;
676
+ const pathParts = path.split('/');
677
+ const collectionIndex = pathParts.indexOf('collections');
678
+ const index = collectionIndex + 1;
679
+ const collection = pathParts[index];
680
+ const collectionName = decodeURIComponent(collection);
681
+
682
+ function findObjectByValue(arr: any, value: string): any {
683
+ for (const item of arr) {
684
+ const language_data=item.language_data
685
+ const code=(language_data && language_data[Language.getLanguage()] && language_data[Language.getLanguage()].seo && language_data[Language.getLanguage()].seo.domain) || item.code
686
+ if (code === value) {
687
+ return item;
688
+ }
689
+ if (item.array.length > 0) {
690
+ const found = findObjectByValue(item.array, value);
691
+ if (found) {
692
+ return found;
693
+ }
683
694
  }
684
695
  }
696
+ return null;
685
697
  }
686
- return null;
687
- }
688
698
 
689
- if ((window as any).gtag) {
690
- if (collectionName) {
691
- const foundObject = findObjectByValue(data, collectionName);
692
- Ad.gtagEvent('view_item_list', {
693
- items: [
694
- {
695
- item_id: foundObject.code,
696
- item_name: foundObject.title,
697
- },
698
- ],
699
- });
700
- Ad.fbqEvent('ViewContent', {
701
- content_ids: [foundObject.code],
702
- content_type: 'product_group',
703
- });
704
- } else {
705
- Ad.gtagEvent('view_item_list', {
706
- items: [
707
- {
708
- item_id: 'all-product',
709
- item_name: '所有商品',
710
- },
711
- ],
712
- });
713
- Ad.fbqEvent('ViewContent', {
714
- content_ids: ['all-product'],
715
- content_type: 'product_group',
716
- });
699
+ if ((window as any).gtag) {
700
+ if (collectionName) {
701
+ const foundObject = findObjectByValue(data, collectionName);
702
+ Ad.gtagEvent('view_item_list', {
703
+ items: [
704
+ {
705
+ item_id: collectionName,
706
+ item_name: foundObject.title,
707
+ },
708
+ ],
709
+ });
710
+ Ad.fbqEvent('ViewContent', {
711
+ content_ids: [collectionName],
712
+ content_type: 'product_group',
713
+ });
714
+ } else {
715
+ Ad.gtagEvent('view_item_list', {
716
+ items: [
717
+ {
718
+ item_id: 'all-product',
719
+ item_name: '所有商品',
720
+ },
721
+ ],
722
+ });
723
+ Ad.fbqEvent('ViewContent', {
724
+ content_ids: ['all-product'],
725
+ content_type: 'product_group',
726
+ });
727
+ }
717
728
  }
729
+ }catch (e) {
730
+ console.log(e)
718
731
  }
719
732
  }
720
733
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-glitter",
3
- "version": "16.2.6",
3
+ "version": "16.2.9",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -94,6 +94,7 @@ class Shopping {
94
94
  }
95
95
  async getProduct(query) {
96
96
  var _a, _b;
97
+ console.log(`query=>`, query);
97
98
  try {
98
99
  query.language = (_a = query.language) !== null && _a !== void 0 ? _a : (await app_js_1.App.getDefLanguage(this.app));
99
100
  query.show_hidden = (_b = query.show_hidden) !== null && _b !== void 0 ? _b : 'true';