<template>
    <div class="bandLevel">
        <div class="bandItem" v-for="(item,index) in dataList" :key="index">
            <p class="title">{{item.name}}</p>
            <div class="progress">
                <div v-if="Number(item.small)!==0" class="small" :style="{width:`calc(${item.small}% - 2px)`}">{{item.small<16?'':item.small+'%'}}</div>
                <div v-if="Number(item.normal)!==0" class="normal" :style="{width:`calc(${item.normal}% - 2px)`,left:`calc(${item.small}% - 2px)`}">{{item.normal<16?'':item.normal + '%'}}</div>
                <div v-if="Number(item.big)!==0" class="big" :style="{width:item.big+'%',left:`calc(${item.normal + item.small}%  - 4px)`}">{{item.big<16?'':item.big + '%'}}</div>
            </div>
        </div>
        <div class="key">
            <div class="box">
                <div class="keyItem">
                    <div class="icon" style="background: #CAD0DA"></div>
                    <p class="type">低消费</p>
                </div>
                <div class="keyItem">
                    <div class="icon" style="background: #ACB9CD"></div>
                    <p class="type">普通消费</p>
                </div>
                <div class="keyItem">
                    <div class="icon" style="background: #1E80FF"></div>
                    <p class="type">高消费</p>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
var uChartsInstance = {};
export default {
    name: "bandLevel",
    data() {
        return {
            dataList: []
        }
    },
    props: {
        data: {
            type: Array,
            default: () => []
        }
    },
    watch: {
        data: {
            handler(value) {
                console.log('carDatawatch', value)
                this.dataList = value
            },
            immediate: true
        }
    },
    methods: {

    }
}
</script>

<style scoped lang="scss">
.bandLevel{
    width: 100%;
    margin-top: 12px;
    .bandItem{
        margin-bottom: 12px;
        .title{
            font-size: 14px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #160002;
            line-height: 20px;
        }
        .progress{
            width: 100%;
            height: 20px;
            box-sizing: border-box;
            margin-top: 6px;
            position: relative;
            font-size: 12px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #FFFFFF;
            .big{
                display: flex;
                align-items: center;
                height: 100%;
                position: absolute;
                top: 0;
                border-radius:  0 2px 2px  0  ;
                box-sizing: border-box;
                padding-left: 4px;
                background: #1E80FF;
            }
            .normal{
                display: flex;
                align-items: center;
                height: 100%;
                position: absolute;
                box-sizing: border-box;
                padding-left: 4px;
                background: #ACB9CD;
            }
            .normal:after{
                position: absolute;
                content:'';
                width: 2px;
                height: 100%;
                background: #FFFFFF;
                z-index:9;
                right: 0;
                top: 0;
            }
            .small{
                display: flex;
                align-items: center;
                height: 100%;
                position: absolute;
                box-sizing: border-box;
                padding-left: 4px;
                border-radius:  2px 0 0 2px ;
                background: #CAD0DA;
            }
            .small:after{
                position: absolute;
                content:'';
                width: 2px;
                height: 100%;
                background: #FFFFFF;
                z-index:9;
                right: 0;
                top: 0;
            }
        }
    }
    .key{
        display: flex;
        width: 100%;
        .box{
            display: flex;
            margin: 0 auto;
            .keyItem{
                display: flex;
                align-items: center;
                margin-right: 12px;
                .icon{
                    width: 12px;
                    height: 12px;
                    border-radius: 2px;
                    margin-right: 4px;
                }
                .type{
                    font-size: 12px;
                    font-family: PingFangSC-Regular, PingFang SC;
                    font-weight: 400;
                    color: #786B6C;
                    line-height: 18px;
                }
            }
        }
    }
}
</style>
