<template>
  <!-- PC端布局 -->
  <div class="flex justify-between w-full h-full">

     
     <!-- 右边内容栏 -->
     <div class="rightcon" id="homeid" @scroll="hmScroll">
        <div class="flex top_search ">
            <div style="width: 572px;height: 69px;margin-left: 415px;">
                <img :src="`/img/index/dlogo.png`" alt="" style="width: 100%;height: 100%;object-fit: cover;">
            </div>
            <div class="inputform">
                <input v-model="inputSearch" class="contactInput w-full md:w-[337px]"
							type="text" placeholder="请输入搜索关键字" />
                <div class="search_rinput" @click="toSearch">
                    <img src="/img/index/hmsearch.png" alt="">
                </div>
            </div>
        </div>

        <div class="flex h-auto home_con"> 
            <div class="fly">
                <!-- <div class="fly_text">
                    <span>逐梦<b style="color: #FFFFFF;">新声</b></span>
                    <img :src="`/img/index/fly.png`" alt=""></img>
                </div> -->
                <div class="re_box" >
                    <div class="swiper" style="border-radius: 12px 0  0 12px;">
                        <swiper class="w-[600px] h-[418px]" @swiper="onSwiperImgs" v-bind="swiperOptionsimgs">
                            <swiper-slide v-for="(item,index) in xsImg" :key="index" @click="openUrl(item.url)">
                                <div class="img_tits">{{ item.title }}</div>
                                <img :src="item.image" style="width: 100%;height: 100%;object-fit: cover;">
                            </swiper-slide>
                        </swiper>
                        <div class="swiper-pagination"></div>
                    </div>
                </div>
            </div>
            <div class="fly1">
                <div class="re_box" style="border-width: 1px;border-style: solid; border-image: linear-gradient(270deg, #CC131A, #FFFFFF) 10 10;border-radius:0;">
                    <div class="flex justify-between align-center w-full ">
                        <img class="re_top_img" :src="`/img/index/wzjx.png`"></img>
                        <div class="pr-[20px] more_j" @click="toMore">
                            <span>查看更多</span>
                            <img src="/img/index/more_j.png" alt="" style="width: 8px;height: 13px;margin-left: 10px;"></img>
                        </div>
                    </div>
                    <div class="re_top_img_line"></div>
                    <div class="re_box_item" v-for="(item,index) in zmList" :key="index" style="margin-top: 10px;" @click="openUrl(item.id)">
                        <div class="re_title">
                            <div class="flex align-center">
                                <div class="dian"></div>
                                <span class="one-line-ellipsis" style="width:400px;">{{ item.title }}</span>
                            </div>
                            <span class="one-line-ellipsis" style="color: #999999;">{{ item.release_time_text.slice(5,10) }}</span>
                        </div>
                        
                        <!-- <div class="slices_rol"></div> -->
                    </div>
                </div>
            </div>
        </div>

        <div class="h-auto home_con1"> 
             <img :src="`/img/index/gwybst.png`" style="margin: 0 auto;" alt=""></img>
             <div class="flex flex-wrap" style="margin-top: 30px;">
                <div class="bstbg" v-for="item,i in bstList" :key="i" @click="openUrl(item.id)">
                    <div class="bst_con" >
                        <img :src="`/img/index/bst${i+1}.png`" alt="" style="width: 34px;height: 34px;margin-top: 25px;margin-bottom: 15px;">
                        <div class="bsttitle">
                            {{ item.title }}
                        </div>
                    </div>
                </div>
             </div>
        </div>
        <div class="flex h-auto home_con2">
            <div class="fly1s">
                <div class="re_boxs">
                    <div class="flex justify-between align-center w-full ">
                        <div class="flex align-center justify-start">
                            <img class="re_top_img" :src="`/img/index/ptgg.png`"></img>
                            <img class="re_top_img" style="padding: 20px 0;" :src="`/img/index/hlines.png`"></img>
                        </div>
                        <div class="pr-[20px] more_j" @click="toMore">
                            <span>查看更多</span>
                            <img src="/img/index/more_j.png" alt="" style="width: 8px;height: 13px;margin-left: 10px;"></img>
                        </div>
                    </div>
                    <!-- <div class="re_top_img_line"></div> -->
                    <div class="re_box_item" v-for="(item,index) in ptList" :key="index" style="margin-top: 10px;" @click="openUrl(item.id)">
                        <div class="re_title">
                            <div class="flex align-center">
                                <div class="dian"></div>
                                <span class="one-line-ellipsis" style="width:400px;">{{ item.title }}</span>
                            </div>
                            <span class="one-line-ellipsis" style="color: #999999;">{{ item.release_time_text.slice(5,10) }}</span>
                        </div>
                        
                        <!-- <div class="slices_rol"></div> -->
                    </div>
                </div>
            </div>
            <div class="fly1s">
                <div class="re_boxs">
                    <div class="flex justify-between align-center w-full ">
                        <div class="flex align-center justify-start">
                            <img class="re_top_img" :src="`/img/index/jcdt.png`"></img>
                            <img class="re_top_img" style="padding: 20px 0;" :src="`/img/index/hlines.png`"></img>
                        </div>
                        <div class="pr-[20px] more_j" @click="toMore">
                            <span>查看更多</span>
                            <img src="/img/index/more_j.png" alt="" style="width: 8px;height: 13px;margin-left: 10px;"></img>
                        </div>
                    </div>
                    <!-- <div class="re_top_img_line"></div> -->
                    <div class="re_box_item" v-for="(item,index) in jcList" :key="index" style="margin-top: 10px;" @click="openUrl(item.id)">
                        <div class="re_title">
                            <div class="flex align-center">
                                <div class="dian"></div>
                                <span class="one-line-ellipsis" style="width:400px;">{{ item.title }}</span>
                            </div>
                            <span class="one-line-ellipsis" style="color: #999999;">{{ item.release_time_text.slice(5,10) }}</span>
                        </div>
                        
                        <!-- <div class="slices_rol"></div> -->
                    </div>
                </div>
            </div>
            <div class="fly1s">
                <div class="re_boxs">
                    <div class="flex justify-between align-center w-full ">
                        <div class="flex align-center justify-start">
                            <img class="re_top_img" :src="`/img/index/qcly.png`"></img>
                            <img class="re_top_img" style="padding: 20px 0;" :src="`/img/index/hlines.png`"></img>
                        </div>
                        <div class="pr-[20px] more_j" @click="toMore">
                            <span>查看更多</span>
                            <img src="/img/index/more_j.png" alt="" style="width: 8px;height: 13px;margin-left: 10px;"></img>
                        </div>
                    </div>
                    <!-- <div class="re_top_img_line"></div> -->
                    <div class="re_box_item" v-for="(item,index) in qcList" :key="index" style="margin-top: 10px;" @click="openUrl(item.id)">
                        <div class="re_title">
                            <div class="flex align-center">
                                <div class="dian"></div>
                                <span class="one-line-ellipsis" style="width:400px;">{{ item.title }}</span>
                            </div>
                            <span class="one-line-ellipsis" style="color: #999999;">{{ item.release_time_text.slice(5,10) }}</span>
                        </div>
                        
                        <!-- <div class="slices_rol"></div> -->
                    </div>
                </div>
            </div>
            <div class="fly1s">
                <div class="re_boxs">
                    <div class="flex justify-between align-center w-full ">
                        <div class="flex align-center justify-start">
                            <img class="re_top_img" :src="`/img/index/mtjj.png`"></img>
                            <img class="re_top_img" style="padding: 20px 0;" :src="`/img/index/hlines.png`"></img>
                        </div>
                        <div class="pr-[20px] more_j" @click="toMore">
                            <span>查看更多</span>
                            <img src="/img/index/more_j.png" alt="" style="width: 8px;height: 13px;margin-left: 10px;"></img>
                        </div>
                    </div>
                    <!-- <div class="re_top_img_line"></div> -->
                    <div class="re_box_item" v-for="(item,index) in mtList" :key="index" style="margin-top: 10px;" @click="openUrl(item.id)">
                        <div class="re_title">
                            <div class="flex align-center">
                                <div class="dian"></div>
                                <span class="one-line-ellipsis" style="width:400px;">{{ item.title }}</span>
                            </div>
                            <span class="one-line-ellipsis" style="color: #999999;">{{ item.release_time_text.slice(5,10) }}</span>
                        </div>
                        
                        <!-- <div class="slices_rol"></div> -->
                    </div>
                </div>
            </div>
        </div>

        <AppFooter></AppFooter>

        
        <!-- 底部鼠标 -->
        <div style="position: absolute;bottom: 30px;right:30px;">
            <img :src="`/img/index/hmouse.png`" alt="">
        </div>
     </div>
  </div>
