You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
1.6 KiB
77 lines
1.6 KiB
const app = getApp<IAppOption>(); |
|
|
|
Page({ |
|
data: { |
|
list: [], |
|
userInfo: { |
|
avatarUrl: "", |
|
}, |
|
}, |
|
onLoad() { |
|
const SystemInfo = app.globalSystemInfo; |
|
if (SystemInfo) { |
|
const { bottom } = SystemInfo.capsulePosition; |
|
this.setData({ |
|
bottom, |
|
}); |
|
} |
|
}, |
|
onShow() { |
|
app.waitLogin().then((_res) => { |
|
app.getUserInfo(this, true); |
|
}); |
|
}, |
|
onChooseAvatar(e) { |
|
const { avatarUrl } = e.detail; |
|
const that = this; |
|
const url = `${app.globalData.upFileUrl}?r=file-service/upload-ali-img`; |
|
wx.showLoading({ |
|
title: "上传中", |
|
}); |
|
wx.uploadFile({ |
|
url, |
|
filePath: avatarUrl, |
|
name: "file", |
|
success(res) { |
|
const data = JSON.parse(res.data); |
|
const avatarUrl = data.data.Url; |
|
wx.ajax({ |
|
method: "POST", |
|
url: "?r=igg4/account/update-user-img", |
|
data: { |
|
UserImg: decodeURI(avatarUrl), |
|
}, |
|
}) |
|
.then(() => { |
|
wx.hideLoading(); |
|
wx.showToast({ |
|
title: "头像更新成功!", |
|
icon: "none", |
|
}); |
|
that.setData({ |
|
"userInfo.UserImg": avatarUrl, |
|
}); |
|
}) |
|
.catch(() => { |
|
wx.hideLoading(); |
|
}); |
|
}, |
|
fail() { |
|
wx.hideLoading(); |
|
}, |
|
}); |
|
}, |
|
routerTo(e) { |
|
const { url } = e.currentTarget.dataset; |
|
wx.navigateTo({ |
|
url, |
|
}); |
|
}, |
|
handleSubmit() { |
|
console.log(this.data.userInfo); |
|
}, |
|
handleBack() { |
|
wx.navigateBack(); |
|
app.getUserInfo(this, true); |
|
}, |
|
});
|
|
|