diff --git a/pages/6155/deviceDetail.vue b/pages/6155/deviceDetail.vue index 952b0be..e1103dc 100644 --- a/pages/6155/deviceDetail.vue +++ b/pages/6155/deviceDetail.vue @@ -896,7 +896,7 @@ }, 1500); } //视频上传 - let uplploadVideo = (videoPath) => { + let uplploadVideo = (videoPath, width, height) => { return new Promise((resolve, reject) => { let start = new Date(); @@ -915,7 +915,9 @@ "clientid": clientid }, formData: { - code: 2 + code: 2, + width: width, + height: height }, timeout: 600000, fail: (ex) => { @@ -1147,16 +1149,36 @@ let width = Math.round(res.width); let height = Math.round(res.height); let duration = res.duration; - console.log("视频信息 - 宽度:", width, "高度:", height, "时长:", duration); + + // 获取平台信息 + const systemInfo = uni.getSystemInfoSync(); + const platform = systemInfo.platform; + const isIOS = platform === 'ios'; + + console.log("平台:", platform, "uni.chooseVideo返回 - 宽度:", width, "高度:", height, "时长:", duration); + + // iOS特殊处理:如果返回的是80*40,很可能是160*80的一半(iOS的bug) + if (isIOS && width === 80 && height === 40) { + console.log("检测到iOS特殊情况:返回80*40,实际应该是160*80,进行修正"); + width = 160; + height = 80; + } + + // 检查分辨率是否符合要求 + let checkResolution = (w, h) => { + // 使用容差比较,允许1像素的误差 + return Math.abs(w - 160) <= 1 && Math.abs(h - 80) <= 1; + }; + let err = []; if (duration < 2) { err.push("视频时长至少2秒"); } - // 使用容差比较,允许1像素的误差(iOS可能有精度问题) - if (Math.abs(width - 160) > 1 || Math.abs(height - 80) > 1) { + if (!checkResolution(width, height)) { err.push("视频宽高必须是160*80,当前分辨率:" + width + "*" + height); } + if (err.length > 0) { err = err.join(";"); these.showPop({ @@ -1167,11 +1189,12 @@ }); return; } + showLoading(these, { text: '正在上传' }); setTimeout(() => { - uplploadVideo(path).then(result => { + uplploadVideo(path, width, height).then(result => { let data = result.data; let convertedData = [];