<template>
    <div class="listNewsBox">
        <div class="listNewsTitle">
            <NuxtLink v-if="titleLink.cid" :href="getLinkPath(titleLink)" :title="titleLink.alias">
                <div>{{ titleLink.alias }}</div>
            </NuxtLink>
        </div>
        <!--样式1-->
        <div class="listNewsContent" v-if="componentStyle == 1">
            <div class="contentLeft">
                <div class="leftTop">
                    <div class="photo">
                        <div v-for="(item, index) in component_style1_News1Array_img_1">
                            <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                                :target="item.islink == 1 ? '_blank' : '_self'">
                                <img :src="item.imgurl" v-if="activeIndex == index">
                            </NuxtLink>
                        </div>
                    </div>
                    <div class="text">
                        <div v-for="(item, index) in component_style1_News1Array_img_1"
                            :class="{ 'active': activeIndex == index }">
                            <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                                @mouseenter="activeIndex = index" :target="item.islink == 1 ? '_blank' : '_self'">
                                {{ item.title }}
                            </NuxtLink>
                        </div>
                    </div>
                </div>
                <div class="leftBottom">
                    <div v-for="item in component_style1_News1Array_text_1">
                        <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                            :target="item.islink == 1 ? '_blank' : '_self'">
                            {{ item.title }}
                        </NuxtLink>
                    </div>
                </div>
            </div>
            <div class="contentLeft">
                <div class="leftTop">
                    <div class="photo">
                        <div v-for="(item, index) in component_style1_News1Array_img_2">
                            <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                                :target="item.islink == 1 ? '_blank' : '_self'">
                                <img :src="item.imgurl" v-if="activeIndex1 == index">
                            </NuxtLink>
                        </div>
                    </div>
                    <div class="text">
                        <div v-for="(item, index) in component_style1_News1Array_img_2"
                            :class="{ 'active': activeIndex1 == index }">
                            <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                                @mouseenter="activeIndex1 = index" :target="item.islink == 1 ? '_blank' : '_self'">
                                {{ item.title }}
                            </NuxtLink>
                        </div>
                    </div>
                </div>
                <div class="leftBottom">
                    <div v-for="item in component_style1_News1Array_text_2">
                        <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                            :target="item.islink == 1 ? '_blank' : '_self'">
                            {{ item.title }}
                        </NuxtLink>
                    </div>
                </div>
            </div>
        </div>
        <!--样式2-->
        <div class="listNewsContent style2" v-if="componentStyle == 2">
            <div class="contentLeft">
                <div class="leftTop">
                    <div class="photo">
                        <div v-for="(item, index) in component_style1_News1Array_img_1">
                            <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                                :target="item.islink == 1 ? '_blank' : '_self'">
                                <img :src="item.imgurl" v-if="activeIndex == index">
                            </NuxtLink>
                        </div>
                    </div>
                    <div class="text">
                        <div v-for="(item, index) in component_style1_News1Array_img_1"
                            :class="{ 'active': activeIndex == index }">
                            <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                                @mouseenter="activeIndex = index" :target="item.islink == 1 ? '_blank' : '_self'">
                                {{ item.title }}
                            </NuxtLink>
                        </div>
                    </div>
                </div>
                <div class="leftBottom">
                    <div v-for="item in component_style1_News1Array_text_1">
                        <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                            :target="item.islink == 1 ? '_blank' : '_self'">
                            {{ item.title }}
                        </NuxtLink>
                    </div>
                </div>
            </div>
            <div class="contentLeft">
                <div class="leftTop">
                    <div class="photo">
                        <div v-for="(item, index) in component_style1_News1Array_img_2">
                            <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                                :target="item.islink == 1 ? '_blank' : '_self'">
                                <img :src="item.imgurl" v-if="activeIndex1 == index">
                            </NuxtLink>
                        </div>
                    </div>
                    <div class="text">
                        <div v-for="(item, index) in component_style1_News1Array_img_2"
                            :class="{ 'active': activeIndex1 == index }">
                            <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                                @mouseenter="activeIndex1 = index" :target="item.islink == 1 ? '_blank' : '_self'">
                                {{ item.title }}
                            </NuxtLink>
                        </div>
                    </div>
                </div>
                <div class="leftBottom">
                    <div v-for="item in component_style1_News1Array_text_2">
                        <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                            :target="item.islink == 1 ? '_blank' : '_self'">
                            {{ item.title }}
                        </NuxtLink>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
//引入vue
import { ref } from 'vue';
//获得新闻数据
const props = defineProps({
    titleLink: Object,//板块名称
    templateData: Array,//新闻数据
    componentStyle: Number,//样式编号
});

const activeIndex = ref(0);
const activeIndex1 = ref(0);

//样式1与样式2共用 start ---------------------------------------->
const component_style1_News1Array_img_1 = ref([]);
const component_style1_News1Array_img_2 = ref([]);
const component_style1_News1Array_text_1 = ref([]);
const component_style1_News1Array_text_2 = ref([]);
//真实数据
// 图文数据
component_style1_News1Array_img_1.value = props.templateData.imgnum.slice(0, 2);
component_style1_News1Array_img_2.value = props.templateData.imgnum.slice(2, 4);
// 文本数据
component_style1_News1Array_text_1.value = props.templateData.textnum.slice(0, 3);
component_style1_News1Array_text_2.value = props.templateData.textnum.slice(3, 6);



//样式1与样式2共用 end ---------------------------------------->
</script>

<style lang="less" scoped>
//基本样式 start ---------------------------------------->
.listNewsBox {
    position: relative;

    .listNewsTitle {
        height: 38px;
        line-height: 38px;
        margin-bottom: 19px;

        div {
            height: 35px;
            width: 138px;
            line-height: 32px;
            font-size: 22px;
            font-weight: bold;
            color: #333333;
            cursor: pointer;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            color: #154079;
            background: url("https://img.bjzxtw.org.cn/pre/image/png/20251104/1762224944805589.png") bottom left no-repeat;
        }
    }

    .listNewsContent {
        display: flex;
        align-items: center;
        justify-content: space-between;

        .contentLeft {
            width: 378px;
            height: 292px;

            .leftTop {
                width: 220px;
                height: 160px;
                position: relative;
                display: flex;
                align-items: center;
                justify-content: flex-start;
                margin-bottom: 20px;

                .photo {
                    width: 220px;
                    height: 160px;
                    margin-right: 20px;
                    position: relative;

                    div {
                        a {
                            img {
                                width: 220px;
                                height: 160px;
                                position: relative;
                            }
                        }
                    }
                }

                .text {
                    div {
                        width: 129px;
                        height: 72px;
                        font-size: 18px;
                        color: #333333;
                        line-height: 24px;
                        display: -webkit-box;
                        -webkit-box-orient: vertical;
                        -webkit-line-clamp: 3;
                        overflow: hidden;
                        text-overflow: ellipsis;
                        word-break: break-all;

                        &:first-child {
                            font-weight: bold;
                            margin-bottom: 10px;
                        }

                        // &.active {
                        //     a {
                        //         color: #154079;
                        //     }
                        // }

                        a {
                            width: 100%;
                            height: 100%;
                            color: #333333;
                        }
                    }
                }
            }

            .leftBottom {
                div {
                    width: 370px;
                    white-space: nowrap;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    font-size: 18px;
                    color: #666666;
                    margin-bottom: 22px;
                    padding-left: 8px;
                    background: url("https://img.bjzxtw.org.cn/pre/image/png/20251203/1764729502583754.png") no-repeat left center;

                    &:last-child {
                        margin-bottom: 0px;
                    }

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