<template>
  <!-- 教学 -->
  <div class="Teaching">
    <div v-if="!type" class="top">
      <div class="title">
        <span class="text"> <!-- 教辅资料  -->{{ $t('Key214') }} </span>
        <div class="more" @click="goMore">
          <span> <!-- 查看更多  -->{{ $t('Key47') }} </span>
          <img src="../../assets/teacherdev/moreImage.png" alt="" />
        </div>
      </div>
    </div>
    <div class="class_list">
      <div v-for="(item, i) in classList" :key="i" @click="gopreview(item)">
        <div class="listImage">
          <img :src="getCoverImg(item)" alt="" />
        </div>
        <p class="one_name">
          {{ item.name }}
        </p>
        <p v-if="item.price * 1 > 0" class="price">
          ¥<span class="price_1" v-html="changePrice(item.price * 1, 24, 16)"></span>
        </p>
      </div>
    </div>
  </div>
</template>

<script>
import { getCoverImg } from '@/utils/index';

export default {
  props: ['classList', 'type'],
  data() {
    return {
      getCoverImg,
    };
  },
  methods: {
    goMore() {
      this.$router.push({
        path: '/Viewmore',
        query: {
          classify: 'TEACHING',
        },
      });
    },
    // 前往预览页面
    gopreview(item) {
      this.$router.push({
        path: '/Preview',
        query: {
          id: item.id,
          allList: this.type ? 'allList' : null,
        },
      });
    },
    changePrice(price, fontSize1, fontSize2) {
      let _price = price || 0;
      _price = _price.toFixed(2).toString();
      let arr = _price.split('.');
      let str = `<span style="font-size: ${fontSize1 || 16}px;">${arr[0]}</span>.<span style="font-size: ${
        fontSize2 || 16
      }px;">${arr[1]}</span>`;
      return str;
    },
  },
};
</script>

<style lang="scss" scoped>
.Teaching {
  .top {
    width: 1200px;
    margin: 0 auto;

    .title {
      display: flex;
      align-items: center;
      justify-content: space-between;
      width: 100%;
      height: 90px;

      .text {
        position: relative;
        font-size: 24px;
        font-weight: bold;
      }

      .more {
        display: flex;
        align-items: center;
        font-size: 16px;
        cursor: pointer;

        span {
          opacity: 0.4;
        }

        img {
          width: 25px;
          height: 19px;
        }
      }
    }
  }

  .class_list {
    box-sizing: border-box;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    width: 1200px;
    padding: 50px 20px 8px;
    margin: 0 auto;
    background: #fff;

    > div {
      width: 192px;
      margin-right: 20px;
      margin-bottom: 32px;
      margin-left: 20px;
      cursor: pointer;
      transition: all 1s;

      .one_name {
        display: -webkit-box;
        height: 48px;
        padding-left: 4px;
        margin-top: 16px;
        overflow: hidden;
        font-size: 16px;
        line-height: 150%;
        color: #2c2c2c;
        text-overflow: ellipsis;
        word-break: break-all;
        cursor: pointer;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
      }

      .price {
        font-size: 24px;
        font-weight: bold;
        color: #2c2c2c;

        .price_2 {
          font-size: 16px;
        }
      }

      p {
        font-size: 16px;
      }

      .listImage {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 256px;
        color: #c0c4cc;

        // border: 1px solid rgba(0, 0, 0, 0.15);
        img {
          max-width: 100%;
          max-height: 100%;
        }
      }

      .gray {
        color: #a3a3a3;
      }

      .origin {
        color: #f90;
      }
    }

    .more {
      position: relative;
      background: url('../../assets/teacherdev/image 13.png') center;

      .shade {
        position: absolute;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
        cursor: pointer;
        background: #000;
        opacity: 0.6;

        > div {
          img {
            width: 58px;
            height: 58px;
          }

          span {
            position: relative;
            top: -20px;
            color: white;
          }
        }
      }
    }
  }
}
</style>
