<template>
  <!-- 我的资产 -->
  <HeaderNav headerText="资产"></HeaderNav>
  <div class="user-asset">
    <div class="notifi-classifi">
      <div
        class="classifi-item"
        :class="current == 'overview' ? 'current-classifi' : 'pf600 fs14 fcA8A8A8'"
        @click="messageChange('overview')">
        总览
      </div>
      <div
        class="classifi-item"
        :class="current == 'balance' ? 'current-classifi' : 'pf600 fs14 fcA8A8A8'"
        @click="messageChange('balance')">
        余额
      </div>
      <div
        class="classifi-item"
        :class="current == 'contract' ? 'current-classifi' : 'pf600 fs14 fcA8A8A8'"
        @click="messageChange('contract')">
        合约
      </div>
      <div
        class="classifi-item"
        :class="
          current == 'financialManagement' ? 'current-classifi' : 'pf600 fs14 fcA8A8A8'
        "
        @click="messageChange('financialManagement')">
        理财
      </div>
      <div
        class="classifi-item"
        :class="current == 'option' ? 'current-classifi' : 'pf600 fs14 fcA8A8A8'"
        @click="messageChange('option')">
        期权
      </div>
      <div
        class="classifi-item"
        :class="current == 'miaoContract' ? 'current-classifi' : 'pf600 fs14 fcA8A8A8'"
        @click="messageChange('miaoContract')">
        秒合约
      </div>
      <div
        class="classifi-item"
        :class="current == 'lever' ? 'current-classifi' : 'pf600 fs14 fcA8A8A8'"
        @click="messageChange('lever')">
        币币
      </div>
    </div>
    <component :is="currentComponent" />
  </div>
</template>
<script setup>
  import HeaderNav from "../index/components/HeaderNav.vue";
  import Balance from "./myAsset/Balance.vue";
  import Contract from "./myAsset/Contract.vue";
  import FinancialManagement from "./myAsset/FinancialManagement.vue";
  import Lever from "./myAsset/Lever.vue";
  import MiaoContract from "./myAsset/MiaoContract.vue";
  import Option from "./myAsset/Option.vue";
  import Overview from "./myAsset/Overview.vue";
  import { ref, computed } from "vue";

  const current = ref("overview");
  const componentsMap = {
    balance: Balance,
    contract: Contract,
    financialManagement: FinancialManagement,
    lever: Lever,
    miaoContract: MiaoContract,
    option: Option,
    overview: Overview,
  };
  const currentComponent = computed(() => componentsMap[current.value]);

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

    .notifi-classifi {
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      align-items: flex-end;
      margin-top: 48px;
      width: 345px;
      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: 14px;
        color: #121212;
        transition: color 0.3s, font-size 0.3s;
      }
    }
  }
</style>
