Compare commits
2 Commits
d59e994b3e
...
638300113b
Author | SHA1 | Date |
---|---|---|
|
638300113b | |
|
17bdb83982 |
10
src/App.vue
10
src/App.vue
|
@ -5,12 +5,14 @@ import { useDark } from "@@/composables/useDark"
|
||||||
import { useWxStore } from "@/pinia/stores/wx"
|
import { useWxStore } from "@/pinia/stores/wx"
|
||||||
import { tokenLogin } from '@/common/apis/ab98'
|
import { tokenLogin } from '@/common/apis/ab98'
|
||||||
import { useAb98UserStore } from '@/pinia/stores/ab98-user'
|
import { useAb98UserStore } from '@/pinia/stores/ab98-user'
|
||||||
|
import { useProductStore } from "./pinia/stores/product"
|
||||||
|
|
||||||
// const userStore = useUserStore()
|
// const userStore = useUserStore()
|
||||||
const wxStore = useWxStore()
|
const wxStore = useWxStore();
|
||||||
const route = useRoute()
|
const route = useRoute();
|
||||||
const router = useRouter()
|
const router = useRouter();
|
||||||
const ab98UserStore = useAb98UserStore()
|
const ab98UserStore = useAb98UserStore();
|
||||||
|
const productStore = useProductStore();
|
||||||
|
|
||||||
const { isDark, initDark } = useDark()
|
const { isDark, initDark } = useDark()
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,9 @@ export function getCabinetDetailApi() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function openCabinet(lockControlNo: number, pinNo: number, data: OpenCabinetApiData) {
|
export function openCabinet(cabinetId: number, pinNo: number, data: OpenCabinetApiData) {
|
||||||
return request<ApiResponseData<void>>({
|
return request<ApiResponseData<void>>({
|
||||||
url: `cabinet/openCabinet/${lockControlNo}/${pinNo}`,
|
url: `cabinet/openCabinet/${cabinetId}/${pinNo}`,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data
|
data
|
||||||
})
|
})
|
||||||
|
|
|
@ -5,10 +5,13 @@ import { GetOpenIdRequestParams } from './type'
|
||||||
|
|
||||||
|
|
||||||
/** 获取商品列表 */
|
/** 获取商品列表 */
|
||||||
export function getShopGoodsApi() {
|
export function getShopGoodsApi(shopId: number|null) {
|
||||||
return request<ShopGoodsResponseData>({
|
return request<ShopGoodsResponseData>({
|
||||||
url: "shop/goods",
|
url: "shop/goods",
|
||||||
method: "get"
|
method: "get",
|
||||||
|
params: {
|
||||||
|
shopId: shopId ? shopId : undefined
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ const handleOpenLocker = async (locker: LockerItem) => {
|
||||||
openingLockerId.value = locker.lockerId
|
openingLockerId.value = locker.lockerId
|
||||||
try {
|
try {
|
||||||
// 调用打开柜口接口
|
// 调用打开柜口接口
|
||||||
await openCabinet(cabinetList.value[activeCabinet.value].lockControlNo, locker.lockerNumber, {
|
await openCabinet(cabinetList.value[activeCabinet.value].cabinetId, locker.lockerNumber, {
|
||||||
cellId: locker.lockerId,
|
cellId: locker.lockerId,
|
||||||
userid: qyUserid.value,
|
userid: qyUserid.value,
|
||||||
isInternal: 2,
|
isInternal: 2,
|
||||||
|
|
|
@ -14,12 +14,24 @@ export interface Product {
|
||||||
|
|
||||||
export const useProductStore = defineStore("product", () => {
|
export const useProductStore = defineStore("product", () => {
|
||||||
// 商品数据
|
// 商品数据
|
||||||
const labels = ref<Array<{ id: number, name: string }>>([])
|
const labels = ref<Array<{ id: number, name: string }>>([]);
|
||||||
const categories = ref<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 getGoods = async () => {
|
||||||
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
|
const shopIdParams = urlParams.get('shopId') || undefined;
|
||||||
|
if (shopIdParams) {
|
||||||
|
shopId.value = Number(shopIdParams);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { data } = await getShopGoodsApi()
|
const { data } = await getShopGoodsApi(shopId.value);
|
||||||
|
|
||||||
// 转换分类标签
|
// 转换分类标签
|
||||||
labels.value = data.categoryList.map(c => ({
|
labels.value = data.categoryList.map(c => ({
|
||||||
|
@ -42,8 +54,7 @@ export const useProductStore = defineStore("product", () => {
|
||||||
console.error("获取商品数据失败:", error)
|
console.error("获取商品数据失败:", error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getGoods()
|
return { labels, categories, shopId, getGoods, setShopId }
|
||||||
return { labels, categories, getGoods }
|
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue