<template>
  <!-- 教材 -->
  <div class="Textbook">
    <div class="top" v-if="!type">
      <div class="title">
        <span>
          <img src="../../assets/learncenter/listTitleImg2.png" alt="" />
        </span>
        <b>{{ $t('Key44') }}</b>
      </div>
      <div class="more" @click="gotolist">
        <span><!-- 查看更多  -->{{ $t('Key47') }}</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> {{ $t('Key323') }}</span>
        </div>
        <p class="one_name">{{ item.name }}</p>
        <p class="price" v-if="item.price > 0 &&item.is_free_license=='false'">
          ￥<span class="price_1" v-html="changePrice(item.price)"></span>
        </p>
      </div>
    </div>
  </div>
</template>

<script>
import { updateWordPack } from '@/utils/i18n'
export default {
  props: ['classList', 'type'],
  data() {
    return {}
  },
  methods: {
    gotolist() {
      this.$router.push({
        path: '/learncenter/ListPage',
        query: { id: 'TEXTBOOK' },
      })
    },
    // 处理价格
    // 处理价格
    changePrice(price) {
      let str = ''
      price = price ? price.toString() : '0.00'
      if (price.indexOf('.') > -1) {
        let arr = price.split('.')
        str = `<span style="font-size: 24px;">${arr[0]}</span>.<span style="font-size: 16px;">${arr[1]}</span>`
      } else {
        str = `<span style="font-size: 24px;">${price}</span>.<span  style="font-size: 16px;">00</span>`
      }

      return str
    },
    // 需要跳到教材系统的教材详情
    gotoIntroduce(item) {
      sessionStorage.setItem('Bookdetail', JSON.stringify(item))
      let href = `/GCLS-Book/#/GoodsDetail?goods_id=${item.id}&goods_type=101&invok_module=GCLS-LC`
      window.open(href, '_blank')
    },
  },
  created() {
    updateWordPack({
      word_key_list: ['Key44', 'Key46'],
    })
  },
}
</script>

<style lang="scss" scoped>
.Textbook {
  .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;
      align-items: center;
      justify-content: center;
      span {
        display: inline-block;
        width: 42px;
        height: 42px;
        border-radius: 50%;
        background: linear-gradient(28.36deg, #ff7d8a 13.41%, #ff616c 84.14%);
        display: flex;
        align-items: center;
        justify-content: center;
        img {
          width: 20px;
          height: 15px;
        }
      }
      b {
        margin: 0 16px;
      }
    }
    .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: 1200px;
    box-sizing: border-box;
    padding: 40px 20px 8px;
    > div {
      margin: 0 20px 32px 20px;
      width: 192px;
      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;
      }
      .price {
        margin-top: 8px;
        font-weight: bold;
        color: #2c2c2c;
        font-size: 24px;
        .price_2 {
          font-size: 16px;
        }
      }
      p {
        font-size: 16px;
      }
      .listImage {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 100%;
        height: 256px;
        border: 1px solid rgba(0, 0, 0, 0.15);
        box-sizing: border-box;
        img {
          max-width: 100%;
          max-height: 100%;
        }
        color: #c0c4cc;
      }
      .gray {
        color: #a3a3a3;
      }
      .origin {
        color: #ff9900;
      }
    }
  }
}
</style>