视频时长限制

This commit is contained in:
丁杰 2026-05-06 15:18:55 +08:00
parent 3e9235844a
commit 2836b0712f
1 changed files with 3 additions and 1 deletions

View File

@ -67,6 +67,7 @@ const handleUpload = async (userId, type, sourceType = ['album', 'camera'], uplo
// ========== 【核心新增:图片比例校验 结束】 ========== // ========== 【核心新增:图片比例校验 结束】 ==========
} else if (uploadType == 'video') { } else if (uploadType == 'video') {
const res = await uni.chooseVideo({ const res = await uni.chooseVideo({
maxDuration:60,
count: 1, count: 1,
sourceType: ['album', 'camera'], sourceType: ['album', 'camera'],
compressed: false compressed: false
@ -77,6 +78,7 @@ const handleUpload = async (userId, type, sourceType = ['album', 'camera'], uplo
// #ifdef APP-PLUS || MP-WEIXIN // #ifdef APP-PLUS || MP-WEIXIN
file = res; file = res;
// #endif // #endif
console.log(res,'resresres');
const duration = res.duration; const duration = res.duration;
if (duration < 3) { if (duration < 3) {
uni.showToast({ uni.showToast({
@ -85,7 +87,7 @@ const handleUpload = async (userId, type, sourceType = ['album', 'camera'], uplo
}); });
return null; return null;
} }
if (duration > 59.9) { if (duration > 61) {
uni.showToast({ uni.showToast({
title: "视频时长不能超过1分钟", title: "视频时长不能超过1分钟",
icon: "none", icon: "none",