<!-- eslint-disable vue/multi-word-component-names -->
<script setup lang='ts'>
import { VolunteerApi } from '@/api/api/volunteerHome';
import { showToast } from 'vant';
import volunteerType from './home.vue'

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

const videos = ref([] as any)

export type volunteerType = {
  createTime: string,
  creatorId: number,
  creatorName: string,
  dirCode: string,
  fileIds: string,
  id: number,
  name: string,
  publishDate: string,
  rtf: string,
  thumb: string,
  type: string,
  updateTime: string
}

const activeDetail = ref({} as volunteerType)

const getDetailById = async () => {
  const res: any = await VolunteerApi.getDetailById(Number(route.params.id))
  if (res.code == 0) {
    activeDetail.value = res.data.entity
    videos.value = res.data.file.filter((item: any) => {
      return item.filePath.includes('.mp4')
    })
  } else {
    showToast('活动信息获取失败')
  }
}


onBeforeMount(() => {
  getDetailById()
})
</script>

<template>
  <div class='detail-box'>
    <img class="thumb-box" :src="activeDetail.thumb" alt="">
    <div class="content-box">
      <div class="name-box">{{ activeDetail.name }}</div>
      <div class="mainbody-box" v-html="activeDetail.rtf"></div>
      <div class="time-box">发布时间：{{ activeDetail.publishDate }}</div>
      <div class="video-box">
        <video :src="item" controls v-for="(item, index) in videos" :key="index"></video>
      </div>
    </div>
    <!-- <img class="back-icon" @click="() => { router.back() }" src="@/assets/images/back.png" alt=""> -->
  </div>
</template>

<style lang='less' scoped>
.detail-box {
  width: 100%;

  .thumb-box {
    width: 100%;
    margin-bottom: 10px;
    height: 30vh;
  }

  .content-box {
    width: 100%;
    padding: 0 10px;
    box-sizing: border-box;
    height: calc(70vh + 25px);
    overflow: auto;
    border-radius: 20px 20px 0 0;
    margin-top: -40px;
    position: relative;
    z-index: 2;
    background: #F7F3E8;
    padding: 25px 20px;
    box-sizing: border-box;

    .name-box {
      width: 100%;
      font-size: 1.2em;
      font-weight: bold;
      color: #333333;
      font-family: 'SourceHanSansCN-Medium';
      line-height: 1.5em;
      margin-bottom: 10px;
    }

    .time-box {
      width: 100%;
      display: flex;
      justify-content: space-between;
      color: #9D4F0B;
      margin: 10px auto;
      font-size: 0.8em;
      align-items: center;
    }

    .abstract-box {
      color: rgba(128, 128, 128, 0.664);
      font-size: 1em;
      margin-bottom: 10px;
      padding: 0 10px;
    }

    .mainbody-box {
      color: #88866F;
    }

    .video-box {
      width: 100%;

      video {
        width: 100%;
        margin-top: 10px;
      }

    }
  }
}
</style>