<template>
    <view>
        <!-- <view class="communication">
            <view><image class="cangwei" src="../../../static/equipment/cangwei.png" /><text class="storeCode_num">{{storeCode}}号仓位</text></view>
            
        </view> -->
        <view class="battery-number">
			<view class="battery-number-left">
				<view class="battery-number-title">
					电池编号
				</view>
				<view class="battery-number-text">
					{{sn ||'-'}}
				</view>
			</view>
			<view class="battery-number-right">
				<view class="battery-number-title">
					专属
				</view>
				<view class="battery-number-text">
					{{ascription || '-'}}
				</view>
			</view>
        </view>
        <view class="percent">
            <view><text>{{soc}}</text></view>
            <view>%</view>
        </view>
        <view class="line"><text></text><text></text></view>
        <view class="power">
            <view class="power-percent">
                <text v-for="item in 100" :key="item" :style="{'backgroundColor': soc >= item ? setcolor :''}"></text>
            </view>
            <view class="power-text">
                <text>电池电量</text>
                <text v-if="showCode ==0">预计 <em>{{chgEstimatedTime}}</em> 分钟后充满</text>
            </view>
        </view>
    </view>
</template>

<script>
export default {
    name: "BatteryStatus",
    props:['storeCode','comState','sn','chgEstimatedTime','soc','showCode', 'ascription'],
    computed:{
     
        setcolor(){
            if(this.soc<=30 && this.soc > 0){
                return '#ce4545'
            }else if(this.soc > 30 && this.soc <= 70){
                return '#f8dc4b'
            }else if(this.soc > 70){
                return '#44ab41'
            }
        }
    }
};
</script>

<style lang="scss" scoped>
.communication {
    display: flex;
    justify-content: space-between;
	.cangwei{
		width: 20px;
		height: 20px;
		 vertical-align: middle;
		 margin-right: 5px;
		 margin-top: -2px;
	}
    view {
        line-height: 32px;
        font-size: 16px;
        font-weight: 600;
        height: 32px;
        text-align: center;
    }

    view:first-child {
        background-color: #1b263a;
        border: #25334d solid 1px;
        color: white;
        line-height: 32px;
        text-align: left;
        padding: 0 10px 0 5px;
        // .image {
        //     vertical-align: middle;
        // }
    }

   
}

.battery-number {
    margin-top: 10px;
    display: flex;
	color: #414A63;
	.battery-number-left {
		flex: 1;
		display: flex;
		.battery-number-title {
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			font-size: 20rpx;
			color: #414A63;
			line-height: 20rpx;
			text-align: left;
		}
		.battery-number-text {
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			font-size: 24rpx;
			color: #fff;
			line-height: 20rpx;
			text-align: left;
			margin-left: 5rpx;
		}
	}
	.battery-number-right {
		display: flex;
		.battery-number-title {
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			font-size: 20rpx;
			color: #414A63;
			line-height: 20rpx;
			text-align: left;
		}
		.battery-number-text {
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			font-size: 24rpx;
			color: #fff;
			line-height: 20rpx;
			text-align: left;
			margin-left: 5rpx;
		}
	}
    text:last-child {
        color: white;
        padding-right: 10px;
        font-size: 14px;
        font-weight: 600;
		margin-left: 10px;
    }
}

.percent {
    margin-top: 10px;
    display: flex;

    view:first-child {
        background-color: #181e2a;
        width: 90%;
        border-radius: 5px;
        height: 10px;

        text {
            color: white;
            font-weight: 600;
            font-size: 16px;
            position: relative;
            bottom: 5px;
        }
    }

    :last-child {
        position: relative;
        bottom: 4px;
        width: 30px;
        text-align: right;
        font-weight: 500;
    }
}

.line {
    display: flex;


    :first-child {
        width: 1%;
        background-color: white;
        height: 2px;
    }

    :last-child {
        height: 2px;
        width: 97%;
        background-color: #14172a;
        margin-left: 5px;
    }
}

.power {
    display: flex;
    flex-direction: column;
    margin-top: 10px;

    .power-percent {
        width: 100%;
        display: flex;

        text {
            background-color: #1e2535;
            height: 6px;
            width: 2px;
            margin-right: 1px;
        }
    }

    .power-text {
        display: flex;
        width: 100%;
        margin-top: 12px;
        justify-content: space-between;

        em {
            color: #87edab;
            font-weight: 500;
            font-style: normal;
        }
    }
}
</style>