vue elementui 上传视频 以及上传视频失败重新上传没反应的处理方法

news/2024/9/8 11:10:02

<template><el-drawertitle="上传视频"size="50%":visible.sync="drawer":direction="direction"><div class="content"><div class="upload-box" v-if="!secondStep"><!--on-exceed:超出数量限制时的钩子file-list:上传的文件列表          --><el-uploadclass="upload-demo"drag:data="uploadData":action="actionUrl":headers="headers":on-success="handleSuccess":on-error="handleError":before-upload="beforeUpload":file-list="fileList":limit="1"accept=".mp4,.mov,.mpeg,.avi"><i class="el-icon-upload"></i><div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div><div class="el-upload__tip" slot="tip"><div>(1) 文件大小: 最大 500 MB。</div><div>(2) 比例:9:16, 16:9 和 1:1。</div><div>(3) 格式:.mp4, .mov, .mpeg, .avi。</div><div>投放位置为TikTok限制:分辨率大于720*1280 px , 码率大于 516 Kbps , 时长 5-60s。</div></div></el-upload></div><div class="batch-box" v-if="secondStep"><el-tableref="multipleTable":data="fileList"tooltip-effect="dark"style="width: 100%"@selection-change="handleSelectionChange"><el-table-columntype="selection"width="55"></el-table-column><el-table-column label="文件名"><template slot-scope="scope"><div class="video-mes"><div class="video-mes-lef"><img :src="scope.row.video_cover_url" /></div><div class="video-mes-rig"><div class="name-box">{{ scope.row.file_name }}<!-- <i class="el-icon-edit"></i> --></div><div class="video-mes-cont"><span>{{ scope.row.duration }}</span> | <span>{{ scope.row.width }}*{{ scope.row.height }}</span> | <span>{{ scope.row.bit_rate }} Mbps</span> | <span>{{ scope.row.size }} MB</span></div></div>                </div></template></el-table-column><!-- <el-table-columnprop="name"label="广告位要求校验"width="180"><template slot-scope="scope"><i class="el-icon-circle-check"></i><i class="el-icon-circle-close"></i>准备好上传</template></el-table-column><el-table-columnprop="status"label="状态" width="180"><template slot-scope="scope"><i class="el-icon-circle-check"></i><i class="el-icon-circle-close"></i>准备好上传</template></el-table-column><el-table-columnprop="remark"label="需要解决的问题"></el-table-column> --></el-table></div></div><div class="demo-drawer__footer"><div class="footer-lef">选择了 {{ multipleSelection.length }}/{{ fileList.length }}</div><div class="footer-rig"><el-button @click="cancelForm">取 消</el-button><el-button type="primary" @click="dataFormSubmit" >上传</el-button></div></div>
</el-drawer>
</template>
<script>//import { filetiktokupload } from "@/api/advertising/index";import store from "@/store";export default {data() {return {          actionUrl: '/api/file/tiktok/upload',headers: {agent_token: store.getters.access_token,},fileList: [],  // 存储上传的文件列表uploadData: {advertiserId: '', // Replace with actual advertiserIdtype: 'video'       // Replace with actual type if necessary},secondStep: false,multipleSelection: [],advertiser_id: "",checkedItem: null,checkedIndex: null,     checked: false,         drawer: false,loading:false,    direction: 'rtl',    };},methods: {init(advertiserId){this.reset()this.uploadData.advertiserId = advertiserIdthis.drawer = true;},      reset(){this.secondStep = falsethis.fileList = []//视频上传失败的时候 该字段重置才能重新上传this.multipleSelection = []        },beforeUpload(file) {const isVideo = file.type.indexOf('video/') > -1;const isLt1G = file.size / 1024 / 1024 / 1024 < 0.5;  // 限制文件大小为500Mbif (!isVideo) {this.$message.error('上传文件只能是视频格式!');return false;}if (!isLt1G) {this.$message.error('上传视频大小不能超过500Mb!');return false;}return true;},handleError(err, file, fileList){this.init()},handleSuccess(response, file, fileList) {if(response.code == 0){let info = response.datathis.$message.success('视频上传成功')this.fileList = []this.fileList.push({            video_id: info.video_id,video_cover_url: info.video_cover_url,preview_url: info.preview_url,file_name: info.file_name,width: info.width,height: info.height,duration: info.duration,bit_rate: (info.bit_rate/1024/1024).toFixed(2),size: (info.size/1024/1024).toFixed(2)})this.secondStep = true}else if(response.code == -1){this.$message.error('上传视频失败,请重试');this.init(this.uploadData.advertiserId)}},handleSelectionChange(val) {this.multipleSelection = val;},dataFormSubmit(){                if(this.multipleSelection.length == 0) {this.$message.error('请选择上传的文件');return}this.$emit("refreshDataList", this.multipleSelection);this.drawer = false;},cancelForm(){this.reset()this.drawer = false;},}};
</script>
<style scoped>
.video-mes-lef{ margin-right: 20px; width: 60px; height: 60px;}
.video-mes-lef img{ width: 100%; height: 100%; object-fit: contain;}
.video-mes{ display: flex; align-items: center;}
.content >>> .el-upload, .content >>> .el-upload-dragger{ width: 100%;}
.content >>> .el-upload-dragger{ height: 267px;}
.content >>> .el-upload-dragger .el-icon-upload{ margin-top: 90px;}
.el-icon-circle-check,.el-icon-circle-close{ margin-right: 6px;}
.el-icon-circle-check{ color: green}
.el-icon-circle-close{ color: red}
.el-icon-edit{ font-size: 14px;}
.footer-lef{ font-size: 14px;}
.content{ padding: 0 20px; height: calc(100% - 50px); overflow-y: scroll;}
>>>.demo-drawer__footer{padding: 0 20px;display: flex;align-items: center;justify-content: space-between;
}
>>>.el-drawer__header{border-bottom: 1px solid #EBEEF5;padding-bottom: 15px;
}
</style>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.cpky.cn/p/14937.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈,一经查实,立即删除!

