<template>
  <div id="mainRight">
    <el-row style="border:1px solid #e6e6e6;">
      <el-col :span="24" class="top">
        <span :style="`background:${backColor}`">{{ topTitile }}</span>
      </el-col>
      <el-col :span="24" class="info">
        <el-col :span="24" class="list" v-for="(item, index) in rightList" :key="index" @click.native="$router.push({ path: `/memberDetail?id=${item.id}` })">
          <el-col :span="5" class="images">
            <el-image style="width:150px;height:95px;" :src="item.pic" v-if="item.pic"></el-image>
            <el-image style="width:150px;height:95px;" :src="Nopic" v-else></el-image>
          </el-col>
          <el-col :span="19" class="right">
            <el-col :span="24" class="rightTop">
              <el-col :span="20" class="title">
                <p class="textOver">{{ item.title }}</p>
              </el-col>
              <el-col :span="4" class="date">
                {{ item.meta && item.meta.createdAt ? new Date(item.meta.createdAt).toLocaleDateString() : '' || '' }}
              </el-col>
            </el-col>
            <el-col :span="24" class="content">
              <p v-html="item.content"></p>
            </el-col>
          </el-col>
        </el-col>
        <el-col :span="24" class="page">
          <el-pagination @current-change="search" :current-page="currentPage" :page-size="pageSize" layout="total, prev, pager, next, jumper" :total="total">
          </el-pagination>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: 'mainRight',
  props: {
    rightList: null,
    backColor: null,
    total: { type: Number, defaultl: 0 },
  },
  components: {},
  data: () => ({
    currentPage: 1,
    pageSize: 8,
    Nopic: require('@/assets/noPic.png'),
  }),
  created() {},
  computed: {
    topTitile() {
      return this.$route.query.title;
    },
  },
  methods: {
    search(page) {
      let skip = (page - 1) * this.pageSize;
      this.$emit('search', { skip: skip, limit: this.pageSize });
    },
  },
};
</script>

<style lang="less" scoped>
p {
  padding: 0;
  margin: 0;
}
.textOver {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top {
  height: 40px;
  line-height: 40px;
}
.top span {
  display: inline-block;
  height: 40px;
  line-height: 40px;
  text-align: center;
  font-size: 18px;
  color: #fff;
  padding: 0 10px;
  background-color: #176ebb;
}
.info {
  min-height: 560px;
  background-color: #fff;
  padding: 10px;
}
.list {
  padding: 8px 10px;
  border-bottom: 1px dashed #ccc;
}
.list .images {
  width: 150px;
  height: 95px;
}
.list .rightTop .title {
  padding: 10px;
}
.list .rightTop .date {
  text-align: center;
  font-size: 16px;
  color: #4f4f4f;
  padding: 10px 0;
}
/deep/.list .content {
  padding: 0 8px;
  height: 45px;
  overflow: hidden;
}
/deep/.list .content p {
  padding: 0;
  margin: 0;
  text-indent: 2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: 2;
  word-break: break-all;
  display: -webkit-box;
  -webkit-box-orient: vertical;
}
.list:hover {
  cursor: pointer;
}
.list:hover .title {
  color: #a32324;
}
.list:hover .date {
  color: #a32324;
}
.page {
  position: absolute;
  bottom: 0;
  height: 100px;
  text-align: center;
  padding: 35px 0;
}
</style>
