<template>
  <div class="main-list">
    <template v-if="list.length">
      <ul>
        <li v-for="item in list" :key="item.id">
          <div class="pic">
            <img />
          </div>
          <div class="text"></div>
        </li>
      </ul>
    </template>
    <template v-else>
      <slot name="empty">
        <div class="empty">暂时没有内容哦，换个搜索词试试吧～</div>
      </slot>
    </template>
  </div>
</template>

<script>
import * as api from '@/api/course.js'
export default {
  name: 'VideoList',
  props: {
    params: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      list: [],
      requestParams: {}
    }
  },
  watch: {
    params: {
      immediate: true,
      handler(value) {
        this.requestParams = Object.assign({}, this.requestParams, value)
      }
    }
  },
  methods: {
    getList() {
      api.getCourseVideoSearchList(this.requestParams).then(response => {
        this.list = response
      })
    },
    // 刷新
    refresh() {
      this.getList()
    }
  },
  beforeMount() {
    this.getList()
  }
}
</script>
