<template>
    <div class="listNewsBox">
        <div class="listNewsTitle" v-if="componentStyle <= 3">
            <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>
        <div class="listNewsTitle dashed" v-if="componentStyle >= 4">
            <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 v-for="item in component_style1_News1Array">
                    <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                        :target="item.islink == 1 ? '_blank' : '_self'">
                        {{ item.title }}
                        <span>{{ getTime(item.updated_at, 'month', 1) }}</span>
                    </NuxtLink>
                </div>
            </div>
            <div class="box1" v-if="activeTab == 1">
                <div v-for="item in component_style1_News2Array">
                    <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                        :target="item.islink == 1 ? '_blank' : '_self'">
                        {{ item.title }}
                        <span>{{ getTime(item.updated_at, 'month', 1) }}</span>
                    </NuxtLink>
                </div>
            </div>
        </div>
        <!-- 样式2 -->
        <div class="listNewsContent style2" v-if="componentStyle == 2">
            <div class="box1" v-if="activeTab == 0">
                <div v-for="item in component_style1_News1Array">
                    <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                        :target="item.islink == 1 ? '_blank' : '_self'">
                        {{ item.title }}
                        <span>{{ getTime(item.updated_at, 'month', 1) }}</span>
                    </NuxtLink>
                </div>
            </div>
            <div class="box1" v-if="activeTab == 1">
                <div v-for="item in component_style1_News2Array">
                    <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                        :target="item.islink == 1 ? '_blank' : '_self'">
                        {{ item.title }}
                        <span>{{ getTime(item.updated_at, 'month', 1) }}</span>
                    </NuxtLink>
                </div>
            </div>
        </div>
        <!-- 样式3 -->
        <div class="listNewsContent style3" v-if="componentStyle == 3">
            <div class="box1" v-if="activeTab == 0">
                <div v-for="item in component_style1_News1Array">
                    <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                        :target="item.islink == 1 ? '_blank' : '_self'">
                        {{ item.title }}
                        <span>{{ getTime(item.updated_at, 'month', 1) }}</span>
                    </NuxtLink>
                </div>
            </div>
            <div class="box1" v-if="activeTab == 1">
                <div v-for="item in component_style1_News2Array">
                    <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                        :target="item.islink == 1 ? '_blank' : '_self'">
                        {{ item.title }}
                        <span>{{ getTime(item.updated_at, 'month', 1) }}</span>
                    </NuxtLink>
                </div>
            </div>
        </div>
        <!-- 样式4 -->
        <div class="listNewsContent" v-if="componentStyle == 4">
            <div class="box1" v-if="activeTab == 0">
                <div v-for="item in component_style1_News1Array">
                    <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                        :target="item.islink == 1 ? '_blank' : '_self'">
                        {{ item.title }}
                        <span>{{ getTime(item.updated_at, 'month', 1) }}</span>
                    </NuxtLink>
                </div>
            </div>
            <div class="box1" v-if="activeTab == 1">
                <div v-for="item in component_style1_News2Array">
                    <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                        :target="item.islink == 1 ? '_blank' : '_self'">
                        {{ item.title }}
                        <span>{{ getTime(item.updated_at, 'month', 1) }}</span>
                    </NuxtLink>
                </div>
            </div>
        </div>
        <!-- 样式5 -->
        <div class="listNewsContent style5" v-if="componentStyle == 5">
            <div class="box1" v-if="activeTab == 0">
                <div v-for="item in component_style1_News1Array">
                    <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                        :target="item.islink == 1 ? '_blank' : '_self'">
                        {{ item.title }}
                        <span>{{ getTime(item.updated_at, 'month', 1) }}</span>
                    </NuxtLink>
                </div>
            </div>
            <div class="box1" v-if="activeTab == 1">
                <div v-for="item in component_style1_News2Array">
                    <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                        :target="item.islink == 1 ? '_blank' : '_self'">
                        {{ item.title }}
                        <span>{{ getTime(item.updated_at, 'month', 1) }}</span>
                    </NuxtLink>
                </div>
            </div>
        </div>
        <!-- 样式6 -->
        <div class="listNewsContent style6" v-if="componentStyle == 6">
            <div class="box1" v-if="activeTab == 0">
                <div v-for="item in component_style1_News1Array">
                    <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                        :target="item.islink == 1 ? '_blank' : '_self'">
                        {{ item.title }}
                        <span>{{ getTime(item.updated_at, 'month', 1) }}</span>
                    </NuxtLink>
                </div>
            </div>
            <div class="box1" v-if="activeTab == 1">
                <div v-for="item in component_style1_News2Array">
                    <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
                        :target="item.islink == 1 ? '_blank' : '_self'">
                        {{ item.title }}
                        <span>{{ getTime(item.updated_at, 'month', 1) }}</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 = ref([]);
const component_style1_News2Array = ref([]);
component_style1_News1Array.value = props.templateData.textnum.slice(0, 5);
component_style1_News2Array.value = props.templateData1.textnum.slice(0, 5);
</script>

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

    .listNewsTitle {
        display: flex;
        align-items: flex-start;
        justify-content: flex-start;
        border-bottom: 1px solid #999999;
        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;

            &.activeTab {
                color: #3848A0;
                background: url("https://img.bjzxtw.org.cn/pre/image/png/20251104/1762224944805589.png") bottom left no-repeat;
            }
        }
    }

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

    .listNewsContent {
        margin-top: 20px;

        .box1 {
            div {
                position: relative;
                padding-left: 16px;
                box-sizing: border-box;
                background: url('https://img.bjzxtw.org.cn/pre/image/jpeg/20251104/1762226432153586.jpg') no-repeat left 9px;
                font-size: 18px;
                color: #333333;
                line-height: 24px;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
                margin-bottom: 14px;

                a {
                    display: inline-block;
                    color: #333333;
                    width: 520px;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    white-space: nowrap;

                    span {
                        position: absolute;
                        top: 0;
                        right: 0;
                        font-size: 16px;
                        color: #999999;
                    }
                }
                &:last-child {
                    margin-bottom: 0;
                }
            }
        }
    }

    // 样式2
    .style2,
    .style5 {
        .box1 {
            div {
                padding-left: 0;
                background: none;
            }
        }

    }

    // 样式3
    .style3,
    .style6 {
        .box1 {
            div {
                background: url('https://img.bjzxtw.org.cn/pre/image/png/20251104/1762226842166040.png') no-repeat left 9px;
            }
        }

    }
}
</style>