article-image.vue 1.68 KB
<template>
  <div class="cover-slide">
    <cube-slide ref="slide" :options="slideOptions" :loop="false" :auto-play="false" :data="imageList">
      <cube-slide-item v-for="(item, index) in imageList" :key="index" @click.native="clickHandler(item, index)">
        <a click="javascript:void 0" class="square-img-container">
          <SquareImg :src="item.image_url" :width="600" :height="600"/>
        </a>
      </cube-slide-item>
      <template slot="dots" slot-scope="props">
        <div class="dot-wrap">
          {{props.current + 1}}/{{imageList.length}}
        </div>
      </template>
    </cube-slide>
  </div>
</template>

<script>
import { Slide } from 'cube-ui';
import SquareImg from '../../product/components/square-img';

export default {
  name: 'articleImage',
  components: {
    'cube-slide': Slide,
    'cube-slide-item': Slide.Item,
    SquareImg
  },
  props: {
    imageList: Array
  },
  data() {
    return {
      slideOptions: {
        eventPassthrough: 'vertical',
      },
    };
  },
  activated() {
    this.$nextTick(()=> {
      this.$refs.slide.refresh();
    });
  },
  methods: {
    clickHandler(item, index) {
      console.log(item, index);
    }
  }
};
</script>

<style lang="scss" scoped>
.cover-slide {
  flex: 1;

  .square-img-container {
    display: block;
    width: 100%;
    height: 750px;
    margin: 0 auto;
  }

  .dot-wrap {
    margin-left: 24px;
    margin-bottom: 24px;
    background: #000;
    opacity: 0.5;
    width: 80px;
    height: 48px;
    border-radius: 30px;
    color: white;
    font-size: 24px;
    letter-spacing: 1.96px;
    line-height: 48px;
    text-align: center;
  }
}

.cube-slide-item {
  img {
    margin: 0 auto;
  }
}

</style>