channel.vue 2.75 KB
<template>
  <div class="scroll-app">
    <div class="scroll-flex">
      <div class="scroll-list-wrap">
        <Scroll
          ref="scroll"
          :options="options"
          @pulling-up="onPullingUp"
          :data="channelList.productlist">
          <div class="body" ref="body">
            <div class="channel-top"></div>
            <div v-for="(item, index) in channelList.list" :key="index">
              <Slider :list="item.data"  v-if="item.template_name == 'focus'" />
              <Hot :list="item.data" v-if="item.template_name == 'hotSeries'" />
              <Banner :list="item.data" v-if="item.template_name == 'single_image'" />
              <TwoBanner :list="item.data" v-if="item.template_name == 'twoPicture'" />
            </div>
            <ScrollNav></ScrollNav>
            <ProductList :list="channelList.productlist"></ProductList>
          </div>
        </Scroll>
      </div>
    </div>
  </div>
</template>

<script>
import { Style, Scroll } from 'cube-ui'
import { createNamespacedHelpers } from 'vuex';
import Slider from './components/slider';
import Banner from './components/banner';
import TwoBanner from './components/twoBanner';
import Hot from './components/hot';
import ScrollNav from './components/scrollNav';
import ProductList from '../../list/components/productList';

const { mapState, mapActions } = createNamespacedHelpers('home/channel');

export default {
  data() {
    return {
      options: {
        bounce: {
          top: false
        },
        pullUpLoad: true
      },
    }
  },
  computed: {
    ...mapState(['channelList']),
  },
  mounted() {
    const params = {
      isPage: true
    } 
    this.fetchChannelList();
    this.fetchProductList(params);
  },
  created() {
    
  },
  methods: {
    ...mapActions(['fetchChannelList','fetchProductList']),
    async onPullingUp() {
      const params = {
        isReset: false
      } 
      await this.fetchProductList(params);
      this.$refs.scroll.forceUpdate()
    }
  },
  components: {
    Slider,
    Banner,
    TwoBanner,
    Hot,
    ScrollNav,
    Style,
    Scroll,
    ProductList
  }
};
</script>

<style lang="scss" scoped>
.channel-top {
  width: 100%;
  height: 400px;
  background: #08304B;
}
.scroll-app {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  font-size: 0.6rem;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -webkit-flex-direction: column;
  flex-direction: column;
}
.scroll-flex {
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    flex: 1;
    overflow: hidden;
    position: relative;
}
.scroll-list-wrap {
  height: 100%;
  width: 100%;
}
.body {
  height: 100%;
  overflow-y: auto;
  // padding: 0 40px;
}
</style>