Browse Source

feat: 首页滚动品牌超量滚动

v1.0.1
jiannibang 3 years ago
parent
commit
1c4494b0ef
  1. 38
      src/views/Index/Index.vue

38
src/views/Index/Index.vue

@ -38,17 +38,21 @@
<h1>推荐美食</h1> <h1>推荐美食</h1>
<h2>此时此刻美食正在等你</h2> <h2>此时此刻美食正在等你</h2>
</div> </div>
<div class="grid">
<div class="marquee">
<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.id" :src="config.sourceUrl + shop.logoUrl" alt="" />
</div> </div>
</div> </div>
</div>
<div v-else class="rec" @click="goPage({ title: '品牌列表', path: '/brand' })"> <div v-else class="rec" @click="goPage({ title: '品牌列表', path: '/brand' })">
<div class="title" :style="{ backgroundImage: `url(${theme.images.recBg})` }"> <div class="title" :style="{ backgroundImage: `url(${theme.images.recBg})` }">
<h1>推荐品牌</h1> <h1>推荐品牌</h1>
<h2>心动之选拥抱美好生活</h2> <h2>心动之选拥抱美好生活</h2>
</div> </div>
<div class="grid">
<img class="item" v-for="shop of shopList.slice(0, 16)" :key="shop.id" :src="config.sourceUrl + shop.logoUrl" alt="" />
<div class="marquee">
<div class="grid" :style="shopList.length <= 12 ? '' : `animation: marquee ${shopList.length}s linear infinite;`">
<img class="item" v-for="shop of shopList" :key="shop.id" :src="config.sourceUrl + shop.logoUrl" alt="" />
</div>
</div> </div>
</div> </div>
@ -91,7 +95,7 @@ const router = useRouter()
const store = useStore() const store = useStore()
const { indexList, currentFloor, buildingList, shopList, sidebarList, config, theme } = storeToRefs(store) const { indexList, currentFloor, buildingList, shopList, sidebarList, config, theme } = storeToRefs(store)
const guideDesc = ref('') const guideDesc = ref('')
const foodList = computed(() => shopList.value.filter(({ isSpecial }) => isSpecial).slice(0, 12) ?? [])
const foodList = computed(() => shopList.value.filter(({ isSpecial }) => isSpecial) ?? [])
const hotRecommend = computed(() => indexList.value.hotSearch.slice(0, 5) ?? []) const hotRecommend = computed(() => indexList.value.hotSearch.slice(0, 5) ?? [])
const bf = computed(() => (buildingList.length > 1 ? currentFloor.value.building + '-' : '') + currentFloor.value.floor) const bf = computed(() => (buildingList.length > 1 ? currentFloor.value.building + '-' : '') + currentFloor.value.floor)
const activityList = ref([]) const activityList = ref([])
@ -118,7 +122,19 @@ getActivityList(3).then(({ data }) => {
console.log(data.activityList) console.log(data.activityList)
}) })
</script> </script>
<style lang="scss">
@keyframes marquee {
from {
transform: translateY(0);
}
95% {
transform: translateY(calc(-100% + 389px - 40px - 15px));
}
to {
transform: translateY(0);
}
}
</style>
<style lang="scss" scoped> <style lang="scss" scoped>
.index-container { .index-container {
display: flex; display: flex;
@ -270,11 +286,14 @@ getActivityList(3).then(({ data }) => {
.food, .food,
.rec { .rec {
position: absolute; position: absolute;
display: flex;
flex-direction: column;
top: 40px; top: 40px;
left: 447px; left: 447px;
width: 565px; width: 565px;
height: 557px; height: 557px;
h1 { h1 {
z-index: 1;
font-weight: 900; font-weight: 900;
font-size: 56px; font-size: 56px;
line-height: 66px; line-height: 66px;
@ -282,11 +301,18 @@ getActivityList(3).then(({ data }) => {
margin-bottom: 8px; margin-bottom: 8px;
} }
h2 { h2 {
z-index: 1;
font-weight: 700; font-weight: 700;
font-size: 16px; font-size: 16px;
line-height: 19px; line-height: 19px;
color: rgba(255, 255, 255, 0.8); color: rgba(255, 255, 255, 0.8);
} }
.marquee {
z-index: 0;
flex: 1;
overflow: hidden;
}
.grid { .grid {
margin-top: 40px; margin-top: 40px;
display: grid; display: grid;
@ -312,6 +338,7 @@ getActivityList(3).then(({ data }) => {
align-items: center; align-items: center;
overflow: hidden; overflow: hidden;
.title { .title {
z-index: 1;
margin-top: 4px; margin-top: 4px;
width: 549px; width: 549px;
background: center / cover no-repeat url(./foodBg.png); background: center / cover no-repeat url(./foodBg.png);
@ -331,6 +358,7 @@ getActivityList(3).then(({ data }) => {
align-items: center; align-items: center;
overflow: hidden; overflow: hidden;
.title { .title {
z-index: 1;
margin-top: 8px; margin-top: 8px;
width: 549px; width: 549px;
background: center / cover no-repeat; background: center / cover no-repeat;

Loading…
Cancel
Save