<template>
    <div>
        <div @click="visibleFun">
            <slot>
                <div class="comoros-input">
                    <div v-if="true" class="comoros-input-empty">
                        <div>选择云手机</div>
                        <img src="@/assets/image/transferDuration/arrow-right.png" alt="" class="comoros-input-empty-img" />
                    </div>
                    <div v-else>
                        <div class="comoros-list-item_left" style="margin: 0 12px;">
                            <img :src="require(`@/assets/image/transferDuration/${img}.png`)" alt=""
                                class="comoros-list-item_left-img" />
                            <div>
                                <div class="comoros-list-item_left-title">123456</div>
                                <div class="comoros-list-item_left-tips red-time">
                                    <img src="@/assets/image/transferDuration/phone_time.png" alt=""
                                        class="tips-img">剩一天23小时
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </slot>
        </div>
        <van-popup v-model="visible" position="bottom">
            <div class="comoros-list">
                <div style="display: flex;justify-content: space-between;margin-bottom: 16px;">
                    <div>请选择云手机</div>
                </div>
                <div class="comoros-list-container">
                    <van-radio-group v-model="id" ref="checkboxGroup">
                        <div v-for="item in 20" :key="item" class="comoros-list-item">
                            <div class="comoros-list-item_left">
                                <img :src="require(`@/assets/image/transferDuration/${img}.png`)" alt=""
                                    class="comoros-list-item_left-img" />
                                <div>
                                    <div class="comoros-list-item_left-title">123456</div>
                                    <div class="comoros-list-item_left-tips red-time">
                                        <img src="@/assets/image/transferDuration/phone_time.png" alt=""
                                            class="tips-img">剩一天23小时
                                    </div>
                                </div>
                            </div>
                            <div class="comoros-list-item_right"><van-radio :name="item" shape="square"
                                    icon-size="15px"></van-radio></div>
                        </div>
                    </van-radio-group>
                </div>
                <div class="comoros-list-btn">
                    <van-button type="info" block>确认</van-button>
                </div>
            </div>
        </van-popup>
    </div>
</template>

<script>
export default {
    name: 'comoros',

    data() {
        return {
            visible: false,
            checkedAll: false,
            img: 'STAR_icon',
            id: ''
        };
    },

    mounted() {

    },

    methods: {
        checkedAllFun(bool) {
            this.$refs.checkboxGroup.toggleAll(bool)
        },
        visibleFun() {
            this.visible = true
            setTimeout(() => {
                const documents = document.getElementsByClassName('comoros-list-container')
                const length = documents.length
                for (let i = 0; i < length; i++) {
                    documents[i].scrollTop = 0
                }
            })
        }
    },
};
</script>

<style lang="scss" scoped>
.comoros-input {
    margin-top: 8px;
    height: 52px;
    background: #2C2C2D;
    border-radius: 8px;
    // line-height: 52px;
    display: flex;
    align-items: center;
    font-size: 12px;

    .comoros-input-empty {
        width: 100%;
        margin: 0 12px;
        display: flex;
        justify-content: space-between;

        .comoros-input-empty-img {
            width: 16px;
            height: 16px;
        }
    }


}

.comoros-list {
    background: #fff;
    margin: 0 10px;
    background: #2C2C2D;
    border-radius: 20px 20px 0 0;
    padding: 24px 16px 8px;
    color: #CFD1D4;
    height: 60vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;

    ::v-deep .van-checkbox__label {
        color: #CFD1D4;
    }

    .comoros-list-container {
        flex: 1;
        overflow-y: auto;

        .comoros-list-item {
            box-sizing: border-box;
            padding: 16px 16px 16px 10px;
            height: 65px;
            background: #363636;
            border-radius: 6px;
            margin-top: 12px;
            display: flex;
            justify-content: space-between;

            .comoros-list-item_right {
                display: flex;
                align-items: center;
            }



        }
    }

    .comoros-list-btn {
        margin: 16px 0 9px;
    }


}


.comoros-list-item_left {
        display: flex;
        vertical-align: middle;
        font-size: 14px;
        line-height: 18px;

        .comoros-list-item_left-img {
            width: 34px;
            height: 34px;
            vertical-align: middle;
            margin-right: 8px;
        }

        .comoros-list-item_left-tips {
            &>img {
                width: 12px;
                height: 12px;
                margin-bottom: 2px;
                margin-right: 5px;
                vertical-align: middle;
            }

            font-size: 12px;
            font-weight: 100;
            vertical-align: middle;

            &.red-time {
                color: #F04646;
            }
        }
    }

::v-deep .van-popup {
    background: transparent;
}
</style>