<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" :class="{ active: currentItem === 0 }" @click="goPagess(0)">
        <img src="../../public/fourBoxes-image/浴室.png" class="Four-image" @transitionend="handleTransitionEnd('yushi')" />
        <div style=" width: 80px; position: absolute; left: 13vw; top: 36vh;">
          <img style=" width:100%;" src="../assets/fourBoxes-2/浴室-2.png" />
        </div>
      </div>
      <div class="index-FourBoxes-yimao test" :class="{ active: currentItem === 1 }" @click="goPagess(1)">
        <img src="../../public/fourBoxes-image/衣帽间.png" class="Four-image" @transitionend="handleTransitionEnd('yimao')" />
        <div style=" width: 80px;; position: absolute; left: 62vw; top: 36vh;">
          <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: 80px;; position: absolute; left: 13vw; top: 77vh;">
          <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: 80px;; position: absolute; left: 62vw; top: 77vh;">
          <img style=" width:100%;" src="../assets/fourBoxes-2/阳台-2.png" />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      currentItem: -1,
      currentType: '',
      styleImage: [
        'opacity: 0.3;',
        'opacity: 0.3;',
        'opacity: 0.3;',
        'opacity: 0.3;',
        ],
      typeYushi: {
        bgImage: require('../../public/yushi-image/1.jpg'),
        swiper: {
          swiper1: require('../../public/yushi-image/2.png'),
          swiper2: require('../../public/yushi-image/3.png'),
          swiper3: require('../../public/yushi-image/4.png')
        }
      },
      typeYimao: {
        bgImage: require('../../public/yimao-image/1.jpg'),
        swiper: {
          swiper1: require('../../public/yimao-image/2.png'),
          swiper2: require('../../public/yimao-image/3.png'),
          swiper3: require('../../public/yimao-image/4.png')
        }
      },
      typeKeting: {
        bgImage: require('../../public/keting-image/1.jpg'),
        swiper: {
          swiper1: require('../../public/keting-image/2.png'),
          swiper2: require('../../public/keting-image/3.png'),
          swiper3: require('../../public/keting-image/4.png'),
          swiper4: require('../../public/keting-image/5.png')
        }
      },
      typeYangtai: {
        bgImage: require('../../public/yangtai-image/1.jpg'),
        swiper: {
          swiper1: require('../../public/yangtai-image/2.png'),
          swiper2: require('../../public/yangtai-image/3.png'),
          swiper3: require('../../public/yangtai-image/4.png'),
          swiper4: require('../../public/yangtai-image/5.png')
        }
      }
    }
  },
  methods: {
    handleTransitionEnd(types) {
      this.$router.push({ name: 'Test', params: { types }})
    },
    goPagess(inx) {
      this.currentItem = inx

      // switch (e) {
      //   case 'yushi':
      //     var arr = JSON.stringify(this.typeYushi)
      //     this.styleImage[0] = 'opacity:1'
      //     setTimeout(()=>{
      //       this.$router.push({
      //           name: 'Test',
      //           params: { types: encodeURIComponent(arr) }
      //       })
      //       // this.styleImage[0] = 'opacity: 0.3;'
      //     },1000)
      //     break
      //   case 'keting':
      //     var arr = JSON.stringify(this.typeKeting)
      //     this.styleImage[1] = ''
      //     setTimeout(()=>{
      //       this.$router.push({
      //         name: 'Test',
      //         params: { types: encodeURIComponent(arr) }
      //       })
      //       // this.styleImage[1] = 'opacity: 0.3;'
      //     },1000)
      //     break
      //   case 'yimao':
      //     var arr = JSON.stringify(this.typeYimao)          
      //     this.styleImage[2] = ''
      //     setTimeout(()=>{
      //       this.$router.push({
      //         name: 'Test',
      //         params: { types: encodeURIComponent(arr) }
      //       })
      //       // this.styleImage[2] = 'opacity: 0.3;'
      //     },1000)
      //     break
      //   case 'yangtai':
      //     var arr = JSON.stringify(this.typeYangtai)
      //     this.styleImage[3] = ''
      //     setTimeout(()=>{
      //       this.$router.push({
      //         name: 'Test',
      //         params: { types: encodeURIComponent(arr) }
      //       })
      //       // this.styleImage[3] = 'opacity: 0.3;'
      //     },1000)
      //     break
      //   default:
      //     return
      // }
    },
    goYimao() {},
    goKeting() {},
    goYangtai() {}
  }
}
</script>

<style lang="scss" scoped>
.index-box {
  width: 100vw;
  height: 100vh;
  display: flex;
  .bg-image {
    width: 100%;
    height: 100vh;
    position: absolute;
  }
  .index-FourBoxes {
    position: relative;
    top: 16vh;
    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: 49%;
      .Four-image {
        width: 100%;
        height: 100%;
      }
    }
    &-yushi,
    &-keting {
      margin-right: 4px;
    }
    &-yimao,
    &-yangtai {
      margin-left: 4px;
    }
  }
}
</style>

