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.

78 lines
1.6 KiB

3 months ago
const app = getApp<IAppOption>();
Page({
data: {
list: [],
userInfo: {
avatarUrl: "",
},
},
onLoad() {
const SystemInfo = app.globalSystemInfo;
if (SystemInfo) {
const { bottom } = SystemInfo.capsulePosition;
this.setData({
bottom: bottom,
});
}
},
onShow() {
app.waitLogin().then((_res) => {
app.getUserInfo(this, true);
});
},
onChooseAvatar(e) {
const { avatarUrl } = e.detail;
const that = this;
let url = `${app.globalData.upFileUrl}?r=file-service/upload-img`;
wx.showLoading({
title: "上传中",
});
wx.uploadFile({
url: url,
filePath: avatarUrl,
name: "file",
success(res) {
let data = JSON.parse(res.data);
let avatarUrl = data.data.Url;
wx.ajax({
method: "POST",
2 months ago
url: "?r=zd/account/update-user-img",
3 months ago
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);
},
});