BUG 27124

This commit is contained in:
aixianling
2022-02-10 16:24:29 +08:00
parent 77414cadfd
commit af184d3f98

View File

@@ -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))