<template>
  <div class="index-box">
    <img src="../../public/fourBoxes-image/1.jpg" class="bg-image" />
    <div class="index-FourBoxes">
      <div class="index-FourBoxes-yushi test" style="margin-bottom:2vw" :class="{ active: currentItem === 0 }" @click="goPagess(0)">
        <img src="../../public/fourBoxes-image/浴室.png" class="Four-image" @transitionend="handleTransitionEnd('yushi')" />
        <div style=" width: 21vw; position: absolute; left: 13.5vw; top: 70vw;">
          <img style=" width:100%;" src="../assets/fourBoxes-2/浴室-2.png" />
        </div>
      </div>
      <div class="index-FourBoxes-yimao test" style="margin-bottom:2vw" :class="{ active: currentItem === 1 }" @click="goPagess(1)">
        <img src="../../public/fourBoxes-image/衣帽间.png" class="Four-image" @transitionend="handleTransitionEnd('yimao')" />
        <div style=" width: 21vw;; position: absolute; right: 13.5vw; top: 70vw;">
          <img style=" width:100%;" src="../assets/fourBoxes-2/衣帽间-2.png" />
        </div>
      </div>
      <div class="index-FourBoxes-keting test" :class="{ active: currentItem === 2 }" @click="goPagess(2)">
        <img src="../../public/fourBoxes-image/客厅.png" @transitionend="handleTransitionEnd('keting')" class="Four-image" />
        <div style=" width: 21vw;; position: absolute; left: 13.5vw; top: 70vw;">
          <img style=" width:100%;" src="../assets/fourBoxes-2/客厅-2.png" />
        </div>
      </div>
      <div class="index-FourBoxes-yangtai test" :class="{ active: currentItem === 3 }" @click="goPagess(3)">
        <img src="../../public/fourBoxes-image/阳台.png" @transitionend="handleTransitionEnd('yangtai')" class="Four-image" />
        <div style=" width: 21vw;; position: absolute; right: 13.5vw; top: 70vw;">
          <img style=" width:100%;" src="../assets/fourBoxes-2/阳台-2.png" />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      currentItem: -1
    }
  },
  methods: {
    handleTransitionEnd(types) {
      this.$router.push({ name: 'Test', query: { types }})
    },
    goPagess(inx) {
      this.currentItem = inx
    }
  }
}
</script>

<style lang="scss" scoped>
.index-box {
  width: 100vw;
  display: flex;
  .bg-image {
    width: 100%;
    position: absolute;
  }
  .index-FourBoxes {
    position: relative;
    top: 29vw;
    width: 98%;
    height: 84%;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    .test {

      & > img {
        opacity: .6;
        transition: opacity .2s ease;
      }

      &.active > img {
        opacity: 1;
      }


      float: left;
      width: 48%;
      height: 80vw;
      position: relative;
      .Four-image {
        width: 100%;
        height: 100%;
      }
    }
    &-yushi,
    &-keting {
      margin-right: 1vw;
    }
    &-yimao,
    &-yangtai {
      margin-left: 1vw;
    }
  }
}
</style>

