上传组件限制
This commit is contained in:
@@ -88,32 +88,38 @@ export default {
|
|||||||
this.$emit('list', this.fileList)
|
this.$emit('list', this.fileList)
|
||||||
},
|
},
|
||||||
upload(wait) {
|
upload(wait) {
|
||||||
let params = {
|
let count = this.limit - (this.fileList?.length||0)
|
||||||
count: this.limit,
|
if(count>0){
|
||||||
sizeType: ['compressed'],
|
let params = {
|
||||||
sourceType: [this.sourceType].flat(),
|
count,
|
||||||
success: (res) => {
|
sizeType: ['compressed'],
|
||||||
let count = this.fileList?.length + (res.tempFiles?.length || res.tempFile ? 1 : 0)
|
sourceType: [this.sourceType].flat(),
|
||||||
if (count > this.limit && this.limit !== 1) {
|
success: (res) => {
|
||||||
return this.$u.toast(`不能超过${this.limit}个`)
|
let count = this.fileList?.length + (res.tempFiles?.length || res.tempFile ? 1 : 0)
|
||||||
}
|
if (count > this.limit && this.limit !== 1) {
|
||||||
if (res.tempFiles) {
|
return this.$u.toast(`不能超过${this.limit}个`)
|
||||||
res.tempFiles?.map((item) => {
|
}
|
||||||
this.uploadFile(item)
|
if (res.tempFiles) {
|
||||||
})
|
res.tempFiles?.map((item) => {
|
||||||
} else if (res?.tempFile) {
|
this.uploadFile(item)
|
||||||
this.uploadFile(res.tempFile)
|
})
|
||||||
}
|
} else if (res?.tempFile) {
|
||||||
},
|
this.uploadFile(res.tempFile)
|
||||||
}
|
}
|
||||||
typeof wait == 'function' && wait()
|
},
|
||||||
if (this.type == 'image') {
|
}
|
||||||
uni.chooseImage(params)
|
typeof wait == 'function' && wait()
|
||||||
} else if (this.type == 'video') {
|
if (this.type == 'image') {
|
||||||
uni.chooseVideo(params)
|
uni.chooseImage(params)
|
||||||
} else {
|
} else if (this.type == 'video') {
|
||||||
uni.chooseFile(params)
|
uni.chooseVideo(params)
|
||||||
|
} else {
|
||||||
|
uni.chooseFile(params)
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
this.$u.toast(`不能超过${this.limit}个`)
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
uploadFile(img) {
|
uploadFile(img) {
|
||||||
if (this.size > 0 && img.size > this.size) {
|
if (this.size > 0 && img.size > this.size) {
|
||||||
|
|||||||
Reference in New Issue
Block a user