| | |
| | | /// </summary> |
| | | private EmailLoginRowForm emailRow; |
| | | /// <summary> |
| | | /// pwdRow |
| | | /// phonePwdRow |
| | | /// </summary> |
| | | private PwdLoginRowForm pwdRow; |
| | | private PwdLoginRowForm phonePwdRow;
|
| | | /// <summary> |
| | | /// emailPwdRow |
| | | /// </summary> |
| | | private PwdLoginRowForm emailPwdRow; |
| | | |
| | | /// <summary> |
| | | /// 账号密码fl |
| | |
| | | /// </summary> |
| | | private Button registerBtn; |
| | | /// <summary> |
| | | /// 账号 |
| | | /// </summary> |
| | | private string account; |
| | | /// <summary> |
| | | /// 密码 |
| | | /// </summary> |
| | | private string password; |
| | | /// <summary> |
| | | /// wechat |
| | | /// </summary> |
| | | private Button wechatBtn; |
| | |
| | | /// qq |
| | | /// </summary> |
| | | private Button qqBtn; |
| | | |
| | | /// <summary>
|
| | | /// 输入的登陆账号(重新登陆时使用)
|
| | | /// </summary> |
| | | private string oldInputAccount = string.Empty; |
| | | |
| | | #endregion |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | LoginViewShow(account, password); |
| | | LoginViewShow(account); |
| | | } |
| | | } |
| | | |
| | |
| | | /// Logins the view show. |
| | | /// </summary> |
| | | /// <param name="account">Account.</param> |
| | | /// <param name="password">Password.</param> |
| | | public void LoginViewShow(string account = "", string password = "") |
| | | public void LoginViewShow(string account = "") |
| | | { |
| | | this.account = account; |
| | | this.password = password; |
| | | //设置一下初始值 |
| | | if (account.Contains("@") == true) { this.oldInputAccount = account; } |
| | | else { this.oldInputAccount = account; } |
| | | |
| | | #region midFrameLayout |
| | | midFrameLayout = new FrameLayout() |
| | | { |
| | |
| | | SelectedBackgroundColor = ZigbeeColor.Current.GXCButtonBlackSelectedColor, |
| | | BackgroundColor = ZigbeeColor.Current.GXCButtonUnSelectedColor, |
| | | Radius = (uint)Application.GetRealHeight(127 / 2), |
| | | Enable = !string.IsNullOrEmpty(pwdRow.PasswrodET?.Text), |
| | | IsSelected = !string.IsNullOrEmpty(pwdRow.PasswrodET?.Text), |
| | | Enable = false, |
| | | IsBold=true |
| | | }; |
| | | midFrameLayout.AddChidren(loginBtn); |
| | |
| | | |
| | | BindEvent(); |
| | | |
| | | if (string.IsNullOrEmpty(account) == false && AccountLogic.Instance.CheckEmail(account) == true) |
| | | if (account.Contains("@") == true) |
| | | { |
| | | SelectPhoneOrEmail_MouseUpEvent(phoneEmailForm.SelectedEmail, null); |
| | | this.account = string.Empty; |
| | | } |
| | | else |
| | | { |
| | | this.account = string.Empty; |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | if (phoneEmailForm.SelectedPhone.IsSelected) |
| | | { |
| | | Login(phoneRow.AccountET.Text.Trim(), pwdRow.PasswrodET.Text.Trim()); |
| | | Login(phoneRow.AccountET.Text.Trim(), phonePwdRow.PasswrodET.Text.Trim()); |
| | | } |
| | | else |
| | | { |
| | | Login(emailRow.AccountET.Text.Trim(), pwdRow.PasswrodET.Text.Trim()); |
| | | Login(emailRow.AccountET.Text.Trim(), emailPwdRow.PasswrodET.Text.Trim()); |
| | | } |
| | | |
| | | } |
| | |
| | | /// <param name="accountStr">Account.</param> |
| | | /// <param name="passwordStr">Password.</param> |
| | | private void Login(string accountStr, string passwordStr) |
| | | { |
| | | {
|
| | | //Application.RunOnMainThread( () => |
| | | //{ |
| | | Action action = async () => |
| | | { |
| | | try |
| | | { |
| | | if(CheckAccount(accountStr)==false) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | if(CheckAccount(accountStr)==false)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | CommonPage.Loading.Start(Language.StringByID(R.MyInternationalizationString.Logining)); |
| | | |
| | | var requestObj = new SendDataToServer.LoginObj |
| | | { |
| | | Account = accountStr, |
| | | Password = passwordStr, |
| | | Source = CommonPage.Source, |
| | | Company = CommonPage.Company |
| | | }; |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestObj); |
| | | var revertObj = await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/Login", System.Text.Encoding.UTF8.GetBytes(requestJson)); |
| | | if (revertObj == null) |
| | | { |
| | | CommonPage.Instance.FailureToServer(); |
| | | CommonPage.Loading.Hide(); |
| | | return; |
| | | } |
| | | var stateCodeStr = revertObj.StateCode.ToUpper(); |
| | | //Error 不能直接从服务器取,只能根据状态码逐一判断 |
| | | if (stateCodeStr == "SUCCESS") |
| | | { |
| | | if (revertObj.ResponseData == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | var requestObj = new SendDataToServer.LoginObj
|
| | | {
|
| | | Account = accountStr,
|
| | | Password = passwordStr,
|
| | | Source = CommonPage.Source,
|
| | | Company = CommonPage.Company
|
| | | };
|
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestObj);
|
| | | var revertObj = await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/Login", System.Text.Encoding.UTF8.GetBytes(requestJson));
|
| | | if (revertObj == null)
|
| | | {
|
| | | CommonPage.Instance.FailureToServer();
|
| | | CommonPage.Loading.Hide();
|
| | | return;
|
| | | }
|
| | | var stateCodeStr = revertObj.StateCode.ToUpper();
|
| | | //Error 不能直接从服务器取,只能根据状态码逐一判断
|
| | | if (stateCodeStr == "SUCCESS")
|
| | | {
|
| | | if (revertObj.ResponseData == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | HomePage.Instance.ShowLoginLoadView(); |
| | | |
| | | new System.Threading.Thread(async () => |
| | | { |
| | | //存储数据 |
| | | var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginRes>(revertObj.ResponseData.ToString()); |
| | | var revertData = responseDataObj; |
| | | Config.ReFresh(); |
| | | Config.Instance.Account = revertData.Account; |
| | | new System.Threading.Thread(async () =>
|
| | | {
|
| | | //存储数据
|
| | | var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginRes>(revertObj.ResponseData.ToString());
|
| | | var revertData = responseDataObj;
|
| | | Config.ReFresh();
|
| | | Config.Instance.Account = revertData.Account;
|
| | | Config.Instance.Password = passwordStr;
|
| | | Config.Instance.MD5PWD = revertData.MD5PWD;
|
| | | Config.Instance.Guid = revertData.Guid; |
| | | Config.Instance.LoginDateTime = DateTime.Now; |
| | | Config.Instance.LoginToken = revertData.Token; |
| | | if (Config.Instance.AccountList.Find((obj) => obj == revertData.Account) == null) |
| | | { |
| | | Config.Instance.AccountList.Add(revertData.Account); |
| | | } |
| | | Config.Instance.Save(); |
| | | |
| | | var resultRegID = await Shared.Common.CommonPage.Instance.PushRegID(); |
| | | var homes = await House.GetHomeLists(); |
| | | //刷新个人中心的内存及线程 |
| | | Config.Instance.Guid = revertData.Guid;
|
| | | Config.Instance.LoginDateTime = DateTime.Now;
|
| | | Config.Instance.LoginToken = revertData.Token;
|
| | | if (Config.Instance.AccountList.Find((obj) => obj == revertData.Account) == null)
|
| | | {
|
| | | Config.Instance.AccountList.Add(revertData.Account);
|
| | | }
|
| | | Config.Instance.Save();
|
| | |
|
| | | var resultRegID = await Shared.Common.CommonPage.Instance.PushRegID();
|
| | | var homes = await House.GetHomeLists();
|
| | | //刷新个人中心的内存及线程
|
| | | await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread();
|
| | | //启动ZigBee
|
| | | ZigBee.Common.Application.Init(); |
| | | |
| | | UserCenter.HdlRoomLogic.Current.InitAllRoom(); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | this.RemoveFromParent(); |
| | | ZigBee.Common.Application.Init();
|
| | |
|
| | | UserCenter.HdlRoomLogic.Current.InitAllRoom();
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | CommonPage.Loading.Hide();
|
| | | this.RemoveFromParent();
|
| | | CommonPage.Instance.RemoveViewByTag("Login"); |
| | | UserPage.Instance.Fresh(); |
| | | }); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | UserPage.Instance.Fresh();
|
| | | });
|
| | | })
|
| | | { IsBackground = true }.Start();
|
| | | }
|
| | | else if (stateCodeStr == "NOTVERIFY")
|
| | | {
|
| | | CommonPage.Loading.Hide();
|
| | | //未激活
|
| | | loginErrorBtn.TextID = R.MyInternationalizationString.NOTVERIFY;
|
| | | }
|
| | | else if (stateCodeStr == "NOTENABLE")
|
| | | {
|
| | | CommonPage.Loading.Hide();
|
| | | //该用户属于调试账号,并未启用
|
| | | loginErrorBtn.TextID = R.MyInternationalizationString.NOTENABLE;
|
| | | }
|
| | | else if (stateCodeStr == "USERNAMEORPWDERROR")
|
| | | {
|
| | | CommonPage.Loading.Hide();
|
| | | //账号或密码错误
|
| | | loginErrorBtn.TextID = R.MyInternationalizationString.USERNAMEORPWDERROR;
|
| | | }
|
| | | else if (stateCodeStr == "ACCOUNTNOEXISTS")
|
| | | {
|
| | | CommonPage.Loading.Hide();
|
| | | //账号不存在
|
| | | loginErrorBtn.TextID = R.MyInternationalizationString.ACCOUNTNOEXISTS;
|
| | | }
|
| | | else if (stateCodeStr == "YOUDATANOISLOCALREGION")
|
| | | {
|
| | | CommonPage.Loading.Hide();
|
| | | //不在本区域,需要重定向区域后再次请求登录
|
| | | if (revertObj.ResponseData == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | | var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginLocalRegionRes>(revertObj.ResponseData.ToString());
|
| | | CommonPage.RequestHttpsHost = responseDataObj.RegionServer;
|
| | | //再次登录
|
| | | Login(accountStr, passwordStr);
|
| | | }
|
| | | else
|
| | | {
|
| | | loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed;
|
| | | } |
| | | else if (stateCodeStr == "NOTVERIFY") |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | //未激活 |
| | | loginErrorBtn.TextID = R.MyInternationalizationString.NOTVERIFY; |
| | | } |
| | | else if (stateCodeStr == "NOTENABLE") |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | //该用户属于调试账号,并未启用 |
| | | loginErrorBtn.TextID = R.MyInternationalizationString.NOTENABLE; |
| | | } |
| | | else if (stateCodeStr == "USERNAMEORPWDERROR") |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | //账号或密码错误 |
| | | loginErrorBtn.TextID = R.MyInternationalizationString.USERNAMEORPWDERROR; |
| | | } |
| | | else if (stateCodeStr == "ACCOUNTNOEXISTS") |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | //账号不存在 |
| | | loginErrorBtn.TextID = R.MyInternationalizationString.ACCOUNTNOEXISTS; |
| | | } |
| | | else if (stateCodeStr == "YOUDATANOISLOCALREGION") |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | //不在本区域,需要重定向区域后再次请求登录 |
| | | if (revertObj.ResponseData == null) |
| | | { |
| | | return; |
| | | } |
| | | var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginLocalRegionRes>(revertObj.ResponseData.ToString()); |
| | | CommonPage.RequestHttpsHost = responseDataObj.RegionServer; |
| | | //再次登录 |
| | | Login(accountStr, passwordStr); |
| | | } |
| | | else |
| | | { |
| | | loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed; |
| | | } |
| | | } |
| | | }
|
| | | catch (Exception ex) |
| | | { |
| | | System.Console.WriteLine($"登录失败--{ex.Message}"); |
| | |
| | | else |
| | | { |
| | | new System.Threading.Thread(async () => |
| | | { |
| | | {
|
| | | var re = await isBindAuthAsync(authStr); |
| | | if (re) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | //直接登录
|
| | | HomePage.Instance.ShowLoginLoadView(); |
| | | HomePage.Instance.ShowLoginLoadView();
|
| | | }); |
| | | var resultRegID = await Shared.Common.CommonPage.Instance.PushRegID(); |
| | | var homes = await House.GetHomeLists(); |
| | |
| | | /// <param name="phoneOrEmail"></param> |
| | | private void AddPhoneOrEmailFL(FrameLayout accountPwdFrameLayout,string phoneOrEmail) |
| | | { |
| | | accountPwdFrameLayout.RemoveAll(); |
| | | |
| | | if (phoneOrEmail == "Phone") |
| | | { |
| | | if (phoneRow != null) |
| | | { |
| | | phoneRow.Visible = true;
|
| | | phonePwdRow.Visible = true; |
| | | if (emailRow != null) |
| | | { |
| | | emailRow.Visible = false; |
| | | emailPwdRow.Visible = false; |
| | | }
|
| | | this.Pwd_TextChange(phonePwdRow); |
| | | return; |
| | | } |
| | | phoneRow = new PhoneLoginRowForm(); |
| | | phoneRow.Init(accountPwdFrameLayout, this, this.account, 29, 29); |
| | | phoneRow.AccountET.TextChangeEventHandler += Account_TextChange; |
| | | phoneRow.Init(accountPwdFrameLayout, this, this.oldInputAccount, 29, 29); |
| | | phoneRow.AccountET.TextChangeEventHandler += Account_TextChange;
|
| | |
|
| | | phonePwdRow = new PwdLoginRowForm();
|
| | | phonePwdRow.Init(accountPwdFrameLayout, 29, 225);
|
| | | phonePwdRow.PasswrodET.TextChangeEventHandler += (sender, e) =>
|
| | | {
|
| | | this.Pwd_TextChange(phonePwdRow);
|
| | | }; |
| | | } |
| | | else |
| | | { |
| | | if (emailRow != null)
|
| | | {
|
| | | emailRow.Visible = true;
|
| | | emailPwdRow.Visible = true;
|
| | | if (phoneRow != null)
|
| | | {
|
| | | phoneRow.Visible = false;
|
| | | phonePwdRow.Visible = false;
|
| | | }
|
| | | this.Pwd_TextChange(emailPwdRow);
|
| | | return;
|
| | | } |
| | | emailRow = new EmailLoginRowForm(); |
| | | emailRow.Init(accountPwdFrameLayout, this.account, 29, 29); |
| | | emailRow.AccountET.TextChangeEventHandler += Account_TextChange; |
| | | emailRow.Init(accountPwdFrameLayout, this.oldInputAccount, 29, 29); |
| | | emailRow.AccountET.TextChangeEventHandler += Account_TextChange;
|
| | |
|
| | | emailPwdRow = new PwdLoginRowForm();
|
| | | emailPwdRow.Init(accountPwdFrameLayout, 29, 225);
|
| | | emailPwdRow.PasswrodET.TextChangeEventHandler += (sender, e) => |
| | | {
|
| | | this.Pwd_TextChange(emailPwdRow);
|
| | | }; |
| | | } |
| | | |
| | | pwdRow = new PwdLoginRowForm(); |
| | | pwdRow.Init(accountPwdFrameLayout, 29, 225); |
| | | pwdRow.PasswrodET.TextChangeEventHandler += Pwd_TextChange; |
| | | } |
| | | #endregion |
| | | |
| | |
| | | /// <summary> |
| | | /// 密码监听事件 |
| | | /// </summary> |
| | | /// <param name="sender">Sender.</param> |
| | | /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param> |
| | | private void Pwd_TextChange(object sender,string mouseEventArgs) |
| | | /// <param name="pwdRow">Sender.</param> |
| | | private void Pwd_TextChange(PwdLoginRowForm pwdRow) |
| | | { |
| | | loginErrorBtn.Text = string.Empty; |
| | | if (1 <= pwdRow.PasswrodET.Text.Trim().Length && pwdRow.PasswrodET.Text.Trim().Length <= 16 && (phoneRow.AccountET.Text.Trim().Length > 0 || emailRow?.AccountET.Text.Trim().Length>0)) |
| | | string pswText = pwdRow.PasswrodET.Text.Trim(); |
| | | if (1 <= pswText.Length && pswText.Length <= 16 && (phoneRow.AccountET.Text.Trim().Length > 0 || emailRow?.AccountET.Text.Trim().Length>0)) |
| | | { |
| | | loginBtn.Enable = loginBtn.IsSelected = true; |
| | | } |
| | | else if (pwdRow.PasswrodET.Text.Trim().Length > 16) |
| | | else if (pswText.Length > 16) |
| | | { |
| | | pwdRow.PasswrodET.Text = mouseEventArgs.Remove(16); |
| | | } |
| | | else if (pwdRow.PasswrodET.Text.Trim().Length > 16 && (phoneRow.AccountET.Text.Trim().Length > 0 || emailRow?.AccountET.Text.Trim().Length > 0)) |
| | | { |
| | | loginBtn.Enable = loginBtn.IsSelected = true; |
| | | pwdRow.PasswrodET.Text = mouseEventArgs.Remove(16); |
| | | pwdRow.PasswrodET.Text = pswText.Substring(0, 16); |
| | | if (phoneRow.AccountET.Text.Trim().Length > 0 || emailRow?.AccountET.Text.Trim().Length > 0)
|
| | | {
|
| | | loginBtn.Enable = loginBtn.IsSelected = true;
|
| | | } |
| | | } |
| | | else |
| | | { |