channel.vue 11 KB
<template>
  <LayoutApp :show-back="true">
    <div class="scroll-list-wrap">
      <Scroll
        ref="scroll"
        :options="options"
        @pulling-up="onPullingUp">
        <div class="body" ref="body">
          <div v-for="(item, index) in channelList.list" :key="index">
            <template v-if="item.template_name == 'focus'">
              <Slider :list="list"></Slider>
            </template>

            <template v-if="item.template_name == 'hotSeries'">
              <Hot :list="item.data"></Hot>
            </template>

            <template v-if="item.template_name == 'single_image'">
              <Banner :linkUrl="linkUrl" :imgUrl="imgUrl"></Banner>
            </template>

            <template v-if="item.template_name == 'twoPicture'">
              <TwoBanner :list="item.data"></TwoBanner>
            </template>
          </div>
          <ScrollNav></ScrollNav>
          <ProductList :list="channelList.productlist"></ProductList>
        </div>
      </Scroll>
    </div>
  </LayoutApp>
</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
      },
      items: [1,2,3,4,5,6,7,8,9],
      list: [
        {
          url: 'http://www.didichuxing.com/',
          image: '//webapp.didistatic.com/static/webapp/shield/cube-ui-examples-slide01.png'
        },
        {
          url: 'http://www.didichuxing.com/',
          image: '//webapp.didistatic.com/static/webapp/shield/cube-ui-examples-slide01.png'
        }
      ],
      linkUrl: 'https://www.baidu.com',
      imgUrl: 'https://ss0.baidu.com/94o3dSag_xI4khGko9WTAnF6hhy/baike/pic/item/cb8065380cd79123d7648113a7345982b3b780d4.jpg',
      list2: [
              {
                "data": [
                    {
                        "bgColor": "",
                        "src": "http://img10.static.yhbimg.com/yhb-img01/2017/07/26/16/01d47fc95f71a19469f38a19c7c843fe43.jpg?imageView2/{mode}/w/{width}/h/{height}",
                        "title": "",
                        "url": "https://m.yohobuy.com/?title=标题&openby:yohobuy={\"action\":\"go.collagehome\",\"params\":{\"title\":\"标题\"}}"
                    },
                    {
                        "bgColor": "",
                        "src": "http://img10.static.yhbimg.com/yhb-img01/2017/07/26/16/01e90704cc16d5a32a1680ae1d415426c6.jpg?imageView2/{mode}/w/{width}/h/{height}",
                        "title": "",
                        "url": "https://m.yohobuy.com/groupPurchase?activityId=56&type=2&title=模式2测试&openby:yohobuy={\"action\":\"go.activitytemplate\",\"params\":{\"activityId\":\"56\",\"type\":\"2\",\"title\":\"模式2测试\"}}"
                    },
                    {
                        "bgColor": "",
                        "src": "http://img10.static.yhbimg.com/yhb-img01/2017/07/27/09/01cc06fea3c1d22375abcd90836759f85f.png?imageView2/{mode}/w/{width}/h/{height}",
                        "title": "",
                        "url": "http://m.yohobuy.com/groupPurchase?activityId=58&type=2&title=团购状态验证&openby:yohobuy={\"action\":\"go.activitytemplate\",\"params\":{\"activityId\":\"58\",\"type\":\"2\",\"title\":\"团购状态验证\"}}"
                    },
                    {
                        "bgColor": "",
                        "src": "http://img11.static.yhbimg.com/yhb-img01/2017/09/20/09/01cf74dac1b0a354b82dc894dc66634352.jpg?imageView2/{mode}/w/{width}/h/{height}",
                        "title": "",
                        "url": "https://list.m.yohobuy.com/?specialsale_id=2&gender=1,3&actiontype=2&cover_url=http://img10.static.yhbimg.com/couponImg/2018/08/27/10/01021a4ec4029934bcffca8ee912f61654.jpg&openby:yohobuy={\"action\":\"go.list\",\"params\":{\"actiontype\":\"2\",\"cover_url\":\"http://img10.static.yhbimg.com/couponImg/2018/08/27/10/01021a4ec4029934bcffca8ee912f61654.jpg\",\"gender\":\"1,3\",\"specialsale_id\":\"2\"}}"
                    },
                    {
                        "bgColor": "",
                        "src": "http://img11.static.yhbimg.com/yhb-img01/2017/10/13/18/018044cceeb5a2afe6223a1412ccda89b9.jpg?imageView2/{mode}/w/{width}/h/{height}",
                        "title": "",
                        "url": "https://search.m.yohobuy.com/?productPool=680&title=618抢先购-6.1折封顶&openby:yohobuy={\"action\":\"go.poollist\",\"params\":{\"title\":\"618抢先购-6.1折封顶\",\"productPool\":\"680\"}}"
                    },
                    {
                        "bgColor": "",
                        "src": "http://img11.static.yhbimg.com/yhb-img01/2018/03/06/11/019dea67754e6c4c08711b118c3d050891.JPG?imageView2/{mode}/w/{width}/h/{height}",
                        "title": "秒杀",
                        "url": "http://m.yohobuy.com/product/seckill?type=2&openby:yohobuy={\"action\":\"go.h5\",\"params\":{\"param\":{\"type\":\"2\"},\"type\":\"2\",\"url\":\"http://m.yohobuy.com/product/seckill\"}}"
                    },
                    {
                        "bgColor": "",
                        "src": "http://img11.static.yhbimg.com/yhb-img01/2018/03/06/11/016a0402a7ff364326046b215f4d088cb8.JPG?imageView2/{mode}/w/{width}/h/{height}",
                        "title": "",
                        "url": "https://m.yohobuy.com/home/family?openby:yohobuy={\"action\":\"go.family\"}"
                    }
                ],
                "focus_type": "2",
                "original_template_id": 1,
                "template_id": "1",
                "template_intro": "焦点图",
                "template_name": "focus"
              },
              {
                "template_name": "hotSeries",
                "data": [
                    {
                        "image_url": "http://img11.static.yhbimg.com/yhb-img01/2017/07/26/16/0186f834d5a21f26717254407c28fc3c53.jpg",
                        "series_name": "哈哈",
                        "series_id": "1"
                    },
                    {
                        "image_url": "http://img11.static.yhbimg.com/yhb-img01/2017/07/26/16/0186f834d5a21f26717254407c28fc3c53.jpg",
                        "series_name": "耐克",
                        "series_id": "2"
                    },
                    {
                        "image_url": "http://img11.static.yhbimg.com/yhb-img01/2017/07/26/16/0186f834d5a21f26717254407c28fc3c53.jpg",
                        "series_name": "哈哈",
                        "series_id": "1"
                    },
                    {
                        "image_url": "http://img11.static.yhbimg.com/yhb-img01/2017/07/26/16/0186f834d5a21f26717254407c28fc3c53.jpg",
                        "series_name": "耐克",
                        "series_id": "2"
                    },
                    {
                        "image_url": "http://img11.static.yhbimg.com/yhb-img01/2017/07/26/16/0186f834d5a21f26717254407c28fc3c53.jpg",
                        "series_name": "哈哈",
                        "series_id": "1"
                    },
                    {
                        "image_url": "http://img11.static.yhbimg.com/yhb-img01/2017/07/26/16/0186f834d5a21f26717254407c28fc3c53.jpg",
                        "series_name": "耐克",
                        "series_id": "2"
                    },
                    {
                        "image_url": "http://img11.static.yhbimg.com/yhb-img01/2017/07/26/16/0186f834d5a21f26717254407c28fc3c53.jpg",
                        "series_name": "耐克",
                        "series_id": "2"
                    },
                ],
                "template_intro": "热门系列",
                "template_id": "1"
              },
              {
                "template_name": "single_image",
                "data": [
                    {
                        "image_url": "http://img11.static.yhbimg.com/yhb-img01/2017/07/26/16/0186f834d5a21f26717254407c28fc3c53.jpg",
                        "series_name": "",
                        "series_id": "1"
                    },
                    {
                        "image_url": "http://img11.static.yhbimg.com/yhb-img01/2017/07/26/16/0186f834d5a21f26717254407c28fc3c53.jpg",
                        "series_name": "",
                        "series_id": "2"
                    }
                ],
                "template_intro": "热门系列",
                "template_id": "1"
              },
              {
                "template_name": "twoPicture",
                "data": [
                    {
                        "src": "http://img11.static.yhbimg.com/yhb-img01/2019/09/24/14/01bdf0e379025b33c9690861b843dbd966.jpg",
                        "id": "",
                        "url": "https://m.yohobuy.com/?openby:yohobuy={'action':'go.bargainlist'}"
                    },
                    {
                        "src": "http://img11.static.yhbimg.com/yhb-img01/2019/09/24/14/01bdf0e379025b33c9690861b843dbd966.jpg",
                        "id": "",
                        "url": "https://m.yohobuy.com/?openby:yohobuy={'action':'go.bargainlist'}"
                    },
                ],
                "template_intro": "热门系列",
                "template_id": "1"
              },
              {
                "template_name": "single_image",
                "data": [
                    {
                        "image_url": "http://img11.static.yhbimg.com/yhb-img01/2017/07/26/16/0186f834d5a21f26717254407c28fc3c53.jpg",
                        "series_name": "",
                        "series_id": "1"
                    },
                    {
                        "image_url": "http://img11.static.yhbimg.com/yhb-img01/2017/07/26/16/0186f834d5a21f26717254407c28fc3c53.jpg",
                        "series_name": "",
                        "series_id": "2"
                    }
                ],
                "template_intro": "热门系列",
                "template_id": "1"
              },
              
          ],
    }
  },
  computed: {
    ...mapState(['channelList']),
  },
  created() {
    
  },
  mounted() {
    this.fetchChannelList();
    this.fetchProductList();
  },
  methods: {
    ...mapActions(['fetchChannelList','fetchProductList']),

    async onPullingUp() {
      await this.fetchProductList();
      setTimeout(() => { this.$refs.scroll.forceUpdate() }, 1000)
    }
    
  },
  components: {
    Slider,
    Banner,
    TwoBanner,
    Hot,
    ScrollNav,
    Style,
    Scroll,
    ProductList
  }
};
</script>

<style lang="scss" scoped>
.scroll-list-wrap {
  height: 100%;
  width: 100%;
}
.body {
  height: 100%;
  overflow-y: auto;
  // padding: 0 40px;
}
</style>