<template>

  <div>
    <!-- <Remark>
      1.已学习完成的课程。回顾，进入学习页面<br/>
      2.重新学习，系统会把课程重置为0<br/>
	  3.历史记录显示已完成的任务/项目/课程
    </Remark> -->
    <div style="display: flex;justify-content:space-between;padding: 12px 32px 10px 22px; ">
      <div style="display: flex;justify-content: flex-start;">
        <div >
          <el-select v-model="params.courseType" clearable placeholder="全部">
            <el-option label="微课" :value="10"></el-option>
            <el-option label="录播课" :value="20"></el-option>
			<!-- <el-option label="课程" value="3"></el-option> -->
         </el-select>
        </div>
		<!-- <el-select style="padding-left: 10px;" v-model="params.type2" clearable placeholder="状态">
		   <el-option label="进行中" value="1"></el-option>
		   <el-option label="已完成" value="2"></el-option>
		</el-select> -->
        <div style="padding-left: 10px;">
          <el-input v-model="params.courseName" clearable placeholder="搜索名称"></el-input>
        </div>
        <div style="padding-left: 10px;">
          <el-button type="primary" icon="el-icon-search" @click="searchData()">搜索</el-button>
        </div>
                <div style="padding-left: 10px"><el-button type="primary" icon="el-icon-refresh-right" @click="reset()">重置</el-button></div>
      </div>
    </div>
    <!--课程列表内容-->
    <div class="uc-list">
      <div class="uc-course" v-for="(item,idx) in couresList" :key="idx">
        <div class="uc-course-img" style="width: 212px;height:119px">
          <!-- <img :src="fileUrl+item.courseImage"> -->
          <course-image :course="item"></course-image>
        </div>
        <div class="uc-course-info">
          <div class="uc-course-name">
            <span v-if="item.courseType==10" class="uc-course-type2">微课</span>
            <span v-if="item.courseType==20" class="uc-course-type2">录播</span>
             <a> {{item.courseName}}</a>
          </div>
          <div style="height: 35px;"></div>
          <div class="uc-course-text">完成时间：{{item.addTime}}</div>
          <!-- <div class="uc-course-text">得分：<span>{{item.lastScore}}</span>分</div> -->
        </div>
        <div class="uc-course-btns">
            <el-button  style="margin-top:60px;" v-if="item.progress==100" type="primary" @click="jumpRouter(item)" size="small" >回顾</el-button>
            <!-- <el-button @click="reStudy(item)" v-if="item.progress==100" type="primary" size="mini">重新学习</el-button> -->
        </div>
      </div>
    </div>
      <div style="text-align: center;margin-top:57px;">
      <el-pagination
       background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="page.pageIndex"
        :page-sizes="[10, 20, 30, 40]"
        :page-size="page.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="page.count"
      ></el-pagination>
    </div>

  </div>
</template>

<script>
import courseImage from "@/components/Course/courseImage.vue"
import apicourseStudy from "@/api/modules/courseStudy.js";
export default {
  name: "ucFinishCourses",
  components: { courseImage},
  data() {
    return {
       fileUrl:process.env.VUE_APP_FILE_BASE_URL,//文章的url路径
      page: {
        pageIndex: 1, //第几页
        pageSize: 10, // 每页多少条
        count: 0
      },
      params: { courseName: "", courseType: "", isFinish: true },
      couresList: []
    };
  },
  mounted() {
    this.searchData();
  },
  methods: {

    reset(){
      this.params.courseName = '',
      this.params.courseType = ''
    },
    jumpRouter(item) {
      // if (item.courseType == 10) {
      //   let routeData = this.$router.resolve({path: "/course/micro?id=" + item.courseId});
      //   window.open(this.webBaseUrl+routeData.href, "_blank");
      // }
      // if (item.courseType == 20) {
        let routeData = this.$router.resolve({ path: "/course/detail?id=" + item.courseId}); // , query: {  id: 1 }
        window.open(this.webBaseUrl+routeData.href, "_blank");
      // }
    },
    handleSizeChange(val) {
      this.page.pageSize = val;
      this.page.pageIndex = 1;
      this.searchData();
    },
    handleCurrentChange(val) {
      this.page.pageIndex = val;
      this.searchData();
    },
    searchData() {
      apicourseStudy.myStudyList(this.params).then(res => {
        if (res.status === 200) {
          this.couresList = res.result.list;
          this.page.count = res.result.count;
          console.log(res)
        } else {
          this.$message.error(res.message);
        }
      });
    },
    handleSizeChange(val) {
      this.page.pageSize = val;
      this.page.pageIndex = 1;
      this.searchData();
    },
    handleCurrentChange(val) {
      this.page.pageIndex = val;
      this.searchData();
    },
    reStudy(item) {
      this.$confirm(
        "您确定要重新学习吗？重新学习会把学习时间重置为0，再开始学习",
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }
      )
        .then(() => {})
        .catch(() => {});
    }
  }
};
</script>

<style scoped lang="scss">
.uc-list{
  padding-left: 24px;
}
.uc-course-type1 {
  width: 62px;
  height: 24px;
  text-align: center;
  line-height: 24px;
  font-size: 14px;
  // padding: 3px 15px;
  background: #3e7fff;
  color: #fff;
  border-radius: 2px
}
.uc-course-type2 {
   width: 62px;
  height: 24px;
  text-align: center;
  line-height: 24px;
  font-size: 14px;
  background: #ff8e00;
  color: #fff;
  border-radius: 2px
}
.uc-badge {
  margin-top: 10px;
  margin-right: 40px;
}
.uc-course {
  display: flex;
  justify-content: space-around;
  // border: 1px solid #f0f0f0;
  border-bottom: 1px solid #E8E8E8;
  margin-right: 32px;
  padding: 20px 0px 15px  0px ;
  .uc-course-img {
    // width: 200px;
    img {
      // width: 200px;
      // border: 1px solid #f4f4f5;
    }
  }
  .uc-course-info {
    flex: 1;
    line-height: 28px;
    padding: 0px 10px;
    .uc-course-name {
      font-size: 18px;
      margin-top: -3px;
      // font-weight: 700;
      a{
        font-size: 18px;
        font-family: PingFang SC-Medium, PingFang SC;
        font-weight: 500;
        color: #333333;
      }
    }
    .uc-course-text {
      margin-top: 35px;
      color: #666;
      font-size: 14px;
      line-height: 30px;
      span{
        color: #ffaa00;
        font-size: 24px;
      }
    }
  }
  .uc-course-btns {

    width: 150px;
  }
}
</style>
