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