<template>
  <div class="bannar" v-if="(list && list.length > 0) || ((basicSet.slide && basicSet.slide.length > 0) || (basicSet.set && basicSet.set.banner_bg_src))"
       :style="{backgroundImage: from === 'supplier' || slide_style == 2 ? '' :`url(${basicSet.set && basicSet.set.banner_bg_src ? basicSet.set.banner_bg_src : ''})`}">
    <!--供应商显示-->
    <div class="swiper m-auto" :class="{'fill-swiper': slide_style == 2}" v-if="from === 'supplier' && list.length > 0">
      <el-carousel trigger="click" arrow="never" :autoplay="true">
        <el-carousel-item v-for="(item, index) in list" v-if="item && item.pc_thumb" :key="index">
          <img :class="[item.pc_link? 'hoverClass':'']" :src="item.pc_thumb" @click="toLink(item)">
        </el-carousel-item>
      </el-carousel>
    </div>

    <!--分类二广告显示-->
    <div class="swiper m-auto" :class="{'fill-swiper': slide_style == 2}" v-if="from === 'category' && list.pc_adv_img_src">
      <img style="height: 400px;" :class="[list.pc_adv_url? 'hoverClass':'']" @click="toLink(list)" :src="list.pc_adv_img_src" :alt="list.pc_adv_img_src">
    </div>

    <!--首页显示-->
    <div class="swiper m-auto" :class="{'fill-swiper': slide_style == 2}" v-if="(from !== 'supplier' && basicSet.slide.length > 0) && (!list || !list.pc_adv_img_src)">
      <el-carousel trigger="click" arrow="never" :autoplay="true">
        <el-carousel-item v-for="(item, index) in basicSet.slide" :key="index">
          <img :class="[item.url? 'hoverClass':'']" :src="item.img_src" @click="toLink(item)">
        </el-carousel-item>
      </el-carousel>
    </div>
  </div>
</template>

<script>
  import {mapState} from 'vuex'

  export default {
    props: ['list','from'],
    data() {
      return {
        slide_style: 1
      };
    },
    computed: {
      ...mapState(['basicSet', 'basic_info'])
    },
    mounted() {
      this.slide_style = this.basicSet.set.slide_style || 1;
    },
    methods: {
      toLink(item) {
        if(item.url) {
          window.open(item.url, "_blank");
        }else if(item.pc_link) {
          window.open(item.pc_link, "_blank");
        }else if(item.pc_adv_url) {
          window.open(item.pc_adv_url, "_blank");
        }
      }
    }
  };
</script>
<style lang="scss" scoped>
  .bannar {
    height: 400px;
    width: 100%;
    /*background-image: url("");*/
    background-repeat: no-repeat;
    background-size: 100% 100%;
    margin-bottom: 80px;
    .swiper {
      padding-top: 30px;
      width: 1200px;
      :deep(.el-carousel__container) {
        height: 428px;
      }
      :deep(.el-carousel__button) {
        width: 16px;
        height: 6px;
        background-color: #fff;
        border-radius: 3px;
        opacity: 1;
      }
      :deep(.el-carousel__indicator.is-active) button {
        background-color: var(--color);
      }
      img {
        width:100%;
        height:100%;
        /*border-radius: 10px;*/
      }
    }
    .swiper.fill-swiper {
      padding-top: 0;
      width: 100%;
      :deep(.el-carousel__container) {
        height: 458px;
      }
    }

    .hoverClass {
      cursor: pointer;
    }
  }
</style>
