<template>
    <div class="newsBox">
        <div class="listNewsTitle_skin2">
            <span>最新资讯</span>
        </div>
        <!--样式1-->
        <div class="newsContent" v-if="componentStyle==1">
            <div v-for="item in component_style1_News1Array" class="newsContentImg">
                <NuxtLink 
                    :href="getLinkPathDetail(item)" 
                    :title="item.title"
                    :target="item.islink == 1 ? '_blank' : '_self'"
                >
                    <img :src="item.imgurl" />
                    <div>{{ item.title }}</div>
                </NuxtLink>
            </div>
            <div v-for="item in component_style1_News2Array" class="newsContentText">
                <NuxtLink 
                    :href="getLinkPathDetail(item)" 
                    :title="item.title"
                    :target="item.islink == 1 ? '_blank' : '_self'"
                >
                    {{ item.title }}
                </NuxtLink>
            </div>
        </div>
        <!--样式2-->
        <div class="newsContent"  v-if="componentStyle==2">
            <div v-for="item in component_style1_News1Array" class="newsContentImg">
                <NuxtLink 
                    :href="getLinkPathDetail(item)" 
                    :title="item.title"
                    :target="item.islink == 1 ? '_blank' : '_self'"
                >
                    <div>{{ item.title }}</div>
                    <img :src="item.imgurl" />
                </NuxtLink>
            </div>
            <div v-for="item in component_style1_News2Array" class="newsContentText">
                <NuxtLink 
                    :href="getLinkPathDetail(item)" 
                    :title="item.title"
                    :target="item.islink == 1 ? '_blank' : '_self'"
                >
                    {{ item.title }}
                </NuxtLink>
            </div>
        </div>
        <!--样式3-->
        <div class="newsContent" v-if="componentStyle == 3">
            <div v-for="item in component_style1_News2Array" class="newsContentText">
                <NuxtLink 
                    :href="getLinkPathDetail(item)" 
                    :title="item.title"
                    :target="item.islink == 1 ? '_blank' : '_self'"
                >
                    {{ item.title }}
                </NuxtLink>
            </div>
            <div v-for="item in component_style1_News1Array" class="newsContentImg">
                <NuxtLink 
                    :href="getLinkPathDetail(item)" 
                    :title="item.title"
                    :target="item.islink == 1 ? '_blank' : '_self'"
                >
                    <img :src="item.imgurl" />
                    <div>{{ item.title }}</div>
                </NuxtLink>
            </div>
        </div>
        <!--样式4-->
        <div class="newsContent" v-if="componentStyle == 4">
            <div v-for="item in component_style1_News2Array" class="newsContentText">
                <NuxtLink 
                    :href="getLinkPathDetail(item)" 
                    :title="item.title"
                    :target="item.islink == 1 ? '_blank' : '_self'"
                >
                    {{ item.title }}
                </NuxtLink>
            </div>
            <div v-for="item in component_style1_News1Array" class="newsContentImg">
                <NuxtLink 
                    :href="getLinkPathDetail(item)" 
                    :title="item.title"
                    :target="item.islink == 1 ? '_blank' : '_self'"
                >
                    <div>{{ item.title }}</div>
                    <img :src="item.imgurl" />
                </NuxtLink>
            </div>
        </div>
        <!--样式5-->
        <div class="newsContent" v-if="componentStyle == 5">
            <div class="newsContentImg" v-for="item in component_style1_News1Array_1">
                <NuxtLink 
                    :href="getLinkPathDetail(item)" 
                    :title="item.title"
                    :target="item.islink == 1 ? '_blank' : '_self'"
                >
                    <img :src="item.imgurl" />
                    <div>{{ item.title }}</div>
                </NuxtLink>
            </div>
            <div class="newsContentImg" v-for="item in component_style1_News1Array_2">
                <NuxtLink 
                    :href="getLinkPathDetail(item)" 
                    :title="item.title"
                    :target="item.islink == 1 ? '_blank' : '_self'"
                >
                    <div>{{ item.title }}</div>
                    <img :src="item.imgurl" />
                </NuxtLink>
            </div>
            <div v-for="item in component_style1_News2Array" class="newsContentText">
                <NuxtLink 
                    :href="getLinkPathDetail(item)" 
                    :title="item.title"
                    :target="item.islink == 1 ? '_blank' : '_self'"
                >
                    {{ item.title }}
                </NuxtLink>
            </div>
        </div>
        <!--样式6-->
        <div class="newsContent" v-if="componentStyle == 6">
            <div class="newsContentImg" v-for="item in component_style1_News1Array_1">
                <NuxtLink 
                    :href="getLinkPathDetail(item)" 
                    :title="item.title"
                    :target="item.islink == 1 ? '_blank' : '_self'"
                >
                    <div>{{ item.title }}</div>
                    <img :src="item.imgurl" />
                </NuxtLink>
            </div>
            <div class="newsContentImg" v-for="item in component_style1_News1Array_2">
                <NuxtLink 
                    :href="getLinkPathDetail(item)" 
                    :title="item.title"
                    :target="item.islink == 1 ? '_blank' : '_self'"
                >
                    <img :src="item.imgurl" />
                    <div>{{ item.title }}</div>
                </NuxtLink>
            </div>
            <div v-for="item in component_style1_News2Array" class="newsContentText">
                <NuxtLink 
                    :href="getLinkPathDetail(item)" 
                    :title="item.title"
                    :target="item.islink == 1 ? '_blank' : '_self'"
                >
                    {{ item.title }}
                </NuxtLink>
            </div>
        </div>
        <!--样式7-->
        <div class="newsContent" v-if="componentStyle == 7">
            <div class="newsContentImg" v-for="item in component_style1_News1Array_1">
                <NuxtLink 
                    :href="getLinkPathDetail(item)" 
                    :title="item.title"
                    :target="item.islink == 1 ? '_blank' : '_self'"
                >
                    <img :src="item.imgurl" />
                    <div>{{ item.title }}</div>
                </NuxtLink>
            </div>
            <div v-for="item in component_style1_News2Array_1" class="newsContentText">
                <NuxtLink 
                    :href="getLinkPathDetail(item)" 
                    :title="item.title"
                    :target="item.islink == 1 ? '_blank' : '_self'"
                >
                    {{ item.title }}
                </NuxtLink>
            </div>
            <div class="newsContentImg" v-for="item in component_style1_News1Array_2">
                <NuxtLink 
                    :href="getLinkPathDetail(item)" 
                    :title="item.title"
                    :target="item.islink == 1 ? '_blank' : '_self'"
                >
                    <img :src="item.imgurl" />
                    <div>{{ item.title }}</div>
                </NuxtLink>
            </div>
            <div v-for="item in component_style1_News2Array_2" class="newsContentText">
                <NuxtLink 
                    :href="getLinkPathDetail(item)" 
                    :title="item.title"
                    :target="item.islink == 1 ? '_blank' : '_self'"
                >
                    {{ item.title }}
                </NuxtLink>
            </div>
        </div>
        <!--样式8-->
        <div class="newsContent" v-if="componentStyle == 8">
            <div class="newsContentImg" v-for="item in component_style1_News1Array_1">
                <NuxtLink 
                    :href="getLinkPathDetail(item)" 
                    :title="item.title"
                    :target="item.islink == 1 ? '_blank' : '_self'"
                >
                    <div>{{ item.title }}</div>
                    <img :src="item.imgurl" />
                </NuxtLink>
            </div>
            <div v-for="item in component_style1_News2Array_1" class="newsContentText">
                <NuxtLink 
                    :href="getLinkPathDetail(item)" 
                    :title="item.title"
                    :target="item.islink == 1 ? '_blank' : '_self'"
                >
                    {{ item.title }}
                </NuxtLink>
            </div>
            <div class="newsContentImg" v-for="item in component_style1_News1Array_2">
                <NuxtLink 
                    :href="getLinkPathDetail(item)" 
                    :title="item.title"
                    :target="item.islink == 1 ? '_blank' : '_self'"
                >
                    <div>{{ item.title }}</div>
                    <img :src="item.imgurl" />
                </NuxtLink>
            </div>
            <div v-for="item in component_style1_News2Array_2" class="newsContentText">
                <NuxtLink 
                    :href="getLinkPathDetail(item)" 
                    :title="item.title"
                    :target="item.islink == 1 ? '_blank' : '_self'"
                >
                    {{ item.title }}
                </NuxtLink>
            </div>
        </div>
    </div>
