<template>
  <div>
    <div class="head">
      <text class="head-text1">电子版答案</text>
      <image class="head-text1-fire" :src="fireIcon"></image>
      <div class="head-text2">共{{ pdfList.length }}个小节</div>
    </div>
    <div class="container">
      <div
        v-for="(item, index) in pdfList"
        :key="index"
        @click="
          goPath('/pages/pdfPreview/index', {
            src: web,
            token:token,
            name:item.dictLabel,
            code:item.dictCode
          })
        "
        class="cell"
      >
        <div class="flex">
          <div class="cell-dot"></div>
          <div class="cell-col2">
            <div class="cell-text1">{{ item.dictLabel }}</div>
            <div style="margin-top:10rpx" class="flex">
              <div class="cell-text2">图文</div>
              <image
                style="width: 28rpx; height: 32rpx"
                :src="diaryIcon"
              ></image>
            </div>
          </div>
        </div>
        <div class="flex">
          <div class="cell-button">开始学习</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import fireIcon from "@/assets/img/fire-icon.png";
import diaryIcon from "@/assets/img/diary-icon.png";
import api from "@/api/index";
import utils from "@/utils/index";
export default {
  data() {
    return {
      web:
        process.env.NODE_ENV === "development"
          ? "https://mn1.zzxcx.net/#/pdf/preview"
          : "https://mn.zzxcx.net/#/pdf/preview",
      fireIcon,
      diaryIcon,
      pdfList: []
    };
  },
  methods: {
    goPath(url, query = {}) {
      uni.navigateTo({
        url: url + "?" + utils.mapToUrlQuery(query),
      });
    },
  },
  computed: {
    token() {
      return this.$store.state.user.tokenObj.token
    }
  },

  mounted() {
    api.open.systemDictDataType("learning_materials").then((res) => {
      this.pdfList = res.data;
    });
  },
};
</script>

<style lang="scss" scoped>
.flex {
  display: flex;
}
.head {
  padding-left: 30px;
  padding-right: 30px;
  width: 100%;
  height: 114rpx;
  background: #fff;
  display: flex;
  align-content: center;
  align-items: center;
  flex-wrap: wrap;
  border-bottom: 2px solid #e8e8e8;
  .head-text1 {
    color: #498ef5;
    font-size: 34rpx;
  }
  .head-text1-fire {
    width: 32rpx;
    height: 37rpx;
    margin-left: 10rpx;
  }
  .head-text2 {
    width: 100%;
    text-align: left;
    color: #8a9099;
    font-size: 26rpx;
  }
}
.container {
  width: 100%;
  padding-left: 30rpx;
  padding-right: 30rpx;
  background: #fff;
  .cell {
    width: 100%;
    display: flex;
    padding-top: 20rpx;
    height: 134rpx;
    justify-content: space-between;
    border-bottom: 2rpx solid #e8e8e8;

    .cell-dot {
      width: 20rpx;
      height: 20rpx;
      background: #498ef5;
      border-radius: 50%;
      margin-top: 10rpx;
      margin-right: 20rpx;
    }
    .cell-col2 {
      .cell-text1 {
        font-size: 30rpx;
      }
      .cell-text2 {
        width: 60rpx;
        height: 32rpx;
        background: #ffffff;
        border-radius: 6rpx 6rpx 6rpx 6rpx;
        opacity: 1;
        border: 2rpx solid #8a9099;
        font-size: 22rpx;
        text-align: center;
        margin-right: 12rpx;
      }
    }
    .cell-button {
      width: 144rpx;
      height: 48rpx;
      border-radius: 60rpx 60rpx 60rpx 60rpx;
      opacity: 1;
      border: 2rpx solid #498ef5;
      font-size: 26rpx;
      line-height: 48rpx;
      color: #498ef5;
      text-align: center;
      margin-top: 24rpx;
    }
  }
}
</style>