<template>
  <div class="t-list f-hflex">
    <swiper ref="orderSwiper" :options="swiperOptions" v-if="list.length> 0">
      <swiper-slide
          v-for="(item, index) in list"
          :key="index"
          class="swiper-slide"
      >
        <div
            class="item f-flex bto-border"
            @click="handleView(item)"
        >
          <slot :data="item"/>
        </div>
      </swiper-slide>
    </swiper>
    <div v-else class="no-data">
      暂无数据
    </div>
  </div>
</template>

<script>
import {swiper, swiperSlide} from "vue-awesome-swiper";

export default {
  name: "DemandSwiperList",
  components: {
    swiper,
    swiperSlide,
  },
  props: {
    list: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      swiperOptions: {
        direction: "vertical", // 滑动方向，可以是 'horizontal' 或 'vertical'
        slidesPerView: 3,
        autoplay: {
          delay: 1000, // 自动切换的间隔时间，单位是毫秒
          disableOnInteraction: true, // 用户操作后是否禁止自动切换
        },
        loop: false, // 是否启用循环模式
        speed: 2000, // 滑动速度，单位是毫秒
      },
    }
  },
  mounted() {

  },
  methods: {
    handleView(item) {
      this.$emit('showDetail', item)
    }
  }
}
</script>

<style lang="scss" scoped>

.f-hflex {
  width: 83px;
}

.f-flex {
  margin-top: 4px;
}

.f-darkGray {
  margin-top: 15px;
}

.no-data {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: .6;
  color: #fff;
}

.t-list {
  position: relative;
  flex: 1;
  width: 100%;

  .swiper-container {
    width: 100%;
    height: 120px;
  }

  .item {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 40px;
    cursor: pointer;
    color: #fff;

    span {
      //text-align: center;
    }

    > :nth-child(1) {
      width: 50px;
      color: #A3B9DA
    }

    > :nth-child(2) {
      overflow: hidden;
      flex: 1;
      white-space: nowrap;
      text-overflow: ellipsis;
    }
  }
}

.swiper-slide {
  padding: 0 4px;
  //height: 36px!important;
  .bto-border {
    border-bottom: 1px solid;
    border-image: linear-gradient(to right, #1c3e69 0%, #4eafd5 50%, #1c3e69 100%);
    border-image-slice: 1;
  }
}

.no-data {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: .6;
  color: #fff;
  height: 120px;
}
</style>