<template>
    <div class="listNewsBox">
        <div class="listNewsTitle">
            <NuxtLink v-if="titleLink1.cid" :href="getLinkPath(titleLink1)" :title="titleLink1.alias">
                <div :class="{ activeTab: activeTab == 0 }" @mouseenter="activeTab = 0">{{ titleLink1.alias }}</div>
            </NuxtLink>
            <NuxtLink v-if="titleLink2.cid" :href="getLinkPath(titleLink2)" :title="titleLink2.alias">
                <div :class="{ activeTab: activeTab == 1 }" @mouseenter="activeTab = 1">{{ titleLink2.alias }}</div>
            </NuxtLink>
        </div>
        <!--样式1-->
        <div class="listNewsContent" v-if="componentStyle == 1">
            <div class="box1" v-if="activeTab == 0">
                <div class="contentLeft" v-for="item in component_style1_News1Array_img_1">
                    <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                        :target="item.islink == 1 ? '_blank' : '_self'">
                        <img :src="item.imgurl" alt="">
                        <span>{{ item.title }}</span>
                    </NuxtLink>
                </div>
                <div class="contentRight">
                    <div v-for="item in component_style1_News1Array_img_2">
                        <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                            :target="item.islink == 1 ? '_blank' : '_self'">
                            <img :src="item.imgurl" alt="">
                            <span>{{ item.title }}</span>
                        </NuxtLink>
                    </div>
                </div>
            </div>
            <div class="box1" v-if="activeTab == 1">
                <div class="contentLeft" v-for="item in component_style1_News1Array_img_3">
                    <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                        :target="item.islink == 1 ? '_blank' : '_self'">
                        <img :src="item.imgurl" alt="">
                        <span>{{ item.title }}</span>
                    </NuxtLink>
                </div>
                <div class="contentRight">
                    <div v-for="item in component_style1_News1Array_img_4">
                        <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                            :target="item.islink == 1 ? '_blank' : '_self'">
                            <img :src="item.imgurl" alt="">
                            <span>{{ item.title }}</span>
                        </NuxtLink>
                    </div>
                </div>
            </div>
        </div>
        <!--样式2-->
        <div class="listNewsContent style2" v-if="componentStyle == 2">
            <div class="box1" v-if="activeTab == 0">
                <div class="contentRight">
                    <div v-for="item in component_style1_News1Array_img_2">
                        <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                            :target="item.islink == 1 ? '_blank' : '_self'">
                            <img :src="item.imgurl" alt="">
                            <span>{{ item.title }}</span>
                        </NuxtLink>
                    </div>
                </div>
                <div class="contentLeft" v-for="item in component_style1_News1Array_img_1">
                    <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                        :target="item.islink == 1 ? '_blank' : '_self'">
                        <img :src="item.imgurl" alt="">
                        <span>{{ item.title }}</span>
                    </NuxtLink>
                </div>
            </div>
            <div class="box1" v-if="activeTab == 1">
                <div class="contentRight">
                    <div v-for="item in component_style1_News1Array_img_4">
                        <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                            :target="item.islink == 1 ? '_blank' : '_self'">
                            <img :src="item.imgurl" alt="">
                            <span>{{ item.title }}</span>
                        </NuxtLink>
                    </div>
                </div>
                <div class="contentLeft" v-for="item in component_style1_News1Array_img_3">
                    <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                        :target="item.islink == 1 ? '_blank' : '_self'">
                        <img :src="item.imgurl" alt="">
                        <span>{{ item.title }}</span>
                    </NuxtLink>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
//引入vue
import { ref } from 'vue';
//获得新闻数据
const props = defineProps({
    titleLink1: Object,//板块1名称
    titleLink2: Object,//板块2名称
    templateData: Array,//新闻数据
    templateData1: Array,//新闻数据
    componentStyle: Number,//样式编号
});
//定义tab切换
const activeTab = ref(0);
// 新闻数据
const component_style1_News1Array_img_1 = ref([]);
const component_style1_News1Array_img_2 = ref([]);

