<template>
  <div class="main_content">
    <!--  -->
    <div class="main_content_plan">
      <!-- 标题 -->
      <div class="main_content_plan_title">
        <slot name="plan_title"></slot>
      </div>
      <!-- tab切换 -->
      <div class="main_content_plan_tab">
        <div v-for="(item, index) in tabList" :key="index" @click="handleTab(index)">
          <div class="tabItem" :class="activeTab === index ? 'tabItem_active' : 'tabItem_inactive'">
            <img :src="item.icon" v-if="activeTab !== index" />
            <img :src="item.iconActive" v-else />
            <div class="tabItem_name">{{ item.tabName }}</div>
          </div>
        </div>
      </div>
    </div>
    <!-- 触发条件 -->
    <div class="main_content_trigger">
      <div class="main_content_trigger_title">
        <slot name="trigger_title"></slot>
      </div>
      <div class="main_content_trigger_con">
        <slot name="trigger_con"></slot>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    tabList: {
      type: Array
    },
    index: { type: Number }
  },
  data() {
    return {
      activeTab: this.index || 0
    }
  },
  methods: {
    handleTab(index) {
      this.activeTab = index
      this.$emit('tabActive', index)
    }
  }
}
</script>
<style lang="scss" scoped>
.main_content {
  width: 883px;
  background: rgba(255, 255, 255, 0.39);
  border: 1px solid #e8e8e8;
  opacity: 1;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  padding: 22px 0 43px 21px;
  .main_content_plan {
    .main_content_plan_title {
      font-size: 18px;
      font-weight: 500;
      color: #333333;
    }
    .main_content_plan_tab {
      display: flex;
      margin-top: 20px;
      .tabItem_active {
        background: #49bba2;
        color: #ffffff;
        .tabItem_name {
          margin-left: 5px;
          font-size: 16px;
          color: #ffffff;
        }
      }
      .tabItem_inactive {
        background: #ffffff;
        border: 1px solid #cdcdcd;
        .tabItem_name {
          margin-left: 5px;
          font-size: 16px;
          color: #6d6d71;
        }
      }
      .tabItem {
        width: 119px;
        height: 36px;
        border-radius: 18px;
        margin-right: 19px;
        display: flex;
        justify-content: center;
        align-items: center;
        img {
          width: 16px;
          height: 16px;
          display: block;
        }
        .tabItem_name {
          margin-left: 5px;
          font-size: 16px;
        }
      }
    }
  }
  .main_content_trigger {
    margin-top: 40px;
    .main_content_trigger_title {
      font-size: 18px;
      font-weight: 500;
      color: #333333;
    }
    .main_content_trigger_con {
      font-size: 16px;
      font-weight: 400;
      color: #333333;
      margin-top: 20px;
    }
  }
}
</style>
