<!-- 站内信 -->
<template>
  <div class="page">
    <topBar
      v-if="topList.length > 0"
      :top-list="topList"
      :moren="moren"
    />
    <div v-if="tableData" class="box">
      <div v-for="(item,index) in tableData" :key="index" class="lists" @click="clickHref(item)">
        <div v-if="index==0" class="style1">最新</div>
        <div v-if="index!=0 && item.readState==1" class="style2 style1">未读</div>
        <div v-if="index!=0 && item.readState==0" class="style3 style1">已读</div>
        <div class="name" :style="index==0?'color:#C8161D;text-decoration:underline':''">{{ item.content }}</div>
        <div class="time">{{ item.creationTime }}</div>
      </div>
     
    </div>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="research"
    />
  </div>
</template>
<script>
import topBar from '@/components/topBar'
import * as api from '@/api/translate'
export default {
  name: 'Message',
  components: {
    topBar
  },
  data() {
    return {
      queryParams: {
        pageNum: 1,
        pageSize: 50,
      },
      total:0,
      tableData: [],
      moren: '/informCentre/message',
      topList: [
        {
          name: '站内信',
          path: '/informCentre/message'
        }
      ]
    }
  },
  created() {
    setTimeout(() => {
      this.research()
    }, 300)
  },
  methods: {
    getDataList(){
      
    },
    clickHref(item) {
      const that = this
      api.updateReadState({ 'pkId': item.pkId, 'readState': item.readState == 0 ? 1 : 0 }).then((res) => {
        if (res.code == '200') {
          window.location.href = item.url
        }
      })
    },
    async getUserId(data) {
      return this.$store.state.user.user.userId
    },
    async research(data) {
      const id = await this.getUserId()
      if (id) {
        api.getShowPuShInfo(Object.assign({}, this.queryParams, { 'userId': id })).then((res) => {
          this.tableData = res.rows
          this.total = res.total
        })
      }
    }
  }
}
</script>
<style lang="scss" scoped>
.time{
  color: #666;
  font-size: 12px;
}
.name{
  color: #333;
  font-size: 18px;
  font-weight: bold;
  flex: 1;
  margin-left: 10px;
  
}
.style3{
  background: rgba(0,155,88,0.3)!important;
  color: #009B58!important;
}
.style2{
  background: rgba(58,58,58,0.3)!important;
  color: #3F3F3F!important;
}
.style1{
  width: 44px;
  height: 22px;
  background: rgba(255,134,134,0.3);
  border-radius: 4px 4px 4px 4px;
  line-height: 22px;
  text-align: center;
  color: #C42525;
  font-size: 14px;
}
.box{
  box-shadow: 0px 2px 20px 0px rgba(238,238,238,0.5);
  border-radius: 10px 10px 10px 10px;
  background-color: #fff;
  height: 1000px;
  padding-bottom: 20px;
  height: 85vh;
  overflow: auto;
}
.lists{
  padding: 5px 20px 5px 20px;
  border-bottom:1px solid rgba(0,0,0,0.1);
  display: flex;
  justify-content: space-between;
  cursor: pointer;
  :hover{
    color:#C8161D;
    text-decoration:underline
  }
}
::v-deep .el-dialog__title{
  font-weight: bold;
}
.button-style{
  width: 209px;
  height: 48px;
  background: #CCCCCC;
  border-radius: 5px 5px 5px 5px;
  opacity: 1;
  line-height: 48px;
  padding: 0!important;
  color: #fff;
  font-size: 18px;
}
::v-deep .el-dialog__header{
  border-bottom: 1px solid rgba(0,0,0,0.1);
}
.button-s{
  padding: 0 2px!important;
}
::v-deep .el-button{
  padding: 10px 20px;
}
::v-deep .el-date-editor .el-range__close-icon{
  margin-top: -10px;
}
::v-deep .el-date-editor .el-range-separator{
  margin-top: -10px;
}
::v-deep .el-date-editor .el-range__icon{
  margin-top: -10px;
}
::v-deep .el-input__inner{
  //height:28px;
  //line-height: 28px;
}
::v-deep .el-form-item{
  margin-bottom: 15px;
}
::v-deep .el-form-item__label{
  color: #333;
  font-weight: inherit;
}
::v-deep .el-row {
  margin-top: 20px;
}
::v-deep .el-table .warning-row {
  background: #f9f9f9;
}

::v-deep .el-table .success-row {
  background: #ffffff;
}
::v-deep .el-table thead {
  color: #000000;
}
.openClose {
  margin-top: 10px;
  margin-right: 10px;
  color: #666666;
  text-align: center;
}
.page {
  padding: 20px;
  background: #f9f9f9;
  font-size: 14px;
  overflow-y: auto;
  //margin-bottom: 100px;
  .thetopbox {
    background: #ffffff;
    border-radius: 8px;
    padding-bottom: 10px;
    .searchbox {
      display: flex;
      align-items: center;
      .searchtitle {
        margin-right: 10px;
      }
      .searchbtn {
        background: #08143f;
        color: #ffffff;
      }
    }
  }
  .main {
    margin-top: 20px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0px 2px 20px 0px rgba(238, 238, 238, 0.5);

    .maintop {
      display: flex;
      padding: 10px 20px;
      justify-content: space-between;
      align-items: center;
      .mainbtn {
        .thebtn1 {
          color: #ffffff;
          background: rgba(67, 145, 253, 1);
        }
      }
    }
  }
}
</style>
