<template>
  <div class="market-details">
    <div class="market-header">
      <div class="header-back" @click="goBack">
        <img src="../../../assets/icon/market/left-arrow.svg" alt="" />
      </div>
      <div class="header-icon pf600 fs18 fc121212" @click="changeIconFlag = true">
        {{ title }}
        <img src="../../../assets/icon/market/btn_triangle_down_bk.svg" alt="" />
      </div>
      <div class="header-func">
        <img src="../../../assets/icon/market/ic_share_bk.svg" alt="" class="share" />
        <img src="../../../assets/icon/market/Star.svg" alt="" class="star" />
      </div>
    </div>
    <div class="notifi-classifi">
      <div class="pf600 fs18 fc121212" @click="messageChange('marketConditions')">
        行情
      </div>
      <!-- <div class="sys-notifi pf600 fs14 fcA8A8A8" @click="messageChange('info')">
        信息
      </div>
      <div
        class="sys-notifi pf600 fs14 fcA8A8A8"
        @click="messageChange('transactionData')">
        交易数据
      </div> -->
    </div>
    <component :is="currentComponent" />
    <ChangeIcon v-show="changeIconFlag" @changeIconClose="changeIconClose"></ChangeIcon>
  </div>
</template>
<script setup>
  import Info from "./Info.vue";
  import MarketConditions from "./MarketConditions.vue";
  import TransactionData from "./TransactionData.vue";
  import ChangeIcon from "../dialog/ChangeIcon.vue";
  import { ref, computed } from "vue";
  import { useRouter, useRoute } from "vue-router";

  const router = useRouter();
  const route = useRoute();

  const title = route.query.type ? route.query.type.toUpperCase() : "";

  const changeIconFlag = ref(false);
  const changeIconClose = () => {
    changeIconFlag.value = false;
  };

  const current = ref("marketConditions");
  const componentsMap = {
    info: Info,
    marketConditions: MarketConditions,
    transactionData: TransactionData,
  };
  const currentComponent = computed(() => componentsMap[current.value]);

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

  const goBack = () => {
    router.back();
  };
</script>
<style lang="less" scoped>
  .market-details {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 40px;
    width: 100%;

    .market-header {
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      align-items: center;
      margin-top: 15px;
      width: 349px;
      height: 24px;

      .header-back {
        width: 24px;
        height: 24px;

        img {
          width: 24px;
          height: 24px;
        }
      }

      .header-icon {
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        margin-left: 40px;
        height: 24px;

        img {
          margin-left: 4px;
          width: 8px;
          height: 8px;
        }
      }

      .header-func {
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        height: 24px;

        .share {
          margin-top: 3px;
          width: 24px;
          height: 24px;
        }

        .star {
          margin-left: 10px;
          width: 24px;
          height: 24px;
        }
      }
    }

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

      .sys-notifi {
        margin-left: 35px;
      }
    }
  }
</style>
