diff --git a/src/views/Brand/Brand.vue b/src/views/Brand/Brand.vue index ee58127..39abfab 100644 --- a/src/views/Brand/Brand.vue +++ b/src/views/Brand/Brand.vue @@ -13,11 +13,13 @@ import View from '@/layouts/View.vue' import BrandScroll from '@/components/BrandScroll/BrandScroll.vue' const store = useStore() -const { config, shopList, indexList } = storeToRefs(store) +const storeRefs = storeToRefs(store) +const { config, shopList, indexList } = storeRefs const shop = ref(null) const selectedList = ref([]) Promise.all([getBrandListByFloor()]).then(([_brandList]) => { + if (storeRefs.shop.value) shop.value = storeRefs.shop.value const recMap = indexList.value.recommendList.reduce((acc, { shopId }) => ({ ...acc, [shopId]: true }), {}) const list = _brandList.data.list selectedList.value = list.map(({ name, shopList: _shopList }) => ({ name, shopList: _shopList.filter(({ shopId }) => recMap[shopId]) })) diff --git a/src/views/Foods/Foods.vue b/src/views/Foods/Foods.vue index 4da9f36..13b9e7a 100644 --- a/src/views/Foods/Foods.vue +++ b/src/views/Foods/Foods.vue @@ -13,11 +13,13 @@ import View from '@/layouts/View.vue' import BrandScroll from '@/components/BrandScroll/BrandScroll.vue' const store = useStore() -const { config, shopList } = storeToRefs(store) +const storeRefs = storeToRefs(store) +const { config, shopList, indexList } = storeRefs const shop = ref(null) const selectedList = ref([]) Promise.all([getBrandListByFloor()]).then(([_brandList]) => { + if (storeRefs.shop.value) shop.value = storeRefs.shop.value const list = _brandList.data.list.map(item => ({ name: item.name, shopList: item.shopList.filter(_ => _.isSpecial) diff --git a/src/views/Index/Index.vue b/src/views/Index/Index.vue index 95f9150..56007c4 100644 --- a/src/views/Index/Index.vue +++ b/src/views/Index/Index.vue @@ -40,7 +40,7 @@
- +
@@ -51,7 +51,7 @@
- +
@@ -113,6 +113,12 @@ const goPage = item => { router.push(item.path) } +const setShopById = id => { + console.log(id) + const shop = shopList.value.find(_shop => _shop.shopId === id) + store.SET_SHOP(shop) +} + function handleHot(item) { const shop = shopList.value.find(_shop => _shop.shopId === item.shopId) store.SET_SHOP(shop)