Browse Source

feat: 点击某个品牌,能直接定位到此品牌

v1.0.1
jiannibang 3 years ago
parent
commit
0ed4c2b64b
  1. 4
      src/views/Brand/Brand.vue
  2. 4
      src/views/Foods/Foods.vue
  3. 10
      src/views/Index/Index.vue

4
src/views/Brand/Brand.vue

@ -13,11 +13,13 @@ import View from '@/layouts/View.vue'
import BrandScroll from '@/components/BrandScroll/BrandScroll.vue' import BrandScroll from '@/components/BrandScroll/BrandScroll.vue'
const store = useStore() const store = useStore()
const { config, shopList, indexList } = storeToRefs(store)
const storeRefs = storeToRefs(store)
const { config, shopList, indexList } = storeRefs
const shop = ref(null) const shop = ref(null)
const selectedList = ref([]) const selectedList = ref([])
Promise.all([getBrandListByFloor()]).then(([_brandList]) => { 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 recMap = indexList.value.recommendList.reduce((acc, { shopId }) => ({ ...acc, [shopId]: true }), {})
const list = _brandList.data.list const list = _brandList.data.list
selectedList.value = list.map(({ name, shopList: _shopList }) => ({ name, shopList: _shopList.filter(({ shopId }) => recMap[shopId]) })) selectedList.value = list.map(({ name, shopList: _shopList }) => ({ name, shopList: _shopList.filter(({ shopId }) => recMap[shopId]) }))

4
src/views/Foods/Foods.vue

@ -13,11 +13,13 @@ import View from '@/layouts/View.vue'
import BrandScroll from '@/components/BrandScroll/BrandScroll.vue' import BrandScroll from '@/components/BrandScroll/BrandScroll.vue'
const store = useStore() const store = useStore()
const { config, shopList } = storeToRefs(store)
const storeRefs = storeToRefs(store)
const { config, shopList, indexList } = storeRefs
const shop = ref(null) const shop = ref(null)
const selectedList = ref([]) const selectedList = ref([])
Promise.all([getBrandListByFloor()]).then(([_brandList]) => { Promise.all([getBrandListByFloor()]).then(([_brandList]) => {
if (storeRefs.shop.value) shop.value = storeRefs.shop.value
const list = _brandList.data.list.map(item => ({ const list = _brandList.data.list.map(item => ({
name: item.name, name: item.name,
shopList: item.shopList.filter(_ => _.isSpecial) shopList: item.shopList.filter(_ => _.isSpecial)

10
src/views/Index/Index.vue

@ -40,7 +40,7 @@
</div> </div>
<div class="marquee"> <div class="marquee">
<div class="grid" :style="foodList.length <= 12 ? '' : `animation: marquee ${foodList.length}s linear infinite;`"> <div class="grid" :style="foodList.length <= 12 ? '' : `animation: marquee ${foodList.length}s linear infinite;`">
<img class="item" v-for="shop of foodList" :key="shop.id" :src="config.sourceUrl + shop.logoUrl" alt="" />
<img class="item" v-for="shop of foodList" :key="shop.shopId" :src="config.sourceUrl + shop.logoUrl" alt="" @click="setShopById(shop.shopId)" />
</div> </div>
</div> </div>
</div> </div>
@ -51,7 +51,7 @@
</div> </div>
<div class="marquee"> <div class="marquee">
<div class="grid" :style="recommendShops.length <= 12 ? '' : `animation: marquee ${recommendShops.length}s linear infinite;`"> <div class="grid" :style="recommendShops.length <= 12 ? '' : `animation: marquee ${recommendShops.length}s linear infinite;`">
<img class="item" v-for="shop of recommendShops" :key="shop.id" :src="config.sourceUrl + shop.logoUrl" alt="" />
<img class="item" v-for="shop of recommendShops" :key="shop.shopId" :src="config.sourceUrl + shop.logoUrl" alt="" @click="setShopById(shop.shopId)" />
</div> </div>
</div> </div>
</div> </div>
@ -113,6 +113,12 @@ const goPage = item => {
router.push(item.path) 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) { function handleHot(item) {
const shop = shopList.value.find(_shop => _shop.shopId === item.shopId) const shop = shopList.value.find(_shop => _shop.shopId === item.shopId)
store.SET_SHOP(shop) store.SET_SHOP(shop)

Loading…
Cancel
Save