feat(shop): 添加店铺列表接口及相关类型定义

- 在type.ts中新增ShopEntity类型定义
- 在shop/index.ts中添加getShopListApi接口
- 修改product.ts中的getGoods方法,支持直接传入shopId参数
This commit is contained in:
dzq 2025-06-10 11:16:21 +08:00
parent 4bf21aa7f6
commit e23719854e
3 changed files with 25 additions and 12 deletions

View File

@ -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<ApiResponseData<ShopEntity[]>>({
url: "shop/list",
method: "get",
params: { corpid }
})
}

View File

@ -177,4 +177,10 @@ export interface OpenCabinetApiData {
mobile: string
// 操作类型1用户 2管理员
operationType: number
}
export interface ShopEntity {
shopId: number
shopName: string
corpid: string
}

View File

@ -20,16 +20,15 @@ export const useProductStore = defineStore("product", () => {
const categories = ref<Product[]>([]);
const shopId = ref<number|null>(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 }
})
/**