|
|
@@ -24,13 +24,38 @@ Page({
|
|
|
onChooseAvatar(e) {
|
|
|
console.log(e);
|
|
|
const { avatarUrl } = e.detail
|
|
|
- API.updateUserAvater({avatarBase64:avatarUrl}).then(res=>{
|
|
|
+
|
|
|
+ this.base64(avatarUrl,'png').then(res => {
|
|
|
+ console.log(res,'base64路径')
|
|
|
+ let pathUrl = '/api/store/user-profile/upload-avatar';
|
|
|
+
|
|
|
+ let data = {
|
|
|
+ avatarBase64:res
|
|
|
+ }
|
|
|
+
|
|
|
+ API.updateUserAvater({avatarBase64:data}).then(res=>{
|
|
|
let {avatarUrl} = res.userProfileDTO;
|
|
|
this.setData({
|
|
|
avatarUrl
|
|
|
})
|
|
|
+ })
|
|
|
+
|
|
|
})
|
|
|
+
|
|
|
},
|
|
|
+ base64(url,type) {
|
|
|
+ return new Promise((resolve,reject) => {
|
|
|
+ wx.getFileSystemManager().readFile({
|
|
|
+ filePath: url, // 选择图片返回的相对路径
|
|
|
+ encoding: 'base64', // 编码格式
|
|
|
+ success: res => {
|
|
|
+ resolve(res.data)
|
|
|
+ },
|
|
|
+ fail: res =>reject(res.errMsg)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
// 监听昵称的输入
|
|
|
inputChange(name){
|
|
|
let nickName = name.detail.value;
|