//上传照片
async afterRead(event) {
let lists = [].concat(event.file);
let index = lists.length+1;
for (let i = 0; i < lists.length; i++) {
const result = await this.uploadFilePromise(lists[i].url);
this.fileListUrl.splice(index, 1, {
status: 'success',
message: '',
url:result
});
}
},
//上传图片
uploadFilePromise(url) {
return new Promise((resolve, reject) => {
uni.uploadFile({
url: '', //接口地址,
filePath: url,
name: 'file',
header: {
'Authorization': uni.getStorageSync("token"),
"Content-Type": "multipart/form-data",
},
success: ({data:res}) => {
if(JSON.parse(res).code==200){
this.formData.images.push(JSON.parse(res).data.id);
this.carPicArr.push(JSON.parse(res).data.id);
resolve('https://'+JSON.parse(res).data.imageUrl);
}else{
reject(JSON.parse(res).msg);
}
}
});
});
},