<template>
  <ai-detail class="party-detail">
    <template slot="title">
      <ai-title
        title="活动详情"
        isShowBack
        isShowBottomBorder
        @onBackClick="cancel()"
      ></ai-title>
    </template>
    <template slot="content">
      <div>
        <ai-card title="活动信息">
          <template #content>
            <ai-wrapper label-width="120px">
              <ai-info-item isLine label="发布地区">{{ info.areaName }}</ai-info-item>
              <ai-info-item isLine label="标题">{{ info.title }}</ai-info-item>
              <ai-info-item isLine label="活动地点">{{ info.address }}</ai-info-item>
              <ai-info-item isLine label="参与名额">{{ info.total }}</ai-info-item>
              <ai-info-item label="报名状态">{{ dict.getLabel('partyReportSignupStatus', info.signupStatus) }}</ai-info-item>
              <ai-info-item label="活动状态">{{ dict.getLabel('activityStatus', info.actionStatus) }}</ai-info-item>
              <ai-info-item label="活动时间">{{ info.beginTime.substring(0, 10) }} 至 {{ info.endTime.substring(0, 10) }}</ai-info-item>
              <ai-info-item label="截至时间">{{ info.stopSignupTime }}</ai-info-item>
              <ai-info-item label="联系人">{{ info.contactPerson }}</ai-info-item>
              <ai-info-item label="联系电话">{{ info.contactPhone }}</ai-info-item>
            </ai-wrapper>
          </template>
        </ai-card>
        <ai-card title="活动介绍">
          <template #content>
            <p v-html="info.content"></p>
          </template>
        </ai-card>
        <ai-card title="报名情况">
          <template #content>
            <p v-html="info.content"></p>
          </template>
        </ai-card>
      </div>
    </template>
  </ai-detail>
</template>

<script>
import { mapState } from "vuex";

export default {
  name: "detail",

  props: {
    instance: Function,
    dict: Object,
    params: Object,
    id: String
  },

  data() {
    return {
      info: {},
    }
  },

  computed: {
    ...mapState(["user"]),
  },

  created() {
    this.dict.load('activityStatus', 'partyReportSignupStatus').then(() => {
      this.getInfo()
    })
  },

  methods: {
    getInfo() {
      this.instance.post(`/app/apppartyreport/queryDetailById?id=${this.id}`).then((res) => {
        if (res?.data) {
          this.info = res.data;
          if (this.info.birthday) {
            this.info.birthday = this.info.birthday.substring(0, 10);
          }
        }
      });
    },
    cancel() {
      this.$emit("goBack")
    },
  },
};
</script>