<template>
    <div class="mp4">
        <div class="flex flex-wrap justify-between video-list">
            <div v-for="item in files" :key="item.annexId">
                <div class="item">
                    <div class="shrink-0 play-bt" @click="start(item)">
                        <doc-icon type="doc-play" />
                    </div>
                </div>
                <div v-if="item.annexFileName" class="text-12 mb-1 text-ellipsis">{{ item.annexFileName }}</div>
            </div>
        </div>
        <van-popup v-model:show="visible" :close-on-click-overlay="false" closeable>
            <video controls width="100%" v-if="visible">
                <source :src="activeVideo.annexUrl" type="video/mp4" />
                播放失败!
            </video>
        </van-popup>
    </div>
</template>

<script>
export default {
    props: {
        files: { default: () => [] }
    },
    data() {
        return {
            visible: false,
            activeVideo: {}
        }
    },
    methods: {
        start(item) {
            this.activeVideo = item
            this.visible = true
        }
    }
}
</script>

<style lang="less" scoped>
.video-list {
    >div {
        width: calc(50% - 5px);
        .item {
            background: url('@/assets/image/residentWX/video-default.png') no-repeat;
            height: .84rem;
            display: flex;
            align-items: center;
            justify-content: center;
        }
    }
    .play-bt {
        display: inline-flex;
        width: 36px;
        height: 36px;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background-color: #E4F2F0;
        font-size: 15px;
        padding-left: 2px;
    }
}
</style>