</template>

<script lang="ts" setup>
import $api from '@/service/webRequest'
import { defineEmits} from 'vue'
import { Swiper, SwiperSlide } from 'swiper/vue'
import emitter from '@/plugins/emitter'
import 'swiper/css'
import 'swiper/css/autoplay'
import "swiper/css/pagination";
import { Autoplay, Navigation, Pagination, Scrollbar, A11y, EffectCoverflow, EffectFade,Mousewheel } from "swiper/modules";
const inputSearch = ref('');

const xsImg = ref([]);
const listType = ref([]);
const detailId = ref(null);

const emit = defineEmits(['toSwpe'])
const swiperOptionsimgs = {
	autoplay: {
		delay: 5000,
		disableOnInteraction: false,
	},
	direction: 'horizontal',
	slidesPerView: 1,
	speed: 500,
	// effect: 'fade',
	loop: true,
	modules: [Autoplay,Pagination],
	pagination: {
		el:'.swiper-pagination'
	},
}
const hmScroll = () => {
    let home = document.getElementById('homeid');
    console.log(home.scrollTop,home.clientHeight,home.scrollHeight);
    if( home.scrollTop + home.clientHeight >= home.scrollHeight){
        setTimeout(function() {
            emit('toSwpe',2);
        }, 500);
    }
    if (home.scrollTop == 0) {
        setTimeout(function() {
            emit('toSwpe',0);
        }, 500);
    }
}
const toSearch =() => {
    // emit('toSwpe',9);
    // emitter.emit('inputSea', {
    //     keywords:inputSearch.value,
    //     type: 1,
    // });
    window.open(`/search_info?type=1&keywords=${inputSearch.value}`)
}
// 查看更多
const toMore = () => {
    emit('toSwpe',3);
}
const bstList = ref([
    {title:"中国共产主义青年团的性质是什么?",id:5969},
    {title:"中国共产主义青年团的行动指南是什么?",id:5970},
    {title:"为什么说共青团是中国共产党的助手和后备军?",id:5971},
    {title:"中国共产主义青年团在新时代的基本任务是什么?",id:5972},
    {title:"怎样加入中国共产主义青年团?",id:5973},
    {title:"团员必须履行哪些义务?",id:5974},
    {title:"团员享有哪些权利?",id:5975},
    {title:"团旗、团徽和团歌分别是什么?",id:5976}
])

