<template>
    <!-- 样式1 -->
    <div class="BannerListBox BannerListBoxStyle1" v-if="componentStyle == 1">
        <div class="listNewsTitle">
            <span>头条新闻</span>
        </div>
        <div class="listNewsText" v-for="item in component_News">
            <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                :target="item.islink == 1 ? '_blank' : '_self'">
                <span class="text">{{ item.title }}</span>
                <span class="time">{{ item.updated_at }}</span>
            </NuxtLink>
        </div>
    </div>
    <!-- 样式2 -->
    <div class="BannerListBox BannerListBoxStyle2" v-if="componentStyle == 2">
        <div class="listNewsTitle">
            <span>新闻头条</span>
        </div>
        <p class="listNewsText_img_li">
            <NuxtLink :href="getLinkPathDetail(component_News1[0])" :title="component_News1[0].title"
                :target="component_News1[0].islink == 1 ? '_blank' : '_self'">
                <span class="listNewsText_li_img_box">
                    <img :src="component_News1[0].imgurl">
                </span>
                <span class="listNewsText_li_img_dot4">{{component_News1[0].title}}</span>
            </NuxtLink>
        </p>
        <div class="listNewsText" v-for="item in component_News2to6">
            <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                :target="item.islink == 1 ? '_blank' : '_self'">
                <span class="text">{{ item.title }}</span>
                <span class="time">{{ item.updated_at }}</span>
            </NuxtLink>
        </div>
    </div>
    <!-- 样式3 -->
    <div class="BannerListBox BannerListBoxStyle3" v-if="componentStyle == 3">
        <div class="listNewsTitle">
            <span>新闻头条</span>
        </div>
        <div class="listNewsText" v-for="item in component_News">
            <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                :target="item.islink == 1 ? '_blank' : '_self'">
                <span class="text">{{ item.title }}</span>
                <span class="time">{{ item.updated_at }}</span>
            </NuxtLink>
        </div>
    </div>
    <!-- 样式4 -->
    <div class="BannerListBox BannerListBoxStyle4" v-if="componentStyle == 4">
        <div class="listNewsTitle">
            <span>新闻头条</span>
        </div>
        <p class="listNewsText_img_li">
            <NuxtLink :href="getLinkPathDetail(component_News1[0])" :title="component_News1[0].title"
                :target="component_News1[0].islink == 1 ? '_blank' : '_self'">
                <span class="listNewsText_li_img_box">
                    <img :src="component_News1[0].imgurl">
                </span>
                <span class="listNewsText_li_img_dot4">{{component_News1[0].title}}</span>
            </NuxtLink>
        </p>
        <div class="listNewsText" v-for="item in component_News2to6">
            <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                :target="item.islink == 1 ? '_blank' : '_self'">
                <span class="text">{{ item.title }}</span>
                <span class="time">{{ item.updated_at }}</span>
            </NuxtLink>
        </div>
    </div>
</template>

<script setup>
//引入vue
import { ref } from 'vue';
//获得新闻数据
const props = defineProps({
    componentStyle: Number,//样式编号
    templateData: Array,//新闻数据
});
//获取新闻数据
const component_News = ref(props.templateData.slice(0,9));
const component_News1 = ref(component_News.value.slice(0,1));
const component_News2to6 = ref(component_News.value.slice(1,6));
</script>

