<template>
  <view class="page ZiXunXiangQing">
    <!-- 标题 -->
    <view class="MainTitle" v-if="Info !== null">
      <text>{{Info.title}}</text>
      <text class="iconfont iconguanbi" @tap="GoBack"></text>
    </view>

    <!-- 内容 -->
    <view class="Container" v-if="Info !== null">
      <image mode="widthFix" class="Img" :src="Info.thumb"></image>
      <!-- <towxml :nodes="nodes" /> -->
      <Markdown :value="(Info || {}).content" />
    </view>
  </view>
</template>

<script>
import { getCurrentInstance } from "@tarojs/taro"
import { createNamespacedHelpers } from "vuex"
import Markdown from '@/components/Markdown'
// const towxml = require('../../../../towxml/index')

const { mapActions: mapIndexActions } = createNamespacedHelpers("index")
export default {
  name: "ZiXunXiangQing",
  components: {
    Markdown
  },
  data() {
    return {
      CurrnetId: null,
      Info: null
    }
  },
  computed: {
    nodes() {
      // const res = towxml((this.Info || {}).content, 'markdown')
      // console.log(res)
      // return res
    }
  },
  created() {
    this.CurrnetId = getCurrentInstance().router.params.id
    this.$authed(() => {
      this.Init()
    })
  },
  methods: {
    ...mapIndexActions([
      "GetNewsDetail", // 获取资讯详情
    ]),
    Init() {
      this.GetNewsDetail({
        urlData: { id: this.CurrnetId }
      }).then((res) => {
        this.Info = res.data.data || null
      })
    },
    GoBack () {
      wx.navigateBack()
    }
  },
}
</script>

<style lang="scss">
@import "page.scss"
</style>
