<template>
  <div>
    <p class="text-2xl font-bold mb-5">{{ title }}</p>{{$route.query.id}}
    <p class="text-gray-400">发布时间：{{ time | formatDate }}</p>
    <img v-if="imageUrl" :src="imageUrl" class=" mx-auto my-5" />
    <p class="text-left p-5" v-html="content">{{ content }}</p>
  </div>
</template>

<script lang="ts">
import Vue from "vue";
import ActivityService from "@/service/ActivityService/index";
import { eActivityItem } from "@/service/ActivityService/type";
import FileService from "@/service/FileService/index";

export default Vue.extend({
  data() {
    return {
      uuid: "",
      title: "",
      file_name: undefined as undefined | string,
      time: 0,
      content: "",
      imageUrl: "",
    };
  },
  async mounted() {
    this.uuid = this.$route.params.uuid;
    const ret = await ActivityService.getInstance().queryActivityInfo(
      this.uuid
    );
    if (ret.code == 200) {
      const item: eActivityItem = ret.data as unknown as eActivityItem;
      this.title = item.title;
      this.time = item.created_at;
      this.content = item.content;
      this.file_name = item.file_name;
    }
    if (this.file_name) {
      this.imageUrl = FileService.getInstance().getImageSrc(this.file_name)

    }
  },
});
</script>