<template>
    <view class="banner-wrap banner-three">
        <view class="title-wrap">
            <view class="title">生态农场指数</view>
            <view class="sub-title">通风透光防病虫，覆草种植原生态</view>
        </view>
        <swiper v-if="boxList.length" class="carousel" :indicator-dots="true" :autoplay="true" style="height: 370px" arrow="always" :interval="5000">
            <swiper-item class="carousel-item" v-for="(item, index) in boxList" :key="index">
                <view class="name">
                    <text>{{ item.title }}： {{item.value}}分 </text>
                    <text class="size">（排名前 {{item.rank}}%）</text>
                </view>
                <image class="img" :src="item.img" alt="" />
                <view class="desc">{{ item.name }}</view>
            </swiper-item>
        </swiper>
    </view>
</template>

<script setup>
import { ref ,watch} from "vue";
const props = defineProps({
    baseData:{
        type:Object,
        defalut:{}
    }
})

const boxList = ref([]);
watch(()=>props.baseData,(newValue) =>{
    boxList.value = []
    getData(newValue)
})

const getData = (data) =>{
    boxList.value.push(
        {
            value:data.ventilationScore,
            name:data.ventilationText,
            img:data.ventilationImg,
            title: "通风率",
            rank:'20',
        },
        {
            value:data.transmittanceScore,
            name:data.transmittanceText,
            img:data.transmittanceImg,
            title: "透光率",
            rank:'20',
        },
        {
            value:data.biodiversityScore,
            name:data.biodiversityText,
            img:data.biodiversityImg,
            title: "生物多样性",
            rank:'5',
        },
        // {
        //     value:data.stfzScore,
        //     name:data.stfzText,
        //     img:data.stfzImg,
        //     title: "生态防治",
        //     rank:'20',
        // }
    )
}

</script>

<style lang="scss" scoped>
.banner-wrap {
    width: 100%;
    height: 100%;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center center;
    .title {
        font-size: 72rpx;
        letter-spacing: 8rpx;
        font-family: "jiangxizhuokai";
    }
    &.banner-three {
        background-image: url("https://birdseye-img.sysuimars.com/youwei-uniapp/home/report-banner-3.png");
        padding: 120rpx 28rpx;
        box-sizing: border-box;
        .sub-title {
            letter-spacing: 6rpx;
            margin-top: 20rpx;
        }
        .carousel {
            margin-top: 24rpx;
            width: 100%;
            ::v-deep {
                .el-carousel__button {
                    width: 10rpx;
                    height: 10rpx;
                    border-radius: 50%;
                }
                .el-carousel__arrow{
                    width: 64rpx;
                    height: 64rpx;
                    background: rgba(0, 0, 0,0.6);
                    .el-icon{
                        font-size: 44rpx;
                        font-weight: bold;
                    }
                }
            }
            .carousel-item {
                width: 100%;
                height: 100%;
                background: rgba(255, 255, 255, 0.6);
                border-radius: 24rpx;
                padding: 78rpx 32rpx 52rpx 32rpx;
                box-sizing: border-box;
                backdrop-filter: blur(4rpx);
                .name {
                    position: absolute;
                    top: 0;
                    left: calc(50% - 450rpx / 2);
                    font-family: "jiangxizhuokai";
                    padding: 12rpx;
                    font-size: 32rpx;
                    color: #333333;
                    text-align: center;
                    width: 450rpx;
                    box-sizing: border-box;
                    background: url("https://birdseye-img.sysuimars.com/youwei-uniapp/home/name-bg.png") no-repeat center center / 100% 100%;
                    .size {
                        font-size: 26rpx;
                    }
                }
                .img{
                    width: 100%;
                    height: 480rpx;
                    object-fit: cover;
                    margin: 22rpx 0;
                    border-radius: 10rpx;
                }
                .desc {
                    color: #333333;
                    font-size: 24rpx;
                    letter-spacing: 2rpx;
                    line-height: 36rpx;
                }
            }
        }
    }
}
</style>
