<template>
  <div class="hot-article">
    <el-card class="popular-card">
      <div slot="header" class="popular-header">
        <img src="../../assets/img/hot-article.jpg" alt="hot-crowd" class="popular-header-img"/>
        <span class="popular-header-title">热门文章</span>
        <el-button style="float: right; padding: 3px 0;line-height: 25px" type="text" @click="goToMore()">>></el-button>
      </div>
      <div class="popular-list">
        <el-row class="popular-list-item" v-for="(item,index) in articleArr" :key="item.id" v-if="index<7">
          <el-col :span="24">
            <img :src="item.photoUrl" alt="logo-project" class="pull-left project-logo-img">
            <div style="margin-left: 55px">
              <div class="list-item-title" @click="gotoArticle(item)">
                {{item.name}}
              </div>
              <div class="project-people-reading">
                {{item.reading}}阅读
              </div>
            </div>
          </el-col>
        </el-row>
      </div>
    </el-card>
  </div>

</template>

<script>
  import Http from '@/js/http.js'

  export default {
    name: 'HotArticle',
    props:['articleArr'],
    data(){
      return {

      }
    },
    methods:{
      gotoArticle(item){
        Http.get(`/api/technical/updateranking/${item.id}`).then(()=>{
          this.$emit('refreshHotArticle');
          window.open(item.articlesUrl);
        });

      },
      goToMore(){
          this.$router.push({
              name: 'TechnologyMore',
          })
      },
    },
    mounted() {
    }
  }
</script>

<style lang="scss">
  @import "../../style/main";

  .popular-card {
    margin-bottom: 5px!important;
  }
  .popular-header .el-card__header{
    border-bottom: 2px solid rgba(0,117,203,1) !important;
  }

  .popular-card .el-card__body{
    padding: 0 !important;
  }
  .popular-header {
    height: 20px;
    vertical-align:middle;
  }
  .popular-header-title {
    display: inline-block;
    line-height: 20px;
    vertical-align:middle;
  }
  .popular-header-img {
    height: 25px;
    width: 25px;
    vertical-align:middle;
  }

  .popular-list {
    .popular-list-item {
      padding: 4px 10px;
      border-bottom: 1px solid #ccc !important;
      .list-item-title{
        cursor:pointer;
        font-size:14px;
        font-family:Source Han Sans CN;
        font-weight:400;
        color:rgba(0,0,0,1);
        overflow: hidden;
        text-overflow:ellipsis; //溢出用省略号显示
        white-space:nowrap; //溢出不换行
      }
      .list-item-info{
        font-size:14px;
        font-family:Adobe Heiti Std;
        font-weight:normal;
        color:rgba(153,153,153,1);
        overflow:hidden; //超出的文本隐藏
        text-overflow:ellipsis; //溢出用省略号显示
        white-space:nowrap; //溢出不换行
      }
      .project-logo-img {
        width: 44px;
        height: 44px;
        display: inline-block;
        margin: 2px 0;
      }
      .project-people-reading {
        font-size:16px;
        font-family:Roboto;
        font-weight:400;
        color:$--color-primary;
      }
    }
  }


</style>
