
接口视频上传
<template>
<div class="component-upload-video">
<el-upload
class="avatar-uploader"
:action="uploadImgUrl"
:on-progress="uploadVideoProcess"
:on-success="handleUploadSuccess"
:limit="limit"
:file-list="fileList"
:before-upload="handleBeforeUpload"
:show-file-list="false"
:headers="headers"
ref="uploadRef"
>
<video
v-if="videoForm.showVideoPath && !videoFlag"
:src="videoForm.showVideoPath"
class="avatar video-avatar"
controls="controls"
>
您的浏览器不支持视频播放
</video>
<!--
<i
v-else-if="!videoForm.showVideoPath && !videoFlag"
class="el-icon-plus avatar-uploader-icon"
></i>
<el-progress
v-if="videoFlag == true"
type="circle"
:percentage="videoUploadPercent"
style="margin-top: 7px"
></el-progress>
</el-upload>
<el-button
v-if="isShowBtn && videoForm.showVideoPath"
class="mt-20"
plain
round
@click="handleDelete"
size="small"
type="primary"
>重新上传<i class="el-icon-upload el-icon--right"></i
></el-button>
</div>
</template>
<script>
import {
getToken } from "@/utils/auth";
export default {
props: {
value: [String, Object, Array],
limit: {
type: Number,
default: 5,
},
fileSize: {
type: Number,
default: 50,
},
indexValue: {
type: Number,
default: null,
},
fileType: {
type: Array,
default: () => ["video/mp4", "video/ogg", "video/flv"],
},
isShowTip: {
type: Boolean,
default: false,
},
isShowUploadVideo: {
type: Boolean,
default: false,
},
isShowBtn: {
type: Boolean,
default: true,
},
},
data() {
return {
number: 0,
dialogVisible: false,
hideUpload: false,
uploadImgUrl: process.env.VUE_APP_BASE_API + "/file/upload",
headers: {
Authorization: "Bearer " + getToken(),
},
fileList: [],
videoForm: {
showVideoPath: "",
},
duration: 0,
videoFlag: false,
videoUploadPercent: 0,
};
},
watch: {
value: {
handler(val) {
if (val) {
this.videoForm.showVideoPath = val;
const list = Array.isArray(val) ? val : this.value.split(",");
this.fileList = list.map((item) => {
if (typeof item === "string") {
item = {
name: item, url: item };
}
return item;
});
} else {
this.fileList = [];
return [];
}
},
deep: true