修复上传组件
This commit is contained in:
@@ -119,16 +119,21 @@ export default {
|
|||||||
return this.$u.toast(`不能超过${Math.ceil(this.size / 1024 / 1024)}MB`)
|
return this.$u.toast(`不能超过${Math.ceil(this.size / 1024 / 1024)}MB`)
|
||||||
}
|
}
|
||||||
uni.showLoading({title: '上传中'})
|
uni.showLoading({title: '上传中'})
|
||||||
let formData = new FormData()
|
|
||||||
formData.append('file', img)
|
|
||||||
if (this.manual) {
|
if (this.manual) {
|
||||||
this.$emit('manual', img)
|
this.$emit('manual', img)
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
} else {
|
} else {
|
||||||
this.$http.post(this.action, formData, {
|
uni.uploadFile({
|
||||||
params: {type: this.type},
|
url: this.$instance.defaults.baseURL + '/admin/file/add',
|
||||||
}).then((res) => {
|
filePath: img,
|
||||||
|
name: 'file',
|
||||||
|
header: {
|
||||||
|
'Content-Type': 'multipart/form-data',
|
||||||
|
Authorization: uni.getStorageSync('token'),
|
||||||
|
},
|
||||||
|
success: response => {
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
|
const res = JSON.parse(response.data)
|
||||||
if (res?.data) {
|
if (res?.data) {
|
||||||
this.$emit('data', res.data)
|
this.$emit('data', res.data)
|
||||||
this.$u.toast('上传成功!')
|
this.$u.toast('上传成功!')
|
||||||
@@ -145,12 +150,12 @@ 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)
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
}
|
||||||
this.$u.toast(err)
|
|
||||||
uni.hideLoading()
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user