视频上传修改优化

This commit is contained in:
xiezhijun 2021-05-10 18:42:13 +08:00
parent 8600f48740
commit 776f8761ad
4 changed files with 38 additions and 4 deletions

View File

@ -398,6 +398,8 @@ public class WechatAppletController extends BaseController {
}
if(StringUtils.isNotEmpty(sysNutritionalVideo.getCoverUrl())){
nutritionalVideoResponse.setCoverUrl(AliyunOSSUtils.generatePresignedUrl(sysNutritionalVideo.getCoverUrl()));
}else{
nutritionalVideoResponse.setCoverUrl(AliyunVideoUtils.getVideoCoverUrl(videoId));
}
nutritionalVideoResponse.setDescription(sysNutritionalVideo.getDescription());
nutritionalVideoResponse.setTags(sysNutritionalVideo.getTags());

View File

@ -238,6 +238,29 @@ public class AliyunVideoUtils {
return result;
}
/**
* 根据VideoId获取封面
* @param videoId
* @return
*/
public static String getVideoCoverUrl(String videoId){
String coverUrl = null;
try{
com.aliyun.vod20170321.Client client = AliyunVideoUtils.createClient();
GetVideoInfoRequest getVideoInfoRequest = new GetVideoInfoRequest()
.setVideoId(videoId);
GetVideoInfoResponse response = client.getVideoInfo(getVideoInfoRequest);
if(response != null){
GetVideoInfoResponseBody body = response.body;
GetVideoInfoResponseBody.GetVideoInfoResponseBodyVideo video = body.video;
coverUrl = video.coverURL;
}
}catch (Exception e){
e.printStackTrace();
}
return coverUrl;
}

View File

@ -9,11 +9,14 @@
:before-upload="beforeAvatarUpload">
<img v-if="imageUrl || coverUrl" :src="imageUrl || coverUrl" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
<div class="el-upload__tip" slot="tip" style="color:#1890ff">
<el-button v-if="imageUrl || coverUrl" size="small" type="danger" @click="removeFile">移除</el-button>
<div>1只能上传pngjpg文件且每个文件不超过{{
upload.fileSize / (1024 * 1024)
}}M</div>
<div style="margin-top:-10px;">{{tips ? ('2、'+tips) : ''}}</div>
<div style="margin-top:5px;">{{tips ? ('2、'+tips) : ''}}</div>
</div>
</el-upload>
</template>
@ -42,7 +45,7 @@ export default {
methods: {
resetUpload(){
this.imageUrl = null;
this.fileUrl = null
this.fileUrl = null;
},
//
handleFileSuccess(response, file, fileList) {
@ -56,6 +59,11 @@ export default {
this.$message.error("文件上传失败");
}
},
removeFile(){
this.resetUpload();
this.coverUrl = null;
this.$emit("callbackMethod", '');
},
//
handleFileFail(err, file, fileList) {
this.$message.error("文件上传失败");

View File

@ -196,7 +196,7 @@
/>
</el-form-item>
<el-form-item label="视频封面" prop="coverUrl">
<UploadFile ref="uploadFile" :prefix="'videoCover'" :coverUrl="form.previewUrl" @callbackMethod="handleCoverUrl"></UploadFile>
<UploadFile ref="uploadFile" v-if="open" :prefix="'videoCover'" :coverUrl="form.previewUrl" @callbackMethod="handleCoverUrl" :tips="'视频未传封面图片时,会主动截取封面,但会存在延迟,请勿直接发布到小程序'"></UploadFile>
</el-form-item>
<el-form-item label="视频类别" prop="cateId">
<el-select v-model="form.cateId" clearable filterable placeholder="请选择类别">
@ -224,7 +224,7 @@
active-text="小程序展示"
inactive-text="小程序不展示">
</el-switch>
<div>提示请保证内容正确再展示到小程序</div>
<div style="color:red">提示请保证内容正确再展示到小程序</div>
</el-form-item>
</el-form>
@ -440,6 +440,7 @@
},
handleCoverUrl(url){
this.form.coverUrl = url;
console.log(this.form.coverUrl);
},
/** 删除按钮操作 */
handleDelete(row) {