diff --git a/src/components/AiUploader/AiUploader.vue b/src/components/AiUploader/AiUploader.vue index 91c94ca..11b3f0c 100644 --- a/src/components/AiUploader/AiUploader.vue +++ b/src/components/AiUploader/AiUploader.vue @@ -87,31 +87,36 @@ export default { this.$emit('list', this.fileList) }, upload(wait) { - let params = { - count: this.limit, - sizeType: ['compressed'], - sourceType: ['album', 'camera'], - success: (res) => { - let count = this.fileList?.length + (res.tempFiles?.length || res.tempFile ? 1 : 0) - if (count > this.limit && this.limit !== 1) { - return this.$u.toast(`不能超过${this.limit}个`) - } - if (res.tempFiles) { - res.tempFiles?.map((item) => { - this.uploadFile(item) - }) - } else if (res?.tempFile) { - this.uploadFile(res.tempFile) - } - }, - } - typeof wait == 'function' && wait() - if (this.type == 'image') { - uni.chooseImage(params) - } else if (this.type == 'video') { - uni.chooseVideo(params) - } else { - uni.chooseFile(params) + let count = this.limit - (this.fileList?.length||0) + if(count>0){ + let params = { + count, + sizeType: ['compressed'], + sourceType: ['album', 'camera'], + success: (res) => { + let count = this.fileList?.length + (res.tempFiles?.length || res.tempFile ? 1 : 0) + if (count > this.limit && this.limit !== 1) { + return this.$u.toast(`不能超过${this.limit}个`) + } + if (res.tempFiles) { + res.tempFiles?.map((item) => { + this.uploadFile(item) + }) + } else if (res?.tempFile) { + this.uploadFile(res.tempFile) + } + }, + } + typeof wait == 'function' && wait() + if (this.type == 'image') { + uni.chooseImage(params) + } else if (this.type == 'video') { + uni.chooseVideo(params) + } else { + uni.chooseFile(params) + } + }else{ + this.$u.toast(`不能超过${this.limit}个`) } }, uploadFile(img) {