const component_style1_News1Array_img_3 = ref([]);
const component_style1_News1Array_img_4 = ref([]);

component_style1_News1Array_img_1.value = props.templateData.imgnum.slice(0, 1);
component_style1_News1Array_img_2.value = props.templateData.imgnum.slice(1, 5);

component_style1_News1Array_img_3.value = props.templateData1.imgnum.slice(0, 1);
component_style1_News1Array_img_4.value = props.templateData1.imgnum.slice(1, 5);
</script>

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

    .listNewsTitle {
        display: flex;
        align-items: flex-start;
        justify-content: flex-start;
        height: 38px;

        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;
            padding-bottom: 5px;

            &.activeTab {
                color: #154079;
                background: url("http://192.168.1.234:19000/pre/image/png/20251218/1766042138413493.png") bottom left no-repeat;
            }
        }
    }

    .dashed {
        border-bottom: 1px dashed #999999;
    }

    .listNewsContent {
        margin-top: 20px;

        .box1 {
            display: flex;
            align-items: flex-start;
            justify-content: flex-start;
            margin-bottom: 20px;

            .contentLeft {
                width: 585px;
                height: 370px;
                margin-right: 30px;
                position: relative;
                cursor: pointer;

                img {
                    width: 585px;
                    height: 370px;
                }

                span {
                    display: inline-block;
                    width: 585px;
                    position: absolute;
                    bottom: 0;
                    left: 0;
                    height: 60px;
                    line-height: 60px;
                    font-size: 18px;
                    color: #fff;
                    padding-left: 20px;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    white-space: nowrap;
                    background-color: #ccc;
                    box-sizing: border-box;
                }

            }

            .contentRight {
                width: 585px;
                height: 370px;
                display: flex;
                flex-wrap: wrap;
                align-items: flex-start;
                justify-content: space-between;

                div {
                    width: 287px;
                    height: 180px;
                    margin-bottom: 10px;
                    position: relative;
                    cursor: pointer;

                    img {
                        width: 287px;
                        height: 180px;
                    }

                    span {
                        display: inline-block;
                        width: 287px;
                        position: absolute;
                        bottom: 0;
                        left: 0;
                        height: 30px;
                        line-height: 30px;
                        font-size: 12px;
                        font-weight: bold;
                        color: #fff;
                        padding-left: 10px;
                        overflow: hidden;
                        text-overflow: ellipsis;
                        white-space: nowrap;
                        background-color: #ccc;
                        box-sizing: border-box;
                    }
                }


            }
        }
    }

    //样式2
    .style2 {
        .box1 {
            .contentLeft {
                margin-right: 0px;
            }

            .contentRight {
                margin-right: 30px;
            }
        }
    }

    // 样式3
    .style3 {
        .textLeft {
            margin-right: 28px;

            .textLeft_2 {
                margin-right: 30px;
            }

            .textLeft_1 {
                margin-right: 0px;
            }
        }
    }

    // 样式4
    .style4 {
        .textLeft {
            margin-right: 28px;

            .textLeft_2 {
                margin-right: 30px;

                .textleftContent {
                    div {
                        padding-left: 8px;
                        background: url("https://img.bjzxtw.org.cn/pre/image/png/20251203/1764739367233513.png") no-repeat left center;
                    }
                }
            }

            .textLeft_1 {
                margin-right: 0px;
            }
        }
    }

    // 样式5
    .style5 {
        .textLeft {
            .textLeft_2 {
                .textleftContent {
                    div {
                        padding-left: 0px;
                        background: none;
                    }
                }
            }
        }
    }

    // 样式6
    .style6 {
        .textLeft {
            margin-right: 28px;

            .textLeft_2 {
                margin-right: 30px;

                .textleftContent {
                    div {
                        padding-left: 0px;
                        background: none;
                    }
                }
            }

            .textLeft_1 {
                margin-right: 0px;
            }
        }
    }



}
</style>