|
|
<template>
|
|
|
<div class="scroll-app">
|
|
|
<div class="scroll-flex">
|
|
|
<div class="scroll-list-wrap">
|
|
|
<Scroll
|
|
|
ref="scroll"
|
|
|
:scroll-events="scrollEvents"
|
|
|
@scroll="scrollHandler"
|
|
|
:options="options"
|
|
|
@pulling-up="onPullingUp"
|
|
|
:data="channelList.productlist">
|
|
|
<div class="body" ref="body">
|
|
|
<div class="channel-top"></div>
|
|
|
<!-- <div class="html">qwdwqdwq、</div> -->
|
|
|
<div v-for="(item, index) in channelList.list" :key="index">
|
|
|
<Swiper :list="item.data" v-if="item.template_name == 'threePicture'"/>
|
|
|
<Hot :list="item.data.list" v-if="item.template_name == 'image_list'" />
|
|
|
<Banner :list="item.data" v-if="item.template_name == 'single_image'" />
|
|
|
<TwoBanner :list="item.data" v-if="item.template_name == 'twoPicture'" />
|
|
|
<ScrollNav :list="item.data.list" v-if="item.template_name == 'guessLike'"></ScrollNav>
|
|
|
<LayoutApp :show-back="true">
|
|
|
<div class="scroll-list-wrap">
|
|
|
<template v-if="isShow">
|
|
|
<div v-for="(item, index) in channelList.list" v-if="item.template_name == 'guessLike'">
|
|
|
<ScrollNav :list="item.data.list"></ScrollNav>
|
|
|
</div>
|
|
|
<ProductList :list="channelList.productlist"></ProductList>
|
|
|
</div>
|
|
|
</Scroll>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
<Scroll
|
|
|
ref="scroll"
|
|
|
:scroll-events="scrollEvents"
|
|
|
@scroll="scrollHandler"
|
|
|
:options="options"
|
|
|
@pulling-up="onPullingUp"
|
|
|
:data="productList.list">
|
|
|
<div class="body" ref="body">
|
|
|
<div class="channel-top"></div>
|
|
|
<div class="marginTop">
|
|
|
<div v-for="(item, index) in channelList.list" :key="index" class="space-between">
|
|
|
<Swiper :list="item.data" v-if="item.template_name == 'threePicture'"/>
|
|
|
<Hot :list="item.data.list" v-if="item.template_name == 'image_list'" />
|
|
|
<Banner :list="item.data" v-if="item.template_name == 'single_image'" />
|
|
|
<TwoBanner :list="item.data" v-if="item.template_name == 'twoPicture'" />
|
|
|
<template v-if="!isShow">
|
|
|
<div ref="sss" v-if="item.template_name == 'guessLike'">
|
|
|
<ScrollNav :list="item.data.list"></ScrollNav>
|
|
|
</div>
|
|
|
</template>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div :style="{minHeight: total + 'px',marginTop: '30px'}">
|
|
|
<ProductList :list="productList.list" v-if="productList.list.length > 0" class="bgColor"></ProductList>
|
|
|
<div v-else> 没有数据! </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</Scroll>
|
|
|
</div>
|
|
|
</LayoutApp>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
...
|
...
|
@@ -36,8 +47,10 @@ import TwoBanner from './components/twoBanner'; |
|
|
import Hot from './components/hot';
|
|
|
import ScrollNav from './components/scrollNav';
|
|
|
import ProductList from '../../list/components/productList';
|
|
|
import { setTimeout } from 'timers';
|
|
|
|
|
|
const { mapState, mapActions } = createNamespacedHelpers('home/channel');
|
|
|
const { mapState: mapStateList, mapActions: mapActionsList } = createNamespacedHelpers('list');
|
|
|
|
|
|
export default {
|
|
|
data() {
|
...
|
...
|
@@ -50,32 +63,58 @@ export default { |
|
|
},
|
|
|
scrollEvents: ['scroll'],
|
|
|
scrollY: 0,
|
|
|
navTop: 0,
|
|
|
navHeight: 0,
|
|
|
isShow: false,
|
|
|
total: 0,
|
|
|
marginTop: 0,
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
...mapState(['channelList']),
|
|
|
...mapStateList(['productList']),
|
|
|
},
|
|
|
mounted() {
|
|
|
const params = {
|
|
|
isPage: true
|
|
|
isPage: true,
|
|
|
isHome: true,
|
|
|
}
|
|
|
this.fetchChannelList();
|
|
|
this.fetchChannelList().then((res)=>{
|
|
|
this.navTop = this.$refs.sss[0].offsetTop;
|
|
|
this.navHeight = this.$refs.sss[0].offsetHeight;
|
|
|
|
|
|
let windowH = document.documentElement.clientHeight || document.body.clientHeight;
|
|
|
this.total = windowH - this.navHeight;
|
|
|
console.log(windowH);
|
|
|
console.log(this.navHeight);
|
|
|
console.log(this.total);
|
|
|
console.log("______");
|
|
|
|
|
|
});
|
|
|
this.fetchProductList(params);
|
|
|
console.log(this.$refs.elememt);
|
|
|
console.log("elememt");
|
|
|
|
|
|
},
|
|
|
created() {
|
|
|
|
|
|
},
|
|
|
methods: {
|
|
|
scrollHandler({ y }) {
|
|
|
// console.log(y);
|
|
|
let scrollY = Math.abs(parseInt(y));
|
|
|
if(scrollY >= this.navTop) {
|
|
|
this.isShow = true;
|
|
|
this.marginTop = 0;
|
|
|
} else {
|
|
|
this.isShow = false;
|
|
|
this.marginTop = '30px';
|
|
|
}
|
|
|
// this.scrollY = -y
|
|
|
},
|
|
|
...mapActions(['fetchChannelList','fetchProductList']),
|
|
|
...mapActions(['fetchChannelList']),
|
|
|
...mapActionsList(['fetchProductList']),
|
|
|
async onPullingUp() {
|
|
|
const params = {
|
|
|
isReset: false
|
|
|
isReset: false,
|
|
|
isHome: true,
|
|
|
}
|
|
|
await this.fetchProductList(params);
|
|
|
this.$refs.scroll.forceUpdate()
|
...
|
...
|
@@ -103,6 +142,9 @@ export default { |
|
|
height: 310px;
|
|
|
background: #08304B;
|
|
|
}
|
|
|
.marginTop {
|
|
|
margin-top: -150px;
|
|
|
}
|
|
|
.scroll-app {
|
|
|
position: absolute;
|
|
|
top: 0;
|
...
|
...
|
@@ -133,11 +175,18 @@ export default { |
|
|
.body {
|
|
|
height: 100%;
|
|
|
overflow-y: auto;
|
|
|
// padding: 0 40px;
|
|
|
}
|
|
|
|
|
|
.html {
|
|
|
margin-top: -250px;
|
|
|
margin-bottom: 20px;
|
|
|
.space-between {
|
|
|
padding: 0 20px;
|
|
|
}
|
|
|
.bgColor {
|
|
|
background: #f5f5f5;
|
|
|
}
|
|
|
.navFixed {
|
|
|
width: 100%;
|
|
|
position: fixed;
|
|
|
top: 0;
|
|
|
left: 0;
|
|
|
z-index: 999;
|
|
|
}
|
|
|
</style> |
...
|
...
|
|