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 } }) /**