From 0ed4c2b64b086dd40ca19a7a2230bc7f8a3107f1 Mon Sep 17 00:00:00 2001 From: jiannibang <271381693@qq.com> Date: Tue, 14 Feb 2023 17:14:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=82=B9=E5=87=BB=E6=9F=90=E4=B8=AA?= =?UTF-8?q?=E5=93=81=E7=89=8C=EF=BC=8C=E8=83=BD=E7=9B=B4=E6=8E=A5=E5=AE=9A?= =?UTF-8?q?=E4=BD=8D=E5=88=B0=E6=AD=A4=E5=93=81=E7=89=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Brand/Brand.vue | 4 +++- src/views/Foods/Foods.vue | 4 +++- src/views/Index/Index.vue | 10 ++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) 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)