<template>
  <section class="home">
    <div class="page">
      <div class="header">
        <p class="title">{{info.title}}</p>
        <div class="info mar-b16"><span class="label">发布单位：</span><span class="value">{{info.organizationName}}</span></div>
        <div class="info" v-if="type == 'know'">发布时间：{{info.createDate || '-'}}</div>
        <div class="info" v-else>发布时间：{{info.publishDate || '-'}}</div>
      </div>
      <div class="content">
        <u-parse :html="info.content"></u-parse>
      </div>
      <AiTransSpeech :src="info.speech" v-if="info.speech"/>
    </div>
  </section>
</template>
<script>
import { mapState } from "vuex";
export default {
  name: "home",
  computed: {
    ...mapState(["user", "token"]),
  },
  data() {
    return {
      id: '',
      info: {},
      content: '',
      type: '', //know 党史知识
    };
  },
  onLoad(options) {
    console.log(options)
    this.id = options.id
    this.type = options.type
    this.getDetail()
  },
  methods: {
    getDetail() {
      this.$http.post(`/app/apppartyeducation/queryDetailById?id=${this.id}`).then((res) => {
        if (res.code == 0) {
          if(res.data.createDate) {
            res.data.createDate = res.data.createDate.substring(0, 10)
          }
          if(res.data.publishDate) {
            res.data.publishDate = res.data.publishDate.substring(0, 10)
          }
          this.info = res.data
        }
      });
    },
  },
};
</script>
<style scoped lang="scss">
@import "../../common/common.css";
.home {
  width: 100%;
  height: 100%;
}
.page {
  width: 100%;
  overflow-x: hidden;
  background-color: #fff;
  .header{
    width: 100%;
    padding: 24px 32px 32px;
    box-sizing: border-box;
    background: #D03A28;
    .title{
      width: 100%;
      font-size: 40px;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      color: #FFF;
      line-height: 64px;
      letter-spacing: 1px;
      word-break: break-all;
      margin-bottom: 16px;
    }
    .info{
      font-size: 28px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #FFF;
      line-height: 40px;
      display: flex;
      .label{
        width: 140px;
      }
      .value{
        width: calc(100% - 140px);
        word-break: break-all;
      }
    }
    .mar-b16{
      margin-bottom: 16px;
    }
  }
  .content{
    padding: 32px;
  }
}
</style>
