<template>
    <div class="message " >
        <div class='sidebar'>
          <div class="sidebar-title">信息公告</div>
          <el-col :span="12">
            <el-menu :default-active="activeName"  class="el-menu-vertical-demo" v-for="item in artList" :key="item.id" @select="handleSelect"
              router >
              <el-menu-item :index="`?id=${item.id}`">
                <i class="el-icon-menu"></i>
                <span slot="title">{{item.title}}</span>
              </el-menu-item>
            </el-menu>
          </el-col>
      </div>
      <ul v-if="isList">
        <li v-for="item in messageList" :key="item.id" @click="urlChage">
          <nuxt-link :to="`/messsage/newsdetails?id=${item.id}`" :messageContext="item" class="flex-between">
            <div class="t2">{{item.title}}</div>
            <div class="t1">发布时间：{{item.createTime}}</div>
          </nuxt-link>
        </li>
      </ul>
      <div class="pagination flex-center" v-if="isList">
          <el-pagination
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="currentPage"
              :size ="size"
              layout="total, prev, pager, next, jumper"
              :total="total">
            </el-pagination style="postion:relative;transform:translateX(-50%)">
      </div>
      <div v-for="item in messageList" :key="item.id" class="content" v-if="!isList">
          <h1>{{item.title}}</h1>
          <div class="flex">
            <span>发布时间:{{item.createTime}}</span>
            <span>作者:{{item.author}}</span>
          </div>
          <div>{{item.content}}</div>
      </div>
   </div>

  
</template>

<script>
import {
  getListContent,
  getCategoryList,
  getCateList,
  getList
} from '@/common/list.js'
  export default {
    data() {
      return {
        contentList:'',
        isList:true,
        activeName: '1',
        conText:"",
        activeIndex: '1',
        size:10,
        total:0,
        artId:0,
        artList:[],
        currentPage:1,
        messageContext:'',
        messageList: [{
            title: "工程招投标活动的突出问题与对策思路",
            time: "2020-09-09 18:12"
          },
          {
            title: "工程招投标活动的突出问题与对策思路",
            time: "2020-09-09 18:12"
          },
          {
            title: "工程招投标活动的突出问题与对策思路",
            time: "2020-09-09 18:12"
          }
        ]
      }
    },
      created(){
      let message = {}
      message.currentPage = 1
      message.size = 10
      this.getListContent(message)
      this.getCategoryList()
    },
    methods:{
      urlChage(){
        this.isList = !this.isList
      },
      handleSelect(key, keyPath) {
        console.log(key, keyPath)
         let keyValue = key.slice(4)
         console.log(keyValue)
         let message = {}
          message.cateId = keyValue
          this.getListContent(message)
      },
      //分类列表
      async getCategoryList(){
        const {data} = await getCategoryList()
        this.artList = data
      },
      //文章列表
      async getListContent(params){
        const {data} = await getListContent(params)
        console.log(data)
        this.messageList = data
        // this.contentList = data
      },
      handleSizeChange(val) {
        this.getListContent(this.currentPage,val)
      },
      handleCurrentChange(val) {
        this.getListContent(val,this.size)
      },
    }
  }
</script>

<style scoped>
  .message {
    border: 1px solid rgba(219, 219, 219, 1);
    height:6.98rem;
    position: relative;
  }

  .message>ul>li {
    width: 9.23rem;
    height: .61rem;
    line-height: .61rem;
    box-sizing: border-box;
    padding-left: 0.3rem;
    padding-right: 0.55rem;
    border-bottom: 1px solid rgba(219, 219, 219, 1);
  }
  .message>ul>li div:last-child{
    color:rgba(151,152,153,1);
  }

  .message>.pagination{
    margin-top: 4rem;
  }
  .sidebar {
    width: 2.4rem;
    border: 1px solid rgba(219, 219, 219, 1);
    position: relative;
  }

  .el-menu {
    border-right: none;
  }

  .sidebar>.sidebar-title {
    width: 2.4rem;
    height: .60rem;
    line-height: .6rem;
    background: rgba(245, 246, 247, 1);
    text-align: center;
    font-size: .20rem;
    color: rgba(0, 0, 0, 1);
    font-weight: bold;
  }
  .el-col-12 {
    width: 100%;
  }
  .content{
    width:925px
  }
</style>


