|
|
|
|
@ -80,14 +80,33 @@ export default { |
|
|
|
|
this.$refs.BetLoading.show() |
|
|
|
|
// 成功选择图片后的回调 |
|
|
|
|
const tempFilePaths = res.tempFilePaths; |
|
|
|
|
|
|
|
|
|
uni.compressImage({ |
|
|
|
|
src: tempFilePaths[0], // 图片路径 |
|
|
|
|
quality: 50, // 压缩质量,范围为0 - 100,100为不压缩 |
|
|
|
|
success: (compressRes) => { |
|
|
|
|
const compressedFilePath = compressRes.tempFilePath; |
|
|
|
|
this.uploadFile(compressedFilePath); |
|
|
|
|
// 使用uni.getFileInfo获取文件信息 |
|
|
|
|
uni.getFileInfo({ |
|
|
|
|
filePath: compressedFilePath, |
|
|
|
|
success: (infoRes) => { |
|
|
|
|
// 获取文件大小,单位为字节 |
|
|
|
|
const size = infoRes.size / 1024 / 1024; // 计算文件大小(单位:M) |
|
|
|
|
if (size > 3) { |
|
|
|
|
uni.showToast({ title: '图片大小不能超过3M', icon: 'none' }); |
|
|
|
|
} else { |
|
|
|
|
this.uploadFile(compressedFilePath); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
fail: (err) => { |
|
|
|
|
console.error('获取文件信息失败:', err); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
@ -97,15 +116,32 @@ export default { |
|
|
|
|
sourceType: ["album", "camera"], |
|
|
|
|
success: (res) => { |
|
|
|
|
this.$refs.BetLoading.show() |
|
|
|
|
const tempFilePaths = res.tempFilePaths; |
|
|
|
|
const tempFilePaths = res.tempFilePath; |
|
|
|
|
// 成功选择视频后的回调 |
|
|
|
|
// this.uploadFile(res.tempFilePath); |
|
|
|
|
uni.compressVideo({ //压缩视频 |
|
|
|
|
src:tempFilePaths, |
|
|
|
|
quality:1, |
|
|
|
|
success:(compressRes)=>{ |
|
|
|
|
this.uploadFile(compressRes.tempFilePath); |
|
|
|
|
src: tempFilePaths, |
|
|
|
|
quality: '1', |
|
|
|
|
success: (compressRes) => { |
|
|
|
|
uni.getFileInfo({ |
|
|
|
|
filePath: compressRes.tempFilePath, |
|
|
|
|
success: (infoRes) => { |
|
|
|
|
// 获取文件大小,单位为字节 |
|
|
|
|
const size = infoRes.size / 1024 / 1024; // 计算文件大小(单位:M) |
|
|
|
|
if (size > 50) { |
|
|
|
|
uni.showToast({ title: '视频大小不能超过50M', icon: 'none' }); |
|
|
|
|
} else { |
|
|
|
|
this.uploadFile(compressRes.tempFilePath); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
fail: (err) => { |
|
|
|
|
console.error('获取文件信息失败:', err); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
fail:(err)=>{ |
|
|
|
|
console.log(666,err) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|