<template>
    <div class="hotList">
        <h1 class="title">
            最新资讯
        </h1>
        <div class="hotList_photo_text">
            <div class="hotList_photo_text1" v-for="(item, index) in hotNewsListdata1" :key="index">
                <NuxtLink
                    :href="getLinkPathDetail(item)"
                    :title="item.title"
                    :key="item.id"
                    :target="item.islink == 1 ? '_blank' : '_self'"
                >
                    <img :src="item.imgurl" :alt="item.title">
                    <span class="hotlist_text">{{ item.title }}</span>
                </NuxtLink>
            </div>
        </div>
        <ul class="message">
            <li class="messageList" v-for="(item, index) in hotNewsListdata2" :key="index">
                <em></em>
                <NuxtLink
                    :href="getLinkPathDetail(item)"
                    :title="item.title"
                    :key="item.id"
                    :target="item.islink == 1 ? '_blank' : '_self'"
                >
                    {{ item.title }}
                </NuxtLink>
            </li>
        </ul>
        <div class="hotList_photo_text">
            <div class="hotList_photo_text1"  v-for="(item, index) in hotNewsListdata3" :key="index">
                <NuxtLink
                    :href="getLinkPathDetail(item)"
                    :title="item.title"
                    :key="item.id"
                    :target="item.islink == 1 ? '_blank' : '_self'"
                >
                    <img :src="item.imgurl" :alt="item.title">
                    <span class="hotlist_text">{{ item.title }}</span>
                </NuxtLink>
            </div>
        </div>
        <ul class="message">
            <li class="messageList" v-for="(item, index) in hotNewsListdata4" :key="index">
                <em></em>
                <NuxtLink
                    :href="getLinkPathDetail(item)"
                    :title="item.title"
                    :key="item.id"
                    :target="item.islink == 1 ? '_blank' : '_self'"
                >
                    {{ item.title }}
                </NuxtLink>
            </li>
        </ul>
    </div>
</template>

<script setup>
const getLinkPathDetail = (item) => {
    if (item.islink == 1) {
        return `${item.linkurl}`;
    } else {
        //return `/${item.aLIas_pinyin}/${item.id}`;
        //return `/newsDetail/${item.id}`
        return `/${item.pinyin}/${item.id}.html`;
    }
}

const hotNewsListdata1 = ref([])
const hotNewsListdata2 = ref([])
const hotNewsListdata3 = ref([])
const hotNewsListdata4 = ref([])

async function getPageData() {
    const mkdata =  await requestDataPromise('/web/getWebsiteArticlett', {
        method: 'GET',
        query: {
            'imgnum': 4,
            'textnum': 4,
            'level': 4,
            'id': 0,
            'placeid': 0,
        },
    });
    if(mkdata.code == 200){
        hotNewsListdata1.value = mkdata.data.img.slice(0, 2);
        hotNewsListdata3.value = mkdata.data.img.slice(2, 4);
        hotNewsListdata2.value = mkdata.data.text.slice(0, 2);
        hotNewsListdata4.value = mkdata.data.text.slice(2, 4);
    }else{
        console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
        console.log("错误位置：获取最新资讯")
        console.log("后端错误反馈：",mkdata.message)
        console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
    }
}
getPageData();
</script>

<style lang="less" scoped>
//标题
.hotList {
    width: 270px;
    height: 618px;
    border-top: 2px solid #dd7d18;

    .title {
        width: 100px;
        height: 40px;
        line-height: 40px;
        font-family: Microsoft YaHei, Microsoft YaHei;
        font-weight: bold;
        margin: 10px 0;
        font-size: 20px;
        color: #333333;
        position: relative;
    }
}
//今日热点
// 图文
.hotList_photo_text {
    width: 270px;

    .hotList_photo_text1 {
        display: flex;

        img {
            float: left;
            width: 120px;
            height: 80px;
            margin-right: 10px;
        }

        .hotlist_text {
            float: left;
            width: 126px;
            height: 74px;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 3;
            overflow: hidden;
            text-overflow: ellipsis;
            word-break: break-all;
            font-weight: 400;
            font-size: 18px;
            color: #333333;
            padding-top: 3px;
        }
    }
    .hotList_photo_text1:first-child {
        margin-bottom: 20px;
    }
    .hotList_photo_text1:hover{
        .hotlist_text{
            color: #dd7d18;
        }
    }
}
// 文字
.message {
    width: 270px;
    margin-top: 20px;

    .messageList {
        width: 270px;
        white-space: nowrap;
        /* 禁止换行 */
        overflow: hidden;
        /* 隐藏超出部分 */
        text-overflow: ellipsis;
        /* 超出部分显示省略号 */
        font-family: Microsoft YaHei, Microsoft YaHei;
        font-weight: 400;
        font-size: 18px;
        color: #333333;
        margin-bottom: 20px;

        a {
            color: #333333;
        }
    }

    >li:hover>a {
        color: #dd7d18;
    }

}
</style>