feat(shop): 添加店铺列表接口及相关类型定义
- 在type.ts中新增ShopEntity类型定义 - 在shop/index.ts中添加getShopListApi接口 - 修改product.ts中的getGoods方法,支持直接传入shopId参数
This commit is contained in:
parent
4bf21aa7f6
commit
e23719854e
|
@ -1,5 +1,5 @@
|
||||||
import { request } from "@/http/axios"
|
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'
|
import { GetOpenIdRequestParams } from './type'
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,3 +73,11 @@ export function getBalanceByQyUserid(corpid: string, userid: string) {
|
||||||
params: { corpid, userid }
|
params: { corpid, userid }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getShopListApi(corpid: string) {
|
||||||
|
return request<ApiResponseData<ShopEntity[]>>({
|
||||||
|
url: "shop/list",
|
||||||
|
method: "get",
|
||||||
|
params: { corpid }
|
||||||
|
})
|
||||||
|
}
|
|
@ -177,4 +177,10 @@ export interface OpenCabinetApiData {
|
||||||
mobile: string
|
mobile: string
|
||||||
// 操作类型(1用户 2管理员)
|
// 操作类型(1用户 2管理员)
|
||||||
operationType: number
|
operationType: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ShopEntity {
|
||||||
|
shopId: number
|
||||||
|
shopName: string
|
||||||
|
corpid: string
|
||||||
}
|
}
|
|
@ -20,16 +20,15 @@ export const useProductStore = defineStore("product", () => {
|
||||||
const categories = ref<Product[]>([]);
|
const categories = ref<Product[]>([]);
|
||||||
const shopId = ref<number|null>(null);
|
const shopId = ref<number|null>(null);
|
||||||
|
|
||||||
const setShopId = (id: number|string) => {
|
const getGoods = async (shopId_?: number) => {
|
||||||
shopId.value = Number(id);
|
if (shopId_) {
|
||||||
getGoods();
|
shopId.value = shopId_;
|
||||||
}
|
} else {
|
||||||
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
const getGoods = async () => {
|
const shopIdParams = urlParams.get('shopId') || undefined;
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
if (shopIdParams) {
|
||||||
const shopIdParams = urlParams.get('shopId') || undefined;
|
shopId.value = Number(shopIdParams);
|
||||||
if (shopIdParams) {
|
}
|
||||||
shopId.value = Number(shopIdParams);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -58,7 +57,7 @@ export const useProductStore = defineStore("product", () => {
|
||||||
console.error("获取商品数据失败:", error)
|
console.error("获取商品数据失败:", error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { labels, categories, shopId, getGoods, setShopId }
|
return { labels, categories, shopId, getGoods }
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue