<template>
  <div class="case_show_container">
    <SubNavigation title="案例展示" />
    <CaseCard :activeTab="classify" />
    <HeadLine
      :title="getTitle()"
      line1="我们精通气动、液动、电动等各种传动机构"
      line2="完成机械所需的各种动作"
    />
    <Card :caseList="getCaseList()" :classify="classify" />
  </div>
</template>

<script setup>
import CaseCard from 'cpns/CaseCard'
import Card from 'cpns/Card'
import SubNavigation from 'cpns/SubNavigation'
import HeadLine from 'cpns/HeadLine'
import { useRoute } from 'vue-router'
import { ref, onMounted } from 'vue'
import { caseList } from '@/mock/case_detail'
const route = useRoute()

const trackList = [
  {
    id: 1,
    title: '医疗健康',
  },
  {
    id: 2,
    title: '智能硬件',
  },
  {
    id: 3,
    title: '工业设备',
  },
  {
    id: 4,
    title: '高铁设备',
  },
  {
    id: 5,
    title: '户外设备',
  },
  {
    id: 6,
    title: '特种装备',
  },
  {
    id: 7,
    title: '智能家居',
  },
  {
    id: 8,
    title: '实验仪器',
  },
  {
    id: 9,
    title: '消费电子',
  },
]

const getTitle = () => {
  const arr = trackList.filter(item => item.id == classify.value)
  if (arr?.length > 0) {
    return arr[0].title
  }
  return ''
}

const getCaseList = () => {
  return caseList[classify.value]
}

const classify = ref('1')

onMounted(() => {
  if (route.query.t) {
    classify.value = route.query.t || '1'
  }
})
</script>

<style lang="scss" scoped>
.case_show_container {
  padding-top: $sub-header-height;
  background: #f5f5f5;
  padding-bottom: 7px;
  .line_cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    column-gap: 7px;
    padding: 0 7px;
    box-sizing: border-box;
    row-gap: 7px;
    .card {
      height: 132px;
      background: #ffffff;
      border-radius: 3px;
      flex: 1;
      box-sizing: border-box;
      display: flex;
      flex-direction: column;
      padding: 11px 7px 7px 7px;
      .title {
        font-size: 8px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #2f2f2f;
        padding-left: 2px;
        margin-bottom: 11px;
      }
      .img_box {
        width: 100%;
        flex: 1;
        position: relative;
        .img {
          width: 100%;
          height: 100%;
          background: red;
        }
        .bottom_text {
          position: absolute;
          left: -50%;
          bottom: -10%;
          height: 34px;
          background: rgba(0, 0, 0, 0.2);
          display: flex;
          align-items: center;
          justify-content: space-evenly;
          font-size: 16px;
          font-family: Source Han Sans CN;
          font-weight: 400;
          color: #ffffff;
          width: 200%;
          transform: scale(0.5);
        }
      }
    }
  }
}
</style>
