<template>
  <swiper class="swiper" :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval" :duration="duration">
    <block v-for="(item, index) in banners" :key="index">
      <swiper-item @click="toDetail(item)">
        <img cless="img" :src="item.icon" class="slide-image" mode="aspectFill" />
      </swiper-item>
    </block>
  </swiper>
</template>

<script>
export default {
  props: {
    banners: {
      type: Array
    }
  },
  data() {
    return {
      indicatorDots: true,
      autoplay: true,
      interval: 3000,
      duration: 500
    };
  },
  methods: {
    toDetail(item) {
     console.log(item)
     let url = item.redirectPath + '?title=' + item.name
     let type = item.redirectType
     if(!item.redirectPath){
       return false
     }
     if (type === 'tab_bar') {
       // 小程序 tab 页
       wx.reLaunch({ url });
     } else if( type == 'bund_page' || type == 'tpl_page' || type == 'inner_page'){
       // 小程序内页
       wx.navigateTo({ url });
     }else if(type == 'web_view'){
       // webview
       wx.navigateTo({
         url: '/pages/h5Page/main?src='+url
       })
     }
    }
  }

};
</script>

<style lang="stylus" scoped>
.swiper {
  height: 200rpx !important;
  img {
    height: 100%;
    width: 100%;
  }
}
</style>
