<template><page-meta :root-font-size="fontSize+'px'"></page-meta>
    <home-base :show="false"><view class="div distributor-article-list">
      <view class="div common-header-wrap">
        <view :style="'height:'+navHeight+'px'"></view>
        <view class="common-header-holder"></view>
        <view class="common-header-fixed">
        <title-header />
        <uni-nav-bar :title="title" class="common-header" left-icon="back" @clickLeft="goBack()">
        </uni-nav-bar>
      </view>
      </view>
	  <view class='main-content'>
		<rich-text class="div content" :nodes='content'></rich-text>
	  </view>
    </view></home-base>
</template>
<script>
import {getFontSize} from '@/util/common'
import TitleHeader from '../../TitleHeader'
import HomeBase from '../HomeBase'
import { getDocumentInfo } from '../../../api/homeArticle'
export default {

  name:'HomeDocument',
  mounted(){
  // #ifdef  MP-WEIXIN
  this.navHeight = uni.getMenuButtonBoundingClientRect().height
  // #endif
  },
  computed:{
  fontSize(){
    return getFontSize()
  },
  },
  data(){
    return {
      navHeight: 0,
      title: '',
      content: ''
    }
  },
  components:{
    TitleHeader,
    HomeBase,
  },
  onLoad: function (option) {
    let type = option.type
    getDocumentInfo(type).then(res => {
      this.title = res.result.document_title
      this.content = res.result.document_content
    }).catch(function (error) {
      uni.showToast({icon:'none',title: error.message})
    })
  },
  methods:{
    goBack(){
      uni.navigateBack({delta:1})
    }
  }

}
</script>
<style  lang="scss" scoped>
.main-content{padding: 0 $pageSpace;box-sizing: border-box;}
.content{padding:.5rem;font-size:$subFontSize;}
</style>
