<template>
  <!-- 精品课 -->
  <div class="Course">
    <div class="top" v-if="!type">
      <div class="title">
        <span>
          <img src="../../assets/learncenter/listTitleImg1.png" alt="" />
        </span>
        教学
      </div>
      <div class="more" @click="gotolist">
        <span> 查看更多 </span>
        <img src="../../assets/learncenter/moreImage.png" alt="" />
      </div>
    </div>
    <div class="class_list">
      <div v-for="(item, i) in classList" :key="i" @click="gotoIntroduce(item)">
        <div class="listImage">
          <!-- <el-image lazy :src="item.picture_url" alt=""></el-image> -->
          <img v-if="item.picture_url" :src="item.picture_url" alt="" />
          <span v-else>加载失败</span>
        </div>

        <p class="one_name">{{ item.name }}</p>
        <p class="price">
          ￥
          <span class="price_1" v-text="changePrice('1', item.price)"></span>
          <span class="price_2" v-text="changePrice('2', item.price)"></span>
        </p>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ["classList", "type"],
  data() {
    return {};
  },
  methods: {
    gotolist() {
      this.$router.push({
        path: "/learncenter/ListPage",
        query: { id: "COURSE" },
      });
    },
    // 处理价格
    changePrice(type, item) {
      item = item + "";
      if (item.indexOf(".") != -1) {
        if (type == 1) {
          return item.split(".")[0];
        } else if (type == 2) {
          return "." + item.split(".")[1];
        }
      } else {
        if (type == 1) {
          return item;
        }
        if (type == 2) {
          return ".00";
        }
      }
    },
    // 需要跳转到教学系统进行查看详情或者购买
    gotoIntroduce(item) {
      let href = `/GCLS-Learn/#/GoodsDetail?goods_id=${item.id}&goods_type=201`;
      window.open(href, "_blank");
    },
  },
};
</script>

<style lang="scss"  scoped>
.Course {
  .top {
    width: 1200px;
    margin: 0 auto;
    height: 90px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .title {
      font-weight: bold;
      font-size: 24px;
      display: flex;
      span {
        display: inline-block;
        width: 42px;
        height: 42px;
        border-radius: 50%;
        background: linear-gradient(
          216.55deg,
          #ffef5a 10.18%,
          #ffd337 10.19%,
          #ffd772 81.9%
        );
        margin-right: 16px;
        display: flex;
        align-items: center;
        justify-content: center;
        img {
          width: 20px;
          height: 15px;
        }
      }
    }
    .title2 {
      font-weight: bold;
      font-size: 16px;
      color: rgba(0, 0, 0, 0.5);
      span {
        color: black;
      }
    }
    .more {
      cursor: pointer;
      font-size: 16px;
      display: flex;
      align-items: center;
      span {
        opacity: 0.4;
      }
      img {
        width: 25px;
        height: 19px;
      }
    }
  }
  .class_list {
    margin: 0 auto;
    background: #fff;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    width: 1160px;
    padding-top: 50px;
    padding-left: 20px;
    padding-right: 20px;
    > div {
      margin-left: 20px;
      margin-right: 20px;
      width: 256px;
      cursor: pointer;
      .one_name {
        width: 100%;
        height: 42px;
        margin-top: 16px;
        line-height: 150%;
        word-break: break-all;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        text-overflow: ellipsis;
        overflow: hidden;
        font-size: 14px;
        color: #2c2c2c;
        padding-left: 5px;
      }
      .price {
        margin-top: 8px;
        font-weight: bold;
        color: #2c2c2c;
        font-size: 24px;
        .price_2 {
          font-size: 16px;
        }
        margin-bottom: 40px;
      }
      p {
        font-size: 16px;
      }
      .listImage {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 100%;
        height: 144px;
        border: 1px solid rgba(0, 0, 0, 0.15);

        img {
          max-width: 100%;
          max-height: 100%;
        }
        color: #c0c4cc;
      }
      // img {
      //   width: 256px;
      //   height: 114px;
      // }
      .gray {
        color: #a3a3a3;
      }
      .origin {
        color: #ff9900;
      }
    }
  }
}
</style>