refactor: remove registration page and update login UI with agreement checkbox
This commit is contained in:
@@ -71,29 +71,53 @@ Page({
|
||||
},
|
||||
|
||||
// 切换头像
|
||||
changeAvatar() {
|
||||
onChooseAvatar(e) {
|
||||
let that = this;
|
||||
wx.chooseImage({
|
||||
count: 1,
|
||||
success: function (e) {
|
||||
wx.showLoading({
|
||||
title: '正在上传...',
|
||||
mask: true,
|
||||
})
|
||||
app.$api.uploadAvatar({
|
||||
filePath: e.tempFilePaths[0]
|
||||
}).then(res => {
|
||||
wx.showToast({
|
||||
title: '上传成功',
|
||||
icon: 'success',
|
||||
})
|
||||
that.getData();
|
||||
}, err => {});
|
||||
},
|
||||
fail: function (res) {
|
||||
console.log(res);
|
||||
},
|
||||
const { avatarUrl } = e.detail;
|
||||
if (!avatarUrl) return;
|
||||
|
||||
wx.showLoading({
|
||||
title: '正在上传...',
|
||||
mask: true,
|
||||
})
|
||||
app.$api.uploadAvatar({
|
||||
filePath: avatarUrl
|
||||
}).then(res => {
|
||||
wx.showToast({
|
||||
title: '上传成功',
|
||||
icon: 'success',
|
||||
})
|
||||
that.getData();
|
||||
}, err => {
|
||||
wx.hideLoading();
|
||||
});
|
||||
},
|
||||
|
||||
// 修改昵称
|
||||
onNicknameChange(e) {
|
||||
let newName = e.detail.value;
|
||||
// 防止重复触发
|
||||
if (!newName || newName === this.data.members.nickname) return;
|
||||
|
||||
// 乐观反显更新
|
||||
this.setData({
|
||||
'members.nickname': newName
|
||||
});
|
||||
|
||||
wx.showLoading({ title: '保存中...', mask: true });
|
||||
app.$api.memberUpdateInformation({
|
||||
nickname: newName
|
||||
}).then(res => {
|
||||
wx.hideLoading();
|
||||
wx.showToast({
|
||||
title: '修改成功',
|
||||
icon: 'success',
|
||||
});
|
||||
// 这里的静默获取能确保和数据库端同步
|
||||
this.getData();
|
||||
}, err => {
|
||||
wx.hideLoading();
|
||||
});
|
||||
},
|
||||
|
||||
// 修改性别
|
||||
@@ -153,14 +177,34 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
// 修改信息
|
||||
changeMessage(e) {
|
||||
let label = e.currentTarget.dataset.label;
|
||||
let value = e.currentTarget.dataset.value ? e.currentTarget.dataset.value : "";
|
||||
wx.removeStorageSync('history');
|
||||
wx.navigateTo({
|
||||
url: `/pages/register/index?label=${label}&value=${value}&codeType=3`,
|
||||
})
|
||||
// 在当前页直接修改文本类别的信息(姓名、年龄、地址)
|
||||
onInfoChange(e) {
|
||||
let type = e.currentTarget.dataset.type;
|
||||
let newValue = e.detail.value;
|
||||
|
||||
if (newValue === undefined || newValue === this.data.members[type]) return;
|
||||
|
||||
let updateData = {};
|
||||
updateData[type] = newValue;
|
||||
|
||||
// 乐观反显
|
||||
let key = 'members.' + type;
|
||||
this.setData({
|
||||
[key]: newValue
|
||||
});
|
||||
|
||||
wx.showLoading({ title: '保存中...', mask: true });
|
||||
app.$api.memberUpdateInformation(updateData).then(res => {
|
||||
wx.hideLoading();
|
||||
wx.showToast({
|
||||
title: '修改成功',
|
||||
icon: 'success',
|
||||
});
|
||||
// 静默获取同步服务器
|
||||
this.getData();
|
||||
}, err => {
|
||||
wx.hideLoading();
|
||||
});
|
||||
},
|
||||
|
||||
// 获取数据
|
||||
|
||||
Reference in New Issue
Block a user