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.
|
|
|
|
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-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);
|
|
|
|
|
},
|
|
|
|
|
});
|