Page({ data: { userInfo: { username: '', // 用户名 password: '', // 密码 }, }, // 获取用户名输入 inputUsername(e) { this.setData({ 'userInfo.username': e.detail.value, // 更新用户名 }); }, // 获取密码输入 inputPassword(e) { this.setData({ 'userInfo.password': e.detail.value, // 更新密码 }); }, // 注册方法 register() { const { username, password } = this.data.userInfo; // 检查用户名和密码是否为空 if (!username || !password) { wx.showToast({ title: '用户名和密码不能为空', icon: 'none', }); return; } // 保存用户信息(用户名和密码)到缓存 wx.setStorageSync('userInfo', this.data.userInfo); // 显示注册成功的提示 wx.showToast({ title: '注册成功', icon: 'success', }); // 注册成功后跳转到登录页面 wx.reLaunch({ url: '/pages/admin/admin', // 登录页面路径 }); }, });