<style lang="less">
.carousel-container {
  width: 100%;
  height: 100%;
  .imgs-container {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
    .swiper {
      height: 100%;
    }
    .imgs-wrap {
      height: 100%;
      display: flex;
      justify-items: flex-start;
      align-items: flex-start;
      flex-wrap: nowrap;
    }
    .wrap-transition {
      transition: ease-in-out .5s;
    }
    .img-block {
      width: 100%;
      height: 100%;
      background-size: cover;
      background-position: center;
      background-repeat: no-repeat;
      flex: none;
    }
  }
  .dots {
    position: absolute;
    z-index: 1;
    bottom: 16rpx;
    left: 50%;
    transform: translateX(-50%);
    width: 50%;
    height: 16rpx;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    .dot {
      display: inline-block;
      height: 16rpx;
      width: 16rpx;
      border-radius: 50%;
      border: 1rpx solid #FFFFFF;
      background: transparent;
      margin-right: 12rpx;
    }
    .dot:nth-last-child(1) {
      margin-right: 0;
      display: none;
    }
    .dot-actived {
      background: #FFFFFF;
    }
  }
}
</style>

<template>
  <div class="carousel-container" ref="container">
    <div class="imgs-container" v-if="imgs.length">
      <swiper
        class="swiper"
        :indicator-dots="true" :autoplay="true" :circular="true"
        :interval="3000" easing-function="easeInOutCubic"
        indicator-color="rgba(255, 255, 255, .5)" indicator-active-color="#ffffff">
        <swiper-item v-for="(img, index) in imgs" :key="index">
          <div  class="img-block"
            :style="{ 'background-image': 'url('+h5Origin+'/'+img.imageUrl+')'}"
            @click="goDetail(img.innerUrl)"
          ></div>
          <view class="swiper-item {{item}}"></view>
        </swiper-item>
      </swiper>
    </div>
  </div>
</template>

<script>
import wepy from '@wepy/core';
import config from '@/config';
import utils from '../../common/utils.js';

const DEFAULT_INTERVAL = 3000
const DEFAULT_ANIMATION_TIME = 500
wepy.component({
  props: {
    imgs: Array,
    interval: Number
  },
  data: {
    h5Origin: config.h5Origin,
  },
  computed: {
  },
  watch: {
    imgs (val) {
      // console.log(val)
    }
  },
  methods: {
    goDetail(absUrl) {
      wx.navigateTo({
        url: `/h5/pages/external-view/h5?url=${absUrl}`,
      });
    }
  },
  ready() {
  }
});
</script>