<template>
    <div class="message">
        <div class="inner">

            <div class="bigTitle" v-if="headlinelist">
                <div class="inner" v-for="(item, index) in headlinelist" :key="index">
                    <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/head/mainTitleicon.png" alt="" class="left">
                    <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                        :target="item.islink == 1 ? '_blank' : '_self'">
                        <h1 class="left">{{ item.title }}</h1>
                    </NuxtLink>
                </div>
            </div>

            <HomeBigTitleList :headlinelist1="headlinelist1" v-if="headlinelist1"></HomeBigTitleList>
            <div class="messageLeft">
                <HomeBigSwiper></HomeBigSwiper>
            </div>
            <div class="messageRight" v-if="hotNewsList">
                <div class="hotTop">
                    <h3>今日热点</h3>
                    <ul>
                        <li v-for="(item, index) in hotNewsList" :key="index">
                            <strong>{{ index + 1 }}</strong>
                            <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                                :target="item.islink == 1 ? '_blank' : '_self'">
                                {{ item.title }}
                            </NuxtLink>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
//0.加载必备依赖 start ---------------------------------------->
import { NuxtLink } from "#components";
import { ref, onMounted } from "vue"
const nuxtApp = useNuxtApp();
const axios = nuxtApp.$axios;

const getLinkPathDetail = (item) => {
    if (item.islink == 1) {
        return `${item.linkurl}`;
    } else {
        return `/${item.pinyin}/${item.id}.html`;
    }
}
//0.加载必备依赖 end ---------------------------------------->

//1.获得板块数据 start ---------------------------------------->
//大标题
const headlinelist = ref([])
//大标题下面的二级内容
const headlinelist1 = ref([])

async function getModelData1() {
    const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
        method: 'GET',
        query: {
            'imgnum':0,
            'textnum': 3,
            'level': 1,
            'placeid': 0,
            'id': ''
        },
    });
    if (mkdata.code == 200) {
        for(let index in mkdata.data.text){
            if(index<1){
                headlinelist.value.push(mkdata.data.text[index])
            }else{
                headlinelist1.value.push(mkdata.data.text[index])
            }
        }

    } else {
        console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
        console.log("错误位置：设置大标题")
        console.log("后端错误反馈：", mkdata.message)
        console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
    }
}
getModelData1()

const hotNewsList = ref("")
async function getModelData3() {
    const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
        method: 'GET',
        query: {
            'imgnum':0,
            'textnum': 8,
            'level': 6,
            'placeid': 0,
            'id': ''
        },
    });
    if (mkdata.code == 200) {
        hotNewsList.value = mkdata.data.text;
    } else {
    
        // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
        // console.log("错误位置：获取首页今日热点")
        // console.log("后端错误反馈：", mkdata.message)
        // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
    }
}
getModelData3()
//1.获得板块数据 end ---------------------------------------->
</script>

<style lang="less" scoped>
// 大标题
.bigTitle {
    width: 100%;
    height: 50px;
    margin-top: 20px;

    img {
        width: 57px;
        height: 52px;
        margin: 6px 17px 9px 97px;
        vertical-align: middle;
    }

    h1 {
        width: 960px;
        height: 70px;
        font-family: PingFang SC, PingFang SC;
        font-weight: 600;
        font-size: 30px;
        // font-size: 38px;
        //margin-bottom: 25px;
        white-space: nowrap;
        /* 防止文本换行 */
        overflow: hidden;
        /* 隐藏溢出的内容 */
        text-overflow: ellipsis;
        color: #49A769;
        line-height: 59px;
        text-align: left;
        font-style: normal;
        text-transform: none;
    }
}

