Browse Source

feat: 所有品牌改为推荐品牌

v1.0.1
jiannibang 3 years ago
parent
commit
409f005d0b
  1. 14
      src/components/BrandScroll/BrandScroll.vue
  2. 6
      src/views/Brand/Brand.vue

14
src/components/BrandScroll/BrandScroll.vue

@ -43,7 +43,7 @@ import ShopItem from '@/base/ShopItem/ShopItem.vue'
import ScrollView from '@/base/ScrollView/ScrollView.vue'
import { storeToRefs } from 'pinia'
import { useStore } from '@/store/root'
import { useElementSize, useMutationObserver } from '@vueuse/core'
import { useElementSize, useMutationObserver, useThrottleFn } from '@vueuse/core'
import { getTranslateValues } from './getTranslateValues'
const store = useStore()
@ -75,15 +75,13 @@ const indicatorIndex = computed(() =>
return start > bounds.value[i - 1] && start <= el
})
)
useMutationObserver(
content,
([{ attributeName, target }]) => {
const throttledFn = useThrottleFn(([{ attributeName, target }]) => {
if (attributeName === 'style') y.value = getTranslateValues(target).y
},
{
}, 500)
useMutationObserver(content, throttledFn, {
attributes: true
}
)
})
const props = defineProps({
list: Array,
config: Object,

6
src/views/Brand/Brand.vue

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

Loading…
Cancel
Save