<template>
    <div class="swiper" v-if="imagelist">

        <el-carousel :interval="2222" :touchable="true" arrow="always" 
            indicator-class="custom-indicator" 
            class="custom-carousel roll_in" @change="handleIndicatorChange">

            <el-carousel-item v-for="(item, index) in imagelist" :key="index">
                <NuxtLink :to="`/${item.pinyin}/${item.id}.html`"
                    :title="item.title">
                    <img :src="item.imgurl" :alt="item.title">
                    <span>{{ item.title }}</span>
                </NuxtLink>
            </el-carousel-item>
            <template #indicator="{ index }">
                <button :class="{ 'active-indicator': currentIndex === index }">{{ index + 1 }}</button>
            </template>
        </el-carousel>
    </div>
</template>

<script setup>
import { ElCarousel, ElCarouselItem } from 'element-plus'
//获取焦点图数据 start---------------------------------------->
const imagelist = ref("")
async function getModelData1() {
    const mkdata =  await requestDataPromise('/web/getWebsiteArticlett', {
        method: 'GET',
        query: {
            'imgnum': 5,
            'textnum': 0,
            'level': 2,
            'placeid': 0,
            'id':''
        },
    });
    if(mkdata.code == 200){
        imagelist.value = mkdata.data.img;
    }else{
        // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
        // console.log("错误位置：获取首页轮播图")
        // console.log("后端错误反馈：",mkdata.message)
        // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
    }
}
getModelData1()

let currentIndex = ref(0)
let handleIndicatorChange = (val) => {
    currentIndex.value = val
}
</script>

<style lang="less" scoped>
.swiper {
    width: 720px;
    height: 405px;
    position: relative;

    img {
        width: 720px;
        height: 405px;
    }

    span {
        display: inline-block;
        width: 720px;
        height: 118px;
        padding-top: 20px;
        padding-left: 23px;
        box-sizing: border-box;
        position: absolute;
        top: 0;
        left: 0;
        font-family: Source Han Sans, Source Han Sans;
        font-weight: 800;
        font-size: 24px;
        color: #FFFFFF;
        background: linear-gradient(to bottom, rgba(0, 0, 0, 1), rgba(0, 0, 0, 0));

    }
}
.roll_in{height:405px;}

.el-carousel {
    // 左右箭头按钮
    .el-carousel__arrow--right :deep(.class-name),
    .el-carousel__arrow--left :deep(.class-name) {
        width: 68px;
        height: 68px;
    }
    //左右箭头图片
    /deep/.el-icon svg {
        height: 1em;
        width: 1em;
        background-color: transparent;
    }
    /deep/.el-carousel__arrow {
        border-radius: 0;
        background-color: transparent;
    }
    /deep/.el-carousel__arrow i {
        font-size: 68px !important;
    }
    /deep/ .el-carousel__indicators {
        // 指示器
        left: unset;
        transform: unset;
        right: 41%;
    }
    /deep/ .el-carousel__button {
        // 指示器按钮
        width: 20px;
        height: 20px;
        border-radius: 50%;
        border: none;
        opacity: 1;
        background-color: #FFFFFF;
    }

    /deep/ .is-active .el-carousel__button {
        // 指示器激活按钮
        background: #46D333;
    }

    /deep/ .el-carousel__container {
        height: 100%;
    }

    /deep/.custom-indicators {
        position: absolute;
        bottom: 10px;
        left: 50%;
        transform: translateX(-50%);
    }

    // 将指示器的所有样式都不显示
    // /deep/.el-carousel__indicators {
    //     display: none;
    // }

}
</style>

<style lang="less" scoped>

    @media screen and (max-width:800px){/*ipad_phone*/

 
        .swiper span{width:100%;line-height:22px;max-height:54px;font-size:16px; 
                        padding:10px 10px 0;top:0px;}
        .swiper /deep/ul.el-carousel__indicators{width:100%; right:0px;text-align:center;}
        .swiper img{width:100%;height:100%;}
        .roll_in{height:55vw;}
         
        .el-carousel /deep/.el-icon svg{width:.4em;display:none;}
        .el-carousel /deep/.el-carousel__button{width:8px;height:8px;margin:0px 2px;}    

    }



</style>









