using System; using System.Collections.Generic; using System.Threading; using HDL_ON.DAL.Server; using HDL_ON.Entity; using HDL_ON.UI.CSS; using Shared; namespace HDL_ON.UI.UI1Login { public partial class RegisterPage : Dialog { #region 控件列表 /// /// 等待提示 /// Loading waitPage; /// /// 当前界面 /// FrameLayout bodyView; /// /// 选择手机登录按钮 /// Button btnPhoneLogin; /// /// 选择邮箱登录按钮 /// Button btnEmailLogin; #region 服务器选择 /// /// 服务器区域 /// FrameLayout serverView; /// /// 服务器Icon按钮 /// Button btnServerIcon; /// /// 服务器文本框 /// Button btnServerText; ///// ///// 服务器文本框 ///// //EditText etServer; ///// ///// 服务器子区域里面的分割线1 ///// //Button btnLineVertical_server; /// ///服务器go按钮 /// Button btnServerGo; /// /// 服务器子区域底部横线 /// Button btnServerBottomLine; #endregion /// /// 账号子区域 /// FrameLayout accountView; /// /// 国际区号按钮 /// Button btnGlobalRoaming; /// /// 账号子区域里面的分割线 /// Button btnDividingLineVertical_AccountView; /// /// 账号文本框 /// EditText etAccount; /// /// 账号Icon按钮 /// Button btnAccountIcon; /// /// 账号子区域底部横线 /// Button btnVerificationCodeViewBottomLine; /// /// 密码子区域 /// FrameLayout passwordView; /// /// 密码Icon按钮 /// Button btnPasswordIcon; /// /// 密码文本框 /// EditText etPassword; /// /// 密码子区域里面的分割线1 /// Button btnDividingLineVertical_PasswordView1; /// /// 密码是否可见按钮 /// Button btnVisiblePassword; /// /// 密码子区域底部横线 /// Button btnPasswordViewBottomLine; /// /// 确认密码子区域 /// FrameLayout repeatPasswordView; /// /// 确认密码Icon按钮 /// Button btnRepeatPasswordIcon; /// /// 确认密码文本框 /// EditText etRepeatPassword; /// /// 确认密码子区域里面的分割线1 /// Button btnRepeatDividingLineVertical_PasswordView1; /// /// 确认密码是否可见按钮 /// Button btnRepeatVisiblePassword; /// /// 确认密码子区域底部横线 /// Button btnRepeatPasswordViewBottomLine; /// /// 验证码子区域 /// FrameLayout verificationCodeView; /// /// 验证码图标 /// Button btnVerificationCodeIcon; /// /// 验证码子区域分割线 /// Button btnDividingLineVertical_VerificationCodeView1; /// /// 验证码文本输入框 /// EditText etVerificationCode; /// /// 获取验证码按钮 /// Button btnGetVerificationCode_Phone; /// /// 获取验证码按钮 /// Button btnGetVerificationCode_Mail; /// /// 验证码子区域底部分割线 /// Button btnAccountViewBottomLine; /// /// 注册按钮 /// Button btnRegister; #endregion #region 局部变量列表 ///// ///// 账号类型 ///// 0:手机 ///// 1:邮箱 ///// //int accountType = 0; /// /// 手机号码是否有效 /// bool ValidMobileNumber = false; /// /// 密码是否有效 /// bool ValidPassword = false; /// /// 服务器请求对象 /// HttpServerRequest pm; /// /// 回调事件 /// //Action callbackAction; /// /// 注册类型 /// 0:手机 /// 1:邮箱 /// int registerType = 0; /// /// 手机区号 /// string phoneZoneCode = "86"; /// /// 是否选择过服务器 /// bool isSelectServer; string registerPhone; string registerEmail; /// /// 是否点击了返回,用于屏蔽EditText失去焦点检测事件 /// bool isHitBack; #endregion /// /// 回调事件 /// 账号,密码,是否手机 /// account,password,isPhone /// Action AutoLoginAction; /// /// /// /// 注册成功回调事件 public RegisterPage(Action autoLoginAction) { AutoLoginAction = autoLoginAction; bodyView = new FrameLayout() { BackgroundColor = CSS_Color.MainBackgroundColor, }; AddChidren(bodyView); //2020-12-22 增加点击隐藏键盘事件 bodyView.MouseDownEventHandler += (sender, e) => { Application.HideSoftInput(); }; pm = new HttpServerRequest(); } //public RegisterPage(Action action) //{ // bodyView = new FrameLayout() // { // BackgroundColor = CSS_Color.MainBackgroundColor, // }; // AddChidren(bodyView); // pm = new HttpServerRequest(); // callbackAction = action; //} public void ShowDialog() { Action backAction = () => { isHitBack = true; //2020-12-22 增加点击隐藏键盘事件 Application.HideSoftInput(); }; new TopViewDiv(this, bodyView, Language.StringByID(StringId.Register)).LoadTopView(backAction); //new PublicAssmebly().LoadTopView(this, bodyView, Language.StringByID(StringId.Register)); #region 注册方式选择 btnPhoneLogin = new Button() { X = Application.GetRealWidth(28), Y = Application.GetRealHeight(112), Width = Application.GetRealWidth(120), Height = Application.GetRealHeight(40), TextID = StringId.RegisterByPhone, TextColor = CSS_Color.MainColor, TextAlignment = TextAlignment.CenterLeft, TextSize = CSS_FontSize.EmphasisFontSize_Secondary, }; bodyView.AddChidren(btnPhoneLogin); btnEmailLogin = new Button() { X = btnPhoneLogin.Right, Y = Application.GetRealHeight(112), Width = Application.GetRealWidth(100), Height = Application.GetRealHeight(40), TextID = StringId.RegisterByEmail, TextColor = CSS_Color.PromptingColor1, TextAlignment = TextAlignment.Center, TextSize = CSS_FontSize.TextFontSize, }; bodyView.AddChidren(btnEmailLogin); if(Language.CurrentLanguage!= "Chinese") { btnPhoneLogin.Width = Application.GetRealWidth(180); btnEmailLogin.Width = Application.GetRealWidth(180); } #endregion #region 服务器选择 serverView = new FrameLayout() { X = Application.GetRealWidth(28), Y = Application.GetRealHeight(167), Width = Application.GetRealWidth(319), Height = Application.GetRealHeight(44), }; bodyView.AddChidren(serverView); btnServerIcon = new Button() { X = Application.GetRealWidth(9), Gravity = Gravity.CenterVertical, Width = Application.GetMinRealAverage(20), Height = Application.GetMinRealAverage(20), UnSelectedImagePath = "LoginIcon/Server.png", }; serverView.AddChidren(btnServerIcon); btnServerText = new Button() { X = Application.GetRealWidth(49), Width = Application.GetRealWidth(319 - 78), TextAlignment = TextAlignment.CenterLeft, TextColor = CSS_Color.PromptingColor1, TextSize = CSS_FontSize.TextFontSize, TextID = StringId.PleaseSelectCountryOrRegion, }; serverView.AddChidren(btnServerText); #region 密码登录-控件加载 btnServerGo = new Button() { X = Application.GetRealWidth(303), Gravity = Gravity.CenterVertical, Width = Application.GetMinRealAverage(16), Height = Application.GetMinRealAverage(16), UnSelectedImagePath = "Public/Right.png", }; serverView.AddChidren(btnServerGo); #endregion btnServerBottomLine = new Button() { Y = Application.GetRealHeight(42), BackgroundColor = CSS_Color.DividingLineColor, SelectedBackgroundColor = CSS_Color.MainColor, Height = Application.GetRealHeight(1), }; serverView.AddChidren(btnServerBottomLine); #endregion int topPadding = Application.GetRealHeight(12); #region 账号填写 accountView = new FrameLayout() { X = Application.GetRealWidth(28), Y = serverView.Bottom + topPadding, Width = Application.GetRealWidth(319), Height = Application.GetRealHeight(44), }; bodyView.AddChidren(accountView); btnGlobalRoaming = new Button() { Width = Application.GetRealWidth(57), X = Application.GetRealWidth(9), TextAlignment = TextAlignment.CenterLeft, TextColor = CSS_Color.FirstLevelTitleColor, Text = "+" + phoneZoneCode, TextSize = CSS_FontSize.TextFontSize, }; //跳转国家区号选择界面 EventHandler eHandler = (sender, e) => { JLCountrycode.CountryCodeView.Current.Show((countryName, code) => { if (!string.IsNullOrEmpty(code)) { phoneZoneCode = code; btnGlobalRoaming.Text = "+" + phoneZoneCode; } }); }; btnGlobalRoaming.MouseUpEventHandler += eHandler; if (registerType == 0) { accountView.AddChidren(btnGlobalRoaming); } //btnDividingLineVertical_AccountView = new Button() //{ // X = Application.GetRealWidth(65), // Gravity = Gravity.CenterVertical, // Width = 1, // Height = Application.GetRealHeight(20), // BackgroundColor = CSS_Color.DividingLineColor, //}; //accountView.AddChidren(btnDividingLineVertical_AccountView); etAccount = new EditText() { X = Application.GetRealWidth(49), Width = Application.GetRealWidth(319 - 78), TextAlignment = TextAlignment.CenterLeft, TextColor = CSS_Color.FirstLevelTitleColor, TextSize = CSS_FontSize.TextFontSize, PlaceholderTextColor = CSS_Color.PromptingColor1, PlaceholderText = Language.StringByID(StringId.PlsEntryPhoneNumber), IsNumberKeyboardType = true }; accountView.AddChidren(etAccount); btnAccountViewBottomLine = new Button() { Y = Application.GetRealHeight(42), BackgroundColor = CSS_Color.DividingLineColor, Height = Application.GetRealHeight(1), }; accountView.AddChidren(btnAccountViewBottomLine); btnAccountIcon = new Button() { X = Application.GetRealWidth(9), Gravity = Gravity.CenterVertical, Width = Application.GetMinRealAverage(20), Height = Application.GetMinRealAverage(20), UnSelectedImagePath = "LoginIcon/AccountIcon.png", }; if (registerType == 1) { accountView.AddChidren(btnAccountIcon); } #endregion #region 密码填写 passwordView = new FrameLayout() { X = Application.GetRealWidth(28), Y = accountView.Bottom + topPadding, Width = Application.GetRealWidth(319), Height = Application.GetRealHeight(44), }; bodyView.AddChidren(passwordView); btnPasswordIcon = new Button() { X = Application.GetRealWidth(9), Gravity = Gravity.CenterVertical, Width = Application.GetMinRealAverage(20), Height = Application.GetMinRealAverage(20), UnSelectedImagePath = "LoginIcon/PasswordIcon.png", }; passwordView.AddChidren(btnPasswordIcon); //btnDividingLineVertical_PasswordView1 = new Button() //{ // X = Application.GetRealWidth(65), // Gravity = Gravity.CenterVertical, // Width = 1, // Height = Application.GetRealHeight(20), // BackgroundColor = CSS_Color.DividingLineColor, //}; //passwordView.AddChidren(btnDividingLineVertical_PasswordView1); etPassword = new EditText() { X = Application.GetRealWidth(49), Width = Application.GetRealWidth(319 - 78), TextAlignment = TextAlignment.CenterLeft, TextColor = CSS_Color.FirstLevelTitleColor, TextSize = CSS_FontSize.TextFontSize, PlaceholderTextColor = CSS_Color.PromptingColor1, PlaceholderText = Language.StringByID(StringId.PlsRegisterPassword), SecureTextEntry = true, }; passwordView.AddChidren(etPassword); #region 密码登录-控件加载 btnVisiblePassword = new Button() { X = Application.GetRealWidth(295), Gravity = Gravity.CenterVertical, Width = Application.GetMinRealAverage(20), Height = Application.GetMinRealAverage(20), UnSelectedImagePath = "LoginIcon/HidePasswordIcon.png", SelectedImagePath = "LoginIcon/ShowPasswordIcon.png", }; passwordView.AddChidren(btnVisiblePassword); #endregion btnPasswordViewBottomLine = new Button() { Y = Application.GetRealHeight(42), BackgroundColor = CSS_Color.DividingLineColor, SelectedBackgroundColor = CSS_Color.MainColor, Height = Application.GetRealHeight(1), }; passwordView.AddChidren(btnPasswordViewBottomLine); #endregion #region 确认密码填写 repeatPasswordView = new FrameLayout() { X = Application.GetRealWidth(28), Y = passwordView.Bottom + topPadding, Width = Application.GetRealWidth(319), Height = Application.GetRealHeight(44), }; bodyView.AddChidren(repeatPasswordView); btnRepeatPasswordIcon = new Button() { X = Application.GetRealWidth(9), Gravity = Gravity.CenterVertical, Width = Application.GetMinRealAverage(20), Height = Application.GetMinRealAverage(20), UnSelectedImagePath = "LoginIcon/PasswordIcon.png", }; repeatPasswordView.AddChidren(btnRepeatPasswordIcon); //btnRepeatDividingLineVertical_PasswordView1 = new Button() //{ // X = Application.GetRealWidth(65), // Gravity = Gravity.CenterVertical, // Width = 1, // Height = Application.GetRealHeight(20), // BackgroundColor = CSS_Color.DividingLineColor, //}; //repeatPasswordView.AddChidren(btnRepeatDividingLineVertical_PasswordView1); etRepeatPassword = new EditText() { X = Application.GetRealWidth(49), Width = Application.GetRealWidth(319 - 78), TextAlignment = TextAlignment.CenterLeft, TextColor = CSS_Color.FirstLevelTitleColor, TextSize = CSS_FontSize.TextFontSize, PlaceholderTextColor = CSS_Color.PromptingColor1, PlaceholderText = Language.StringByID(StringId.PlsRegisterRepeatPassword), SecureTextEntry = true, }; repeatPasswordView.AddChidren(etRepeatPassword); #region 密码登录-控件加载 btnRepeatVisiblePassword = new Button() { X = Application.GetRealWidth(295), Gravity = Gravity.CenterVertical, Width = Application.GetMinRealAverage(20), Height = Application.GetMinRealAverage(20), UnSelectedImagePath = "LoginIcon/HidePasswordIcon.png", SelectedImagePath = "LoginIcon/ShowPasswordIcon.png", }; repeatPasswordView.AddChidren(btnRepeatVisiblePassword); #endregion btnRepeatPasswordViewBottomLine = new Button() { Y = Application.GetRealHeight(42), BackgroundColor = CSS_Color.DividingLineColor, SelectedBackgroundColor = CSS_Color.MainColor, Height = Application.GetRealHeight(1), }; repeatPasswordView.AddChidren(btnRepeatPasswordViewBottomLine); #endregion #region 验证码填写 verificationCodeView = new FrameLayout() { X = Application.GetRealWidth(28), Y = repeatPasswordView.Bottom + topPadding, //Y = Application.GetRealHeight(335), Width = Application.GetRealWidth(319), Height = Application.GetRealHeight(44), }; bodyView.AddChidren(verificationCodeView); btnVerificationCodeIcon = new Button() { X = Application.GetRealWidth(9), Gravity = Gravity.CenterVertical, Width = Application.GetMinRealAverage(20), Height = Application.GetMinRealAverage(20), UnSelectedImagePath = "LoginIcon/VerificationCodeIcon.png", }; verificationCodeView.AddChidren(btnVerificationCodeIcon); //btnDividingLineVertical_VerificationCodeView1 = new Button() //{ // X = Application.GetRealWidth(65), // Gravity = Gravity.CenterVertical, // Width = 1, // Height = Application.GetRealHeight(20), // BackgroundColor = CSS_Color.DividingLineColor, //}; //verificationCodeView.AddChidren(btnDividingLineVertical_VerificationCodeView1); etVerificationCode = new EditText() { X = Application.GetRealWidth(49), Width = Application.GetRealWidth(61 + 84), TextAlignment = TextAlignment.CenterLeft, TextColor = CSS_Color.FirstLevelTitleColor, TextSize = CSS_FontSize.TextFontSize, PlaceholderTextColor = CSS_Color.PromptingColor1, PlaceholderText = Language.StringByID(StringId.PlsEntryVerificationCode), }; verificationCodeView.AddChidren(etVerificationCode); btnGetVerificationCode_Phone = new Button() { X = Application.GetRealWidth(219), Width = Application.GetRealWidth(100), TextID = StringId.GetVerificationCode, SelectedTextColor = CSS_Color.MainColor, TextColor = CSS_Color.PromptingColor1, TextAlignment = TextAlignment.CenterRight, TextSize = CSS_FontSize.PromptFontSize_FirstLevel, }; verificationCodeView.AddChidren(btnGetVerificationCode_Phone); btnGetVerificationCode_Mail = new Button() { X = Application.GetRealWidth(219), Width = Application.GetRealWidth(100), TextID = StringId.GetVerificationCode, SelectedTextColor = CSS_Color.MainColor, TextColor = CSS_Color.PromptingColor1, TextAlignment = TextAlignment.CenterRight, TextSize = CSS_FontSize.PromptFontSize_FirstLevel, Visible = false }; verificationCodeView.AddChidren(btnGetVerificationCode_Mail); btnVerificationCodeViewBottomLine = new Button() { Y = Application.GetRealHeight(42), BackgroundColor = CSS_Color.DividingLineColor, SelectedBackgroundColor = CSS_Color.MainColor, Height = Application.GetRealHeight(1), }; verificationCodeView.AddChidren(btnVerificationCodeViewBottomLine); #endregion btnRegister = new Button() { Gravity = Gravity.CenterHorizontal, Y = verificationCodeView.Bottom + Application.GetRealHeight(42), //Y = Application.GetRealHeight(421), Width = Application.GetRealWidth(220), Height = Application.GetRealWidth(44), Radius = (uint)Application.GetRealWidth(22), SelectedBackgroundColor = CSS_Color.MainColor, BackgroundColor = CSS_Color.PromptingColor1, TextID = StringId.Register, TextSize = CSS_FontSize.SubheadingFontSize, TextColor = CSS_Color.MainBackgroundColor, TextAlignment = TextAlignment.Center, }; bodyView.AddChidren(btnRegister); LoadEventList(); } /// /// 注册成功之后自动登录 /// void LoadEvent_AutoLogin(string account, string password) { Dialog dialog = new Dialog(); FrameLayout frame = new FrameLayout() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(198), Width = Application.GetRealWidth(288), Height = Application.GetRealHeight(206), BackgroundColor = CSS_Color.MainBackgroundColor, Radius = (uint)Application.GetRealWidth(12), BorderWidth = 0, BorderColor = 0x00000000, }; dialog.AddChidren(frame); Button btnAccountText = new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(40), Height = Application.GetRealHeight(17 + 14 + 14), IsMoreLines = true, TextAlignment = TextAlignment.Center, TextColor = CSS_Color.FirstLevelTitleColor, TextSize = CSS_FontSize.TextFontSize, Text = account, }; frame.AddChidren(btnAccountText); Button btnTipRegisterSuccess = new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(123), Height = Application.GetRealHeight(30), TextAlignment = TextAlignment.Center, TextColor = CSS_Color.MainColor, TextSize = CSS_FontSize.SubheadingFontSize, TextID = StringId.CongratulationsRegistration, }; frame.AddChidren(btnTipRegisterSuccess); Button btnAutoLoginTip = new Button() { Gravity = Gravity.CenterHorizontal, Y = btnTipRegisterSuccess.Bottom, Height = Application.GetRealHeight(17 + 8), TextAlignment = TextAlignment.Center, TextColor = CSS_Color.PromptingColor1, TextSize = CSS_FontSize.PromptFontSize_FirstLevel, TextID = StringId.AutomaticallyLogin, }; frame.AddChidren(btnAutoLoginTip); Button btnHeadImage = new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(150), Width = Application.GetRealWidth(84), Height = Application.GetRealWidth(84), Radius = (uint)Application.GetRealWidth(42), BorderColor = 0x00000000, BorderWidth = 0, UnSelectedImagePath = "LoginIcon/2.png", }; dialog.AddChidren(btnHeadImage); dialog.Show(); new Thread(() => { Thread.Sleep(1500); Application.RunOnMainThread(() => { ////创建登录线程 //var loginThread = LoadThread_Login(account, password); //waitPage = new Loading(); //new PublicAssmebly().LoadPage_WaitPage(loginThread, bodyView, waitPage); dialog.Close(); var isPhone = registerType == 0; AutoLoginAction?.Invoke(account, password, isPhone); }); }) { IsBackground = true }.Start(); } //#region 登录线程部分 ///// ///// 加载登录线程 ///// //Thread LoadThread_Login(string account,string password) //{ // var loginThread = new Thread(() => // { // try // { // //登录 // var loginResult = LoadMethod_Login(account,password); // if (loginResult) // { // //获取住宅信息 // var getResidencesResult = LoadMethod_GetResidences(); // if (getResidencesResult) // { // /* // * Wait : 推送注册 // */ // Application.RunOnMainThread(() => // { // waitPage.RemoveFromParent(); // waitPage = null; // //跳转页面---- // MainPage.GoUserPage(); // }); // } // } // } // catch (Exception ex) // { // MainPage.Log($"LoginPage : {ex.Message}"); // } // }) // { IsBackground = true }; // return loginThread; //} ///// ///// 调用登录接口登录 ///// //bool LoadMethod_Login(string account, string password) //{ // var result = false; // //调用登录接口 // var loginResult = pm.LoginByPassword(account, password); // if (loginResult.Code == StateCode.SUCCESS) // { // var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject(loginResult.Data.ToString()); // // UserInfo.Current = new UserInfo // //{ // // userType = revertData.userType, // // accountString = account, // // password = password, // // lastTime = DateTime.Now, // // ID = revertData.userId, // // loginTokenString = revertData.headerPrefix + revertData.accessToken, // // refreshToken = revertData.refreshToken, // // userName = revertData.name // //}; // UserInfo.Current.userType = revertData.userType; // UserInfo.Current.AccountString = account; // //UserInfo.Current.password = password; // UserInfo.Current.LastTime = DateTime.Now; // UserInfo.Current.ID = revertData.userId; // UserInfo.Current.LoginTokenString = revertData.headerPrefix + revertData.accessToken; // UserInfo.Current.RefreshToken = revertData.refreshToken; // UserInfo.Current.userName = revertData.name; // UserInfo.Current.SaveUserInfo(); // MainPage.Log("登录成功。"); // result = true; // } // else // { // //登录失败 // IMessageCommon.Current.ShowErrorInfoAlter(loginResult.Code); // Application.RunOnMainThread(() => // { // btnPasswordViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2; // btnPasswordViewBottomLine.Height = Application.GetRealHeight(2); // }); // } // return result; //} ///// ///// 获取住宅列表 ///// //bool LoadMethod_GetResidences() //{ // var result = false; // var responsePack = pm.GetHomePager(); // if (responsePack == StateCode.SUCCESS) // { // //2020-11-13 待确认,没有住宅,不算登录成功 // if (UserInfo.Current.regionList != null && UserInfo.Current.regionList.Count > 0) // { // result = true; // } // } // else // { // IMessageCommon.Current.ShowErrorInfoAlter(responsePack); // } // return result; //} //#endregion } }