From af184d3f985db0a2df02ff7ed036e236040309a1 Mon Sep 17 00:00:00 2001 From: aixianling Date: Thu, 10 Feb 2022 16:24:29 +0800 Subject: [PATCH] BUG 27124 --- src/components/AiUploader.vue | 56 ++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/src/components/AiUploader.vue b/src/components/AiUploader.vue index aa59ba3b..6dddb783 100644 --- a/src/components/AiUploader.vue +++ b/src/components/AiUploader.vue @@ -54,7 +54,7 @@ export default { action: {default: '/app/wxcp/upload/uploadFile'}, preview: Boolean, size: {default: 10 * 1024 * 1024}, - disabled: Boolean + disabled: Boolean, }, computed: { ...mapState(['token']), @@ -121,31 +121,39 @@ export default { uni.showLoading({title: '上传中'}) let formData = new FormData() formData.append('file', img) - this.$http.post(this.action, formData, { - params: {type: this.type}, - }).then((res) => { + if (this.manual) { + this.$emit('manual', img) uni.hideLoading() - if (res?.data) { - this.$emit('data', res.data) - this.$u.toast('上传成功!') - if (this.action == '/app/wxcp/upload/uploadFile') { - this.$emit('update:mediaId', res.data?.media?.mediaId) - this.$emit('update:fileId', res.data.file.id) - this.fileList.push(res.data.file) - } else if (this.action == '/admin/file/add2') { - let info = res.data - this.$emit('update:fileId', info?.id) - this.fileList.push(res.data) + } else { + this.$http.post(this.action, formData, { + params: {type: this.type}, + }).then((res) => { + uni.hideLoading() + if (res?.data) { + this.$emit('data', res.data) + this.$u.toast('上传成功!') + if (this.action == '/app/wxcp/upload/uploadFile') { + this.$emit('update:mediaId', res.data?.media?.mediaId) + this.$emit('update:fileId', res.data.file.id) + this.fileList.push(res.data.file) + } else if (this.action == '/admin/file/add2') { + let info = res.data + this.$emit('update:fileId', info?.id) + this.fileList.push(res.data) + } else if (this.action == '/admin/file/add-portrait') { + this.fileList.push({url: res.data?.split(";")?.[0], id: res.data?.split(";")?.[1]}) + } + this.$emit("update:def", this.fileList) + this.$emit("list", this.fileList) + } else { + this.$u.toast(res.msg) } - this.$emit("update:def", this.fileList) - this.$emit("list", this.fileList) - } else { - this.$u.toast(res.msg) - } - }).catch(err => { - this.$u.toast(err) - uni.hideLoading() - }) + }).catch(err => { + this.$u.toast(err) + uni.hideLoading() + }) + } + }, handleReUpload(i) { this.upload(() => this.remove(i))