<template>
  <div class="imgcon">
    <iframe class="v-image" @click.stop allowfullscreen="true" :src="link[current]" frameborder="0"></iframe>

    <span class="toLeft" @click="handle('left')">
      <img :src="require('@/assets/images/icons/arrow_left@2x.png')" alt="" />
    </span>
    <span class="toRight" @click="handle('right')">
      <img :src="require('@/assets/images/icons/arrow_right@2x.png')" alt="" />
    </span>

    <div class="btmdot">{{ current + 1 }} / {{ link.length }}</div>
  </div>
</template>

<script>
export default {
  props: ["link"],
  data() {
    return {
      current: 0,
    };
  },
  methods: {
    handle(type) {
      if (type == "left") {
        this.current == 0 ? (this.current = this.link.length - 1) : (this.current -= 1);
      } else {
        this.current == this.link.length - 1 ? (this.current = 0) : (this.current += 1);
      }
    },
  },
};
</script>

<style lang="less" scoped>
.imgcon {
  .v-image {
    width: 100%;
    height: 540px;
  }
  .toLeft,
  .toRight {
    font-size: 0;
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
    z-index: 99;
    cursor: pointer;
    position: absolute;
    color: #fff;
    width: 52px;
    height: 52px;
    background: rgba(0, 0, 0, 0.5);
    padding: 14px;
    > img {
      width: 100%;
      height: 100%;
      cursor: pointer;
    }
  }
  .toRight {
    left: auto;
    right: 10px;
  }
  .scale {
    font-size: 0;
    bottom: 10px;
    right: 10px;
    z-index: 99;
    cursor: pointer;
    position: absolute;
    color: #fff;
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 18px;
    > img {
      width: 100%;
      height: 100%;
      cursor: pointer;
    }
  }
  .btmdot {
    height: 28px;
    line-height: 28px;
    padding: 0 20px;
    font-size: 14px;
    color: #fff;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 14px;
    position: absolute;
    letter-spacing: 1px;
    transform: translateX(-50%);
    left: 50%;
    z-index: 999;
    bottom: 16px;
  }
}
</style>
