<template>
    <div class="uploadAlCloud">
        <el-upload
                ref="upload"
                action="aaa"
                class="avatar-uploader"
                :http-request="uploadFileImage"
                :show-file-list="false">
            <img v-if="imageUrl" :src="imageUrl" class="avatar" alt="头像">
            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
    </div>
</template>

<script>
    export default {
        name: "UploadAlCloud",
        props: {
            imageUrl: {
                type: String,
                default: '',
            },
        },
        methods: {
            // 自定义上传
            uploadFileImage(params) {
                this.$emit('uploadFileStart', params);
            }
        }
    }
</script>

<style lang="scss">
    .uploadAlCloud {
        display: block;

        .avatar-uploader .el-upload {
            border: 1px dashed #d9d9d9;
            border-radius: 6px;
            cursor: pointer;
            position: relative;
            overflow: hidden;
        }
        /*.avatar-uploader .el-upload:hover {
            border-color: #409EFF;
        }*/
        .avatar-uploader-icon {
            font-size: 28px;
            color: #8c939d;
            width: 178px;
            height: 178px;
            line-height: 178px;
            text-align: center;
        }
        .avatar {
            width: 178px;
            height: 178px;
            display: block;
        }
        @media screen and (max-width: 1440px){
            .avatar{
                width: 140px; // 必须指定宽高
                height: 140px;
                line-height: 140px;
            }
            .avatar-uploader-icon{
                width: 140px;
                height: 140px;
                line-height: 140px;
            }
        }
    }
</style>
