<template>
  <div class="exItem" @click="onClickExItem(exData)">
    <!-- <img :src="require('@/assets/images/resource/exItem.jpg')" alt="" /> -->
    <template v-if="currentRouteName=='gdmuseum'">
      <img :src="`http://gdbwg.4dage.com${exData.thumb}`" alt="" />
      <p class="title">{{ exData.name }}</p>
      <p v-if="exData.type!='long'" class="date">{{ exData.timeEnd }}</p>
    </template>

    <div v-else class="heng">
      <div class="img" :style="{backgroundImage:`url(http://gdbwg.4dage.com${exData.thumb})`}"></div>
      <div class="info">
        <p class="title">{{ exData.name }}</p>
        <p v-if="exData.type!='long'" class="date">{{ exData.timeEnd }}</p>
        <span class="type">{{exData.type=='long'?'常设展览':'临时展览'}}</span>
      </div>

      <div class="viewbtn">查看详情</div>
    </div>

  </div>
</template>

<script setup>
import { defineProps, computed, watch, nextTick, ref } from "vue";
import { useRouter, useRoute } from "vue-router";

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

const currentRouteName = computed(() => route.name)

const props = defineProps({
  exData: {
    type: Object,
    default: () => {
      return {}
    },
  }
});


let onClickExItem = (data) => {
  console.log(data);
  router.push({ name: 'zhanlan', params: { id: data.id } })
}

</script>

<style lang="scss" scoped>
.exItem {
  padding: 38px 0 56px;
  margin-bottom: 20px;
  cursor: pointer;
  .title {
    font-size: 30px;
    font-weight: 400;
    color: #333333;
    margin: 28px 0 16px;
  }

  > img {
    max-height: 700px;
    max-width: 1400px;
    object-fit: contain;
  }

  .date {
    font-size: 20px;
    color: #999999;
  }

  .heng{
    display: flex;
    .img{
      flex: 0 0 auto;
      width: 300px;
      height: 150px;
      background-position: center;
      background-size: cover;
    }
    .info{
      flex: 1 1 1px;
      margin-left: 30px;
      display: flex;
      flex-direction: column;
      position: relative;
      .title{
        margin: 0 0 10px 0;
      }
      .date{
        font-size: 16px;
      }
      .type{
        position: absolute;
        left: 0;
        bottom: 4px;
        color: #B61E22;
      }
    }
    .viewbtn{
      flex: 0 0 auto;
      position: absolute;
      right: 0;
      top: 50%;
      transform: translateY(-50%);
      width: 120px;
      height: 36px;
      background: #fff;
      color: #999999;
      border: 1px solid #999999;
      border-radius: 60px;
      text-align: center;
      line-height: 36px;
      &:hover{
        background: var(--main-color);
        color: var(--font-active);
        border: 1px solid var(--main-color);
      }
    }
  }
}


@media screen and (max-width: 1000px) {
  .exItem {
    padding: 20px 0;
    margin-bottom: 20px;
    cursor: pointer;

    .title {
      font-size: 20px;
      margin: 10px 0;
    }

    >img {
      width: 100%;
    }

    .date {
      font-size: 14px;
      color: #999999;
    }

    .heng{
    display: block;
    .img{
      width: 100%;
      height: 150px;
      background-position: center;
      background-size: cover;
    }
    .info{
      margin-left: 0;
      display: flex;
      position: relative;
      width: 100%;
      .title{
        margin: 10px 0;
      }
      .date{
        font-size: 16px;
      }
      .type{
        position: absolute;
        right: 0;
        left: unset;
        font-size: 14px;
        top: 50%;
        transform: translateY(-50%);
        color: #B61E22;
      }
    }
    .viewbtn{
      display: none;
      position: absolute;
      right: 0;
      top: 50%;
      transform: translateY(-50%);
      width: 120px;
      height: 36px;
      background: #fff;
      color: #999999;
      border: 1px solid #999999;
      border-radius: 60px;
      text-align: center;
      line-height: 36px;
      &:hover{
        background: var(--main-color);
        color: var(--font-active);
        border: 1px solid var(--main-color);
      }
    }
  }
  }

}
</style>
