submit() {
let files = [];
let url = config.baseUrl + '/input/hiddendanger';
let {
sourceName,
hiddendangerLocation,
hiddendangerDescription,
possibleHarm,
targetTask
} = this.form
let formData = {
...this.form1,
sourceName,
hiddendangerLocation,
hiddendangerDescription,
possibleHarm,
targetTask
}
this.$refs.form.validate().then(res => {
this.fileList.forEach(item=>{
files.push({
name:'problemAttachment',
uri:item.url
})
})
this.fileList1.forEach(item=>{
files.push({
name:'problemAttachment1',
uri:item.url
})
})
uni.uploadFile({
url,
header: {
'Authorization': 'Bearer ' + getToken()
},
filePath:'', // 必须添加这个属性
files,
formData,
success: (res) => {
let data = JSON.parse(res.data);
if (data.code === 200) {
uni.showToast({
title: '录入成功',
duration: 2000
});
} else {
uni.showToast({
title: '录入失败',
type: 'error'
});
}
}
})
}).catch(errors => {
uni.$u.toast('校验失败')
})
}
filePath:'', // 必须添加这个属性(记录一下这个踩到的坑)