From e23719854e595e49be8d4ff8d91f1387032246f3 Mon Sep 17 00:00:00 2001 From: dzq Date: Tue, 10 Jun 2025 11:16:21 +0800 Subject: [PATCH] =?UTF-8?q?feat(shop):=20=E6=B7=BB=E5=8A=A0=E5=BA=97?= =?UTF-8?q?=E9=93=BA=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3=E5=8F=8A=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E7=B1=BB=E5=9E=8B=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在type.ts中新增ShopEntity类型定义 - 在shop/index.ts中添加getShopListApi接口 - 修改product.ts中的getGoods方法,支持直接传入shopId参数 --- src/common/apis/shop/index.ts | 10 +++++++++- src/common/apis/shop/type.ts | 6 ++++++ src/pinia/stores/product.ts | 21 ++++++++++----------- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/common/apis/shop/index.ts b/src/common/apis/shop/index.ts index 6f19f75..342db5d 100644 --- a/src/common/apis/shop/index.ts +++ b/src/common/apis/shop/index.ts @@ -1,5 +1,5 @@ import { request } from "@/http/axios" -import { GetBalanceResponse, GetOrdersByOpenIdDTO, OpenCabinetApiData, QyLoginDTO, QyLoginRequestParams, ShopGoodsResponseData, SubmitOrderRequestData, SubmitOrderResponseData } from './type' +import { GetBalanceResponse, GetOrdersByOpenIdDTO, OpenCabinetApiData, QyLoginDTO, QyLoginRequestParams, ShopEntity, ShopGoodsResponseData, SubmitOrderRequestData, SubmitOrderResponseData } from './type' import { GetOpenIdRequestParams } from './type' @@ -73,3 +73,11 @@ export function getBalanceByQyUserid(corpid: string, userid: string) { params: { corpid, userid } }) } + +export function getShopListApi(corpid: string) { + return request>({ + url: "shop/list", + method: "get", + params: { corpid } + }) +} \ No newline at end of file diff --git a/src/common/apis/shop/type.ts b/src/common/apis/shop/type.ts index a560cd8..be2f537 100644 --- a/src/common/apis/shop/type.ts +++ b/src/common/apis/shop/type.ts @@ -177,4 +177,10 @@ export interface OpenCabinetApiData { mobile: string // 操作类型(1用户 2管理员) operationType: number +} + +export interface ShopEntity { + shopId: number + shopName: string + corpid: string } \ No newline at end of file diff --git a/src/pinia/stores/product.ts b/src/pinia/stores/product.ts index a94a0c9..b578761 100644 --- a/src/pinia/stores/product.ts +++ b/src/pinia/stores/product.ts @@ -20,16 +20,15 @@ export const useProductStore = defineStore("product", () => { const categories = ref([]); const shopId = ref(null); - const setShopId = (id: number|string) => { - shopId.value = Number(id); - getGoods(); - } - - const getGoods = async () => { - const urlParams = new URLSearchParams(window.location.search); - const shopIdParams = urlParams.get('shopId') || undefined; - if (shopIdParams) { - shopId.value = Number(shopIdParams); + const getGoods = async (shopId_?: number) => { + if (shopId_) { + shopId.value = shopId_; + } else { + const urlParams = new URLSearchParams(window.location.search); + const shopIdParams = urlParams.get('shopId') || undefined; + if (shopIdParams) { + shopId.value = Number(shopIdParams); + } } try { @@ -58,7 +57,7 @@ export const useProductStore = defineStore("product", () => { console.error("获取商品数据失败:", error) } } - return { labels, categories, shopId, getGoods, setShopId } + return { labels, categories, shopId, getGoods } }) /**