const openUrl = (id: number) => {
	window.open(`/info/${id}?type=1`)
}
//跳转详情
// const gotoDetail = (id: number) => {
//      detailId.value = {
//         id: id,
//         type: '1'
//     };
//     localStorage.setItem('detailId', JSON.stringify(detailId.value));
//     emit('toSwpe',6)
//     emitter.emit('detailId', detailId.value);
// }
let newsSwiper: any = null
const onSwiperImgs = (swiper: any) => {
	newsSwiper = swiper
	// swiper.on('slideChange', () => {
	// 	// 更新当前活动幻灯片索引
		
	// })
}
//文章精选
const zmList = ref([]);

//国务院百事通
const ptList = ref([]);
const jcList = ref([]);
const qcList = ref([]);
const mtList = ref([]);

//新闻分类
const getNewstypeList = async () => {
    let ptggid = null,jcdtid = null,qclyid = null,mtjjid = null;    // 分类id 
	const res = await $api.get('/api/home.news/cate?home=1')
	listType.value = res.data.data.list.map((item: any) => {
        if (item.name == '平台公告') {
            ptggid = item.id;
        }
        if (item.name == '基层动态') {
            jcdtid = item.id;
        }

        if (item.name == '青春洛阳') {
            qclyid = item.id;
        }
        if (item.name == '媒体聚焦') {
            mtjjid = item.id;
        }
    });

    // xsId.value = listType.value[0].id;
    //逐梦新声列表 //万众瞩目列表
	// const ress = await $api.get(`/api/home.news/index?cate_id=${xsId.value}&page=1&limit=4`)
	// xsList.value = ress.data.data.list;
    
    //精选文章
    const ress1 = await $api.get(`/api/home.news/index?page=1&limit=5&fine=1`)
	zmList.value = ress1.data.data.list;

    //平台公告
    const ress2 = await $api.get(`/api/home.news/index?cate_id=${ptggid}&page=1&limit=5`)
	ptList.value = ress2.data.data.list;
    //基层动态
    const ress3 = await $api.get(`/api/home.news/index?cate_id=${jcdtid}&page=1&limit=5`)
	jcList.value = ress3.data.data.list;
    //青春洛阳
    const ress4 = await $api.get(`/api/home.news/index?cate_id=${qclyid}&page=1&limit=5`)
	qcList.value = ress4.data.data.list;
    //媒体聚焦
    const ress5 = await $api.get(`/api/home.news/index?cate_id=${mtjjid}&page=1&limit=5`)
	mtList.value = ress5.data.data.list;
}

