async uploadPic() { mpvue.chooseImage({ count: 1, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], success: (res) => { //转换临时文件为base64 wx.getFileSystemManager().readFile({ filePath: res.tempFilePaths[0], //选择图片返回的相对路径 encoding: 'base64', //编码格式 success: res => { //成功的回调 this.icon = 'data:image/png;base64,' + res.data; this.uploadimg(res.data); } }) } }); },
///请求接口更新用户头像
uploadimg() { this.$http.post('/orgAnization/updateIcon', { uid: this.LOGIN_INFO.uid, icon: this.icon }).then((data) => { wx.showToast({title: data.message}); }); },