<template>
<div class='container'>
  <div class='title'>{{news.info_Title}}</div>
  <div class='subhead'>
    <div class='tags'>{{news.info_Tag}}</div>
    <span>浏览{{news.read_Count}}</span>
    <span class='time'>{{news.timeFull}}</span>
  </div>
  <img v-if='news.title_Pic' :src='rootAvatar + news.title_Pic' mode='widthFix'>
  <div class='main'>
    <wxParse :content='news.info_Content' noData='加载中……' :imageProp='imageProp'/>
    <!-- <rich-text :nodes='content' /> -->
  </div>
  <div style='width:100%;height:130rpx;'/>
</div>
</template>
<script>
import wxParse from 'mpvue-wxparse'
export default {
  components: {
    wxParse
  },
  data() {
    return {
      news:{},
      imageProp:{}
    }
  },
  methods: {
    loadNews(i) {
      const news = wx.getStorageSync('newsList')[i]
      this.news = news
      this.addReadTimes(news.jpubid)
    },
    addReadTimes(jpubid){
      wx.request({
        url: this.rootUrl + '/jpub/read',
        method: 'POST',
        header: {'content-type': 'application/x-www-form-urlencoded'},
        data:{ jpubid }
      })
    }
  },
  onLoad() {
    this.imageProp = {mode:'aspectFit', padding: 0, lazyLoad:false, domain:this.rootAvatar.replace('https:','')}
    this.loadNews(this.$root.$mp.query.index)
  },
  onUnload() {
    this.news = {}
  }
}
</script>
<style lang="stylus" scoped>
@import url('~mpvue-wxparse/src/wxParse.css')
.container
  padding 40rpx 30rpx 0 30rpx
  .title
    Font(40rpx, 60rpx, bold)
  .subhead
    margin-top 20rpx
    Font(28rpx, 40rpx)
    Flex(flex,, center)
    color #777
    .tags
      Font(24rpx, 32rpx)
      border-radius 8rpx
      border 1rpx solid themeColor
      color themeColor
      padding 0 8rpx
      margin-right 20rpx
    .time
      margin 0 0 0 auto
  img
    width 100%
    margin 30rpx 0
  .main
    width 100%
    Font(30rpx, 40rpx)
    text-align justify
</style>
