<template>
    <div class="live_show_fixrecord_pc_1">
        <div class="container">
            <div class="row">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <div class="learningtool-title">
                        <span class="sp1">直播预告</span>
                    </div>
                </div>
            </div>
            <div class="row row-livefixrecord-part">
                <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12" v-for="(item,index) in Livelist" :key="index">
                    <!--循环-->
                    <div class="livefixrecord-part">
                        <div class="sp1">
                            <span class="spp1"><a @click="licdetail(item.lylId)">{{item.lylName}}</a></span>
                            <span class="spp2"><i>{{item.lylStartDate  |formatDate}}</i>
                                <!-- | <a href="">开启提醒</a> -->
                   </span>
                        </div>
                        <div class="sp2 clearfix">
                            <span class="spp1"><img :src="item.lylPhoto" alt=""></span>
                            <span class="spp2">
                     <p class="p1">{{item.lylAnchorNickname}}</p>
                     <p class="p2">{{item.lylInfo}}</p>
                  </span>
                        </div>
                    </div>
                </div>

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

<script>
    import {httpPost} from '../../../src/utils/utils';
    import formMixin from '../../../src/mixins/formMixin';
    import lenye_base from "lenye_base";
    import $ from 'fy-kit';

    export default {
        filters: {
            formatDate: function (value) {
                if (value == '' || value == 'undefined') {
                    return '';
                }
                var datavalue = value.replace(/\-/g, '/');
                let date = new Date(datavalue);
                let y = date.getFullYear();
                let MM = date.getMonth() + 1;
                MM = MM < 10 ? ('0' + MM) : MM;
                let d = date.getDate();
                d = d < 10 ? ('0' + d) : d;
                let h = date.getHours();
                h = h < 10 ? ('0' + h) : h;
                let m = date.getMinutes();
                m = m < 10 ? ('0' + m) : m;
                // let s = date.getSeconds();
                // s = s < 10 ? ('0' + s) : s;
                return y + '年' + MM + '月' + d + '日 ' + h + ":" + m;
            },
            getNowTime: function(value) {
                var secondTime = parseInt(value); // 秒
                var minuteTime = 0 // 分
                var hourTime = 0 // 小时
                var dayTime = 0 // 天
                var result = ''
                if (value < 60) {
                    result = secondTime + '秒'
                } else {
                    if (secondTime >= 60) { // 如果秒数大于60，将秒数转换成整数
                        // 获取分钟，除以60取整数，得到整数分钟
                        minuteTime = parseInt(secondTime / 60)
                        // 获取秒数，秒数取佘，得到整数秒数
                        secondTime = parseInt(secondTime % 60)
                        // 如果分钟大于60，将分钟转换成小时
                        if (minuteTime >= 60) {
                            // 获取小时，获取分钟除以60，得到整数小时
                            hourTime = parseInt(minuteTime / 60)
                            // 获取小时后取佘的分，获取分钟除以60取佘的分
                            minuteTime = parseInt(minuteTime % 60)
                            if (hourTime >= 24) {
                                // 获取天数， 获取小时除以24，得到整数天
                                dayTime = parseInt(hourTime / 24)
                                // 获取小时后取余小时，获取分钟除以24取余的分；
                                hourTime = parseInt(hourTime % 24)
                            }
                        }
                    }
                    if (secondTime > 0) {
                        secondTime = parseInt(secondTime) >= 10 ? secondTime : secondTime
                        result = '' + secondTime + '秒'
                    }
                    if (minuteTime > 0) {
                        minuteTime = parseInt(minuteTime) >= 10 ? minuteTime : minuteTime;
                        result = '' + minuteTime + '分钟' + result
                    }
                    if (hourTime > 0) {
                        result = '' + parseInt(hourTime) + '小时' + result
                    }
                    if (dayTime > 0) {
                        result = '' + parseInt(dayTime) + '天' + result
                    }
                }
                return result
            }
        },
        name: 'ElLiveShowFixrecordPc1',
        //  mixins: [formMixin],
        data() {
            return {
                Livelist: []
            }
        },
        mounted() {
            this.getLiveList()
        },
        filters: {
            format(val) {
                return $.date.moment(val).format('YYYY-MM-DD');
            }
        },
        methods: {

            getLiveList() {

                const that = this;
                httpPost(
                    lenye_base.base_data.getapiUrl() +
                    "/learnyeai-live-service/common/lylLive/queryUsablePage.do",
                    lenye_base.base_data.getformatting({
                        // sites: lenye_base.site_data.getsiteData().siteId,
                        lylLiveStatus:0,
                        sorts: "createDate=0",
                        rows: 8,
                    }),
                    function (data) {
                        that.Livelist = data.data;
                        console.log(data.data)
                    }
                );
            },
            licdetail(id){
                window.open('/livedetail?id='+id)
            }
        }

    };
</script>
