图片上传
This commit is contained in:
@@ -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){
|
||||||
|
|||||||
@@ -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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user