<template>
  <div class="padding" v-if="pageShow">
    <header>{{ detail.title }}</header>
    <div class="info">
      <span>{{ detail.publishUnitName }} {{ detail.createTime && detail.createTime.slice(0, 16) }}</span>
      <div class="right">
        <em>{{ detail.views }}</em>人看过
      </div>
    </div>
    <div class="notice-content">
      <u-parse :html="detail.content"/>
    </div>
    <div class="photo">
      <img :src="item.url" alt="" v-for="(item,index) in images" :key="index" @click="preview(index)">
    </div>
  </div>
</template>

<script>

export default {
  name: "AppNotice",
  appName:"通知公告",
  data() {
    return {
      id: null,
      pageShow: false,
      detail: {},
      images: [],
    }
  },
  onLoad({id}) {
    this.$loading()
    this.id = id;
    this.getDetail();
  },
  methods: {
    preview(index) {
      this.$previewImage(this.images, index, 'path');
    },
    getDetail() {
      this.$instance.post("/app/appmininotice/queryDetailById", null, {
        params: {id: this.id}
      }).then(res => {
        if (res?.data) {
          this.detail = res.data;
          this.images = JSON.parse(res.data.images || '[]');
          this.$nextTick(() => {
            this.pageShow = true
          })
        }

        this.$hideLoading()
      })
    }
  },
}
</script>

<style lang="scss" scoped>
.padding {
  min-height: 100%;
  box-sizing: border-box;
  padding: 40px 32px;
  background-color: #fff;

  header {
    font-size: 48px;
    font-weight: 600;
    color: #333333;
    line-height: 66px;
  }

  .info {
    display: flex;
    justify-content: space-between;
    font-size: 30px;
    font-weight: 400;
    color: #999999;
    padding: 16px 0 64px;

    .right {
      display: flex;
      flex-shrink: 0;
      margin-left: 16px;

      & > em {
        font-style: normal;
        color: #4181FF;
      }
    }
  }

  .notice-content {
    font-size: 28px;
    // color: #333;
    // line-height: 64px;
  }

  .photo {
    display: flex;
    flex-direction: column;

    & > img {
      width: 100%;
      margin-top: 32px;
    }
  }
}
</style>
