<template>
    <div>
        <!-- 头部 -->
        <page-header></page-header>
        <div class="background">
        </div>
        <div class="container">
            <div class="top">
                <ul class="com">
                    <li class="active">新闻中心</li>
                </ul>
            </div>
            <div class="content">
                <div class="con" v-for="(item,index) in news">
                    <!-- {{item.id}} -->
                    <div class="new-div" @click=goinfo(item.id) @mouseenter='enter($event, index)' @mouseleave='leave($event, index)'>
                        <div class="left"><img :src=item.thumbnail alt=""></div>
                        <div class="mid">
                            <h1>{{title}}</h1>
                            <p>{{item.post_excerpt}}</p>
                        </div>                        
                        <div class="right">
                            <p>{{time}}</p>
                            <p class="fa fa-long-arrow-right"></p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <page-footer></page-footer>
    </div>
</template>
<script>
    // 公用

    import share from "./share.js";
    export default {
        name: "news",
        // 混入
        mixins: [share],
        data() {
            return {
                msg: "news",
                news:[],
                day:'',
                time:'',
                title:''
              
            };
        },
        // methods: {
        
        // }
        methods: {
            enter(event, index) {
                $('.new-div').eq(index).addClass('n-active');

            },
            leave() {
                $('.new-div').removeClass('n-active');
            }, 
            getLiveList() {
                this.$http.post('/api/postlist?category_id=1')
                    .then((res) => {
                        this.news=res.body.data 
                        console.log(this.news)
                        this.news.forEach(e => {
                            this.day=e.published_time
                            this.title=e.post_title.replace(/&quot;/g,'"')
                            this.day.substring(this.day.length,this.day.length-5)
                            this.time=this.day.substring(this.day.length-9,this.day.length-14)
                        });

                    })
                    .catch((err) => {
                        console.log(err)
                    })
                
            },
            goinfo(id){
                this.$router.push('/xmsig/newinfo?id=' + id)
            }

        },
        created () {
           this.getLiveList()
        }
    }

</script>
<style scoped>
    * {
        box-sizing: border-box;
    }
    /*背景图  */

    .background {
        min-width: 1200px;
        width: 100%;
        height: 300px;
        background-size: 100% 100%;
        background-image: url('../assets/images/new01.jpg');
    }

    .container {
        width: 1200px;
        margin: 0 auto;
        padding: 0;
        margin-bottom: 200px;
    }

    .content {
        width: 1200px;
        margin: 0 auto;
        margin-top: 185px;
    }

    .content .con .new-div {
        font-size: 12px;
        display: flex;
        border-top: 1px solid rgba(0, 0, 0, 0);
        border-left: 1px solid rgba(0, 0, 0, 0);
        border-right: 1px solid rgba(0, 0, 0, 0);
        border-bottom: 1px solid #aaa;
    }

    .com {
        width: 240px;
        height: 60px;
        margin: 0 auto;
        margin-top: -30px;
        color: #fff;
        background-color: #fff;
        /* border: 1px solid red; */
        box-shadow: 0px 4px 5px #ddd;
    }

    .com li {
        width: 100%;
        text-align: center;
        line-height:60px;
        font-size: 22px;
    }

    .active {
        background-color: #B5A14E;
    }

    p {
        color: #aaa;
    }

    .left {
        width: 342px;
    }

    .left img {
        width: 342px;
        height: 144px;
        margin-top: 30px;
        margin-bottom: 30px;
    }

    .mid {
        width: 578px;
        margin-left: 50px;
    }

    .mid h1 {
        margin-top: 66px;
        margin-bottom: 30px;
        font-weight: bold;
        color: #666;
    }

    .right {
        margin-left: 133px;
        width: 150px;
        text-align: center;
    }

    .right p:nth-child(1){
        margin-top: 50px;
        font-size: 16px;
        margin-bottom: 55px;
    }
    .fa {
        margin-left: 0.2vw;
        font-size: 1.5vw;
        border-left: 1px solid #aaa;
        padding-left: 1.2vw;
    }

    .mid p {
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    .n-active {
        box-shadow: 0 5px 5px rgba(0, 0, 0, 0.1), 0 5px 5px rgba(0, 0, 0, 0.1), 0 5px 5px rgba(0, 0, 0, 0.1), 0 5px 5px rgba(0, 0, 0, 0.1);
        padding-left: 20px;
        border: none;
        transform: translate(0, -2px);
    }

  
</style>