<template>
  <div class="app">
    <div class="m-right-block fr">
      <div class="right-block-bd">
        <div class="panel-tit clear">
          <p class="fl">学习向导</p>
        </div>
        <div class="train_step_box clear mt10">
          <div class="train_step fl">
            <p><span class="fs3 t-b b v-m">第1步</span>
              <a @click="gotoPage('/center/market')" class="train_btn" title="报名培训">报名培训</a>
            </p>

            <p class="fs15 mt10">请根据您持有的证书进行报班</p>
          </div><span class="p-ico2 step-ico fl"></span>
          <div class="train_step fl">
            <p><span class="fs3 t-b b v-m">第2步</span>
              <a @click="gotoPage('/center/class/train')" class="train_btn w150" title="进班学习">进班学习</a></p>
            <p class="fs15 mt10">完成班级内培训内容，通过班级考核</p>
          </div><span class="p-ico2 step-ico fl"></span>
          <div class="train_step fl">
            <p>
              <span class="fs3 t-b b v-m">第3步</span>
              <a @click="gotoPage('/center/sign')" class="train_btn w150" title="下载证明">下载证明</a>
            </p>
            <p class="fs15 mt10">班级培训合格，即可以下载学时证明</p>
          </div>
        </div>
        <div class="panel-tit mt30 clear">
          <p class="fl">最近学习课程</p>
        </div>

        <div class="clear mt10">
          <div class="m-history-course fl ng-scope" v-for="item in list" :key="item.courseId" style="width:464px; margin-left:8px;cursor:pointer">
            <a  class="course-img" @click="gotoPlay(item.courseId)">
              <img :src="item.tb">
              <span class="p-ico2"></span>
            </a>
            <div class="history-course-bd" style="width:276px">
              <p class="tit ng-binding">{{item.name}}</p>
              <div class="info">课程进度
                <span class="num ml10 ng-binding">{{getPercent(item)}}</span>
                <span class="t-b">%</span>
              </div>
              <div class="info">最近一次学习
                <span>{{item.endDate}}</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

  </div>

</template>

<script>
  import {
    httpServer
  } from "@/components/httpServer/httpServer.js";
  export default {
    name: "Index",
    data() {
      return {
        page: 1,
        size: 12,
        total: 1,
        media: {},
        list: [],
      };
    },
    beforeMount() {
      this.getData()
    },
    methods: {
      gotoPlay(courseId) {
        this.$router.push({name:'play', params:{courseId}})
      },
      gotoPage(route) {
        this.$router.push(route);
      },
      getPercent(item) {
        if (item.getXs >= item.totalXs) {
          return 100
        } else {
          return parseInt(item.getXs * 10000 / item.totalXs) / 100
        }
      },
      getData() {
        let {
          page,
          size
        } = this
        let param = {
          from: (page - 1) * size,
          isFree: 1,
          size
        }
        httpServer('course.GetHistoryCourseList', param).then(({
          data,
          code
        }) => {
          this.list = data.list || 0;
          this.total = data.total || 0;
        })
      }
    }
  };
</script>

<style lang="less">
  @import "./index.less";
  @import "../../../assets/css/course.css";
</style>
