@gt6/sdk 1.0.45 → 1.0.47
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/dist/gt6-sdk.cjs.js +67 -2
- package/dist/gt6-sdk.cjs.js.map +1 -1
- package/dist/gt6-sdk.esm.js +67 -2
- package/dist/gt6-sdk.esm.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/modules/articles.d.ts.map +1 -1
- package/dist/modules/products.d.ts +1 -0
- package/dist/modules/products.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/gt6-sdk.cjs.js
CHANGED
|
@@ -643,11 +643,13 @@ class ArticlesAPI {
|
|
|
643
643
|
limit: options?.limit || 10
|
|
644
644
|
};
|
|
645
645
|
}
|
|
646
|
+
// 将文章ID列表倒序排列
|
|
647
|
+
const reversedArticleIds = [...categoryData.articleIds].reverse();
|
|
646
648
|
// 应用分页
|
|
647
649
|
const page = options?.page || 1;
|
|
648
650
|
const limit = options?.limit || 10;
|
|
649
651
|
const offset = (page - 1) * limit;
|
|
650
|
-
const paginatedArticleIds =
|
|
652
|
+
const paginatedArticleIds = reversedArticleIds.slice(offset, offset + limit);
|
|
651
653
|
// 获取文章详情 - 修复:提取 articleId 字段
|
|
652
654
|
const articles = await Promise.all(paginatedArticleIds.map(articleId => this.getArticle_all(articleId)));
|
|
653
655
|
// 应用状态过滤
|
|
@@ -804,7 +806,9 @@ class ArticlesAPI {
|
|
|
804
806
|
try {
|
|
805
807
|
const categoryData = await this.client.request(`/big-article-categories/${singleCategoryId}.json`);
|
|
806
808
|
if (categoryData && categoryData.articleIds && categoryData.articleIds.length > 0) {
|
|
807
|
-
|
|
809
|
+
// 将每个分类的文章数据倒序排列后再追加
|
|
810
|
+
const reversedArticleIds = [...categoryData.articleIds].reverse();
|
|
811
|
+
allArticleData.push(...reversedArticleIds);
|
|
808
812
|
totalArticles += categoryData.articleIds.length;
|
|
809
813
|
}
|
|
810
814
|
}
|
|
@@ -1877,6 +1881,64 @@ class ProductsAPI {
|
|
|
1877
1881
|
}
|
|
1878
1882
|
return product;
|
|
1879
1883
|
}
|
|
1884
|
+
/* 1.1 根据产品ID获取产品详情(平台用户都可以使用)
|
|
1885
|
+
*/
|
|
1886
|
+
async getProduct01_all(productId) {
|
|
1887
|
+
const product = await this.client.request(`/products_all/${productId}.json`);
|
|
1888
|
+
// 检查产品是否有销售区域和税费模板
|
|
1889
|
+
if (product.regions && product.regions.length > 0 &&
|
|
1890
|
+
product.taxTemplates && product.taxTemplates.length > 0) {
|
|
1891
|
+
try {
|
|
1892
|
+
// 获取税费信息
|
|
1893
|
+
const taxInfo = await this.getTaxInfo();
|
|
1894
|
+
// 为每个税费模板添加规则
|
|
1895
|
+
product.taxTemplates = product.taxTemplates.map(template => {
|
|
1896
|
+
const matchingTemplate = taxInfo.templates.find(t => t.templateId === template.templateId);
|
|
1897
|
+
if (matchingTemplate) {
|
|
1898
|
+
// 过滤出产品可销售区域的规则
|
|
1899
|
+
const productRegionIds = product.regions.map(r => r.regionId);
|
|
1900
|
+
const applicableRules = matchingTemplate.rules.filter(rule => productRegionIds.includes(rule.regionId));
|
|
1901
|
+
return {
|
|
1902
|
+
...template,
|
|
1903
|
+
rules: applicableRules
|
|
1904
|
+
};
|
|
1905
|
+
}
|
|
1906
|
+
return template;
|
|
1907
|
+
});
|
|
1908
|
+
}
|
|
1909
|
+
catch (error) {
|
|
1910
|
+
// 如果获取税费信息失败,不影响产品详情返回
|
|
1911
|
+
console.warn('Failed to fetch tax info:', error);
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
// 检查产品是否有销售区域和运费模板
|
|
1915
|
+
if (product.regions && product.regions.length > 0 &&
|
|
1916
|
+
product.shippingTemplates && product.shippingTemplates.length > 0) {
|
|
1917
|
+
try {
|
|
1918
|
+
// 获取运费信息
|
|
1919
|
+
const shippingInfo = await this.getShippingInfo();
|
|
1920
|
+
// 为每个运费模板添加规则
|
|
1921
|
+
product.shippingTemplates = product.shippingTemplates.map(template => {
|
|
1922
|
+
const matchingTemplate = shippingInfo.templates.find(t => t.templateId === template.templateId);
|
|
1923
|
+
if (matchingTemplate) {
|
|
1924
|
+
// 过滤出产品可销售区域的规则
|
|
1925
|
+
const productRegionIds = product.regions.map(r => r.regionId);
|
|
1926
|
+
const applicableRules = matchingTemplate.rules.filter(rule => productRegionIds.includes(rule.regionId));
|
|
1927
|
+
return {
|
|
1928
|
+
...template,
|
|
1929
|
+
rules: applicableRules
|
|
1930
|
+
};
|
|
1931
|
+
}
|
|
1932
|
+
return template;
|
|
1933
|
+
});
|
|
1934
|
+
}
|
|
1935
|
+
catch (error) {
|
|
1936
|
+
// 如果获取运费信息失败,不影响产品详情返回
|
|
1937
|
+
console.warn('Failed to fetch shipping info:', error);
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
return product;
|
|
1941
|
+
}
|
|
1880
1942
|
/**
|
|
1881
1943
|
* 1.2 获取平台产品分类列表
|
|
1882
1944
|
*/
|
|
@@ -3590,6 +3652,9 @@ class GT6SDK {
|
|
|
3590
3652
|
async getProduct_all(productId) {
|
|
3591
3653
|
return this.products.getProduct_all(productId);
|
|
3592
3654
|
}
|
|
3655
|
+
async getProduct01_all(productId) {
|
|
3656
|
+
return this.products.getProduct01_all(productId);
|
|
3657
|
+
}
|
|
3593
3658
|
/**
|
|
3594
3659
|
* 8.2. 便捷方法:获取父平台产品分类列表
|
|
3595
3660
|
*/
|