<template>
  <div class="Detail">
    <div class="header-top">
      <div class="titles">{{data.title}}</div>

      <div class="titles-bottom">
        <span>类型：</span>
        <span>{{selectList[data.showIndex].categoryName}}</span>
        <span class="to-left">浏览量：</span>
        <span>{{data.viewCount}}</span>
      </div>
    </div>

    <div class="header-middle">
      <span class="contsnts">{{data.content}}</span>
      <div class="img-list" v-if="data.files && data.files.length">
        <img :src="item.accessUrl" alt="" v-for="(item, index) in data.files" :key="index" />
      </div>
      
    </div>
  </div>
</template>

<script>
export default {
  name: 'Detail',
  components: {},
  props: {},
  data() {
    return {
      data: {},
      id: '',
      listName: '',
      selectList: []
    }
  },
  computed: {},
  watch: {},
  onLoad(o) {
    this.id = o.id
    this.listName = o.listName
    this.getType()
  },
  mounted() {},
  methods: {
    getDetail() {
      this.$http.post(`/app/appcontentinfo/queryDetailById?id=${this.id}`).then((res) => {
        if (res?.data) {
          this.data = res.data
          if(this.selectList.length) {
            this.selectList.map((item, index) => {
              if(item.id == res.data.categoryId) {
                this.data.showIndex = index
              }
            })
          }
        }
      })
    },
    getType() {
      this.$http.post(`/app/appcontentmoduleinfo/listByName?names=${this.listName}`).then((res) => {
        if (res.code == 0) {
          if(res.data && res.data[0].categoryList.length) {
            this.selectList = res.data[0].categoryList
            this.getDetail()
          }
        }
      })
    },
  },
}
</script>

<style scoped lang="scss">
uni-page-body {
  height: 100%;
}
.Detail {
  height: 100%;
  padding: 0 32px;
  background: #fff;
  .header-top {
    padding: 40px 0 32px 0;
    .titles {
      font-size: 48px;
      font-weight: 600;
    }

    .titles-bottom {
      margin-top: 16px;
      font-size: 30px;
      color: #999999;
      .to-left {
        margin-left: 32px;
      }
    }
  }

  .header-middle {
    padding: 32px 0;
    .contsnts {
      font-size: 36px;
      line-height: 1.5;
      word-break: break-all;
    }
    img {
      margin-top: 30px;
      width: 686px;
      height: 486px;
    }
  }

  .img-list{
    img{
      width: 204px;
      height: 204px;
      margin: 0 8px 8px 0;
    }
  }
}
</style>
