<template>
  <u-navbar
      :title="title"
      :auto-back="true"
      left-icon-size="40rpx"
      :safe-area-inset-top="true"
      :placeholder="true"
      bgColor="#ffffff"
  ></u-navbar>
  <u-row :custom-style="{padding:'38rpx 66rpx'}">
    <u-col :span="12">
      <view class="content">
        <u-parse :content="content"></u-parse>
      </view>
    </u-col>
  </u-row>
</template>

<script>
import {
  imghost
} from '@/config/host.js'
import MzSubsection from '@/components/MzSubsection/Index.vue';
import api from '@/utils/functions.js';
import {newDetail} from "@/api/other";

export default {
  onShareAppMessage() {
    let result = {
      title:this.title,
      path:'/pages/News/detail?id=' + this.id,
    };
    if(this.cover){
      result.imageUrl = this.cover;
    }
    return result;
  },
  onShareTimeline() {
    let result = {
      title:this.title,
      path:'/pages/News/detail?id=' + this.id,
    };
    if(this.cover){
      result.imageUrl = this.cover;
    }
    return result;
  },
  components: {
    MzSubsection
  },
  data() {
    return {
      title: '资讯详情',
      loading: true,
      staticImage: {
        bg: imghost + '/BG.png',
        newIcon: imghost + '/new-icon.png',
      },
      isTop: false,
      content:'',
      id:0,
      cover:'',
    }
  },
  onLoad(option) {
    this.id = option.id;
    this.getDetail(option.id);
  },
  computed: {
    api() {
      return api
    },
  },
  methods: {
    getDetail(id){
      newDetail({id:id}).then(res => {
        this.title = res.data.info.title;
        this.content = res.data.info.content;
        this.cover =  res.data.info.cover;
      })
    }
  },
  onPageScroll(res) {
    if (res.scrollTop <= 20) {
      uni.$emit('isTop', true);
    } else {
      uni.$emit('isTop', false);
    }
  },
  created() {

  }
}
</script>

<style lang="scss">
@import './components/detail.scss';
</style>