<template>
    <div class="literacy-container">
        <div class="literacy-search">
            <Input v-model="keyword" suffix="ios-search" placeholder="搜索" style="width: 200px;margin-top:0px" @on-change="search" />
        </div>
        <!-- <div class="literacy-mgt-top">
            <Input v-model="keyword" suffix="ios-search" placeholder="搜索" style="width: 200px;margin-top:0px" @on-change="search" />
        </div> -->
        <vuescroll>
            <div class="literacy-block-box">
                <div class="literacy-item" v-for="(item,index) in videoListShow" :key="item.title" @click="toDetailPage(index)">
                    <div class="literacy-img-box">
                        <div class="literacy-img" :style="{backgroundImage: `url(${item.poster})`}"></div>
                    </div>
                    <div class="info-item" v-show="!item.type">
                        <span class="info-label">报告人：</span>
                        <span>{{item.reporter}}</span>
                    </div>
                    <div class="info-item">
                        <span class="info-label">主题：</span>
                        <span>{{item.title}}</span>
                    </div>
                </div>
                <!-- <div class="literacy-item" v-for="(item,index) in course" :key="index" @click="toDetailPage1(index)">
                    <div class="literacy-img-box">
                        <div class="literacy-img" :style="{backgroundImage: `url(${item.poster})`}"></div>
                    </div>
                    <div class="info-item">
                        <span class="info-label">主题：</span>
                        <span>{{item.title}}</span>
                    </div>
                </div> -->
            </div>
            <EmptyData textContent="未搜到相关课程" v-show="!videoListShow.length" :top="100"></EmptyData>
        </vuescroll>
    </div>
</template>
<script>
const courseData = require('@/static/course.json')
export default {
    data() {
        return {
            keyword: '',
            videoList: [],
            videoListShow: [],
            course: []
        }
    },
    methods: {
        search() {
            if (this.keyword) {
                this.videoListShow = this.videoList.filter(item => {
                    return JSON.stringify(item).includes(this.keyword)
                })
            } else {
                this.videoListShow = this.videoList
            }

        },
        toDetailPage(index) {
            this.$router.push({
                name: 'literacyDetail',
                params: {
                    videoInfo: this.videoList[index]
                }
            })
        },
        toDetailPage1(index) {
            this.$router.push({
                name: 'literacyDetail',
                params: {
                    videoInfo: this.course[index]
                }
            })
        }
    },
    created() {
        this.videoList = require('@/static/video.json')
        this.course = []
        this.course = this._.cloneDeep(courseData)
        let sas = this.$store.state.user.schoolProfile.blob_sas
        let blobUrl = JSON.parse(decodeURIComponent(localStorage.school_profile, "utf-8")).blob_uri
        this.course.forEach(item => {
            let url = `${blobUrl}${item.link}?${sas}`
            item.link = url
            item.type = 'policy'
        })
        this.videoList.push(...this.course)
        //如果后面数据量更多需要做分页或者懒加载
        this.videoListShow = this.videoList

    }
}
</script>
<style lang="less" scoped>

.literacy-container {
    width: 100%;
    height: 100%;
    background: #f7f7f7;
    padding: 15px;
}
.literacy-block-box {
    // background: white;
    width: 100%;
    // min-height: 800px;
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
}
.literacy-item {
    width: 300px;
    background: white;
    border: 1px solid #f0f0f0;
    padding-bottom: 10px;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 30px;
    margin-right: 30px;
    cursor: pointer;
    height: fit-content;
    transition: all 0.2s ease 0s;
    .info-label {
        color: #a5a5a5;
    }
    &:hover {
        box-shadow: 0 26px 40px -24px #aaa;
        transform: translateY(-4px);
    }
    &:hover .literacy-img {
        transform: scale(1.1);
    }
    .literacy-img-box {
        width: 300px;
        height: 150px;
        overflow: hidden;
    }
    .literacy-img {
        transition: all 0.3s;
        width: 300px;
        height: 150px;
        background-size: cover;
        background-repeat: no-repeat;
    }
    .info-item {
        margin-top: 10px;
        width: 100%;
        padding-left: 5px;
        font-size: 16px;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
    }
}
.literacy-mgt-top {
    width: ~"calc(100% - 20px)";
    height: 40px;
    box-shadow: 0px 2px 5px #e9e9e9;
    margin-left: 10px;
    padding-left: 10px;
    padding-right: 20px;
    margin-bottom: 10px;
    line-height: 40px;
}
.literacy-search{
    float: right;
    margin-top: -52px;
    margin-right: 20px;
}
</style>
<style lang="less">
</style>