<template>
  <div class="apcontainer">
    <div class="list">
      <div class="item" v-for="(item,index) in courseWatchLogList" :key="index">
        <div class="left">
          <img :src="item.thumbnail" />
          <div class="box">
            <div class="title">{{item.courseName}}</div>
            <div class="text">播放时长：{{item.duration}}</div>
            <div class="text">创建时间：{{item.createTime}}</div>
            <div class="text">记录编号：{{item.logId}}</div>
          </div>
        </div>
        <div class="right">
         {{type(item.logType)}}
        </div>
      </div>
    </div>
  <!--  <el-table border v-loading="loading" :data="courseWatchLogList">
      <el-table-column label="记录编号" align="center" prop="logId" />
      <el-table-column label="用户账号" align="center" prop="userName" />
      <el-table-column label="会员昵称" align="center" prop="fsNickName">
        <template slot-scope="scope">
          <div style="display: flex;white-space: nowrap">
            <div style="margin: auto">
              {{scope.row.fsNickName}}
            </div>
            <el-popover
              placement="right"
              title=""
              trigger="hover">
              <img slot="reference" :src="scope.row.fsAvatar" style="width: 30px;height: 30px">
              <img :src="scope.row.fsAvatar" style="max-width: 200px;max-height: 200px">
            </el-popover>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="项目" align="center" prop="projectName" />
      <el-table-column label="课程名称" align="center" prop="courseName" />
      <el-table-column label="小节名称" align="center" prop="videoName" />
      <el-table-column label="记录类型" align="center" prop="logType">
        <template slot-scope="scope">
          <dict-tag :options="logTypeOptions" :value="scope.row.logType"/>
        </template>
      </el-table-column>
      <el-table-column label="播放时长" align="center" prop="duration" />
      <el-table-column label="创建时间" align="center" prop="createTime" />
      <el-table-column label="更新时间" align="center" prop="updateTime" />
      <el-table-column label="完课时间" align="center" prop="finishTime" />
      <el-table-column label="营期时间" align="center" prop="campPeriodTime" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    /> -->

  </div>
</template>

<script>
import { listCourseWatchLog } from "@/api/course/courseWatchLog";
import { getQwExternalContactWatchLogList } from "@/api/qw/im";
import {mapState} from "vuex";
export default {
  name: "CourseWatchLog",
  data() {
    return {
      activeName:"00",
      logTypeOptions:[],
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 短链课程看课记录表格数据
      courseWatchLogList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 3,
       qwExternalContactId:null,
        // logType: null,
      },
    };
  },
  computed: {
    ...mapState({
      companyUserId: state => state.user.user.userId,
    }),

    type(){
       return (val) => { // 闭包函数，接收 val
             if (val) {
               if(val==3){
                 return '待看课';
               }else{
                 let str=this.logTypeOptions.find(item => Number(item.dictValue) == val)
                 return str?str.dictLabel:'-';
               }
             }else{
               return '-';
             }
           }
    }
  },
  created() {
    this.getDicts("sys_course_watch_log_type").then(response => {
      this.logTypeOptions = response.data;
    });
    this.queryParams.companyUserId = this.companyUserId
  },
  methods: {
    getUserWatchLog(id) {
      this.queryParams.qwExternalContactId = id
      this.getList()
    },
    /** 查询短链课程看课记录列表 */
    getList() {
      this.loading = true;
      if(this.queryParams.logType == "10"){
        this.queryParams.logType = null;
      }

      getQwExternalContactWatchLogList(this.queryParams).then(response => {
        this.courseWatchLogList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
  }
};
</script>

<style scoped lang="scss">
.apcontainer {
  /* padding: 10px; */
  padding-top: 20px;
  /* font-size: 12px; */
  .list{
    .item{
      display: flex;
      align-items:flex-start;
      justify-content: space-between;
      margin-bottom: 12px;
      .left{
        flex:1;
        display: flex;
        align-items: center;
        img{
          width: 86px;
          height: 86px;
          border-radius: 4px 4px 4px 4px;
        }
        .box{
          height: 86px;
          margin-left: 10px;
          display: flex;
          flex-direction: column;
          align-items: flex-start;
          justify-content: space-between;
          .title{
            font-weight: 400;
            font-size: 14px;
            color: #202124;
          }
          .text{
            font-weight: 400;
            font-size: 12px;
            color: #84868C;
          }
        }
      }
      .right{
        font-weight: 400;
        font-size: 12px;
        color: #FC4B0E;
      }
    }
  }
}
</style>
