上传图片
onUploadImg(type) {
const that = this
console.log('允许从相机和相册扫码')
const urlFile = that.$myConfig.web+'/common/uploadImgFile'
console.log(urlFile)
const count = 1
uni.chooseImage({
count:count,
success:(res)=> {
console.log(res)
const car_lic = res.tempFilePaths[0]
that.car_lic = car_lic
console.log(that.car_lic)
uni.uploadFile({
url: urlFile, //仅为示例,非真实的接口地址
filePath: car_lic,
name: 'file',
formData: {
'user': 'test',
'img_level':'private',
},
success: (uploadFileRes) => {
const data = JSON.parse(uploadFileRes.data);
const url = data.data
console.log(url)
const urlNew = that.$myConfig.web+url
console.log('图片地址为:'+urlNew)
if (type == 1) {
that.fromData.card_up_img = urlNew
} else {
that.fromData.card_down_img = urlNew
}
}
});
//
}
})
}