import { useRouter } from 'vue-router' import { storeToRefs } from 'pinia' import { useRootStore } from '@/store/root' import Brand from '@/utils/Class/Brand' export const useActivityNav = () => { const router = useRouter() const store = useRootStore() const { shopList } = storeToRefs(store) const NO_POINT_TYPE = -1 function nav(activity: Activity) { let shop if (activity.shopCode.length) { shop = shopList.value.find(item => item.shopCode === activity?.shopCode) } else if (activity.point > NO_POINT_TYPE) { const { activityName, floorOrder, floor, point, fileUrl, activityId } = activity shop = new Brand({ shopName: activityName, floorOrder, floor, logoUrl: fileUrl, yaxis: point, shopCode: activityId }) } if (!shop) { return } store.SET_SHOP(shop) router.push('/nav') } return { nav } }