<template>
  <div class="study-index" v-loading="loading">
    <Remark>

    </Remark>
  </div>
</template>

<script>
  import studyItem from '@/components/Course/studyItem.vue'
  import apicourseStudy  from '@/api/modules/courseStudy.js';
  // import apiBoeCourse from '@/api/boe/course.js';
  import {resListMap, resOwnerListMap,courseType,getType} from '@/utils/tools.js';
  import apiBoe  from '@/api/boe/boeApiAjax.js';
  import axios from 'axios'
  import { mapGetters,mapActions} from 'vuex';
  export default {
    name: 'ucStudyIndex',
    components:{studyItem},
    data(){
        return {
          loading:false,
          lastTabName:'course',
          getCourseType:courseType,
          lastStudy:{
            aname: "",
            contentId: "",
            contentName: "",
            contentType: 0,
            courseId: "",
            courseName: "",
            courseType: "",
            coverImg: "",
            itemId: "",
            lastStudyTime: 0,
            lastTime: "",
            progress: 100,
            score: "",
            studyDuration: "",
            studyId: "",
          },
          params:{
            pageIndex: 1,//第几页
            pageSize: 5,
            isFinish:false,
          },
          couresList:[],
          couresCount:0,
          taskList:[]
        }
    },
    beforeCreate() {
      this.loading = true;
      let params={
          // keyword:this.keyword,
          page:1,
          size:10,
          // cmtask_status:this.cmtask_status,
          // cmtask_name:this.cmtask_name,
        }

      // apiBoeCourse.cmtaskList(params).then(res=>{
      //   if(res.status==200){
      //      this.total = res.result.count
      //      this.couresList = res.result.list;
      //      this.loading = false;
      //      if(this.$route.fullPath != '/uc/study/task' &&  this.$route.fullPath != '/uc/study/courses' && this.$route.fullPath != '/study/index') {
      //        return;
      //      }
      //      if(res.result.count > 0) {
      //         this.$router.push('/uc/study/task')
      //      } else {
      //        if(this.$route.query.study == '1') {
      //           this.$router.push('/uc/study/task')
      //        } else {
      //           this.$router.push('/uc/study/courses')
      //        }
      //      }
      //    }else{
      //       this.$router.push('/uc/study/courses')
      //    }
      // }).catch(err=>{
      //   if(this.$route.fullPath != '/uc/study/task' ||  this.$route.fullPath != '/uc/study/courses' || this.$route.fullPath != '/study/index') {
      //       return;
      //     }
      //   this.$router.push('/uc/study/courses');
      // })
    },
    created() {
      this.$router.push('/uc/study/courses');
      // this.searchData();
      // this.getLastStudy();
      // this.loadRemoteTask();
      // this.loadResOwners();
      // this.loadSysTypes();

    },
    methods:{
      continueStudy(item){
        // if(item.courseType==10){
        //   return '../course/micro?id='+item.courseId
        // }else{
          return '../course/studyindex?id='+item.courseId
        // }
      },
      ...mapActions({
        getResOwnerTree:'resOwner/getResOwnerTree',
        loadResOwners:'resOwner/loadResOwners',
        getSysTypeTree:'sysType/getSysTypeTree',
        loadSysTypes:'sysType/loadSysTypes'
      }),
      getLastStudy() {
        apicourseStudy.lastStudy().then(res=>{
        if(res.status === 200) {
          this.lastStudy=res.result;
        } else {
          this.$message.error(res.message);
        }
      })
      },
      loadRemoteTask(){
         //调用远程接口
         // let url="http://u.boe.com/api/b1/system/cmtask/cmtask-list";
         // let jsonData={
         //   cmtask_status:'',
         //   cmtask_name:'',
         //   page:1,
         //   size:10
         // }
         // axios.post(url,jsonData).then(rs=>{
         //   console.log(rs)
         // })
         // apiBoe.postJson(url,jsonData).then(rs=>{
         //   if(rs.status==200){

         //   }
         // })
      },
     searchData() {
      apicourseStudy.myStudyList(this.params).then(res=>{
        if(res.status === 200) {
           this.couresList =res.result.list;
           this.couresCount = res.result.count;
        } else {
          this.$message.error(res.message);
        }
      })
    },
      lastTabChange(tab,event){
        // console.log(tab.name);
      }
    }
  }
</script>

<style scoped lang="scss">
.study-index{
  .title{
    padding: 6px 10px;
    font-size: 16px;
    font-weight: 700;
    color: #707070;
    border-bottom: 1px solid #dedede;
  }
   .more {
      float: right;
      margin-top: 7px;
      color: #666666;
      font-size: 14px;
    }
}

  .uc-badge{
    margin-top: 10px;
    margin-right: 40px;
  }
  .uc-course{
    display: flex;
    justify-content: space-around;
    border: 1px solid #F0F0F0;
    padding: 10px;
    .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;
        font-weight: 700;
      }
      .uc-course-text{
        color: #747474;
      }
    }
    .uc-course-btns{
      width: 150px;
    }
  }
</style>
