<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>
</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([])

async function getPageData() {
    const mkdata =  await requestDataPromise('/web/getWebsiteArticlett', {
        method: 'GET',
        query: {
            'pageSize':6,
            'level': 4,
            'id': 0,
        },
    });
    if(mkdata.code == 200){
        hotNewsListdata1.value = mkdata.data.slice(0, 2);
        hotNewsListdata2.value = mkdata.data.slice(2, 6);
    }else{
        console.log("错误位置：获取最新资讯")
    }
}
getPageData();
</script>

<style lang="less" scoped>
.title {
    width: 100px;
    font-family: Microsoft YaHei, Microsoft YaHei;
    font-weight: bold;
    font-size: 22px;
    color: #255590;
    margin: 10px 0 20px;
    position: relative;
    border-left: #255590 5px solid;
    padding-left: 15px;

}

.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: 72px;
            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: #255590;
        }
    }
}

// 文字
.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;
        }
        em{
            display: inline-block;
            width: 8px;
            height: 8px;
            background-color: #D9D9D9 ;
            border-radius: 50%;
            vertical-align: middle;
            margin-right: 10px;
        }
    }

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

}
</style>