//逐梦新声轮播图
const getxsImg = async () => {
	const res = await $api.get('/api/index/images?page=1&limit=3')
	xsImg.value = res.data.data.list;
}

onMounted(() => {
    window.addEventListener('scroll', hmScroll);
    getxsImg();
    getNewstypeList();
})
</script>

<style lang="scss" scoped>
@import '@/assets/index.scss';


/* pc端样式 */

    .swiper{

        .swiper-pagination{
            text-align: right;
            padding-right: 10px;
            bottom: 0;
            height: 38px;
            line-height: 38px;
            --swiper-pagination-color: #FFCD52;/* 两种都可以 */
        }
        .img_tits{
            font-family: Microsoft YaHei UI;
            font-weight: bold;
            font-size: 18px;
            color: #FFFEFE;
            position: absolute;
            bottom: 0;
            left: 0;
            background: rgba(0, 0, 0, 0.44);
            width: 100%;
            height: 38px;
            line-height: 38px;
            padding-left: 10px;
        }
    }
    
  
  
    .rightcon{
        width:100%;
        height:100%;
        background-image: url('/img/index/rightcons.png');
        background-size: 100% 100%;
        overflow-y: auto;
        
    }
    .top_search{
        margin-top: 50px;
        height: 70px;
        justify-content: space-between;
        align-items: center;
    }
    .inputform {
		position: relative;
		width: 340px;
        margin-right: 319px;
	}
    .contactInput {
        width: 337px;
        height: 50px;
        background: #FFFFFF;
        border-radius: 8px;
        border: 1px solid #DEE4E8;
        padding-left: 15px;
    }

    .contactInput::placeholder {
        color: #999999;
    }

    .contactInput:focus {
        outline: none;
    }
    .search_rinput{
        width: 68px;
        height: 50px;
        background: #E6E6E6;
        border-radius: 0px 8px 8px 0px;
        position: absolute;
        top: 0;
        right: 0;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .home_con{
        width: 1200px;
        box-sizing: border-box;
        // margin: 0 auto;
        margin-top: 50px;
        margin-left: 400px;
        .fly_text{
            position: relative;
            width: 305px;
            height: 101px;
            img{
                position: absolute;
                top: 0;
                right: 0;
                width: 305px;
                height: 101px;
            }
            span{
                position: absolute;
                top: 40px;
                left: 100px;
                font-family: Microsoft YaHei UI;
                font-weight: bolder;
                font-size: 36px;
                color: #FFA234;
                z-index: 1;
            }
        }
        .fly{
            width: 600px;
            // padding-left: 80px;
        }
        .fly1{
            width: 600px;
            // margin-left: 30px;
        }
        .re_box{
                width: 100%;
                height: 418px;
                display: flex;
                flex-wrap: wrap;
                justify-content: flex-start;
                align-content: flex-start;
                // gap: 10px;
                background: #FFFFFF;
                position: relative;
                border-radius: 12px 0 0 12px;
                .re_top_img{
                    padding:20px;
                }
                .more_j{
                    font-family: Microsoft YaHei UI;
                    font-weight: 400;
                    font-size: 16px;
                    color: #999999;
                    display: flex;
                    align-items: center;
                    cursor: pointer;
                }
                .re_top_img_line{
                    width: 559px;
                    height: 2px;
                    background: #EEEEEE;
                    margin-left: 20px;
                }
                .re_box_item{
                    width: 100%;
                    padding:15px 20px;
                    box-sizing: border-box;
                    display: flex;
                    justify-content: space-between;
                    align-items: center;
                    .re_title{
                        width: 100%;
                        font-family: Microsoft YaHei;
                        font-weight: 400;
                        font-size: 16px;
                        color: #323232;
                        display: flex;
                        align-items: center;
                        justify-content: space-between;
                        cursor: pointer;
                        .dian{
                            width: 10px;
                            height: 10px;
                            background: #3B90DF;
                            border-radius: 50%;
                            margin-right: 15px;
                        }
                    }
                    // &:hover{
                    //     background-image: url('/img/index/listhmbg.png');
                    //     background-size: 100% 100%;
                    //     cursor: pointer;
                    //     .slices_rol{
                    //         width: 10px;
                    //         height: 88px;
                    //         background: #FAA828;
                    //         position: absolute;
                    //         right: 0;
                    //     }
                    // }
                }
            } 
    }
    .home_con1{
        width: 1200px;
        box-sizing: border-box;
        // margin: 0 auto;
        margin-top: 50px;
        margin-left: 400px;
        
        .bstbg{
            width: 280px;
            height: 150px;
            background-image: url('/img/index/bstbg.png');
            background-size: 100% 100%;
            background-repeat: no-repeat;
            margin-right: 20px;
            margin-bottom: 20px;
            cursor: pointer;
            .bst_con{
                width: 100%;
                display: flex;
                justify-content: center;
                align-items: center;
                flex-direction: column;
                .bsttitle{
                    width: 210px;
                    font-family: Microsoft YaHei UI;
                    font-weight: bold;
                    font-size: 18px;
                    color: #FFFFFF;
                    line-height: 26px;
                    text-align: center;
                }
                &:hover{
                    .bsttitle{
                        color: #FFE7B8;
                    }
                        
                }
            }
        }
    }
    .home_con2{
        width: 1200px;
        box-sizing: border-box;
        // margin: 0 auto;
        // margin-top: 10px;
        margin-left: 400px;
        flex-wrap: wrap;
        .fly1s{
            width: 580px;
            margin-right: 20px;
            margin-bottom: 20px;
        }
        .re_boxs{
                width: 100%;
                height: 406px;
                display: flex;
                flex-wrap: wrap;
                justify-content: flex-start;
                align-content: flex-start;
                // gap: 10px;
                background: #FFFFFF;
                position: relative;
                border-radius: 12px;
                .re_top_img{
                    padding:20px;
                }
                .more_j{
                    font-family: Microsoft YaHei UI;
                    font-weight: 400;
                    font-size: 16px;
                    color: #999999;
                    display: flex;
                    align-items: center;
                    cursor: pointer;
                }
                
                .re_box_item{
                    width: 100%;
                    padding:15px 20px;
                    box-sizing: border-box;
                    display: flex;
                    justify-content: space-between;
                    align-items: center;
                    .re_title{
                        width: 100%;
                        font-family: Microsoft YaHei;
                        font-weight: 400;
                        font-size: 16px;
                        color: #323232;
                        display: flex;
                        align-items: center;
                        justify-content: space-between;
                        cursor: pointer;
                        .dian{
                            width: 10px;
                            height: 10px;
                            background: #3B90DF;
                            border-radius: 50%;
                            margin-right: 15px;
                        }
                    }
                    // &:hover{
                    //     background-image: url('/img/index/listhmbg.png');
                    //     background-size: 100% 100%;
                    //     cursor: pointer;
                    //     .slices_rol{
                    //         width: 10px;
                    //         height: 88px;
                    //         background: #FAA828;
                    //         position: absolute;
                    //         right: 0;
                    //     }
                    // }
                }
            } 
    }
</style>
