<template>
  <div>
    <div class="btn-tabs-boxs">
      <template v-for="(item, index) in data.options">
        <div :key="index" :class="tabsIndex == index && 'active'" @click="tabs(index)">{{ item }}</div>
      </template>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    data: {
      type: Object,
      default: {}
    }
  },
  data() {
    return {
      tabsIndex: 0
    }    
  },
  mounted() {
    if (this.data.index) {
      this.tabsIndex = this.data.index
    }
  },
  methods: {
    tabs(n) {
      this.tabsIndex = n
      this.$emit('tabsChange', n)
    }
  },
  watch: {
    $route: {
      handler: function(val, oldVal){
        if (this.$route.query.type !== undefined || this.$route.query.type !== 'undefined') {
          this.tabsIndex = parseInt(this.$route.query.type)
        }
      },
      deep: true
    }
  }
}
</script>
<style lang="scss" scoped>
.btn-tabs-boxs{
    // padding: 24px 0 30px;
    display: flex;
    // justify-content: center;
    div{
      cursor: pointer;
      // text-align: center;
      // width: 200px;
      // height: 56px;
      // background: #F9F9F9;
      // font-size: 18px;
      // color: #666666;
      // line-height: 56px;
      // &.active{
      //   color: #fff;
      //   background: linear-gradient(315deg, rgba(225, 47, 116, 0.83) 0%, #C01540 100%);
      // }
      width: 88px;
      height: 34px;
      border-radius: 27px;
      text-align: center;
      line-height: 34px;
      font-size: 14px;
      color: #444444;
      &.active{
        background: #A81A41;
        color: #fff;
      }
    }
  }
</style>