</template>

<script setup>
//引入vue
import {ref} from 'vue';
//获得新闻数据
const props = defineProps({
    componentStyle:Number,//样式编号
});
const component_style1_News1Array = ref([]);
const component_style1_News1Array_1 = ref([]);
const component_style1_News1Array_2 = ref([]);
const component_style1_News2Array = ref([]);
const component_style1_News2Array_1 = ref([]);
const component_style1_News2Array_2 = ref([]);
// component_style1_News1Array.value = props.templateData.img.slice(0,2);
// component_style1_News2Array.value = props.templateData.text.slice(0,4);

//最新资讯数据 start ---------------------------------------->
async function getPageData() {
    const mkdata =  await requestDataPromise('/web/getWebsiteArticlett', {
        method: 'GET',
        query: {
            'imgnum': 4,
            'textnum': 4,
            'level': 4,
            'id': 0,
            'placeid': 0,
        },
    });
    if(mkdata.code == 200){
        component_style1_News1Array.value = mkdata.data.img.slice(0, 2);
        component_style1_News1Array_1.value = mkdata.data.img.slice(0, 1);
        component_style1_News1Array_2.value = mkdata.data.img.slice(1, 2);
        component_style1_News2Array.value = mkdata.data.text.slice(0, 4);
        component_style1_News2Array_1.value = mkdata.data.text.slice(0, 2);
        component_style1_News2Array_2.value = mkdata.data.text.slice(2, 4);
    }
}
getPageData();
</script>

<style lang="less" scoped>
//基本样式 start ---------------------------------------->
.newsBox {
    .listNewsTitle_skin2 {
        font-size:22px;
        font-weight:bold;
        height: 40px;
        line-height: 40px;
        background-color: #fdf8f7;
        margin-bottom: 20px;
        box-sizing: border-box;
        span {
            display: inline-block;
            width: 112px;
            height: 40px;
            line-height: 40px;
            background: #c82200;
            color:#fff;
            text-align: center;
            a{
                color: #fff;
                background-color: #c82200;
            }
        }
    }
    .newsContent {
        .newsContentImg {
            a {
                display: block;
                display: flex;
                align-items: center;
                justify-content: space-between;
                margin-bottom: 20px;
                font-size:18px;
                div {
                    overflow: hidden;
                    display: -webkit-box;
                    -webkit-line-clamp: 3;
                    -webkit-box-orient: vertical;
                    text-overflow: ellipsis;
                    color:#333333;
                    width: 130px;
                }
                img {
                    display: block;
                    width: 120px;
                    height: 80px;
                }
            }
            
        }
        .newsContentText {
            font-size:18px;
            color:#333333;
            margin-bottom: 20px;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
            a {
                color:#333333;
            }
        }
    }
}
//基本样式 end ---------------------------------------->
</style>