| | |
| | | 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; |
| | | |
| | |
| | | public partial class RegisterPage : Dialog |
| | | { |
| | | #region 控件列表 |
| | | /// <summary> |
| | | /// 等待提示 |
| | | /// </summary> |
| | | Loading waitPage; |
| | | /// <summary> |
| | | /// 当前界面 |
| | | /// </summary> |
| | |
| | | /// <summary> |
| | | /// 账号子区域底部横线 |
| | | /// </summary> |
| | | Button btnAccountViewBottomLine; |
| | | Button btnVerificationCodeViewBottomLine; |
| | | /// <summary> |
| | | /// 密码子区域 |
| | | /// </summary> |
| | |
| | | /// <summary> |
| | | /// 验证码子区域底部分割线 |
| | | /// </summary> |
| | | Button btnVerificationCodeViewBottomLine; |
| | | Button btnAccountViewBottomLine; |
| | | /// <summary> |
| | | /// 注册按钮 |
| | | /// </summary> |
| | |
| | | /// <summary> |
| | | /// 回调事件 |
| | | /// </summary> |
| | | Action<string> callbackAction; |
| | | //Action callbackAction; |
| | | /// <summary> |
| | | /// 注册类型 |
| | | /// 0:手机 |
| | |
| | | pm = new HttpServerRequest(); |
| | | } |
| | | |
| | | public RegisterPage(Action<string> action) |
| | | { |
| | | bodyView = new FrameLayout() |
| | | { |
| | | BackgroundColor = CSS_Color.MainBackgroundColor, |
| | | }; |
| | | AddChidren(bodyView); |
| | | |
| | | pm = new HttpServerRequest(); |
| | | callbackAction = action; |
| | | } |
| | | //public RegisterPage(Action action) |
| | | //{ |
| | | // bodyView = new FrameLayout() |
| | | // { |
| | | // BackgroundColor = CSS_Color.MainBackgroundColor, |
| | | // }; |
| | | // AddChidren(bodyView); |
| | | // pm = new HttpServerRequest(); |
| | | // callbackAction = action; |
| | | //} |
| | | |
| | | public void ShowDialog() |
| | | { |
| | | new PublicAssmebly().LoadTopView(this, bodyView, Language.StringByID(R.InternationalizationString.Register)); |
| | | new TopViewDiv(this, bodyView, Language.StringByID(StringId.Register)).LoadTopView(); |
| | | //new PublicAssmebly().LoadTopView(this, bodyView, Language.StringByID(StringId.Register)); |
| | | |
| | | #region 注册方式选择 |
| | | btnPhoneLogin = new Button() |
| | |
| | | Y = Application.GetRealHeight(112), |
| | | Width = Application.GetRealWidth(120), |
| | | Height = Application.GetRealHeight(40), |
| | | TextID = R.InternationalizationString.LoginByPhone, |
| | | TextID = StringId.LoginByPhone, |
| | | TextColor = CSS_Color.MainColor, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextSize = CSS_FontSize.EmphasisFontSize_Secondary, |
| | |
| | | Y = Application.GetRealHeight(112), |
| | | Width = Application.GetRealWidth(100), |
| | | Height = Application.GetRealHeight(40), |
| | | TextID = R.InternationalizationString.LoginByEmail, |
| | | TextID = StringId.LoginByEmail, |
| | | TextColor = CSS_Color.PromptingColor1, |
| | | TextAlignment = TextAlignment.Center, |
| | | TextSize = CSS_FontSize.TextFontSize, |
| | |
| | | TextColor = CSS_Color.FirstLevelTitleColor, |
| | | TextSize = CSS_FontSize.TextFontSize, |
| | | PlaceholderTextColor = CSS_Color.PromptingColor1, |
| | | PlaceholderText = Language.StringByID(R.InternationalizationString.PlsEntryPhoneNumber), |
| | | PlaceholderText = Language.StringByID(StringId.PlsEntryPhoneNumber), |
| | | }; |
| | | accountView.AddChidren(etAccount); |
| | | |
| | |
| | | TextColor = CSS_Color.FirstLevelTitleColor, |
| | | TextSize = CSS_FontSize.TextFontSize, |
| | | PlaceholderTextColor = CSS_Color.PromptingColor1, |
| | | PlaceholderText = Language.StringByID(R.InternationalizationString.PlsRegisterPassword), |
| | | PlaceholderText = Language.StringByID(StringId.PlsRegisterPassword), |
| | | SecureTextEntry = true, |
| | | }; |
| | | passwordView.AddChidren(etPassword); |
| | |
| | | TextColor = CSS_Color.FirstLevelTitleColor, |
| | | TextSize = CSS_FontSize.TextFontSize, |
| | | PlaceholderTextColor = CSS_Color.PromptingColor1, |
| | | PlaceholderText = Language.StringByID(R.InternationalizationString.PlsRegisterRepeatPassword), |
| | | PlaceholderText = Language.StringByID(StringId.PlsRegisterRepeatPassword), |
| | | SecureTextEntry = true, |
| | | }; |
| | | repeatPasswordView.AddChidren(etRepeatPassword); |
| | |
| | | TextColor = CSS_Color.FirstLevelTitleColor, |
| | | TextSize = CSS_FontSize.TextFontSize, |
| | | PlaceholderTextColor = CSS_Color.PromptingColor1, |
| | | PlaceholderText = Language.StringByID(R.InternationalizationString.PlsEntryVerificationCode), |
| | | PlaceholderText = Language.StringByID(StringId.PlsEntryVerificationCode), |
| | | }; |
| | | verificationCodeView.AddChidren(etVerificationCode); |
| | | |
| | |
| | | { |
| | | X = Application.GetRealWidth(219), |
| | | Width = Application.GetRealWidth(100), |
| | | TextID = R.InternationalizationString.GetVerificationCode, |
| | | TextID = StringId.GetVerificationCode, |
| | | SelectedTextColor = CSS_Color.MainColor, |
| | | TextColor = CSS_Color.PromptingColor1, |
| | | TextAlignment = TextAlignment.CenterRight, |
| | |
| | | Radius = (uint)Application.GetRealHeight(22), |
| | | SelectedBackgroundColor = CSS_Color.MainColor, |
| | | BackgroundColor = CSS_Color.PromptingColor1, |
| | | TextID = R.InternationalizationString.Register, |
| | | TextID = StringId.Register, |
| | | TextSize = CSS_FontSize.SubheadingFontSize, |
| | | TextColor = CSS_Color.MainBackgroundColor, |
| | | TextAlignment = TextAlignment.Center, |
| | |
| | | |
| | | LoadEventList(); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 注册成功之后自动登录 |
| | | /// </summary> |
| | | 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); |
| | | }); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | |
| | | #region 登录线程部分 |
| | | /// <summary> |
| | | /// 加载登录线程 |
| | | /// </summary> |
| | | 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; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 调用登录接口登录 |
| | | /// </summary> |
| | | bool LoadMethod_Login(string account, string password) |
| | | { |
| | | var result = false; |
| | | //调用登录接口 |
| | | var loginResult = pm.LoginByPassword(account, password); |
| | | if (loginResult.StateCode.ToUpper() == "SUCCESS") |
| | | { |
| | | var loginDataStr = Newtonsoft.Json.Linq.JObject.FromObject(loginResult.ResponseData); |
| | | |
| | | //记录用户数据 |
| | | MainPage.LoginUser = new UserInfo |
| | | { |
| | | ID = (int)loginDataStr.GetValue("UserID"), |
| | | masterID = (int)loginDataStr.GetValue("MainUserID"), |
| | | accountType = (int)loginDataStr.GetValue("UserType"), |
| | | accountString = account, |
| | | password = password, |
| | | lastTime = DateTime.Now, |
| | | SIP_Account = loginDataStr.GetValue("AllVisionRegisterDevUserNameGuid").ToString(), |
| | | userName = loginDataStr.GetValue("Remark").ToString(), |
| | | }; |
| | | MainPage.LoginUser.SaveUserInfo(); |
| | | MainPage.Log("登录成功。"); |
| | | result = true; |
| | | |
| | | |
| | | } |
| | | //登录失败 |
| | | else |
| | | { |
| | | string tipStr = "Sever erorr"; |
| | | switch (loginResult.StateCode) |
| | | { |
| | | case "USERNAMEORPWDERROR": |
| | | tipStr = Language.StringByID(StringId.LoginFailed_AccountOrPasswordError); |
| | | break; |
| | | case "Self:Net_Error": |
| | | tipStr = Language.StringByID(StringId.NetworkAnomaly); |
| | | break; |
| | | } |
| | | //账号或者密码错误 |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | //提示原因 |
| | | var tip = new Tip() |
| | | { |
| | | Text = tipStr, |
| | | CloseTime = 3, |
| | | Direction = AMPopTipDirection.None |
| | | }; |
| | | tip.Show(bodyView); |
| | | btnPasswordViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2; |
| | | btnPasswordViewBottomLine.Height = Application.GetRealHeight(2); |
| | | }); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取住宅列表 |
| | | /// </summary> |
| | | bool LoadMethod_GetResidences() |
| | | { |
| | | var result = false; |
| | | var responsePack = pm.GetHomePager(); |
| | | if (responsePack == "Success") |
| | | { |
| | | } |
| | | else |
| | | { |
| | | var tipStr = "Server erorr"; |
| | | switch (responsePack) |
| | | { |
| | | case "NoLogin": |
| | | tipStr = Language.StringByID(StringId.InvalidLoginCertificate); |
| | | break; |
| | | } |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | //提示原因 |
| | | var tip = new Tip() |
| | | { |
| | | Text = tipStr, |
| | | CloseTime = 3, |
| | | Direction = AMPopTipDirection.None |
| | | }; |
| | | tip.Show(bodyView); |
| | | }); |
| | | |
| | | } |
| | | return result; |
| | | } |
| | | #endregion |
| | | } |
| | | } |