相关文章

uniapp手写滚动选择器

文章目录 效果展示HTML/Template部分&#xff1a;JavaScript部分&#xff1a;CSS部分&#xff1a;完整代码 没有符合项目要求的选择器 就手写了一个 效果展示 实现一个时间选择器的功能&#xff0c;可以选择小时和分钟&#xff1a; HTML/Template部分&#xff1a; <picker…

企业获客重要途径-大数据获客系统

企业获客的重要途径之一是通过大数据获客系统。这一系统利用大数据技术和分析方法&#xff0c;帮助企业更精准地获取客户&#xff0c;提高市场营销的效率和效果。 所以整理了以下是大数据获客系统作为企业获客重要途径的详细阐述&#xff1a; 一、大数据获客系统的定义与功能…

Redis底层数据结构-简单动态字符串SDS

简单动态字符串&#xff08;simple dynamic string&#xff0c;SDS&#xff09;。Redis没有直接使用C语言传统的字符串&#xff0c;而是自己构建了一种简单动态字符串(SDS)的抽象类型。C字符串只会作为字符串字面量&#xff08;string literal&#xff09;用在一些无须对字符串…

mesa LLVMpipe ORCJIT 上游化:一场历时两年的后端合并马拉松,幕后英雄竟是 TA!

内容来源&#xff1a;deepin&#xff08;深度&#xff09;社区 近日&#xff0c;mesa 开源图形驱动合并了 llvmpipe 的 ORCJIT 后端的 Merge Request (MR)&#xff0c;并实现了对 riscv64 架构的支持。 LLVMpipe 是什么&#xff1f; LLVMpipe 是 mesa 驱动中的一种软件渲染器…

短视频矩阵系统,一键智能成片

在信息爆炸的时代&#xff0c;短视频以其短平快的特点迅速崛起&#xff0c;成为人们获取信息、娱乐消遣的重要渠道。然而&#xff0c;如何在这个竞争激烈的领域中脱颖而出&#xff0c;制作出吸引眼球的爆款视频呢&#xff1f;今天&#xff0c;我们就来揭秘一款神奇的短视频矩阵…

灰色关联分析【系统分析+综合评价】

系统分析&#xff1a; 判断哪个因素影响最大 基本思想&#xff1a;根据序列曲线几何形状的相似程度来判断其练习是否紧密 绘制统计图并进行分析 确定子序列和母序列 对变量进行预处理&#xff08;去量纲、缩小变量范围&#xff09; 熟练使用excel与其公式和固定&#xff08…