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.

67 lines
1.2 KiB

const { User } = require('../../lib/av-live-query-weapp-min');
Page({
data: {
name: "",
username: '',
password: '',
error: null,
},
onLoad: function() {
const user = User.current();
if (user) {
this.setData({
name: user.get("name"),
username: user.get('username'),
});
}
},
updateName: function({
detail: {
value
}
}){
this.setData({name: value});
},
updateUsername: function ({
detail: {
value
}
}) {
this.setData({
username: value
});
},
updatePassword: function ({
detail: {
value
}
}) {
this.setData({
password: value
});
},
save: function () {
this.setData({
error: null,
});
const { name, username, password } = this.data;
const user = User.current();
if (name) user.set({name});
if (username) user.set({ username });
if (password){
user.set({ password });
user.set("passwd", password);
}
user.save().then(() => {
wx.showToast({
title: '更新成功',
icon: 'success',
});
}).catch(error => {
this.setData({
error: error.message,
});
});
}
});