const { User } = require('../../lib/av-live-query-weapp-min'); const app = getApp(); Page({ data: { name: "", username: '', password: '', error: null, }, onLoad: function() { const user = app.client.current_user; if (user) { this.setData({ name: user.name, username: user.login, }); } }, 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}); console.log("name:"+name); if(name!="未命名"){ user.set("name_setted", true); } } 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, }); }); } });