<template>
  <!-- ICO-首页 -->
  <HeaderNav headerText="ICO"></HeaderNav>
  <div class="ico-index">
    <div class="index-classifi">
      <div
        class="classifi-item pf600 fs18 fc121212"
        :class="current == 'subscription' ? 'current-classifi' : 'pf600 fs14 fcA8A8A8'"
        @click="messageChange('subscription')">
        认购
        <div class="active-line" v-if="current == 'subscription'"></div>
      </div>
      <div
        class="classifi-item pf600 fs14 fcA8A8A8"
        :class="current == 'placement' ? 'current-classifi' : 'pf600 fs14 fcA8A8A8'"
        @click="messageChange('placement')">
        配售
        <div class="active-line" v-if="current == 'placement'"></div>
      </div>
      <div
        class="classifi-item pf600 fs14 fcA8A8A8"
        :class="current == 'lotteryResult' ? 'current-classifi' : 'pf600 fs14 fcA8A8A8'"
        @click="messageChange('lotteryResult')">
        中签结果
        <div class="active-line" v-if="current == 'lotteryResult'"></div>
      </div>
      <div
        class="classifi-item pf600 fs14 fcA8A8A8"
        :class="current == 'coinPreview' ? 'current-classifi' : 'pf600 fs14 fcA8A8A8'"
        @click="messageChange('coinPreview')">
        新币预览
        <div class="active-line" v-if="current == 'coinPreview'"></div>
      </div>
      <div
        class="classifi-item pf600 fs14 fcA8A8A8"
        :class="current == 'relus' ? 'current-classifi' : 'pf600 fs14 fcA8A8A8'"
        @click="messageChange('relus')">
        ICO规则
        <div class="active-line" v-if="current == 'relus'"></div>
      </div>
    </div>
    <component :is="currentComponent" />
  </div>
</template>
<script setup>
  import HeaderNav from "../components/HeaderNav.vue";
  import CoinPreview from "./CoinPreview.vue";
  import LotteryResult from "./LotteryResult.vue";
  import Placement from "./Placement.vue";
  import Relus from "./Relus.vue";
  import Subscription from "./Subscription.vue";
  import { ref, computed } from "vue";

  const current = ref("subscription");
  const componentsMap = {
    coinPreview: CoinPreview,
    lotteryResult: LotteryResult,
    placement: Placement,
    relus: Relus,
    subscription: Subscription,
  };
  const currentComponent = computed(() => componentsMap[current.value]);

  const messageChange = (key) => {
    current.value = key;
  };
</script>
<style lang="less" scoped>
  .ico-index {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    width: 100%;

    .index-classifi {
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      align-items: center;
      margin-top: 48px;
      width: 349px;
      height: 24px;

      .classifi-item {
        position: relative;

        .active-line {
          position: absolute;
          bottom: -6px;
          left: 50%;
          transform: translateX(-50%);
          width: 20px;
          height: 3px;
          background-color: #323233;
          border-radius: 2px;
        }

        &:first-child {
          margin-left: 0;
        }
      }

      .current-classifi {
        font-family: "PingFang SC";
        font-style: normal;
        font-weight: 600;
        font-size: 18px;
        color: #121212;
        transition: color 0.3s, font-size 0.3s;
      }
    }
  }
</style>
