修复上传组件

This commit is contained in:
aixianling
2022-02-25 11:15:38 +08:00
parent 78e6ad0292
commit 6c7c9f5da6

View File

@@ -51,7 +51,7 @@ export default {
fileId: String, fileId: String,
mediaId: String, mediaId: String,
def: {default: () => []}, def: {default: () => []},
action: {default: '/app/wxcp/upload/uploadFile'}, action: {default: '/admin/file/add'},
preview: Boolean, preview: Boolean,
size: {default: 10 * 1024 * 1024}, size: {default: 10 * 1024 * 1024},
disabled: Boolean, disabled: Boolean,
@@ -124,7 +124,7 @@ export default {
uni.hideLoading() uni.hideLoading()
} else { } else {
uni.uploadFile({ uni.uploadFile({
url: this.$instance.defaults.baseURL + '/admin/file/add', url: this.$instance.defaults.baseURL + this.action,
filePath: img, filePath: img,
name: 'file', name: 'file',
header: { header: {
@@ -137,10 +137,10 @@ export default {
if (res?.data) { if (res?.data) {
this.$emit('data', res.data) this.$emit('data', res.data)
this.$u.toast('上传成功!') this.$u.toast('上传成功!')
if (this.action == '/app/wxcp/upload/uploadFile') { if (this.action == '/admin/file/add') {
this.$emit('update:mediaId', res.data?.media?.mediaId) this.fileList.push({url: res.data?.split(";")?.[0], id: res.data?.split(";")?.[1]})
this.$emit('update:fileId', res.data.file.id) this.$emit('input', [...this.fileList])
this.fileList.push(res.data.file) this.$emit('change', [...this.fileList])
} else if (this.action == '/admin/file/add2') { } else if (this.action == '/admin/file/add2') {
let info = res.data let info = res.data
this.$emit('update:fileId', info?.id) this.$emit('update:fileId', info?.id)
@@ -150,8 +150,6 @@ export default {
} }
this.$emit("update:def", this.fileList) this.$emit("update:def", this.fileList)
this.$emit("list", this.fileList) this.$emit("list", this.fileList)
this.$emit('input', [...this.fileList])
this.$emit('change', [...this.fileList])
} else { } else {
this.$u.toast(res.msg) this.$u.toast(res.msg)
} }