This commit is contained in:
微微一笑
2025-11-21 14:43:23 +08:00
parent 5b62fd176f
commit fc1fad0579

View File

@ -896,7 +896,7 @@
}, 1500); }, 1500);
} }
//视频上传 //视频上传
let uplploadVideo = (videoPath) => { let uplploadVideo = (videoPath, width, height) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let start = new Date(); let start = new Date();
@ -915,7 +915,9 @@
"clientid": clientid "clientid": clientid
}, },
formData: { formData: {
code: 2 code: 2,
width: width,
height: height
}, },
timeout: 600000, timeout: 600000,
fail: (ex) => { fail: (ex) => {
@ -1147,16 +1149,36 @@
let width = Math.round(res.width); let width = Math.round(res.width);
let height = Math.round(res.height); let height = Math.round(res.height);
let duration = res.duration; 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 = []; let err = [];
if (duration < 2) { if (duration < 2) {
err.push("视频时长至少2秒"); err.push("视频时长至少2秒");
} }
// 使用容差比较允许1像素的误差iOS可能有精度问题 if (!checkResolution(width, height)) {
if (Math.abs(width - 160) > 1 || Math.abs(height - 80) > 1) {
err.push("视频宽高必须是160*80当前分辨率" + width + "*" + height); err.push("视频宽高必须是160*80当前分辨率" + width + "*" + height);
} }
if (err.length > 0) { if (err.length > 0) {
err = err.join(";"); err = err.join(";");
these.showPop({ these.showPop({
@ -1167,11 +1189,12 @@
}); });
return; return;
} }
showLoading(these, { showLoading(these, {
text: '正在上传' text: '正在上传'
}); });
setTimeout(() => { setTimeout(() => {
uplploadVideo(path).then(result => { uplploadVideo(path, width, height).then(result => {
let data = result.data; let data = result.data;
let convertedData = []; let convertedData = [];