<template>
    <div class="oilLable">
        <div class="oilLable-sele flex ac jc">
            请提醒加油员使用 <span style="color:red">“星油云站”</span> 进行订单核实
        </div>
        <div class="oilLableDetails">
            <div @click="seleFn(index)" v-for="(itemx, index) in oilType.oilSitePriceDetailsVos" :key="index"
                class="oilLableDetails-item flex ac">
                <div :class="seleIndex == index ? 'seleLable' : 'label'" class=" flex ac jc">
                    <van-icon size="15" :color="seleIndex == index ? '#FFFFFF' : '#636262'" name="success" />
                </div>
                <div style=" overflow: hidden;" class="flex ac">
                    <span class="oilLableDetails-item-tip">惠</span>
                    <span class="oilLableDetails-item-oilNumber">{{ itemx.oilProductCode }}</span>
                    <span class="oilLableDetails-item-oilPrice">￥{{ itemx.sitePrice | moneyIntercept }}/L</span>
                    <span class="oilLableDetails-item-originalPrice">￥{{ itemx.oilSitePrice | moneyIntercept }}/L</span>
                    <span class="oilLableDetails-item-text ">预计每100L节省{{ (100 * (itemx.oilSitePrice - itemx.sitePrice))
                            | moneyFormat
                    }}元</span>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    props: {
        value: {
            type: Object,
            default: null
        },
        oilType: {
            type: Object,
            default: () => null
        }
    },
    data() {
        return {
            seleIndex: 0
        }
    },
    created() {
        this.seleFn(this.seleIndex)
    },
    methods: {
        seleFn(index) {
            console.log(11)
            this.seleIndex = index;
            this.$emit('input', Object.assign(Object.assign(JSON.parse(JSON.stringify(this.value)), this.oilType.oilSitePriceDetailsVos[index])))
        },
    },
    filters: {
        moneyIntercept(value) {
            if (value != 'xxx.x') {
                return String(value).split('.')[1] && String(value).split('.')[1].length > 2 ? Number(`${String(value).split('.')[0]}.${String(value).split('.')[1].substring(0, 1)}${Number(String(value).split('.')[1].substring(1, 2)) + 1}`) : Number(value).toFixed(2);
            } else {
                return Number(value).toFixed(2)
            }
        },
        moneyFormat(value) {
            if (value != 'xxx.x') {
                console.log('old:', value)
                let realAmount = Math.floor(value * 100) / 100
                console.log('new:', realAmount)
                // return realAmount
                return Number(value).toFixed(2)
            } else {
                return Number(value).toFixed(2)
            }
        },
        channelCodeFamt(value) {
            if (value) {
                // 渠道编码 ( XOIL：星油 WJY：万金油 LV：老吕（找油网） TY：团油 YDJY：一点加油（壳牌）)
                switch (value) {
                    case 'XOIL':
                        return '星油'
                    case 'WJY':
                        return '万金油'
                    case 'LV':
                        return '老吕（找油网）'
                    case 'TY':
                        return '团油'
                    case 'YDJY':
                        return '一点加油（壳牌）'
                }
            }
        }
    }
}
</script>

<style scoped>
.seleLable {
    width: 31px;
    height: 31px;
    border: none;
    border-radius: 50%;
    background-color: #FF6700;
}

.label {
    /* box-sizing: border-box; */
    width: 31px;
    height: 31px;
    /* border: solid 1px #636262; */
    border-radius: 50%;
}

.oilLableDetails-item:last-child {
    margin-bottom: 0px !important;
}

.oilLableDetails-item-text {
    font-size: 22px;
    font-family: PingFang SC-中等, PingFang SC;
    font-weight: normal;
    color: #999999;
    margin-left: 10px;
    width: 300px;
    flex: 1;
    /* background-color: #999999; */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.oilLableDetails-item-originalPrice {
    font-size: 22px;
    font-family: PingFang SC-中等, PingFang SC;
    font-weight: normal;
    color: #999999;
    text-decoration: line-through;
    margin-left: 13px;
}

.oilLableDetails-item-oilPrice {
    font-size: 32px;
    font-family: PingFang SC-特粗, PingFang SC;
    font-weight: normal;
    color: #FF6700;
    margin-left: 10px;
}

.oilLableDetails-item-oilNumber {
    color: #000000;
    font-size: 34px;
    margin-left: 17px;
    min-width: 70px;
    text-align: center;
}

.oilLableDetails-item-tip {
    width: 35px;
    /* height: 35px; */
    box-sizing: border-box;
    border: solid 1px #FF6700;
    font-size: 25px;
    color: #FF6700;
    margin-left: 15px;
    /* padding: 2px; */
}

.oilLableDetails-item {
    width: 100%;
    /* overflow: hidden; */
    margin-bottom: 15px;
}

.oilLableDetails {
    width: 100%;
    margin-top: 37px;
}

.oilLable-sele-item {
    width: fit-content;
    border-bottom: 4px solid #FF6700;
    padding-bottom: 5px;
    box-sizing: border-box;
}

.oilLable-sele img {
    width: 45px;
    height: 45px;
    margin-right: 10px;
}

.oilLable-sele {
    width: 100%;
    font-size: 28px;
    font-family: PingFang SC-中等, PingFang SC;
    font-weight: normal;
    color: #333333;
}

.oilLable {
    --pd: calc((100vw - 684px)/2);
    width: 100%;
    background-color: #ffffff;
    margin-top: -62px;
    box-sizing: border-box;
    padding-top: 102px;
    padding-left: var(--pd);
    padding-right: var(--pd);
    padding-bottom: 36px;
}
</style>