<template>
  <div class="otc-header">
    <div class="header-content pf600 fs16 fc1F2937">
      <img
        class="left-arrow-image"
        src="@/assets/icon/index/left-arrow.svg"
        @click="toPath()" />
      OTC交易
      <div class="save pf500 fs14 fcDF384C">
        <img src="@/assets/icon/index/Headphones.svg" class="service" alt="" />
        <img src="@/assets/icon/asset/search-black.svg" class="search" alt="" />
      </div>
    </div>
  </div>
  <div class="index">
    <div class="notifi-classifi">
      <div
        class="classifi-item"
        :class="current == 'c2c' ? 'current-classifi' : 'pf600 fs14 fcA8A8A8'"
        @click="messageChange('c2c')">
        C2C
        <div class="active-line" v-if="current == 'c2c'"></div>
      </div>
      <div
        class="classifi-item"
        :class="current == 'fast' ? 'current-classifi' : 'pf600 fs14 fcA8A8A8'"
        @click="messageChange('fast')">
        快捷交易
        <div class="active-line" v-if="current == 'fast'"></div>
      </div>
      <div
        class="classifi-item"
        :class="current == 'bulk' ? 'current-classifi' : 'pf600 fs14 fcA8A8A8'"
        @click="messageChange('bulk')">
        大宗交易
        <div class="active-line" v-if="current == 'bulk'"></div>
      </div>
    </div>
    <component :is="currentComponent" />
  </div>
</template>
<script setup>
  import { ref, computed } from "vue";
  import { useRoute, useRouter } from "vue-router";
  import C2C from "./C2C.vue";
  import Fast from "./Fast.vue";
  import Bulk from "./Bulk.vue";

  const router = useRouter();

  const current = ref("c2c");
  const componentsMap = {
    c2c: C2C,
    fast: Fast,
    bulk: Bulk,
  };
  const currentComponent = computed(() => componentsMap[current.value]);

  const messageChange = (key) => {
    current.value = key;
  };

  const toPath = () => {
    router.push("/");
  };
</script>
<style lang="less" scoped>
  .otc-header {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1;
    width: 100%;
    height: 48px;
    background: #ffffff;
    overflow: hidden;

    .header-content {
      display: flex;
      flex-direction: row;
      justify-content: center;
      align-items: center;
      position: relative;
      width: 100%;
      height: 48px;

      .left-arrow-image {
        position: absolute;
        left: 14px;
        top: 16px;
        width: 9px;
        height: 16px;
      }

      .save {
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        position: absolute;
        top: 12px;
        right: 16px;
        height: 24px;

        .search {
          margin-left: 20px;
          width: 17px;
          height: 17px;
        }

        .service {
          margin-top: 2px;
        }
      }
    }
  }

  .index {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    margin-top: 48px;
    width: 100%;

    .notifi-classifi {
      display: flex;
      flex-direction: row;
      justify-content: flex-start;
      align-items: flex-end;
      margin-top: 10px;
      width: 349px;
      height: 24px;

      .classifi-item {
        position: relative;
        margin-left: 43px;

        .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>
