<!-- 资讯 -->
<template>
    <div class="message">
        <div class="inner">

            <!-- 大标题 -->
            <div class="bigTitle">
                <div class="inner" v-for="(item, index) in headlinelist" :key="index">
                    <img src="../../static/head/mainTitleicon.png" alt="" class="left">
                    <!-- <h1 class="left">{{ item.title }}</h1> -->
                    <!-- <a>{{ item.title }}</a> -->
                    <NuxtLink :to="item.linkurl" target="_blank" v-if="item.islink==1">
                        <h1 class="left">{{ item.title }}</h1>
                    </NuxtLink>
                    <NuxtLink :to="`/newsDetail/${item.id}`" target="_blank" v-if="item.islink==0">
                        <h1 class="left">{{ item.title }}</h1>
                    </NuxtLink>
                </div>
            </div>

            <!-- 大标题下的列表 -->
            <HomeBigTitleList></HomeBigTitleList>


            <div class="messageLeft">
                <!-- 轮播图 -->
                <HomeBigSwiper></HomeBigSwiper>

                <!-- 小图列表 -->
                <!-- <ul class="smallList">
                    <li v-for="(item, index) in recommendImage" :key="index">
                        <NuxtLink :to="`/newsDetail/${item.id}`" target="_blank">
                            <img :src="item.imgurl" alt="">
                            <p>{{ item.title }}</p>
                        </NuxtLink>
                    </li>
                </ul> -->
            </div>

            <div class="messageRight">
                <!-- 列表 -->
                <div class="hotTop">
                    <h3>
                        今日热点
                        <!-- <span>查看更多</span> -->
                    </h3>
                    <ul>
                        <li v-for="(item, index) in hotNewsList" :key="index">
                            <strong>{{ index + 1 }}</strong>
                            <NuxtLink :to="item.linkurl" target="_blank" v-if="item.islink==1">{{ item.title }}</NuxtLink>
                            <NuxtLink :to="`/newsDetail/${item.id}`" target="_blank" v-if="item.islink==0">{{ item.title }}</NuxtLink>
                        </li>
                    </ul>
                </div>
                <!-- <div class="suggest">
                    <h3>
                        资讯推荐
                        
                    </h3>
                    <ul>
                        <li v-for="(item, index) in messageList" :key="index">
                            <em></em>
                            <NuxtLink :to="`/newsDetail/${item.id}`" target="_blank">{{ item.title }}</NuxtLink>
                        </li>
                    </ul>
                </div> -->
            </div>
        </div>
    </div>
</template>

<script setup>
import { NuxtLink } from "#components";
import { ref, onMounted } from "vue"
const nuxtApp = useNuxtApp();
const axios = nuxtApp.$axios;

//大头条
const headlinelist = useState("headlinelist", () => "");
const headline = async () => {
    try {
        const response = await axios.get(`/web/getWebsiteArticlett?pageSize=${1}&level=${1}&placeid=${0}`);
        console.log('大标题', response.data);
        headlinelist.value = response.data;
    } catch (error) {
        console.error(error);
    }
}

//获取推荐图
const recommendImage = useState("recommendImage", () => "");
const recommendList = async () => {
    try {
        const response = await axios.get(`/web/getWebsiteArticlett?pageSize=${3}&level=${3}&placeid=${0}`);
        // console.log(response.data);
        recommendImage.value = response.data;
    } catch (error) {
        console.error(error);
    }
}


//热点资讯
const hotNewsList = useState("hotNews", () => "");
const hotNews = async () => {
    try {
        const response = await axios.get(`/web/getWebsiteArticlett?pageSize=${8}&level=${4}&placeid=${0}`);
        console.log('hotNewsList', response.data);
        hotNewsList.value = response.data;
    } catch (error) {
        console.error(error);
    }
}

//资讯推荐
const messageList = useState("messagelist", () => "");
const message = async () => {
    try {
        const response = await axios.get(`/web/getWebsiteArticlett?pageSize=${6}&level=${5}&placeid=${0}`);
        // console.log(response.data);
        messageList.value = response.data;
    } catch (error) {
        console.error(error);
    }
}



onMounted(() => {
    // 头条
    headline()

    //推荐图
    recommendList()

    // 热点资讯
    hotNews()

    //资讯推荐
    message()
})

</script>

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

    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: 570px;

    .messageLeft,
    .messageRight {
        float: left;
    }

    // 左侧
    .messageLeft {

        // 轮播图
        >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>