<template>
  <div style="height: 40px;">
    <div class="tab-block">
      <div v-audio v-for="(text, index) in tab" :key="index" :class="{active: tabIndex === index}" class="tab-box btn" @click="tabIndex = index">
        <img v-if="tabIndex === index" class="tab-img" src="https://kuawai.s3.ap-east-1.amazonaws.com/resource/assets/Textures/second/Rounded%20Rectangle%2019.png" alt="">
        <img v-else class="tab-img" src="https://kuawai.s3.ap-east-1.amazonaws.com/resource/assets/Textures/second/last_game%20%E6%8B%B7%E8%B4%9D%202.png" alt="">
        <div class="text">{{ text }}</div>
        <div v-if="index === 0" class="version">{{ `1.0.020` }}</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tab: [
        // '个人资料',
        '游戏记录',
        '分数转账表',
      ],
      tabIndex: 0,
    }
  },
  watch: {
    tabIndex(value) {
      console.log('value', value)
      this.$emit('on-change', value)
    },
  },
}
</script>

<style lang="scss" scoped>
.tab-block {
  display: flex;
  position: relative;
  top: -10px;
  .tab-box {
    position: relative;
    color: #16bcc7;
    text-align: center;
    line-height: 38px;
    font-size: 15px;
    font-weight: bold;
    flex: 1;
    height: 50px;
    $margin-size: -8px;
    overflow: hidden;
    transition-duration: 0s;
    &:nth-child(2) {
      z-index: 1;
      margin-left: $margin-size;
      margin-right: $margin-size;
    }
    &:first-child {
      margin-right: $margin-size;
    }
    &:last-child {
      margin-left: $margin-size;
    }
    &.active {
      .tab-img {
        position: absolute;
        height: 50px;
        z-index: 2;
      }
      font-size: 16px;
      line-height: 30px;
    }
    .tab-img {
      position: absolute;
      left: 0;
      height: 100%;
      bottom: -2px;
      width: 100%;
      height: 42px;
    }
    .text {
      position: relative;
      z-index: 4;
      margin-top: 10px;
    }
    .version {
      font-size: 12px;
      color: rgb(188, 188, 188);
      position: absolute;
      bottom: -10px;
      text-align: center;
      width: 100%;
      z-index: 3;
    }
  }
}
</style>
