const Pluse = ref(true);
const videoUploadPercent = ref(0);
const videoFlag = ref(false);
const videoForm = ref({
videoId: '',
videoUrl: '',
});
const beforeUploadVideo = (file) => {
//文件大小
const isLt300M = file.size / 1024 / 1024 < 300;
//视频后缀检查
if (['video/mp4', 'video/ogg', 'video/flv', 'video/avi', 'video/wmv', 'video/rmvb'].indexOf(file.type) === -1) {
error('请上传正确的视频格式');
return false;
}
if (!isLt300M) {
error('上传视频大小不能超过300MB哦!');
return false;
}
};
const uploadVideoProcess = (event, file, fileList) => {
Pluse.value = false;
videoFlag.value = true;
videoUploadPercent.value = +file.percentage.toFixed(0);
};
const handleVideoSuccess = (res, file) => {
Pluse.value = false;
videoUploadPercent.value = 100;
console.log(res);
// 如果为200代表视频保存成功
if (res.code == '1') {
// 接收视频传回来的名称和保存地址
// 至于怎么使用看你啦~
videoForm.value.videoId = res.msg;
videoForm.value.videoUrl = 'xxxxxx' + res.data.url;
console.log(videoForm.value.videoUrl);
success('视频上传成功!');
} else {
error('视频上传失败,请重新上传!');
}
};