| | |
| | | using System.Collections.Generic; |
| | | using HDL_ON.UI.CSS; |
| | | using Shared; |
| | | using HDL_ON.Entity; |
| | | |
| | | namespace HDL_ON.UI.UI1Login |
| | | { |
| | |
| | | { |
| | | btnGetVerificationCode.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | if (btnGetVerificationCode.IsSelected) |
| | | if (!btnGetVerificationCode.IsSelected) |
| | | { |
| | | string phoneNumber = etAccount.Text.Trim(); |
| | | btnGetVerificationCode.IsSelected = false; |
| | | if (string.IsNullOrEmpty(phoneNumber)) |
| | | { |
| | | var tip = new Tip() |
| | | { |
| | | Text = Language.StringByID(StringId.PlsEntryPhoneNumber), |
| | | CloseTime = 3, |
| | | Direction = AMPopTipDirection.None |
| | | }; |
| | | tip.Show(bodyView); |
| | | |
| | | btnAccountViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2; |
| | | btnAccountViewBottomLine.Height = Application.GetRealHeight(2); |
| | | return; |
| | | } |
| | | if (!Regex.IsMatch(account, @"^[1]+\d{10}")) |
| | | { |
| | | var tip = new Tip() |
| | | { |
| | | Text = Language.StringByID(StringId.PlsEntryCorrectMobilNeumber), |
| | | CloseTime = 3, |
| | | Direction = AMPopTipDirection.None |
| | | }; |
| | | tip.Show(bodyView); |
| | | |
| | | btnAccountViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2; |
| | | btnAccountViewBottomLine.Height = Application.GetRealHeight(2); |
| | | return; |
| | | } |
| | | btnGetVerificationCode.IsSelected = true; |
| | | btnGetVerificationCode.TextColor = CSS_Color.PromptingColor1; |
| | | int time = 60; |
| | | new Thread(() => |
| | |
| | | } |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | btnGetVerificationCode.IsSelected = true; |
| | | btnGetVerificationCode.IsSelected = false; |
| | | btnGetVerificationCode.TextID = StringId.GetVerificationCode; |
| | | }); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | //获取验证码 |
| | | pm.GetPhoneLoginVerCode(phoneNumber); |
| | | new Thread(() => |
| | | { |
| | | //获取验证码 |
| | | var result = pm.GetPhoneLoginVerCode(phoneNumber); |
| | | if (result.StateCode == "SUCCESS") |
| | | { |
| | | } |
| | | //登录失败 |
| | | else |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | btnGetVerificationCode.IsSelected = false; |
| | | btnGetVerificationCode.TextID = StringId.GetVerificationCode; |
| | | }); |
| | | string tipStr = "Sever erorr"; |
| | | switch (result.StateCode.ToUpper()) |
| | | { |
| | | case "USERNAMEORPWDERROR": |
| | | tipStr = Language.StringByID(StringId.LoginFailed_AccountOrPasswordError); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | btnPasswordViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2; |
| | | btnPasswordViewBottomLine.Height = Application.GetRealHeight(2); |
| | | }); |
| | | break; |
| | | case "ACCOUNTNOEXISTS": |
| | | tipStr = Language.StringByID(StringId.ACCOUNTNOEXISTS); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | btnAccountViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2; |
| | | btnAccountViewBottomLine.Height = Application.GetRealHeight(2); |
| | | }); |
| | | break; |
| | | case "SENDFAIL": |
| | | tipStr = Language.StringByID(StringId.FailedToSendVerificationCode); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | btnAccountViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2; |
| | | btnAccountViewBottomLine.Height = Application.GetRealHeight(2); |
| | | }); |
| | | 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); |
| | | btnGetVerificationCode.IsSelected = false; |
| | | }); |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | }; |
| | | } |
| | |
| | | btnEmailLogin.TextSize = CSS_FontSize.TextFontSize; |
| | | btnPhoneLogin.TextColor = CSS_Color.MainColor; |
| | | btnPhoneLogin.TextSize = CSS_FontSize.EmphasisFontSize_Secondary; |
| | | etAccount.PlaceholderText = Language.StringByID(StringId.PlsEntryCorrectMobilNeumber); |
| | | etAccount.PlaceholderText = Language.StringByID(StringId.PlsEntryPhoneNumber); |
| | | #endregion |
| | | |
| | | #region 切换登录方式及图标 |
| | |
| | | { |
| | | btnSwitchLoginMode.TextID = StringId.PasswordLogin; |
| | | passwordView.AddChidren(btnGetVerificationCode); |
| | | etPassword.PlaceholderText = Language.StringByID(StringId.PlsEntryVerificationCode); |
| | | btnPasswordIcon.IsSelected = true; |
| | | if (btnVisiblePassword.Parent != null) |
| | | { |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 文本框选中事件 |
| | | /// 文本框焦点变化事件 |
| | | /// </summary> |
| | | void LoadPage_SelectionEditText() |
| | | { |
| | |
| | | { |
| | | btnAccountViewBottomLine.BackgroundColor = CSS_Color.DividingLineColor; |
| | | btnAccountViewBottomLine.Height = Application.GetRealHeight(1); |
| | | account = etAccount.Text.Trim(); |
| | | if (account.Length == 0) |
| | | return; |
| | | if (logintType == 0) |
| | | { |
| | | if (!Regex.IsMatch(account, @"^[1]+\d{10}")) |
| | | { |
| | | var tip = new Tip() |
| | | { |
| | | Text = Language.StringByID(StringId.PlsEntryCorrectMobilNeumber), |
| | | CloseTime = 3, |
| | | Direction = AMPopTipDirection.None |
| | | }; |
| | | tip.Show(bodyView); |
| | | |
| | | btnAccountViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2; |
| | | btnAccountViewBottomLine.Height = Application.GetRealHeight(2); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (!Regex.IsMatch(account, "([a-zA-Z0-9_\\.\\-])+\\@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,5})+")) |
| | | { |
| | | var tip = new Tip() |
| | | { |
| | | Text = Language.StringByID(StringId.PlsEntryCorrectEmailAddress), |
| | | CloseTime = 3, |
| | | Direction = AMPopTipDirection.None |
| | | }; |
| | | tip.Show(bodyView); |
| | | btnAccountViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2; |
| | | btnAccountViewBottomLine.Height = Application.GetRealHeight(2); |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | //当焦点在密码文本框时,文本框底线点亮 |
| | |
| | | |
| | | if (logintType == 0) |
| | | { |
| | | if (!Regex.IsMatch(account, @"^[1]+\d{9}")) |
| | | if (!Regex.IsMatch(account, @"^[1]+\d{10}")) |
| | | { |
| | | var tip = new Tip() |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | if (!Regex.IsMatch(account, "^[\\w-]+@[\\w-]+\\.(com|net|org|edu|mil|tv|biz|info)$")) |
| | | if (!Regex.IsMatch(account, "([a-zA-Z0-9_\\.\\-])+\\@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,5})+")) |
| | | { |
| | | var tip = new Tip() |
| | | { |
| | |
| | | //创建登录线程 |
| | | var loginThread = LoadThread_Login(); |
| | | waitPage = new Loading(); |
| | | new WaitPageMothed().LoadPage_WaitPage(loginThread, bodyView, waitPage); |
| | | new PublicAssmebly().LoadPage_WaitPage(loginThread, bodyView, waitPage); |
| | | |
| | | } |
| | | }; |
| | |
| | | bool LoadMethod_Login() |
| | | { |
| | | var result = false; |
| | | //调用登录接口 |
| | | var loginResult = pm.LoginByPassword(account, password); |
| | | ResponsePack loginResult; |
| | | if (logintMode == 0) |
| | | { |
| | | //调用登录接口 |
| | | loginResult = pm.LoginByPassword(account, password); |
| | | } |
| | | else |
| | | { |
| | | //调用登录接口 |
| | | loginResult = pm.LoginValidCode(account, password); |
| | | } |
| | | if (loginResult.StateCode == "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, |
| | | 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; |
| | | //获取用户信息 |
| | | new Thread(() => |
| | | { |
| | | pm.GetUserInfo(); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | //登录失败 |
| | | else |
| | |
| | | { |
| | | case "USERNAMEORPWDERROR": |
| | | tipStr = Language.StringByID(StringId.LoginFailed_AccountOrPasswordError); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | btnPasswordViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2; |
| | | btnPasswordViewBottomLine.Height = Application.GetRealHeight(2); |
| | | }); |
| | | break; |
| | | case "ACCOUNTNOEXISTS": |
| | | tipStr = Language.StringByID(StringId.ACCOUNTNOEXISTS); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | btnAccountViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2; |
| | | btnAccountViewBottomLine.Height = Application.GetRealHeight(2); |
| | | }); |
| | | break; |
| | | case "NoRecord": |
| | | tipStr = Language.StringByID(StringId.PlsGetTheVerificationCode); |
| | | break; |
| | | case "Self:Net_Error": |
| | | tipStr = Language.StringByID(StringId.NetworkAnomaly); |
| | |
| | | //账号或者密码错误 |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | waitPage.Hide(); |
| | | //提示原因 |
| | | var tip = new Tip() |
| | | { |
| | |
| | | Direction = AMPopTipDirection.None |
| | | }; |
| | | tip.Show(bodyView); |
| | | btnPasswordViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2; |
| | | btnPasswordViewBottomLine.Height = Application.GetRealHeight(2); |
| | | }); |
| | | } |
| | | return result; |
| | |
| | | } |
| | | else |
| | | { |
| | | MainPage.LoginUser.HomeLists = new List<RegionInfoRes>(); |
| | | MainPage.LoginUser.regionList = new List<RegionInfoRes>(); |
| | | foreach (var jsonData in dataStr.GetValue("PageData")) |
| | | { |
| | | var homeJsonStr = Newtonsoft.Json.Linq.JObject.FromObject(jsonData); |
| | |
| | | RegionID = homeJsonStr.GetValue("Id").ToString(), |
| | | RegionName = homeJsonStr.GetValue("RegionName").ToString(), |
| | | Name = homeJsonStr.GetValue("Name").ToString(), |
| | | Address = homeJsonStr.GetValue("Address").ToString(), |
| | | }; |
| | | MainPage.LoginUser.HomeLists.Add(home); |
| | | MainPage.LoginUser.regionList.Add(home); |
| | | } |
| | | UserConfig.Instance.CurrentRegion = MainPage.LoginUser.HomeLists[0]; |
| | | UserConfig.Instance.SaveUserConfig(); |
| | | DB_ResidenceData.residenceData.residecenInfo = MainPage.LoginUser.regionList[0]; |
| | | DB_ResidenceData.residenceData.SaveResidenceData(); |
| | | MainPage.LoginUser.SaveUserInfo(); |
| | | } |
| | | result = true; |
| | |
| | | btnRegister.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | //回调事件 |
| | | Action<string> callBackAction = (callBackPar_Action) => |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | try |
| | | { |
| | | etAccount.Text = callBackPar_Action; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"login callBackAction : {ex.Message}"); |
| | | } |
| | | }); |
| | | }; |
| | | //Action callBackAction = () => |
| | | //{ |
| | | // Application.RunOnMainThread(() => |
| | | // { |
| | | // try |
| | | // { |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // MainPage.Log($"login callBackAction : {ex.Message}"); |
| | | // } |
| | | // }); |
| | | //}; |
| | | |
| | | var registerPage = new RegisterPage(callBackAction); |
| | | var registerPage = new RegisterPage(); |
| | | registerPage.Show(); |
| | | registerPage.ShowDialog(); |
| | | }; |