@gt6/sdk 1.0.28 → 1.0.29
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 +41 -1
- package/dist/gt6-sdk.cjs.js.map +1 -1
- package/dist/gt6-sdk.esm.js +41 -1
- package/dist/gt6-sdk.esm.js.map +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/modules/articles.d.ts +1 -1
- package/dist/modules/products.d.ts +10 -0
- package/dist/modules/products.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/gt6-sdk.esm.js
CHANGED
@@ -104,7 +104,7 @@ class ArticlesAPI {
|
|
104
104
|
return this.client.request(`/articles/${articleId}.json`);
|
105
105
|
}
|
106
106
|
/**
|
107
|
-
* 1.1 根据文章ID
|
107
|
+
* 1.1 根据文章ID获取文章详情(平台使用)
|
108
108
|
*/
|
109
109
|
async getArticle_p(articleId) {
|
110
110
|
return this.client.request(`/parentarticles/${articleId}.json`);
|
@@ -905,6 +905,40 @@ class ProductsAPI {
|
|
905
905
|
limit
|
906
906
|
};
|
907
907
|
}
|
908
|
+
/**
|
909
|
+
* 4.3. 根据大分类ID获取平台产品列表
|
910
|
+
* 先从big-product-categories/${categoryId}.json获取产品ID,再分页后用getProduct_p获取详情
|
911
|
+
*/
|
912
|
+
async getProductsByCategory_b(categoryId, options) {
|
913
|
+
// 从大型分类静态文件获取该分类的产品ID列表
|
914
|
+
const categoryData = await this.client.request(`/big-product-categories/${categoryId}.json`);
|
915
|
+
if (!categoryData || !categoryData.productIds || categoryData.productIds.length === 0) {
|
916
|
+
return {
|
917
|
+
products: [],
|
918
|
+
total: 0,
|
919
|
+
page: options?.page || 1,
|
920
|
+
limit: options?.limit || 10
|
921
|
+
};
|
922
|
+
}
|
923
|
+
// 应用分页
|
924
|
+
const page = options?.page || 1;
|
925
|
+
const limit = options?.limit || 10;
|
926
|
+
const offset = (page - 1) * limit;
|
927
|
+
const paginatedProductIds = categoryData.productIds.slice(offset, offset + limit);
|
928
|
+
// 获取产品详情(使用上级平台数据)
|
929
|
+
const products = await Promise.all(paginatedProductIds.map(productId => this.getProduct_p(productId)));
|
930
|
+
// 应用状态过滤
|
931
|
+
let filteredProducts = products;
|
932
|
+
if (options?.status !== undefined) {
|
933
|
+
filteredProducts = products.filter(product => product.status === options.status);
|
934
|
+
}
|
935
|
+
return {
|
936
|
+
products: filteredProducts,
|
937
|
+
total: categoryData.productIds.length,
|
938
|
+
page,
|
939
|
+
limit
|
940
|
+
};
|
941
|
+
}
|
908
942
|
/**
|
909
943
|
* 5. 根据标签ID获取产品列表
|
910
944
|
* 支持单个标签ID或标签ID数组
|
@@ -2739,6 +2773,12 @@ class GT6SDK {
|
|
2739
2773
|
async getProductsByCategory_t(categoryId, options) {
|
2740
2774
|
return this.products.getProductsByCategory_t(categoryId, options);
|
2741
2775
|
}
|
2776
|
+
/**
|
2777
|
+
* 11.3. 便捷方法:根据大分类ID获取平台产品列表(从big-product-categories静态JSON获取)
|
2778
|
+
*/
|
2779
|
+
async getProductsByCategory_b(categoryId, options) {
|
2780
|
+
return this.products.getProductsByCategory_b(categoryId, options);
|
2781
|
+
}
|
2742
2782
|
/**
|
2743
2783
|
* 12. 便捷方法:根据标签ID获取产品列表
|
2744
2784
|
*/
|