<template>
  <div id="detail">
    <el-row>
      <el-col :span="24" class="style">
        <el-col :span="24" class="top">
          <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
        </el-col>
        <el-col :span="24" class="main">
          <span v-if="this.type == '7'">
            <el-col :span="24" class="contactInfo">
              <p>{{ contactInfo.title }}</p>
              <p>{{ contactInfo.publish_time }}</p>
              <p v-html="contactInfo.content"></p>
            </el-col>
          </span>
          <span v-else>
            <el-col :span="24" class="newsInfo">
              <p>{{ newsInfo.title }}</p>
              <p>
                <span>{{
                  newsInfo.type == '0'
                    ? '会议简介'
                    : newsInfo.type == '1'
                    ? '会议日程'
                    : newsInfo.type == '2'
                    ? '主办方介绍'
                    : newsInfo.type == '3'
                    ? '协办方介绍'
                    : newsInfo.type == '4'
                    ? '专家介绍'
                    : newsInfo.type == '5'
                    ? '继续教育学分申请'
                    : newsInfo.type == '6'
                    ? '温馨提示'
                    : '暂无'
                }}</span>
                <span>发布时间：{{ newsInfo.publish_time }}</span>
              </p>
              <el-image :src="newsInfo.filedir" class="image"></el-image>
              <p v-html="newsInfo.content"></p>
            </el-col>
          </span>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { mapState, createNamespacedHelpers } from 'vuex';
import NavBar from '@/layout/common/topInfo.vue';
const { mapActions: contact } = createNamespacedHelpers('contact');
const { mapActions: news } = createNamespacedHelpers('news');
export default {
  name: 'detail',
  props: {},
  components: {
    NavBar,
  },
  data: function() {
    return {
      // 头部标题
      title: '',
      // meta为true
      isleftarrow: '',
      // 返回
      navShow: true,
      // 联系客服
      contactInfo: {},
      // 其他信息
      newsInfo: {},
    };
  },
  created() {
    this.search();
    this.getTitle();
  },
  methods: {
    ...contact(['query']),
    ...news(['fetch']),
    getTitle() {
      if (this.type === '0') {
        this.title = '会议简介';
      } else if (this.type === '1') {
        this.title = '会议日程';
      } else if (this.type === '2') {
        this.title = '主办方介绍';
      } else if (this.type === '3') {
        this.title = '协办方介绍';
      } else if (this.type === '4') {
        this.title = '专家介绍';
      } else if (this.type === '6') {
        this.title = '温馨提示';
      } else if (this.type === '7') {
        this.title = '联系客服';
      }
      // console.log(this.title);
    },
    async search() {
      if (this.type == '7') {
        let res = await this.query();
        if (this.$checkRes(res)) {
          this.$set(this, `contactInfo`, res.data[0]);
        }
      } else {
        let res = await this.fetch(this.id);
        if (this.$checkRes(res)) {
          this.$set(this, `newsInfo`, res.data);
        }
      }
    },
  },
  computed: {
    ...mapState(['user']),
    type() {
      return this.$route.query.type;
    },
    id() {
      return this.$route.query.id;
    },
    pageTitle() {
      return `${this.$route.meta.title}`;
    },
  },
  mounted() {
    // this.title = this.$route.meta.title;
    this.isleftarrow = this.$route.meta.isleftarrow;
  },
};
</script>

<style lang="less" scoped>
.style {
  width: 100%;
  min-height: 667px;
  position: relative;
  background-color: #f9fafc;
}
.top {
  height: 46px;
  overflow: hidden;
  position: relative;
  z-index: 999;
}
.main {
  min-height: 570px;
  .contactInfo {
    padding: 15px 10px;
    p:first-child {
      text-align: center;
      font-size: 18px;
      padding: 0 0 5px 0;
    }
    p:nth-child(2) {
      text-align: center;
      font-size: 14px;
      color: #ccc;
      padding: 0 0 5px 0;
    }
  }
  .newsInfo {
    padding: 15px 10px;
    p:first-child {
      text-align: center;
      font-size: 18px;
      padding: 0 0 5px 0;
    }
    p:nth-child(2) {
      text-align: center;
      font-size: 14px;
      color: #ccc;
      padding: 0 0 10px 0;
      span:first-child {
        display: inline-block;
        width: 40%;
        text-align: left;
      }
    }
    .image {
      width: 100%;
      height: 200px;
    }
  }
}
</style>
