<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="index" @click="toDetailPage(index)">
                    <div class="literacy-img" :style="{backgroundImage: `url(${item.poster})`}"></div>
                    <p class="img-text">{{item.title}}<p/>
                </div>
                <div class="literacy-item" v-for="(item,index) in course" :key="index" @click="toDetailPage(index)">
                    <div class="literacy-img" :style="{backgroundImage: `url(${item.poster})`}"></div>
                    <p class="img-text">{{item.title}}<p/>
                </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: 'diagDetail',
                params: {
                    videoInfo: this.videoList[index]
                }
            })
        }
    },
    created() {
        this.videoList = require('@/static/diagnosis.json')
        this.videoListShow = this.videoList
        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
        })
    }
}
</script>
<style lang="less" scoped>
.literacy-container {
    width: 100%;
    height: 100%;
    background: white;
    padding: 15px;
}
.literacy-block-box {
    width: 100%;
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
}
.literacy-item {
    width: 300px;
    background: #fcfcfc;
    border: 1px solid #f0f0f0;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 30px;
    margin-right: 30px;
    cursor: pointer;
    height: 180px;
    position: relative;
    transition: all 0.2s ease 0s;
    &: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: 180px;
        background-size: cover;
        background-repeat: no-repeat;
    }
    .img-text{
        width: 300px;
        height: 180px;
        position: absolute;
        left: 0px;
        top: 0px;
        background: rgba(20, 20, 20, .1);
        color: white;
        font-size: 14px;
        padding: 5px;
        &:hover{
            background: rgba(20, 20, 20, .2);
        }
    }
}
.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>