<script setup lang="ts">
import Card from '@/page/urge/components/Card.vue'

interface Staff {
  name: string
  education: string
  tags: string[]
  intro: string
  pic: string
  content: string[]
}

withDefaults(
  defineProps<{
    teacher?: Staff
    loading?: boolean
  }>(),
  {
    loading: false,
  },
)

const OSS_URL = import.meta.env.VITE_OSS_URL
</script>

<template>
  <Card>
    <div v-if="loading" class="loadincontainer">
      <Icon name="global_loading" loading :size="80"></Icon>
    </div>
    <template v-else-if="teacher">
      <div class="card-pic">
        <img :src="teacher.pic" :alt="teacher.name" />
      </div>
      <div class="card-body">
        <div class="card-title">
          <h2>{{ teacher.name }}</h2>
          <span v-for="(tag, index) in teacher.tags" :key="index" class="card-tag">
            {{ tag }}
          </span>
          <span class="card-education">{{ teacher.education }}</span>
        </div>
        <div class="card-intro">{{ teacher.intro }}</div>
        <p v-for="(content, index) in teacher.content" :key="index">{{ content }}</p>
      </div>
    </template>
    <div v-else class="empty-tip">
      <img :src="`${OSS_URL}/urm/empty_goods.svg`" alt="empty" />
      <p>正在为您精心匹配督学师</p>
      <p>请耐心等待～</p>
    </div>
  </Card>
</template>

<style scoped lang="scss">
.loadincontainer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: grid;
  place-content: center;
}

.empty-tip {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;

  color: #afbfcf;
  font-family: $font-special, sans-serif;
  font-size: 2vh;
  line-height: 3vh;

  img {
    height: 13.33vh;
    width: 160px;
  }
}

.card-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 16px;

  &:after {
    display: block;
    content: ' ';
    height: 0.17vh;
    width: 100%;
    background: repeating-linear-gradient(
      to right,
      #ccc,
      #ccc 10px,
      transparent 10px,
      transparent 20px
    );
    margin: 2vh 0;
  }

  .card-tag {
    border-radius: 0.83vh;
    background: #92fc90;
    padding: 0.33vh 24px;

    color: $font-color;
    font-size: 2.33vh;
    font-weight: 400;
    line-height: 3.5vh;
  }

  h2 {
    color: $font-color;
    font-family: $font-special, serif;
    font-size: 4vh;
    font-style: normal;
    font-weight: 400;
    line-height: 6vh;
    display: flex;
    align-items: center;

    & + .card-education {
      margin-left: $space-2;
    }
  }

  .card-education {
    color: #666;
    font-family: OPPOSans, Arial, sans-serif;
    font-size: 2.33vh;
    font-style: normal;
    font-weight: 400;
    line-height: 3.5vh;
    margin-top: 0.33vh;
  }
}

.card-pic {
  position: absolute;
  background: linear-gradient(4deg, #b3ffd8 8.53%, #e3ffd3 84.26%);
  border: 0.33vh solid $font-color;
  border-radius: 50%;
  overflow: hidden;
  width: 318px;
  height: 26.5vh;
  z-index: 1;
  top: 2vh;
  left: 24px;

  img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}

.card-body {
  border-radius: 1.33vh;
  background: linear-gradient(180deg, #fafafa 0%, #f4f0fa 100%);

  height: 31.5vh;
  padding: 2vh 32px 2.67vh 362px;
  position: relative;
  overflow: auto;

  &::after {
    content: ' ';
    display: block;
    width: 410px;
    height: 30.08vh;
    background: url('../../assets/hole-purple.svg') no-repeat right bottom;
    background-size: 50%;
    position: fixed;
    right: 0;
    bottom: 0;
    pointer-events: none;
  }

  p {
    color: #666;
    font-size: 2.33vh;
    font-style: normal;
    font-weight: 400;
    line-height: 3.5vh;
    display: flex;
    margin-top: $space-2_h;

    &::before {
      display: block;
      content: ' ';
      width: 40px;
      flex-shrink: 0;
      height: 3.33vh;
      background: url('../../assets/leaf.svg') center no-repeat;
      margin-right: $space-2;
      background-size: 100%;
    }
  }
}

.card-intro {
  margin-top: 0.33vh;
  color: $font-color;
  font-size: 2.67vh;
  font-style: normal;
  font-weight: 400;
  line-height: 4vh;
}
</style>
