private async Task Register() { if (RegisterPasswordBox.Text.Length <= 6) { // 本地密码有效检测 // TODO 具体规则待定,这里暂时设计成长度必须大于6 // 最终确定后要在登陆面板把规则显示给用户 PART_SnackBar.IsActive = true; SnackBarContent.Content = "密码长度过短"; return; } RegisterResponse response = await NetworkHelper.GetAsync(new RegisterRequest() { PhoneNumber = RegisterUserPhoneNumberTextBox.Text, Password = Hash(RegisterPasswordBox.Text) }).DisableElements(PrimaryButton, SwitchButton, RegisterUserPhoneNumberTextBox, RegisterPasswordBox) .Progress(PART_ProgressBar); if (response.UserId < 0) { // 服务器判断账号密码错误 PART_SnackBar.IsActive = true; SnackBarContent.Content = "不能注册,用户名已存在"; } else { UserInfo.Id = response.UserId; UserInfo.PhoneNumber = RegisterUserPhoneNumberTextBox.Text; MainWindow mainWindow = new MainWindow(); mainWindow.Show(); Close(); } }
private async Task Login() { if (string.IsNullOrEmpty(LoginUserPhoneNumberTextBox.Text) || string.IsNullOrEmpty(LoginPasswordBox.Password)) { // 本地用户名密码有效检测 PART_SnackBar.IsActive = true; SnackBarContent.Content = "用户名或密码不能为空"; return; } LoginResponse response = await NetworkHelper.GetAsync(new LoginRequest() { PhoneNumber = LoginUserPhoneNumberTextBox.Text, Password = Hash(LoginPasswordBox.Password) }).DisableElements(PrimaryButton, SwitchButton, LoginUserPhoneNumberTextBox, LoginPasswordBox) .Progress(PART_ProgressBar); if (response.UserId < 0) { // 服务器判断账号密码错误 PART_SnackBar.IsActive = true; SnackBarContent.Content = "用户名或密码错误"; } else { UserInfo.Id = response.UserId; UserInfo.PhoneNumber = LoginUserPhoneNumberTextBox.Text; MainWindow mainWindow = new MainWindow(); mainWindow.Show(); Close(); } }
private async void Window_Loaded(object sender, RoutedEventArgs e) { Snackbar = PART_SnackBar; SnackbarMessage = SnackBarContent; PART_Frame.Content = new MyMainPage(this); UserInfoResponse response = await NetworkHelper.GetAsync(new UserInfoRequest() { UserId = UserInfo.Id }).Progress(PART_ProgressBar); UserInfo.PhoneNumber = response.PhoneNumber; UserInfo.HomeAddress = response.HomeAddress; UserInfo.UserType = response.UserType; // 要根据用户类型调整tab,目前测试状态,禁用这段代码 RefreshTabDisplay(); }
private async Task Login() { // TODO: 这段代码开发的时候注释掉,上线的时候要用 //if (string.IsNullOrEmpty(LoginUserNameTextBox.Text) || string.IsNullOrEmpty(LoginPasswordBox.Password)) //{ // // 本地用户名密码有效检测 // PART_SnackBar.IsActive = true; // SnackBarContent.Content = "用户名或密码不能为空"; // return; //} PrimaryButton.IsEnabled = false; // 防止重复按下 LoginResponse loginResponse = await NetworkHelper.GetAsync(new LoginRequest() { UserName = LoginUserNameTextBox.Text, Password = Hash(LoginPasswordBox.Password) }); loginResponse = new LoginResponse() { UserId = 0 }; // TODO 假数据 if (loginResponse.UserId < 0) { // 服务器判断账号密码错误 PrimaryButton.IsEnabled = true; PART_SnackBar.IsActive = true; SnackBarContent.Content = "用户名或密码错误"; } else { UserInfo.Id = loginResponse.UserId; // TODO 假数据(用户信息的假数据不要在这里刷新) UserInfo.Name = "UXX65535"; UserInfo.PhoneNumber = "152-1111-1111"; UserInfo.HomeAddress = "XX省-XX市-XX区-XX街道-XX小区-XXXXXXXXXXXXX"; UserInfo.UserType = UserType.ADMIN; MainWindow mainWindow = new MainWindow(); mainWindow.Show(); Close(); } }
private async void Window_Loaded(object sender, RoutedEventArgs e) { PART_Frame.Content = new MyMainPage(this); // TODO 用户信息假数据 UserInfoResponse response = await NetworkHelper.GetAsync(new UserInfoRequest() { UserId = UserInfo.Id }).Progress(PART_ProgressBar); response = new UserInfoResponse() { PhoneNumber = "152-1111-1111", HomeAddress = "XX省-XX市-XX区-XX街道-XX小区-XXXXXXXXXXXXX", UserType = UserType.ADMIN }; UserInfo.PhoneNumber = response.PhoneNumber; UserInfo.HomeAddress = response.HomeAddress; UserInfo.UserType = response.UserType; // TODO 要根据用户类型调整tab,目前测试状态,禁用这段代码 // RefreshTabDisplay(); }
private async Task Login() { // TODO: 这段代码开发的时候注释掉,上线的时候要用 //if (string.IsNullOrEmpty(LoginUserNameTextBox.Text) || string.IsNullOrEmpty(LoginPasswordBox.Password)) //{ // // 本地用户名密码有效检测 // PART_SnackBar.IsActive = true; // SnackBarContent.Content = "用户名或密码不能为空"; // return; //} LoginResponse response = await NetworkHelper.GetAsync(new LoginRequest() { PhoneNumber = LoginUserPhoneNumberTextBox.Text, Password = Hash(LoginPasswordBox.Password) }).DisableElements(PrimaryButton, SwitchButton, LoginUserPhoneNumberTextBox, LoginPasswordBox); response = new LoginResponse() { UserId = 0 }; // TODO 假数据 if (response.UserId < 0) { // 服务器判断账号密码错误 PART_SnackBar.IsActive = true; SnackBarContent.Content = "用户名或密码错误"; } else { UserInfo.Id = response.UserId; UserInfo.PhoneNumber = LoginUserPhoneNumberTextBox.Text; MainWindow mainWindow = new MainWindow(); mainWindow.Show(); Close(); } }