// 资讯
.message {
    width: 100%;
    height: 520px;

    .messageLeft,
    .messageRight {
        float: left;
    }

    // 左侧
    .messageLeft {
        width: 720px;
        height: 440px;

        // 轮播图
        >img {
            width: 790px;
            height: 440px;
        }

        // 轮播图下小图列表
        .smallList {
            width: 790px;
            height: 140px;
            margin-top: 16px;


            >li {
                width: 250px;
                height: 140px;
                float: left;
                padding-right: 20px;
                position: relative;
                // background-color: #f5f5f5;

                img {
                    width: 250px;
                    height: 140px;
                }

                p {
                    position: absolute;
                    bottom: 0;
                    left: 0;
                    width: 250px;
                    height: 30px;
                    white-space: nowrap;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    line-height: 30px;
                    padding-left: 4px;
                    box-sizing: border-box;
                    font-family: PingFang SC, PingFang SC;
                    font-weight: 500;
                    font-size: 16px;
                    color: #FFFFFF;
                    text-align: left;
                    font-style: normal;
                    text-transform: none;
                    background: rgba(0, 0, 0, 0.5);
                    border-radius: 0px 0px 2px 2px;
                }
            }

            >li:nth-child(3) {
                padding-right: 0px;
            }
        }
    }

    // 右侧
    .messageRight {
        width: 450px;
        height: 405px;
        margin-left: 30px;

        .hotTop,
        .suggest {
            width: 450px;
            height: 283px;

            >h3 {
                height: 40px;
                line-height: 40px;
                font-family: Source Han Sans, Source Han Sans;
                font-weight: bold;
                font-size: 24px;
                color: #000000;
                line-height: 28px;
                text-align: left;
                font-style: normal;
                text-transform: none;
                border-bottom: 1px solid #139602;

                >span {
                    float: right;
                    width: 56px;
                    height: 20px;
                    line-height: 24px;
                    font-family: PingFang SC, PingFang SC;
                    font-weight: 400;
                    font-size: 14px;
                    color: #999999;
                    font-style: normal;
                    text-transform: none;
                }
            }

            ul {
                >li {
                    height: 25px;
                    padding-top: 20px;

                    >strong {
                        display: inline-block;
                        width: 24px;
                        height: 24px;
                        line-height: 24px;
                        background-color: #cecece;
                        padding-left: 6px;
                        box-sizing: border-box;
                        font-family: Source Han Sans, Source Han Sans;
                        font-weight: 500;
                        font-size: 18px;
                        color: #FFFFFF;
                        font-style: normal;
                        text-transform: none;
                        vertical-align: -2px;
                    }

                    &:nth-child(1)>strong {
                        background-color: #00C524;
                    }

                    &:nth-child(2)>strong {
                        background-color: #FFDF27;
                    }

                    &:nth-child(3)>strong {
                        background-color: #F3C57F;
                    }

                    >em {
                        display: inline-block;
                        width: 6px;
                        height: 6px;
                        border-radius: 10px;
                        border: 2px solid #8CBA86;
                        vertical-align: -1px;
                    }

                    >a,
                    >span {
                        display: inline-block;
                        width: 416px;
                        height: 25px;
                        font-family: PingFang SC, PingFang SC;
                        font-weight: 500;
                        font-size: 18px;
                        color: #333333;
                        line-height: 21px;
                        text-align: left;
                        font-style: normal;
                        text-transform: none;
                        padding-left: 9px;
                        white-space: nowrap;
                        overflow: hidden;
                        text-overflow: ellipsis;
                        vertical-align: middle;
                    }

                    >a:hover,
                    >span:hover {
                        color: #139609;
                    }

                }
            }
        }

        .hotTop {
            width: 450px;
        }

        .suggest {
            margin-top: 32px;
        }
    }
}
</style>

<style lang="less" scoped>

    

    @media screen and (max-width:800px){/*ipad_phone*/

        .bigTitle{height:auto;overflow:hidden;  line-height: 50px; display:block;margin-top:0px;}        
        .bigTitle .inner{height:auto;overflow:hidden;text-align:center;display:flex;align-items: center;
            justify-content: center;}

        .bigTitle img{margin: 10px 7px 9px 0px;float:none; width:30px;height:auto;}


        .bigTitle a{    display: inline-flex; /* 改为弹性布局 */
            align-items: center; /* 垂直居中 */
            justify-content: center; /* 水平居中 */
            text-align: center;
            max-height: 55px;
            overflow: hidden;
        
        }

        .bigTitle h1{
             display: inline-block;
            float: none;
            width: auto;
            line-height: 25px; /* 移除固定行高 */
             
             height: 25px;
             
            font-size: 22px;text-align:center;
             
            margin: auto 0; /* 自动外边距辅助居中 */

             

            }

         .message{overflow:hidden;height:auto;}        
         .message .messageLeft {width:100%;height:auto;}        
         .message .swiper {width:100%;height:auto;margin-bottom:12px;}        
          
         .message .messageRight{margin:0px auto;width:100%;height:auto;}


          
        .message .messageRight .hotTop{width:100%;}
        .message .messageRight .hotTop ul{height:175px;}
        .message .messageRight .hotTop ul > li > a{
             width:90%;   
             word-break: keep-all; white-space: nowrap;overflow:hidden;text-overflow:ellipsis; 
        }


        .message .messageRight .hotTop ul > li{display:none;}
        .message .messageRight .hotTop ul > li:nth-of-type(-n+5){display:block;padding-top:10px;}
        .message .messageRight .hotTop ul > li a{font-size:16px; line-height:25px;}

        .message .messageRight .hotTop{height:auto;}
        .message .messageRight .hotTop > h3{font-size:18px;height:auto;line-height:40px;}
        

        .message .messageRight .hotTop ul > li > strong{vertical-align:middle}

    }
 
</style>



    





