图片,视频,文件大小限制
This commit is contained in:
@@ -315,15 +315,34 @@ export default {
|
|||||||
sizeType: ['compressed'],
|
sizeType: ['compressed'],
|
||||||
sourceType: ['album'],
|
sourceType: ['album'],
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
|
console.log(res);
|
||||||
let count = this.files?.length + (res.tempFiles?.length || res.tempFile ? 1 : 0)
|
let count = this.files?.length + (res.tempFiles?.length || res.tempFile ? 1 : 0)
|
||||||
if (count > 9) {
|
if (count > 9) {
|
||||||
return this.$u.toast(`不能超过9个`)
|
return this.$u.toast(`不能超过9个`)
|
||||||
}
|
}
|
||||||
|
let maxImage = 10 * 1024 // 10M
|
||||||
|
let maxVideo = 10 * 1024 // 10M
|
||||||
|
let maxFile = 20 * 1024 // 20M
|
||||||
if (res.tempFiles) {
|
if (res.tempFiles) {
|
||||||
|
if(type == "image") {
|
||||||
|
if(res.tempFiles.every(e=> e.size > maxImage)) {
|
||||||
|
return this.$u.toast(`图片最大不能超过10M`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(type == "file") {
|
||||||
|
if(res.tempFiles.every(e=> e.size > maxFile)) {
|
||||||
|
return this.$u.toast(`文件最大不能超过20M`)
|
||||||
|
}
|
||||||
|
}
|
||||||
res.tempFiles?.map((item) => {
|
res.tempFiles?.map((item) => {
|
||||||
this.uploadFile(item,type)
|
this.uploadFile(item,type)
|
||||||
})
|
})
|
||||||
} else if (res?.tempFile) {
|
} else if (res?.tempFile) {
|
||||||
|
if(type == "video") {
|
||||||
|
if(res.tempFile.size > maxVideo) {
|
||||||
|
return this.$u.toast(`视频最大不能超过10M`)
|
||||||
|
}
|
||||||
|
}
|
||||||
this.uploadFile(res.tempFile,type)
|
this.uploadFile(res.tempFile,type)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user