From 95d57a92621f5473d2ed3319dcdb450c440a206c Mon Sep 17 00:00:00 2001 From: weiwei Date: Thu, 11 Sep 2025 19:59:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=85=B1=E5=AF=8C=E5=95=86=E5=93=81?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E6=96=B0=E5=A2=9E=E5=92=8C=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/prosperity-shop/goods-form.vue | 255 +++++++++++++++--- src/pages/prosperity-shop/goods-manage.vue | 72 ++--- src/sheep/api/prosperityShop.ts | 20 +- src/sheep/components/shop-categary-picker.vue | 52 ++++ 4 files changed, 329 insertions(+), 70 deletions(-) create mode 100644 src/sheep/components/shop-categary-picker.vue diff --git a/src/pages/prosperity-shop/goods-form.vue b/src/pages/prosperity-shop/goods-form.vue index 69770c1..51450ed 100644 --- a/src/pages/prosperity-shop/goods-form.vue +++ b/src/pages/prosperity-shop/goods-form.vue @@ -1,22 +1,31 @@ diff --git a/src/pages/prosperity-shop/goods-manage.vue b/src/pages/prosperity-shop/goods-manage.vue index 9ba3c7d..ab8a89c 100644 --- a/src/pages/prosperity-shop/goods-manage.vue +++ b/src/pages/prosperity-shop/goods-manage.vue @@ -15,29 +15,25 @@ @scroll="pageHook.scroll" > - + - {{ v.title }} - + {{ v.title }} + {{ state.category.find((item) => item.id == v.categoryId)?.name || "未知分类" }} {{ v.status == "0" ? "在售" : "未售" }} - - 单位 {{ v.unit }} - 库存 {{ v.totalStock }} + + 单位 {{ v.unit }} + 库存 {{ v.totalStock }} @@ -80,10 +76,10 @@ ¥ - {{ v.spuPrice.toFixed(2).split(".")[0] }}. - {{ v.spuPrice.toFixed(2).split(".")[1] }} + {{ v.spuPrice.toFixed(2).split(".")[0] }}. + {{ v.spuPrice.toFixed(2).split(".")[1] }} - 到手价 + 到手价 @@ -101,6 +97,10 @@ + + 新增商品 + 分类管理 + @@ -109,7 +109,7 @@ import { reactive, ref } from "vue" import { prosperityShopApi } from "@/sheep/api" import { hooks } from "@/sheep" import { filePath } from "@/sheep/utils/file" -import { onLoad } from "@dcloudio/uni-app" +import { onLoad, onShow } from "@dcloudio/uni-app" const state = reactive({ params: { @@ -121,7 +121,7 @@ const state = reactive({ }) const pageRef = ref(null) -const pageHook = hooks.usePage(pageRef, prosperityShopApi.getGoodsList, null, "data.records") +const pageHook = hooks.usePage(pageRef, prosperityShopApi.getManageGoodsList, null, "data.records") const query = (page: number, pagesize: number) => { pageHook.startPage(page, pagesize, false, state.params) @@ -131,6 +131,10 @@ onLoad(async () => { await getGoodsCategory() }) +onShow(() => { + pageRef.value && pageRef.value.reload(false) +}) + const getGoodsCategory = async () => { const { code, data, msg } = await prosperityShopApi.getGoodsCategory() if (code != 0) return uni.showToast({ title: msg || "商品分类获取失败", icon: "none" }) diff --git a/src/sheep/api/prosperityShop.ts b/src/sheep/api/prosperityShop.ts index fc623fa..affb054 100644 --- a/src/sheep/api/prosperityShop.ts +++ b/src/sheep/api/prosperityShop.ts @@ -25,7 +25,7 @@ export default { }) }, // 获取超市商品分类列表树 - getGoodsCategoryTree: (params: { merchantId: string }): Promise => { + getGoodsCategoryTree: (params?: { merchantId: string }): Promise => { return request({ url: `/supermarket/app/mall/category/tree`, method: "GET", @@ -35,7 +35,7 @@ export default { // 获取商品列表 getGoodsList: (params: any): Promise => { return request({ - url: `/supermarket/app/mall/merchant/product/list`, + url: `/supermarket/app/mall/product/page`, method: "GET", params, }) @@ -47,6 +47,14 @@ export default { method: "GET", }) }, + // 共富商城商品管理获取自己商户的商品列表 + getManageGoodsList: (params: any): Promise => { + return request({ + url: `/supermarket/app/mall/merchant/product/list`, + method: "GET", + params, + }) + }, // 删除商品 deleteGoods: (id: string): Promise => { return request({ @@ -54,4 +62,12 @@ export default { method: "DELETE", }) }, + // 新增商品 + addGoods: (data: any): Promise => { + return request({ + url: `/supermarket/app/mall/merchant/product/create`, + method: "POST", + data, + }) + }, } diff --git a/src/sheep/components/shop-categary-picker.vue b/src/sheep/components/shop-categary-picker.vue new file mode 100644 index 0000000..ea462ae --- /dev/null +++ b/src/sheep/components/shop-categary-picker.vue @@ -0,0 +1,52 @@ + + + + +