<template>
    <div class="hotNews">
        <div class="hotNews_title">
            热点精选
        </div>
        <ul class="hotNews_message">
            <li class="hotNews_messageList" v-for="(item, index) in hotNewsList" :key="index">
                <span class="number">{{ index + 1 }}</span>
                <NuxtLink
                    :href="getLinkPathDetail(item)"
                    :title="item.title"
                    :key="item.id"
                    :target="item.islink == 1 ? '_blank' : '_self'"
                >
                    <span class="hotlist_text">{{ item.title }}</span>
                </NuxtLink>
            </li>
        </ul>
    </div>
</template>

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

const hotNewsList = ref([])
async function getPageData() {
    const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
        method: 'GET',
        query: {
            'imgnum':0,
            'textnum':8,
            'level': 5,
            '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 ---------->")
    }
}
getPageData();
</script>


<style lang="less" scoped>
.hotNews {
    width: 270px;
    margin-top: 20px;
    height: 550px;

    //标题
    .hotNews_title {
        width: 100px;
        font-family: Microsoft YaHei, Microsoft YaHei;
        font-weight: bold;
        margin: 30px 0 10px;
        font-size: 20px;
        color: #004564;
        // border-left: #004564 5px solid;
        // padding-left: 17px;
    }

    //新闻列表
    .hotNews_message {
        width: 270px;

        .hotNews_messageList {
            width: 270px;
            height: 64px;
            line-height: 64px;
            border-bottom: 1px solid #E4E4E4;
            font-weight: 400;
            font-size: 18px;
            color: #333333;
            ;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;

            a {
                color: #333333;
            }

            .number {
                color: #999999;
                margin-right: 13px;
                font-family: DingTalk JinBuTi, DingTalk JinBuTi;
            }
        }

        .hotNews_messageList:nth-child(1) {
            .number {
                color: #004564;
            }
        }

        .hotNews_messageList:nth-child(2) {
            .number {
                color: #004564;
            }
        }

        .hotNews_messageList:nth-child(3) {
            .number {
                color: #004564;
            }
        }

        .hotNews_messageList:hover {
            color: #004564;

            a {
                color: #004564;
            }
        }
    }
}
</style>