forked from gxwebsoft/mp-10550
feat(home): 添加商品上下架状态管理功能
- 在商品模型中新增status字段用于标识商品上下架状态 - 首页请求商品列表时默认传入status为0参数 - 商品列表数据过滤仅显示上架状态的商品 - 添加商品状态注释说明0为上架1为下架
This commit is contained in:
@@ -147,4 +147,6 @@ export interface ShopGoodsParam extends PageParam {
|
|||||||
stock?: number;
|
stock?: number;
|
||||||
keywords?: string;
|
keywords?: string;
|
||||||
recommend?: number;
|
recommend?: number;
|
||||||
|
// 0上架 1下架(以实际后端约定为准)
|
||||||
|
status?: number;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,8 +166,8 @@ function Home() {
|
|||||||
const tab = tabs.find((t) => t.key === activeTabKey) || tabs[0]
|
const tab = tabs.find((t) => t.key === activeTabKey) || tabs[0]
|
||||||
if (!tab) return
|
if (!tab) return
|
||||||
|
|
||||||
pageShopGoods({ ...tab.params })
|
pageShopGoods({ ...tab.params, status: 0 })
|
||||||
.then((res) => setGoodsList(res?.list || []))
|
.then((res) => setGoodsList((res?.list || []).filter((g) => g?.status === 0)))
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error('首页商品列表加载失败:', err)
|
console.error('首页商品列表加载失败:', err)
|
||||||
setGoodsList([])
|
setGoodsList([])
|
||||||
|
|||||||
Reference in New Issue
Block a user