<template>
  <div id="index">
    <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">
          <el-col
            :span="24"
            class="newsList"
            v-for="(item, index) in newsList"
            :key="index"
            @click.native="$router.push({ path: '/meetingBrief/detail', query: { type: item.type, id: item.id } })"
          >
            <el-col :span="8" class="image">
              <el-image :src="item.filedir"></el-image>
            </el-col>
            <el-col :span="16" class="text">
              <p class="title textOver">{{ item.title }}</p>
              <p class="type">
                {{
                  item.type == '0'
                    ? '会议简介'
                    : item.type == '1'
                    ? '会议日程'
                    : item.type == '2'
                    ? '主办方介绍'
                    : item.type == '3'
                    ? '协办方介绍'
                    : item.type == '4'
                    ? '专家介绍'
                    : item.type == '5'
                    ? '继续教育学分申请'
                    : item.type == '6'
                    ? '温馨提示'
                    : '暂无'
                }}
              </p>
              <p class="time">发布时间：{{ item.publish_time }}</p>
            </el-col>
          </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: news } = createNamespacedHelpers('news');
export default {
  name: 'index',
  props: {},
  components: {
    NavBar,
  },
  data: function() {
    return {
      // 头部标题
      title: '',
      // meta为true
      isleftarrow: '',
      // 返回
      navShow: true,
      newsList: [],
    };
  },
  created() {
    this.search();
    this.getTitle();
  },
  methods: {
    ...news({ newsquery: 'query' }),
    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 = '联系客服';
      }
    },
    async search() {
      let res = await this.newsquery({ type: this.type });
      if (this.$checkRes(res)) {
        this.$set(this, `newsList`, res.data);
      }
    },
  },
  computed: {
    ...mapState(['user']),
    type() {
      return this.$route.query.type;
    },
    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;
  .newsList {
    margin: 10px;
    border-bottom: 1px dashed #ccc;
    width: 95%;
    .image {
      .el-image {
        border-radius: 10px;
      }
    }
    .text {
      padding: 0 10px;
      .title {
        padding: 10px 0;
      }
      .type {
        font-size: 14px;
        color: #ccc;
        padding: 5px 0;
      }
      .time {
        font-size: 14px;
        color: #ccc;
        padding: 5px 0;
      }
    }
  }
}
</style>
