<template>
    <view class="banner">
        <uni-swiper-dot :info="list" :current="current" mode="dot" :dotsStyles="dotsStyles">
            <swiper
                :indicator-dots="false"
                :autoplay="autoplay"
                :interval="interval"
                :duration="duration"
                :circular="true"
                :style="{ height: height }"
                :current="current"
                @change="onChange"
            >
                <swiper-item v-for="(item, index) in list" :key="index">
                    <view class="swiper-item" :style="[{ margin: margin }]" @click.stop="$emit('click', index)">
                        <image :src="item" :style="{ borderRadius: radius }"></image>
                    </view>
                </swiper-item>
            </swiper>
        </uni-swiper-dot>
    </view>
</template>

<script>
export default {
    name: 'goods-image-swiper',
    props: {
        list: {
            type: Array,
            default: () => []
        },
        current: {
            type: Number,
            default: 0
        },
        autoplay: {
            type: Boolean,
            default: true
        },
        interval: {
            type: Number,
            default: 3000
        },
        duration: {
            type: Number,
            default: 200
        },
        margin: {
            type: String,
            default: '0'
        },
        radius: {
            type: String,
            default: '0'
        },
        height: {
            type: String,
            default: '750rpx'
        }
    },
    data() {
        return {
            dotsStyles: {
                width: 6,
                bottom: 8,
                color: 'background: rgba(255, 255, 255, 0.39)',
                backgroundColor: 'background: rgba(255, 255, 255, 0.39)',
                border: '0',
                selectedBackgroundColor: '#FF457B',
                selectedBorder: '#FF457B'
            }
        }
    },
    methods: {
        onChange(e) {
            this.$emit('change', e.detail.current)
        }
    }
}
</script>

<style lang="scss" scoped>
.swiper-item {
    overflow: hidden;
    height: 100%;
    image {
        display: block;
        width: 100%;
        height: 100%;
    }
}
</style>
