<template>
  <swiper 
    class="image-swiper" 
    circular
    :style="{ height: height }"
    :indicator-dots="true"
    :autoplay="true"
    :interval="2000"
    :duration="1000"
  >
    <swiper-item v-for="(item, key) in images" :key="key">
      <view class="item">
        <Image
          :src="item"
          width="100%"
          :height="height"
          :radius="15"
          mode="aspectFit"
          touchable
          @click="onPreviewImage(key)"
        />
      </view>
    </swiper-item>
  </swiper>
</template>

<script setup lang="ts">
import { useSwiperImagePreview } from '@/common/composeabe/SwiperImagePreview';
import Image from '@/components/basic/Image.vue';
import type { PropType } from 'vue';

const props = defineProps({
  images: {
    type: Array as PropType<string[]>,
    default: () => [],
  },
  height: {
    type: String,
    default: '400rpx',
  },
})

const { onPreviewImage } = useSwiperImagePreview(() => props.images || [])

</script>

<style lang="scss">
.image-swiper {
  height: 400rpx;

  image {
    border-radius: 20rpx;
  }
}
</style>