<template>
  <div id="detail">
    <el-row>
      <el-col :span="24" class="detail">
        <el-col :span="24" class="top">
          <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow" @onClickLeft="onClickLeft"> </NavBar>
        </el-col>
        <el-col :span="24" class="main">
          <el-col :span="24" class="title">{{ info.title }}</el-col>
          <el-col :span="24" class="other">
            <span class="textOver">信息来源：{{ info.orgin || '暂无' }}</span>
            <span class="textOver">发布时间：{{ info.publish_time || '暂无' }}</span>
          </el-col>
          <el-col :span="24" v-if="info.picture != null || undefined" class="img">
            <van-image :src="info.picture">
              <div slot="error" class="image-slot">
                <i class="el-icon-picture-outline"></i>
              </div>
            </van-image>
          </el-col>
          <el-col :span="24" class="con" v-html="info.content"> </el-col>
          <el-col :span="24" class="four" v-if="info.filepath">
            <h4>附件：</h4>
            <el-link :href="info.filepath" :underline="false">{{ info.filepathname || '附件下载' }}</el-link>
          </el-col>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { mapState, createNamespacedHelpers } from 'vuex';
import NavBar from '@/layout/common/topInfo.vue';
const { mapActions: journnews } = createNamespacedHelpers('journnews');
export default {
  metaInfo() {
    return { title: this.$route.meta.title };
  },
  name: 'detail',
  props: {},
  components: {
    NavBar,
  },
  data: function() {
    return {
      // 头部标题
      title: '',
      // meta为true
      isleftarrow: '',
      // 返回
      navShow: true,
      //详情
      info: {},
    };
  },
  created() {
    this.search();
  },
  methods: {
    ...journnews({ newsquery: 'query', newsfetch: 'fetch' }),
    //查询详情
    async search() {
      const res = await this.newsfetch(this.id);
      if (this.$checkRes(res)) {
        this.$set(this, `info`, res.data);
      }
    },
    // 返回
    onClickLeft() {
      this.$router.push({ path: '/journ/index' });
    },
  },
  computed: {
    ...mapState(['user']),
    id() {
      return this.$route.query.id;
    },
  },
  mounted() {
    this.title = this.$route.meta.title;
    this.isleftarrow = this.$route.meta.isleftarrow;
  },
};
</script>

<style lang="less" scoped>
.detail {
  width: 100%;
  min-height: 667px;
  position: relative;
  background-color: #f9fafc;
}
.top {
  height: 46px;
  overflow: hidden;
}
.main {
  // min-height: 570px;
  // margin: 0 0 50px 0;
  padding: 10px;
  .title {
    text-align: center;
    color: #044b79;
    font-size: 18px;
    font-weight: bolder;
  }
  .other {
    font-size: 16px;
    color: #666;
    padding: 20px 0;
    border-bottom: 1px dashed #ccc;
    span {
      display: inline-block;
      width: 50%;
    }
  }
  .img {
    text-align: center;
    margin: 0 0 15px 0;
    .el-image {
      width: 60%;
    }
  }
  .con {
    margin-top: 20px;
  }
}
/deep/table {
  width: 100%;
}
/deep/.con p img {
  width: 100%;
  height: 300px;
  margin: 5px 0px;
  display: block;
}
/deep/.con div img {
  width: 100%;
  height: 260px;
  display: block;
}
/deep/.con p {
  font-size: 14px;
  color: #444;
}
</style>
