图片上传

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
+10 -3
View File
@@ -435,11 +435,18 @@
url: 'http://219.157.255.213:9007/upload/uploadImage',
filePath: imgUrl,
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) => {
const path=JSON.parse(uploadFileRes.data)
that.form[name] = path.data.path
console.log(that.form)
if(path.code==-1){
uni.showToast({
title: path.message,
icon: 'none'
});
}else{
that.form[name] = path.data.path
console.log(that.form)
}
}
});
},
+11 -4
View File
@@ -165,12 +165,19 @@
uni.uploadFile({
url: 'http://219.157.255.213:9007/upload/uploadImage',
filePath: imgUrl,
name: 'image',
header:{'content-type': 'application/x-www-form-urlencoded','Authorization': 'Bearer ' + uni.getStorageSync('token')},
name: 'files',
// header:{'content-type': 'application/x-www-form-urlencoded','Authorization': 'Bearer ' + uni.getStorageSync('token')},
success: (uploadFileRes) => {
const path=JSON.parse(uploadFileRes.data)
that.userinfo.avatar = path.data.image_url
console.log(that.carinfo)
if(path.code==-1){
uni.showToast({
title: path.message,
icon: 'none'
});
}else{
that.userinfo.avatar = path.data.path
console.log(that.form)
}
}
});
},