<template>
  <div class="track_container">
    <div class="card_wrap">
      <div
        :class="item.bg ? 'card bg' : 'card'"
        v-for="item in trackList"
        :key="item.id"
      >
        <div v-if="item.id != activeTab" class="stand">
          <img class="icon" :src="item.pic" />
          <p class="title">{{ item.title }}</p>
          <div class="btn" @click="toClassifyPage(item.id)">点击查看更多</div>
        </div>
        <div v-else class="selected">
          <img :src="getImg(item.id)" alt="" class="img" />
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { trackList } from '@/mock'
import A1 from '@/static/img/caseshow/healthcare.png'
import A2 from '@/static/img/caseshow/hardware.png'
import A3 from '@/static/img/caseshow/industry.png'
import A4 from '@/static/img/caseshow/railway.png'
import A5 from '@/static/img/caseshow/outdoors.png'
import A6 from '@/static/img/caseshow/specialequip.png'
import A7 from '@/static/img/caseshow/healthcare.png'
import A8 from '@/static/img/caseshow/smarthome.png'
import A9 from '@/static/img/caseshow/electronics.png'
import { useRoute, useRouter } from 'vue-router'
const router = useRouter()
const route = useRoute()
import { watch } from 'vue'
const props = defineProps({
  activeTab: {
    type: Number,
  },
})
watch(
  () => route.query.t,
  () => {
    router.go(0)
  },
)
const toClassifyPage = id => {
  router.push({
    path: '/case-show',
    query: {
      t: id,
    },
  })
}
const getImg = id => {
  if (id == 1) {
    return A1
  }
  if (id == 2) {
    return A2
  }
  if (id == 3) {
    return A3
  }
  if (id == 4) {
    return A4
  }
  if (id == 5) {
    return A5
  }
  if (id == 6) {
    return A6
  }
  if (id == 7) {
    return A7
  }
  if (id == 8) {
    return A8
  }
  if (id == 9) {
    return A9
  }
}
</script>

<style lang="scss" scoped>
.track_container {
  .card_wrap {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    box-sizing: border-box;
    .card {
      flex: 1;
      background: #fff;
      .stand {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 20px 0;
        .icon {
          width: auto;
          height: 20px;
          margin-bottom: 11px;
        }
        .title {
          font-size: 16px;
          transform: scale(0.5);
          line-height: 8px;
          font-family: Alibaba PuHuiTi;
          font-weight: 400;
          color: #262626;
          margin-bottom: 4px;
        }
        .btn {
          border: 1px solid #262626;
          padding: 8px 16px;
          display: flex;
          align-items: center;
          justify-content: center;
          font-size: 12px;
          transform: scale(0.5);
          font-family: Alibaba PuHuiTi;
          font-weight: 300;
          color: #262626;
          white-space: nowrap;
        }
      }
      .selected {
        display: flex;
        align-items: center;
        justify-content: center;
        flex: 1;
        height: 100%;
        .img {
          width: 90px;
          height: 90px;
          box-shadow: 0px 2px 7px 0px rgba(8, 69, 71, 0.09);
          border-radius: 11px;
        }
      }
    }
    .bg {
      background: #fafafa;
    }
  }
}
</style>