<style lang="less" scoped>
//基本样式 start ---------------------------------------->
//基本样式
.BannerListBox {
    div {
        cursor: pointer;
        font-size: 18px;
        color: #333;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        height: 24px;
        line-height: 24px;
        margin-bottom: 24px;
        &:last-child {
            margin-bottom: 0;
        }
    }
    .listNewsTitle {
        font-size: 22px;
        font-weight: bold;
        height: 47px;
        line-height: 47px;
        border-top: 2px solid #A72213;
        border-bottom: 1px solid #DCDDDF;
        color: #A72213;
        margin-bottom: 20px;
        box-sizing: border-box;
        span {
            display: inline-block;
            color: #A72213;
            height: 47px;
            line-height: 47px;
            // border-bottom: 6px solid #3848a0;
            font-weight: bold;
            /* 可选：为了避免内容紧贴边框，添加内边距 */
        }
    }
    .listNewsText {
        position: relative;
        .text {
            display: block;
            width: 100%;
            padding-right: 13px;
            overflow: hidden;
            box-sizing: border-box;
            text-overflow: ellipsis;
            white-space: nowrap;
            height: 24px;
            text-indent: 16px;
            line-height: 24px;
        }
        .time {
            position: absolute;
            top: 0;
            right: 0;
            display: inline-block;
            width: 51px;
            color: #999999;
            display: none;
        }
        a {
            color: #333;
        }
    }
}
//样式1
.BannerListBoxStyle1 {
    a {
        color: #333333;
    }
    .listNewsText::before {
        content: '';
        display: block;
        position: absolute;
        top: 9px;
        left: 0px;
        width: 6px;
        height: 6px;
        background-color: #d7daec;
        margin-right: 10px;
        vertical-align: 10px;
    }
}
//样式2
.BannerListBoxStyle2 {
    .listNewsText::before {
        content: '';
        display: block;
        position: absolute;
        top: 9px;
        left: 0px;
        width: 6px;
        height: 6px;
        background-color: #d7daec;
        margin-right: 10px;
        vertical-align: 10px;
    }
    .listNewsText_img_li {
        width: 100%;
        display: flex;
        height: 130px;
        margin: 0px 0px 21px 0px;
        a {
            display: block;
            display: flex;
            align-items: center;
            justify-content: center;
            .listNewsText_li_img_box {
                margin-right: 20px;
                height: 100%;
                width: 185px;
                height: 130px;
            }
            .listNewsText_li_img_box img {
                display: block;
                width: 100%;
                height: 100%;
            }
            .listNewsText_li_img_dot4 {
                display: block;
                flex: 1;
                width: 100%;
                color: #333;
                font-size: 18px;
                overflow: hidden;
                margin-top: 17px;
                height: 96px;
                box-sizing: border-box;
                padding-right: 13px;
                line-height: 24px;
                overflow: hidden;
                display: -webkit-box !important;
                -webkit-box-orient: vertical;
                -webkit-line-clamp: 4;
                word-wrap: break-word;
                overflow-wrap: break-word;
                white-space: pre-wrap;
                word-break: break-all;
            }
        }
    }
    
}
//样式2
.BannerListBoxStyle3 {
    .listNewsText::before {
        content: '';
        display: block;
        position: absolute;
        top: 9px;
        left: 0px;
        width: 6px;
        height: 6px;
        background-color: #d7daec;
        margin-right: 10px;
        vertical-align: 10px;
    }
}
//样式2
.BannerListBoxStyle4 {
    .listNewsText::before {
        content: '';
        display: block;
        position: absolute;
        top: 9px;
        left: 0px;
        width: 6px;
        height: 6px;
        background-color: #d7daec;
        margin-right: 10px;
        vertical-align: 10px;
    }
    .listNewsText_img_li {
        width: 100%;
        display: flex;
        height: 130px;
        margin: 0px 0px 21px 0px;
        a {
            display: block;
            display: flex;
            align-items: center;
            justify-content: center;
            .listNewsText_li_img_box {
                margin-right: 20px;
                height: 100%;
                width: 185px;
                height: 130px;
            }
            .listNewsText_li_img_box img {
                display: block;
                width: 100%;
                height: 100%;
            }
            .listNewsText_li_img_dot4 {
                display: block;
                flex: 1;
                width: 100%;
                color: #333;
                font-size: 18px;
                overflow: hidden;
                margin-top: 17px;
                height: 96px;
                box-sizing: border-box;
                padding-right: 13px;
                line-height: 24px;
                overflow: hidden;
                display: -webkit-box !important;
                -webkit-box-orient: vertical;
                -webkit-line-clamp: 4;
                word-wrap: break-word;
                overflow-wrap: break-word;
                white-space: pre-wrap;
                word-break: break-all;
            }
        }
    }
    
}
</style>
