图片上传

This commit is contained in:
浅念
2025-03-22 17:32:44 +08:00
parent da30bda3b0
commit 93b8f8729b
2 changed files with 21 additions and 7 deletions
+8 -1
View File
@@ -435,12 +435,19 @@
url: 'http://219.157.255.213:9007/upload/uploadImage', url: 'http://219.157.255.213:9007/upload/uploadImage',
filePath: imgUrl, filePath: imgUrl,
name: 'files', name: 'files',
header:{'content-type': 'application/x-www-form-urlencoded','Authorization': 'Bearer ' + uni.getStorageSync('token')}, // header:{'content-type': 'application/x-www-form-urlencoded','Authorization': 'Bearer ' + uni.getStorageSync('token')},
success: (uploadFileRes) => { success: (uploadFileRes) => {
const path=JSON.parse(uploadFileRes.data) const path=JSON.parse(uploadFileRes.data)
if(path.code==-1){
uni.showToast({
title: path.message,
icon: 'none'
});
}else{
that.form[name] = path.data.path that.form[name] = path.data.path
console.log(that.form) console.log(that.form)
} }
}
}); });
}, },
select(e){ select(e){
+11 -4
View File
@@ -165,12 +165,19 @@
uni.uploadFile({ uni.uploadFile({
url: 'http://219.157.255.213:9007/upload/uploadImage', url: 'http://219.157.255.213:9007/upload/uploadImage',
filePath: imgUrl, filePath: imgUrl,
name: 'image', name: 'files',
header:{'content-type': 'application/x-www-form-urlencoded','Authorization': 'Bearer ' + uni.getStorageSync('token')}, // header:{'content-type': 'application/x-www-form-urlencoded','Authorization': 'Bearer ' + uni.getStorageSync('token')},
success: (uploadFileRes) => { success: (uploadFileRes) => {
const path=JSON.parse(uploadFileRes.data) const path=JSON.parse(uploadFileRes.data)
that.userinfo.avatar = path.data.image_url if(path.code==-1){
console.log(that.carinfo) uni.showToast({
title: path.message,
icon: 'none'
});
}else{
that.userinfo.avatar = path.data.path
console.log(that.form)
}
} }
}); });
}, },