image-carousel.vue 2.41 KB
<template>
    <div class="image-carousel">
        <div class="swipe-wrap">
            <swipe :continuous="true" :auto="0" :show-indicators="goods && goods.length > 1" ref="swipe">
                <swipe-item v-for="item in goods" :key="item.color_image">
                    <img :title="item.title"
                        v-img-src="{src: item.color_image, width: 580, height: 773}"
                        width="100%" alt=""
                        @click.prevent="showcase()">
                </swipe-item>
            </swipe>
        </div>
        <div class="indicators-bg"></div>
    </div>
</template>
<style l>
    .image-carousel {
        width: 100%;
        height: 833px;
        overflow: hidden;

        .swipe-wrap {
            width: 100%;
            padding: 0 85px;
            font-size: 0;
        }

        .mint-swipe {
            display: inline-block;
            width: 100%;
            height: 773px;
            overflow: visible;

            .mint-swipe-items-wrap > div {
            }

            .mint-swipe-item {
                width: 100%;

                &.active {
                }
            }
        }

        .mint-swipe-indicators {
            bottom: -35px;
        }

        .mint-swipe-indicator {
            width: 10px;
            height: 10px;
            line-height: 10px;
            display: inline-block;
            border-radius: 0;

            &.active {
                width: 20px;
                height: 10px;
                background: #000;
                opacity: 0.6;
                margin: 0 5px;
            }
        }

        .indicators-bg {
            height: 60px;
            width: 100%;
            background-color: #f7f7f7;
        }
    }
</style>
<script>
    import { Swipe, SwipeItem } from 'vue-swipe';
    import yoho from 'yoho';

    export default {
        props: {
            goods: [Object]
        },
        data() {
            return {
            };
        },
        components: {
            swipe: Swipe,
            swipeItem: SwipeItem,
        },
        methods: {
            showcase: function() {
                const opts = {
                    images: this.goods.map((item) => {
                        return item.color_image;
                    }).filter(image => image),
                    index: this.$refs.swipe.index
                };

                yoho.goImageBrowser(opts);
            }
        }
    };
</script>