<template>
  <div class="free-reading">
    <div
      class="item"
      v-for="item in freeData"
      :key="item.FREE_TOP"
      @click="viewDetail(item)"
      >
      <img :src="item.PIC_PATH" alt="试读">
      <div class="tit">
        <p>{{item.TIT}}</p>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'FreeReading',
  props: {
    freeData: {
      type: Array,
      default: ()=>([])
    }
  },
  methods: {
    viewDetail(item) {
      this.$router.push({
        path: '/article',
        query: {
          id: item.ID,
          purchase: true
        }
      })
    }
  }
}
</script>

<style scoped>
.free-reading {
  padding: 30px 0;
  display: flex;
  /*justify-content: space-between;*/
  overflow-x: auto;
  border-bottom: 2px dashed rgba(255,255,255,.15);
}
.free-reading img {
  width: 240px;
  height: 140px;
}
.item {
  position: relative;
  cursor: pointer;
  width: 240px;
  height: 140px;
}
.item .tit {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  display: flex;
  align-items: center;
  background: rgba(0,0,0,.5);
}
.tit p {
  padding: 0 25px;
  color: #EAEBF0;
  font-size: 18px;
  display: -webkit-box;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.tit::after {
  content: '试读';
  display: inline-block;
  position: absolute;
  right: 0;
  top: 0;
  font-size: 14px;
  color: #fff;
  background: rgb(235, 51, 59);
  padding: 4px 6px;
  border-radius: 0 0 0 5px;
}
.free-reading > div:nth-child(even) {
  margin: 0 33px; 
}
</style>
