| | |
| | | using System; |
| | | using Shared.Common; |
| | | using Shared.Phone.UserView; |
| | | using Shared.Phone.Device.CommonForm; |
| | | using System;
|
| | | using Shared.Common;
|
| | | using Shared.Phone.UserView;
|
| | | using Shared.Phone.Device.CommonForm;
|
| | | using Shared.Phone.UserCenter;
|
| | |
|
| | | namespace Shared.Phone.Login |
| | | { |
| | | /// <summary> |
| | | /// 登录界面 |
| | | /// </summary> |
| | | public class AccountLogin : FrameLayout |
| | | { |
| | | #region ◆ 变量____________________________ |
| | | /// <summary> |
| | | /// 背景视图 |
| | | /// </summary> |
| | | private FrameLayout midFrameLayout; |
| | | /// <summary> |
| | | /// 手机邮箱 |
| | | /// </summary> |
| | | private PhoneEmailForm phoneEmailForm; |
| | | /// <summary> |
| | | /// phoneRowForm |
| | | /// </summary> |
| | | private PhoneLoginRowForm phoneRow; |
| | | /// <summary> |
| | | /// emailRow |
| | | /// </summary> |
| | | private EmailLoginRowForm emailRow; |
| | | /// <summary> |
| | | /// phonePwdRow |
| | | /// </summary> |
| | | private PwdLoginRowForm phonePwdRow;
|
| | | /// <summary> |
| | | /// emailPwdRow |
| | | /// </summary> |
| | | private PwdLoginRowForm emailPwdRow; |
| | | |
| | | /// <summary> |
| | | /// 账号密码fl |
| | | /// </summary> |
| | | private FrameLayout accountPwdFL; |
| | | /// <summary> |
| | | /// 登录错误提示按钮 |
| | | /// </summary> |
| | | private Button loginErrorBtn; |
| | | /// <summary> |
| | | /// 忘记密码按钮 |
| | | /// </summary> |
| | | private Button forgotPasswordBtn; |
| | | /// <summary> |
| | | /// 登录按钮 |
| | | /// </summary> |
| | | private Button loginBtn; |
| | | /// <summary> |
| | | /// 验证码登录按钮 |
| | | /// </summary> |
| | | private Button loginByCodeBtn; |
| | | /// <summary> |
| | | /// 注册按钮 |
| | | /// </summary> |
| | | private Button registerBtn; |
| | | /// <summary> |
| | | /// wechat |
| | | /// </summary> |
| | | private Button wechatBtn; |
| | | /// <summary> |
| | | /// qq |
| | | /// </summary> |
| | | private Button qqBtn; |
| | | /// <summary>
|
| | | /// 输入的登陆账号(重新登陆时使用)
|
| | | /// </summary> |
| | | private string oldInputPhone = string.Empty;
|
| | | /// <summary>
|
| | | /// 输入的登陆账号(重新登陆时使用)
|
| | | /// </summary> |
| | | private string oldInputEmail = string.Empty; |
| | | |
| | | #endregion |
| | | |
| | | #region ◆ 构造方法_________________________ |
| | | |
| | | /// <summary> |
| | | /// 构造方法 |
| | | /// </summary> |
| | | public AccountLogin() |
| | | { |
| | | CommonPage.Instance.IsDrawerLockMode = true; |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; |
| | | Tag = "Login"; |
| | | } |
| | | |
| | | public override void RemoveFromParent() |
| | | { |
| | | base.RemoveFromParent(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ◆ 显示界面_________________________ |
| | | |
| | | /// <summary> |
| | | /// 显示界面 |
| | | /// </summary> |
| | | /// <param name="account">Account.</param> |
| | | /// <param name="password">Password.</param> |
| | | public void Show(string account = "", string password = "") |
| | | { |
| | | if (Config.Instance.IsLogin) |
| | | { |
| | | |
| | | } |
| | | else |
| | | { |
| | | LoginViewShow(account); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Logins the view show. |
| | | /// </summary> |
| | | /// <param name="account">Account.</param> |
| | | public void LoginViewShow(string account = "") |
| | | { |
| | | //设置一下初始值 |
| | | if (account.Contains("@") == true) { this.oldInputEmail = account; } |
| | | else { this.oldInputPhone = account; } |
| | | |
| | | #region midFrameLayout |
| | | midFrameLayout = new FrameLayout() |
| | | { |
| | | Width = LayoutParams.MatchParent, |
| | | Height = Application.GetRealHeight(CommonPage.AppRealHeight), |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor |
| | | }; |
| | | AddChidren(midFrameLayout); |
| | | #endregion |
| | | |
| | | #region 布局账户,密码,忘记密码,注册 手机验证码登录 |
| | | |
| | | var logoBG = new Button() |
| | | { |
| | | Height = Application.GetRealHeight(619), |
| | | UnSelectedImagePath = "Account/Logo_loginBG.png" |
| | | }; |
| | | midFrameLayout.AddChidren(logoBG); |
| | | |
| | | var phoneEmailBGFL = new FrameLayout() |
| | | { |
| | | Y = logoBG.Bottom, |
| | | Height = Application.GetRealHeight(1921), |
| | | BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor |
| | | }; |
| | | midFrameLayout.AddChidren(phoneEmailBGFL); |
| | | |
| | | var logo = new Button() |
| | | { |
| | | Width = Application.GetMinRealAverage(184), |
| | | Height = Application.GetMinRealAverage(184), |
| | | Y = Application.GetRealHeight(230), |
| | | UnSelectedImagePath = "Account/Logo_White.png", |
| | | Gravity = Gravity.CenterHorizontal |
| | | }; |
| | | midFrameLayout.AddChidren(logo); |
| | | |
| | | var logoName = new Button() |
| | | { |
| | | Y = logo.Bottom, |
| | | Height = Application.GetRealHeight(69), |
| | | Width = Application.GetRealWidth(300), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | TextID = R.MyInternationalizationString.AppName, |
| | | TextColor = ZigbeeColor.Current.GXCTextWhiteColor, |
| | | TextSize = 16 |
| | | }; |
| | | midFrameLayout.AddChidren(logoName); |
| | | |
| | | phoneEmailForm = new PhoneEmailForm(); |
| | | phoneEmailForm.Init(midFrameLayout); |
| | | |
| | | |
| | | //错误提示Btn |
| | | loginErrorBtn = new Button() |
| | | { |
| | | X = Application.GetRealWidth(242), |
| | | Y = Application.GetRealHeight(740), |
| | | Width = Application.GetRealWidth(700), |
| | | Height = Application.GetRealHeight(58), |
| | | TextColor = ZigbeeColor.Current.GXCTextRed, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextSize = CommonFormResouce.TextSize, |
| | | IsBold = true |
| | | }; |
| | | midFrameLayout.AddChidren(loginErrorBtn); |
| | | |
| | | accountPwdFL = new FrameLayout() |
| | | { |
| | | Y = Application.GetRealHeight(801), |
| | | Height = Application.GetRealHeight(553), |
| | | Width = Application.GetRealWidth(942), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, |
| | | Radius = (uint)Application.GetRealHeight(17) |
| | | }; |
| | | midFrameLayout.AddChidren(accountPwdFL); |
| | | |
| | | AddPhoneOrEmailFL(accountPwdFL, "Phone"); |
| | | |
| | | forgotPasswordBtn = new Button() |
| | | { |
| | | X = Application.GetRealWidth(CommonPage.AppRealWidth - 115 - 250), |
| | | Y = Application.GetRealHeight(1198), |
| | | Width = Application.GetRealWidth(250), |
| | | Height = Application.GetRealHeight(58), |
| | | TextID = R.MyInternationalizationString.ForgotPWD_1, |
| | | TextSize = CommonFormResouce.loginTextSize, |
| | | TextColor = Shared.Common.ZigbeeColor.Current.GXCTextGrayColor, |
| | | TextAlignment = TextAlignment.CenterRight |
| | | }; |
| | | midFrameLayout.AddChidren(forgotPasswordBtn); |
| | | |
| | | loginBtn = new Button() |
| | | { |
| | | Y = Application.GetRealHeight(1293), |
| | | Width = Application.GetRealWidth(688), |
| | | Height = Application.GetRealHeight(127), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | TextID = R.MyInternationalizationString.Login, |
| | | TextSize = 16, |
| | | TextColor = ZigbeeColor.Current.GXCTextGrayColor, |
| | | SelectedTextColor = ZigbeeColor.Current.GXCTextWhiteColor, |
| | | SelectedBackgroundColor = ZigbeeColor.Current.GXCButtonBlackSelectedColor, |
| | | BackgroundColor = ZigbeeColor.Current.GXCButtonUnSelectedColor, |
| | | Radius = (uint)Application.GetRealHeight(127 / 2), |
| | | Enable = false, |
| | | IsBold = true |
| | | }; |
| | | midFrameLayout.AddChidren(loginBtn); |
| | | |
| | | loginByCodeBtn = new Button() |
| | | { |
| | | X = Application.GetRealWidth(98), |
| | | Y = Application.GetRealHeight(1466), |
| | | Width = Application.GetRealWidth(300), |
| | | Height = Application.GetRealHeight(49), |
| | | TextID = R.MyInternationalizationString.LoginByCode, |
| | | TextColor = ZigbeeColor.Current.GXCTextGrayColor, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextSize = CommonFormResouce.loginTextSize |
| | | }; |
| | | midFrameLayout.AddChidren(loginByCodeBtn); |
| | | |
| | | registerBtn = new Button() |
| | | { |
| | | X = Application.GetRealWidth(738), |
| | | Y = Application.GetRealHeight(1466), |
| | | Width = Application.GetRealWidth(244), |
| | | Height = Application.GetRealHeight(49), |
| | | TextID = R.MyInternationalizationString.Register, |
| | | TextColor = ZigbeeColor.Current.GXCTextGrayColor, |
| | | TextAlignment = TextAlignment.CenterRight, |
| | | TextSize = CommonFormResouce.loginTextSize |
| | | }; |
| | | midFrameLayout.AddChidren(registerBtn); |
| | | |
| | | wechatBtn = new Button |
| | | { |
| | | X = Application.GetRealWidth(395), |
| | | Y = Application.GetRealHeight(1737), |
| | | Width = Application.GetMinRealAverage(115), |
| | | Height = Application.GetMinRealAverage(115), |
| | | UnSelectedImagePath = "Account/Wechat.png", |
| | | Gravity = Gravity.CenterHorizontal |
| | | }; |
| | | midFrameLayout.AddChidren(wechatBtn); |
| | | |
| | | qqBtn = new Button |
| | | { |
| | | X = Application.GetRealWidth(567), |
| | | Y = Application.GetRealHeight(1737), |
| | | Width = Application.GetMinRealAverage(115), |
| | | Height = Application.GetMinRealAverage(115), |
| | | UnSelectedImagePath = "Account/QQ.png" |
| | | }; |
| | | //midFrameLayout.AddChidren(qqBtn); |
| | | |
| | | //添加服务协议控件 |
| | | //this.AddServiceAgreementControl(phoneEmailBGFL); |
| | | |
| | | #endregion |
| | | |
| | | BindEvent(); |
| | | |
| | | if (account.Contains("@") == true) |
| | | { |
| | | SelectPhoneOrEmail_MouseUpEvent(phoneEmailForm.SelectedEmail, null); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ◆ 绑定事件_________________________ |
| | | |
| | | /// <summary> |
| | | /// 绑定按钮事件 |
| | | /// </summary> |
| | | private void BindEvent() |
| | | { |
| | | //选择手机邮箱 |
| | | phoneEmailForm.SelectedPhone.MouseUpEventHandler += SelectPhoneOrEmail_MouseUpEvent; |
| | | phoneEmailForm.SelectedEmail.MouseUpEventHandler += SelectPhoneOrEmail_MouseUpEvent; |
| | | //登录事件 |
| | | loginBtn.MouseUpEventHandler += LoginBtnEvent; |
| | | //短信登录 |
| | | loginByCodeBtn.MouseUpEventHandler += LoginByCode; |
| | | //注册事件 |
| | | registerBtn.MouseUpEventHandler += Register; |
| | | //忘记密码 |
| | | forgotPasswordBtn.MouseUpEventHandler += ForgetPWD_MouseUpEvent; |
| | | //wechat |
| | | wechatBtn.MouseUpEventHandler += LoginByWechat; |
| | | //qq |
| | | qqBtn.MouseUpEventHandler += LoginByQQ; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ◆ 登录____________________________ |
| | | |
| | | /// <summary> |
| | | /// 登录事件 |
| | | /// </summary> |
| | | /// <param name="sender">Sender.</param> |
| | | /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param> |
| | | private void LoginBtnEvent(object sender, MouseEventArgs mouseEventArgs) |
| | | { |
| | | //检测隐私协议 |
| | | if (this.CheckPrivacyPolicy() == false)
|
| | | {
|
| | | return;
|
| | | } |
| | | if (phoneEmailForm.SelectedPhone.IsSelected) |
| | | { |
| | | Login(phoneRow.AccountET.Text.Trim(), phonePwdRow.PasswrodET.Text.Trim()); |
| | | } |
| | | else |
| | | { |
| | | Login(emailRow.AccountET.Text.Trim(), emailPwdRow.PasswrodET.Text.Trim()); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 登录 |
| | | /// </summary> |
| | | /// <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;
|
| | | }
|
| | | namespace Shared.Phone.Login
|
| | | {
|
| | | /// <summary>
|
| | | /// 登录界面
|
| | | /// </summary>
|
| | | public class AccountLogin : FrameLayoutBase
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | 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;
|
| | | }
|
| | |
|
| | | 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();
|
| | | //标记上一次是不是同一个账号登陆
|
| | | UserCenter.UserCenterResourse.ResidenceOption.TheSameLoginAccount = Config.Instance.Guid == revertData.Guid;
|
| | | 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;
|
| | | 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();
|
| | | CommonPage.Instance.RemoveViewByTag("Login"); |
| | | 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;
|
| | | } |
| | | }
|
| | | catch (Exception ex) |
| | | { |
| | | System.Console.WriteLine($"登录失败--{ex.Message}"); |
| | | CommonPage.Loading.Hide(); |
| | | CommonPage.Instance.FailureToServer(); |
| | | } |
| | | finally |
| | | { |
| | | //CommonPage.Loading.Hide(); |
| | | } |
| | | //}); |
| | | }; |
| | | action(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// CheckAccount |
| | | /// </summary> |
| | | /// <param name="accountStr"></param> |
| | | /// <returns></returns> |
| | | private bool CheckAccount(string accountStr) |
| | | { |
| | | if (phoneEmailForm.SelectedEmail.IsSelected) |
| | | { |
| | | if (AccountLogic.Instance.CheckEmail(accountStr) == false) |
| | | { |
| | | loginErrorBtn.TextID = R.MyInternationalizationString.TheEmailError; |
| | | return false; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (AccountLogic.Instance.CheckPhone(accountStr) == false) |
| | | { |
| | | loginErrorBtn.TextID = R.MyInternationalizationString.ThePhoneError; |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 通过验证码登录 |
| | | /// </summary> |
| | | /// <param name="sender">Sender.</param> |
| | | /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param> |
| | | private void LoginByCode(object sender, MouseEventArgs mouseEventArgs) |
| | | { |
| | | //检测隐私协议 |
| | | if (this.CheckPrivacyPolicy() == false)
|
| | | {
|
| | | return;
|
| | | } |
| | | //this.RemoveFromParent(); |
| | | var loginByCodePage = new AccountLoginByCode(); |
| | | CommonPage.Instance.AddChidren(loginByCodePage); |
| | | loginByCodePage.Show(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// wechat登录 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="mouseEventArgs"></param> |
| | | private void LoginByWechat(object sender, MouseEventArgs mouseEventArgs) |
| | | {
|
| | | //检测隐私协议 |
| | | if (this.CheckPrivacyPolicy() == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | | #if Android |
| | | //var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP),
|
| | | // Language.StringByID(R.MyInternationalizationString.LoginByWechat),
|
| | | // Language.StringByID(R.MyInternationalizationString.Cancel),
|
| | | // Language.StringByID(R.MyInternationalizationString.Confrim));
|
| | | //alert.Show();
|
| | | //alert.ResultEventHandler += (send, e) =>
|
| | | //{
|
| | | //if (e)
|
| | | //{
|
| | | com.hdl.home.Application.WXLogin();
|
| | | com.hdl.home.WXEntryActivity.RespAction = (authStr) =>
|
| | | {
|
| | | if (authStr == null)
|
| | | {
|
| | |
|
| | | }
|
| | | else
|
| | | {
|
| | | new System.Threading.Thread(async () =>
|
| | | {
|
| | | var re = await isBindAuthAsync(authStr);
|
| | | if (re)
|
| | | {
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | //直接登录
|
| | | HomePage.Instance.ShowLoginLoadView();
|
| | | });
|
| | | 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(() =>
|
| | | {
|
| | | this.RemoveFromParent();
|
| | | CommonPage.Instance.RemoveViewByTag("Login");
|
| | | UserPage.Instance.Fresh();
|
| | | });
|
| | | }
|
| | | else
|
| | | {
|
| | | var authRes = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.AuthUserRes>(authStr);
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | var registerPage = new AccountRegister();
|
| | | Shared.Common.CommonPage.Instance.AddChidren(registerPage);
|
| | | registerPage.OpenID = authRes.openid;
|
| | | registerPage.Show();
|
| | | });
|
| | | }
|
| | | })
|
| | | { IsBackground = true }.Start();
|
| | | }
|
| | | };
|
| | | //}
|
| | | //};
|
| | | #endif |
| | |
|
| | | #if iOS |
| | | Home.IOS.AppDelegate.WXLogin();
|
| | | Home.IOS.AppDelegate.RespAction = (authStr) => |
| | | { |
| | | if (authStr == null) |
| | | { |
| | | |
| | | } |
| | | else |
| | | { |
| | | new System.Threading.Thread(async () => |
| | | { |
| | | |
| | | var re = await isBindAuthAsync(authStr); |
| | | if (re) |
| | | { |
| | | //直接登录 |
| | | //this.RemoveFromParent(); |
| | | |
| | | //UserPage.Instance.Fresh(); |
| | | var resultRegID = await Shared.Common.CommonPage.Instance.PushRegID(); |
| | | var homes = await House.GetHomeLists(); |
| | | //启动ZigBee |
| | | ZigBee.Common.Application.Init(); |
| | | //刷新个人中心的内存及线程 |
| | | await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread(); |
| | | UserCenter.HdlRoomLogic.Current.InitAllRoom(); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | this.RemoveFromParent(); |
| | | UserPage.Instance.Fresh(); |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | var authRes = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.AuthUserRes>(authStr); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | var registerPage = new AccountRegister(); |
| | | Shared.Common.CommonPage.Instance.AddChidren(registerPage); |
| | | registerPage.OpenID = authRes.openid; |
| | | registerPage.Show(); |
| | | }); |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | }; |
| | | #endif |
| | |
|
| | |
|
| | |
|
| | | } |
| | | |
| | | /// <summary> |
| | | /// qq登录 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="mouseEventArgs"></param> |
| | | private void LoginByQQ(object sender, MouseEventArgs mouseEventArgs) |
| | | { |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// phone/email 选择 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="mouseEventArgs"></param> |
| | | private void SelectPhoneOrEmail_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs) |
| | | { |
| | | phoneEmailForm.SelectedPhone.IsSelected = phoneEmailForm.SelectedEmail.IsSelected = false; |
| | | phoneEmailForm.SelectedPhone.IsBold = phoneEmailForm.SelectedEmail.IsBold = false; |
| | | loginBtn.Enable = loginBtn.IsSelected = false; |
| | | loginErrorBtn.Text = string.Empty; |
| | | (sender as Button).IsSelected = (sender as Button).IsBold = true; |
| | | if ((sender as Button).Tag.ToString() == "Phone") |
| | | { |
| | | AddPhoneOrEmailFL(accountPwdFL, "Phone"); |
| | | } |
| | | else |
| | | { |
| | | AddPhoneOrEmailFL(accountPwdFL, "Email"); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// AddPhoneOrEmailFL |
| | | /// </summary> |
| | | /// <param name="accountPwdFrameLayout"></param> |
| | | /// <param name="phoneOrEmail"></param> |
| | | private void AddPhoneOrEmailFL(FrameLayout accountPwdFrameLayout, string phoneOrEmail) |
| | | { |
| | | 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.oldInputPhone, 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.oldInputEmail, 29, 29); |
| | | emailRow.AccountET.TextChangeEventHandler += Account_TextChange;
|
| | |
|
| | | emailPwdRow = new PwdLoginRowForm();
|
| | | emailPwdRow.Init(accountPwdFrameLayout, 29, 225);
|
| | | emailPwdRow.PasswrodET.TextChangeEventHandler += (sender, e) => |
| | | {
|
| | | this.Pwd_TextChange(emailPwdRow);
|
| | | }; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | #region ◆ 忘记密码________________________ |
| | | /// <summary> |
| | | /// 忘记密码 |
| | | /// </summary> |
| | | private void ForgetPWD_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs) |
| | | { |
| | | //检测隐私协议 |
| | | if (this.CheckPrivacyPolicy() == false)
|
| | | {
|
| | | return;
|
| | | } |
| | | var forgot = new AccountForgetPWD(); |
| | | CommonPage.Instance.AddChidren(forgot); |
| | | forgot.Show(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ◆ 注册_____________________________ |
| | | |
| | | /// <summary> |
| | | /// 注册 |
| | | /// </summary> |
| | | /// <param name="sender">Sender.</param> |
| | | /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param> |
| | | private void Register(object sender, MouseEventArgs mouseEventArgs) |
| | | { |
| | | //检测隐私协议 |
| | | if (this.CheckPrivacyPolicy() == false)
|
| | | {
|
| | | return;
|
| | | } |
| | | var registerPage = new AccountRegister(); |
| | | CommonPage.Instance.AddChidren(registerPage); |
| | | registerPage.Show(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ◆ 账号密码监听______________________ |
| | | /// <summary> |
| | | /// 账号监听 |
| | | /// </summary> |
| | | /// <param name="sender">Sender.</param> |
| | | /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param> |
| | | private void Account_TextChange(object sender, string mouseEventArgs) |
| | | { |
| | | loginErrorBtn.Text = string.Empty; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 密码监听事件 |
| | | /// </summary> |
| | | /// <param name="pwdRow">Sender.</param> |
| | | private void Pwd_TextChange(PwdLoginRowForm pwdRow) |
| | | { |
| | | loginErrorBtn.Text = string.Empty; |
| | | 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 (pswText.Length > 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 |
| | | { |
| | | loginBtn.Enable = loginBtn.IsSelected = false; |
| | | } |
| | | }
|
| | |
|
| | |
|
| | | #endregion |
| | |
|
| | |
|
| | |
|
| | |
|
| | | #region ■ 变量声明___________________________ |
| | | |
| | | /// <summary>
|
| | | /// 错误提示控件
|
| | | /// </summary> |
| | | private NormalViewControl btnErrorMsg = null; |
| | | /// </summary>
|
| | | private NormalViewControl btnErrorMsg = null;
|
| | | /// <summary>
|
| | | /// 是否同意隐私协议
|
| | | /// </summary> |
| | | private bool isAgreePrivacyPolicy = true; |
| | | |
| | | #endregion |
| | | /// </summary>
|
| | | private bool isAgreePrivacyPolicy = true;
|
| | |
|
| | | #region ■ 初始化_____________________________ |
| | | |
| | | #endregion
|
| | |
|
| | | #region ■ 初始化_____________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 界面显示
|
| | | /// </summary>
|
| | |
| | | {
|
| | | return;
|
| | | }
|
| | | CommonPage.Instance.IsDrawerLockMode = true; |
| | | this.Tag = "Login"; |
| | | |
| | | //界面上部的黑色图片 |
| | | var btnTopBlackPic = new NormalViewControl(this.Width, Application.GetRealHeight(619), false); |
| | | btnTopBlackPic.UnSelectedImagePath = "Account/Logo_loginBG.png"; |
| | | this.AddChidren(btnTopBlackPic); |
| | | |
| | | //中间浅白色的背景 |
| | | var frameMidBack = new FrameLayout(); |
| | | frameMidBack.Y = btnTopBlackPic.Bottom; |
| | | frameMidBack.Height = this.Height - btnTopBlackPic.Bottom; |
| | | frameMidBack.BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor; |
| | | this.AddChidren(frameMidBack); |
| | | |
| | | //HdlHome的图标 |
| | | var btnLogoIcon = new PicViewControl(184, 184); |
| | | btnLogoIcon.Y = Application.GetRealHeight(230); |
| | | btnLogoIcon.UnSelectedImagePath = "Account/Logo_White.png"; |
| | | CommonPage.Instance.IsDrawerLockMode = true;
|
| | | this.Tag = "Login";
|
| | |
|
| | | //界面上部的黑色图片
|
| | | var btnTopBlackPic = new NormalViewControl(this.Width, Application.GetRealHeight(619), false);
|
| | | btnTopBlackPic.UnSelectedImagePath = "Account/Logo_loginBG.png";
|
| | | this.AddChidren(btnTopBlackPic);
|
| | |
|
| | | //中间浅白色的背景
|
| | | var frameMidBack = new FrameLayout();
|
| | | frameMidBack.Y = btnTopBlackPic.Bottom;
|
| | | frameMidBack.Height = this.Height - btnTopBlackPic.Bottom;
|
| | | frameMidBack.BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor;
|
| | | this.AddChidren(frameMidBack);
|
| | |
|
| | | //HdlHome的图标
|
| | | var btnLogoIcon = new PicViewControl(184, 184);
|
| | | btnLogoIcon.Y = Application.GetRealHeight(230);
|
| | | btnLogoIcon.UnSelectedImagePath = "Account/Logo_White.png";
|
| | | btnLogoIcon.Gravity = Gravity.CenterHorizontal;
|
| | | this.AddChidren(btnLogoIcon); |
| | | //Hdl Home |
| | | this.AddChidren(btnLogoIcon);
|
| | | //Hdl Home
|
| | | var btnLogoName = new NormalViewControl(300, 69, true);
|
| | | btnLogoName.Y = btnLogoIcon.Bottom;
|
| | | btnLogoName.Gravity = Gravity.CenterHorizontal;
|
| | | btnLogoName.TextID = R.MyInternationalizationString.AppName;
|
| | | btnLogoName.TextColor = ZigbeeColor.Current.GXCTextWhiteColor;
|
| | | btnLogoName.TextAlignment = TextAlignment.Center;
|
| | | btnLogoName.TextSize = 16; |
| | | btnLogoName.TextSize = 16;
|
| | | this.AddChidren(btnLogoName);
|
| | |
|
| | | //1:手机号 2:邮箱
|
| | | int selectIndex = account.Contains("@") == false ? 1 : 2;
|
| | |
|
| | | //初始化 手机账号登陆窗口
|
| | | var frameAccLoginPhoneback = this.InitAccoutLoginWindow(frameMidBack, selectIndex == 1 ? account : string.Empty, 1); |
| | | var frameAccLoginPhoneback = this.InitAccoutLoginWindow(frameMidBack, selectIndex == 1 ? account : string.Empty, 1);
|
| | | //初始化 邮箱账号登陆窗口
|
| | | var frameEmailLoginPhoneback = this.InitAccoutLoginWindow(frameMidBack, selectIndex == 1 ? string.Empty : account, 2);
|
| | | //初始化 手机账号验证码登陆窗口
|
| | | var frameAccCodeLoginPhoneback = this.InitCodeLoginWindow(frameMidBack, selectIndex == 1 ? account : string.Empty, 1); |
| | | var frameAccCodeLoginPhoneback = this.InitCodeLoginWindow(frameMidBack, selectIndex == 1 ? account : string.Empty, 1);
|
| | | //初始化 邮箱账号验证码登陆窗口
|
| | | var frameEmailCodeLoginPhoneback = this.InitCodeLoginWindow(frameMidBack, selectIndex == 1 ? string.Empty : account, 2); |
| | | |
| | | //定义这两个东西,是为了减少判断的代码 |
| | | var framePhone = frameAccLoginPhoneback; |
| | | var frameEmail = frameEmailLoginPhoneback; |
| | | |
| | | //邮箱,手机号的切换控件 |
| | | var sitchControl = new Controls.PhoneEmailSelectControl(); |
| | | sitchControl.Y = Application.GetRealHeight(559); |
| | | this.AddChidren(sitchControl); |
| | | var frameEmailCodeLoginPhoneback = this.InitCodeLoginWindow(frameMidBack, selectIndex == 1 ? string.Empty : account, 2);
|
| | |
|
| | | //定义这两个东西,是为了减少判断的代码
|
| | | var framePhone = frameAccLoginPhoneback;
|
| | | var frameEmail = frameEmailLoginPhoneback;
|
| | |
|
| | | //邮箱,手机号的切换控件
|
| | | var sitchControl = new Controls.PhoneEmailSelectControl();
|
| | | sitchControl.Y = Application.GetRealHeight(559);
|
| | | this.AddChidren(sitchControl);
|
| | | sitchControl.SelectMenuEvent += (selectMenu) =>
|
| | | {
|
| | | selectIndex = selectMenu;
|
| | |
| | | framePhone.Visible = false;
|
| | | frameEmail.Visible = true;
|
| | | }
|
| | | }; |
| | | //执行初始化 |
| | | sitchControl.InitControl(ZigbeeColor.Current.GXCButtonSelectedColor, selectIndex); |
| | | |
| | | //错误提示控件 |
| | | this.btnErrorMsg = new NormalViewControl(700, 60, true); |
| | | btnErrorMsg.Y = frameAccLoginPhoneback.Y - Application.GetRealHeight(60 + 3); |
| | | btnErrorMsg.X = Application.GetRealWidth(288); |
| | | btnErrorMsg.TextColor = ZigbeeColor.Current.GXCTextRed; |
| | | btnErrorMsg.IsBold = true; |
| | | };
|
| | | //执行初始化
|
| | | sitchControl.InitControl(ZigbeeColor.Current.GXCButtonSelectedColor, selectIndex);
|
| | |
|
| | | //错误提示控件
|
| | | this.btnErrorMsg = new NormalViewControl(700, 60, true);
|
| | | btnErrorMsg.Y = frameAccLoginPhoneback.Y - Application.GetRealHeight(60 + 3);
|
| | | btnErrorMsg.X = Application.GetRealWidth(288);
|
| | | btnErrorMsg.TextColor = ZigbeeColor.Current.GXCTextRed;
|
| | | btnErrorMsg.IsBold = true;
|
| | | frameMidBack.AddChidren(btnErrorMsg);
|
| | |
|
| | | //验证码登陆
|
| | | //1:账号登陆 2:验证码登陆
|
| | | int codeDiv = 1;
|
| | | var btnLoginByCode = new NormalViewControl(300, 100, true); |
| | | var btnLoginByCode = new NormalViewControl(300, 100, true);
|
| | | btnLoginByCode.X = Application.GetRealWidth(98);
|
| | | btnLoginByCode.Y = frameAccLoginPhoneback.Bottom + Application.GetRealHeight(21); |
| | | btnLoginByCode.TextID = R.MyInternationalizationString.LoginByCode; |
| | | btnLoginByCode.TextColor = UserCenterColor.Current.TextGrayColor3; |
| | | btnLoginByCode.Y = frameAccLoginPhoneback.Bottom + Application.GetRealHeight(21);
|
| | | btnLoginByCode.TextID = R.MyInternationalizationString.LoginByCode;
|
| | | btnLoginByCode.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | btnLoginByCode.TextSize = 12;
|
| | | frameMidBack.AddChidren(btnLoginByCode);
|
| | | btnLoginByCode.ButtonClickEvent += (sender, e) =>
|
| | |
| | | };
|
| | |
|
| | | //注册用户
|
| | | var btnRegister = new NormalViewControl(244, 100, true); |
| | | btnRegister.Y = btnLoginByCode.Y; |
| | | btnRegister.X = frameMidBack.Width - Application.GetRealWidth(98 + 244); |
| | | btnRegister.TextID = R.MyInternationalizationString.Register; |
| | | btnRegister.TextColor = UserCenterColor.Current.TextGrayColor3; |
| | | btnRegister.TextSize = 12; |
| | | var btnRegister = new NormalViewControl(300, 100, true);
|
| | | btnRegister.Y = btnLoginByCode.Y;
|
| | | btnRegister.X = frameMidBack.Width - Application.GetRealWidth(98 + 300);
|
| | | btnRegister.TextID = R.MyInternationalizationString.Register;
|
| | | btnRegister.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | btnRegister.TextSize = 12;
|
| | | btnRegister.TextAlignment = TextAlignment.CenterRight;
|
| | | frameMidBack.AddChidren(btnRegister);
|
| | | btnRegister.ButtonClickEvent += (sender, e) =>
|
| | |
| | | };
|
| | |
|
| | | //微信图标
|
| | | var btnWebChat = new IconViewControl(115); |
| | | btnWebChat.Y = frameMidBack.Height - Application.GetRealHeight(69) - btnWebChat.IconSize; |
| | | btnWebChat.UnSelectedImagePath = "Account/Wechat.png"; |
| | | var btnWebChat = new IconViewControl(115);
|
| | | btnWebChat.Y = frameMidBack.Height - Application.GetRealHeight(69) - btnWebChat.IconSize;
|
| | | btnWebChat.UnSelectedImagePath = "Account/Wechat.png";
|
| | | btnWebChat.Gravity = Gravity.CenterHorizontal;
|
| | | frameMidBack.AddChidren(btnWebChat);
|
| | | btnWebChat.ButtonClickEvent += (sender, e) =>
|
| | |
| | | };
|
| | |
|
| | | //添加服务协议控件
|
| | | // this.AddServiceAgreementControl(frameMidBack);
|
| | | //this.AddServiceAgreementControl(frameMidBack);
|
| | |
|
| | | //游客体验
|
| | | var btnTiyan = new NormalViewControl(300, 100, true);
|
| | | btnTiyan.Y = btnLoginByCode.Y;
|
| | | btnTiyan.TextAlignment = TextAlignment.Center;
|
| | | btnTiyan.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | btnTiyan.TextSize = 12;
|
| | | btnTiyan.Gravity = Gravity.CenterHorizontal;
|
| | | btnTiyan.Text = "游客体验";
|
| | | frameMidBack.AddChidren(btnTiyan);
|
| | | btnTiyan.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | btnTiyan.CanClick = false;
|
| | | //显示启动页
|
| | | HomePage.Instance.ShowLoginLoadView();
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //初始化全部体验数据
|
| | | HdlExperienceAccountLogic.Current.InitAllExperienceData();
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | this.RemoveFromParent();
|
| | | CommonPage.Instance.RemoveViewByTag("Login");
|
| | | UserPage.Instance.Fresh();
|
| | | });
|
| | | });
|
| | | };
|
| | | }
|
| | |
|
| | | #endregion |
| | | #endregion
|
| | |
|
| | | #region ■ 初始化账号登陆窗口_________________ |
| | | |
| | | #region ■ 初始化账号登陆窗口_________________
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化账号登陆窗口
|
| | | /// </summary>
|
| | | /// <param name="frameMidBack">中间浅色的背景容器</param>
|
| | | /// <param name="i_account">登陆账号</param>
|
| | | /// <param name="i_div">1:手机号 2:邮箱</param> |
| | | /// <param name="i_div">1:手机号 2:邮箱</param>
|
| | | private FrameLayout InitAccoutLoginWindow(FrameLayout frameMidBack, string i_account, int i_div)
|
| | | {
|
| | | //登陆按钮
|
| | |
| | | txtAccount.TextChangeEventHandler += (sender, e) =>
|
| | | {
|
| | | //隐藏错误提示
|
| | | if (this.btnErrorMsg.Visible == true)
|
| | | {
|
| | | this.btnErrorMsg.Visible = false;
|
| | | }
|
| | | this.btnErrorMsg.Text = string.Empty;
|
| | | if (txtAccount.Text.Trim().Length > 0 && txtPsw.Text.Length > 0)
|
| | | {
|
| | | //能够登陆
|
| | |
| | | //隐藏或者显示密码的图标
|
| | | var btnHiden = new IconViewControl(92);
|
| | | btnHiden.X = rowPassword.Width - Application.GetRealWidth(46) - btnHiden.IconSize;
|
| | | btnHiden.SelectedImagePath = "Account/UnhidePwd.png"; |
| | | btnHiden.SelectedImagePath = "Account/UnhidePwd.png";
|
| | | btnHiden.UnSelectedImagePath = "Account/HidePwd.png";
|
| | | btnHiden.Gravity = Gravity.CenterVertical; |
| | | btnHiden.Gravity = Gravity.CenterVertical;
|
| | | rowPassword.AddChidren(btnHiden);
|
| | | btnHiden.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | |
| | | };
|
| | |
|
| | | //忘记密码?
|
| | | var btnForgot = new NormalViewControl(250, 90, true); |
| | | btnForgot.Y = rowPassword.Bottom + Application.GetRealHeight(15); |
| | | btnForgot.X = frameWhiteBack.Width - Application.GetRealWidth(250 + 35); |
| | | btnForgot.TextSize = 12; |
| | | btnForgot.TextColor = UserCenterColor.Current.TextGrayColor3; |
| | | btnForgot.TextAlignment = TextAlignment.CenterRight; |
| | | btnForgot.TextID = R.MyInternationalizationString.ForgotPWD_1; |
| | | var btnForgot = new NormalViewControl(250, 90, true);
|
| | | btnForgot.Y = rowPassword.Bottom + Application.GetRealHeight(15);
|
| | | btnForgot.X = frameWhiteBack.Width - Application.GetRealWidth(250 + 35);
|
| | | btnForgot.TextSize = 12;
|
| | | btnForgot.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | btnForgot.TextAlignment = TextAlignment.CenterRight;
|
| | | btnForgot.TextID = R.MyInternationalizationString.ForgotPWD_1;
|
| | | frameWhiteBack.AddChidren(btnForgot);
|
| | | btnForgot.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | |
| | | return frameBack;
|
| | | }
|
| | |
|
| | | #endregion |
| | | #endregion
|
| | |
|
| | | #region ■ 初始化验证码登陆窗口_______________
|
| | |
|
| | |
| | | /// </summary>
|
| | | /// <param name="frameMidBack">中间浅色的背景容器</param>
|
| | | /// <param name="i_account">登陆账号</param>
|
| | | /// <param name="i_div">1:手机号 2:邮箱</param> |
| | | /// <param name="i_div">1:手机号 2:邮箱</param>
|
| | | private FrameLayout InitCodeLoginWindow(FrameLayout frameMidBack, string i_account, int i_div)
|
| | | {
|
| | | //登陆按钮
|
| | |
| | | txtAccount.TextChangeEventHandler += (sender, e) =>
|
| | | {
|
| | | //隐藏错误提示
|
| | | if (this.btnErrorMsg.Visible == true)
|
| | | {
|
| | | this.btnErrorMsg.Visible = false;
|
| | | }
|
| | | this.btnErrorMsg.Text = string.Empty;
|
| | | //必须要发送成功才行
|
| | | if (hadSendCode = true && txtAccount.Text.Trim().Length > 0 && txtVerCode.Text.Length > 0)
|
| | | if (hadSendCode == true && txtAccount.Text.Trim().Length > 0 && txtVerCode.Text.Length > 0)
|
| | | {
|
| | | //能够登陆
|
| | | if (btnLogin.CanClick == false) { btnLogin.CanClick = true; }
|
| | |
| | | txtVerCode.Gravity = Gravity.CenterVertical;
|
| | | txtVerCode.PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputVerificationCode);
|
| | | txtVerCode.PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor;
|
| | | txtVerCode.SecureTextEntry = true;
|
| | | rowVerCode.AddChidren(txtVerCode);
|
| | | txtVerCode.TextChangeEventHandler += (sender, e) =>
|
| | | {
|
| | | txtAccount.TextChangeEventHandler(sender, e);
|
| | | };
|
| | | //竖线
|
| | | var btnLine2 = new NormalViewControl(1, Application.GetRealHeight(66), false); |
| | | var btnLine2 = new NormalViewControl(1, Application.GetRealHeight(66), false);
|
| | | btnLine2.X = Application.GetRealWidth(611);
|
| | | btnLine2.Gravity = Gravity.CenterVertical;
|
| | | btnLine2.BackgroundColor = ZigbeeColor.Current.GXCLineColor;
|
| | | rowVerCode.AddChidren(btnLine2);
|
| | | //获取验证码
|
| | | var btnSendCode = new NormalViewControl(250, 70, true); |
| | | btnSendCode.X = btnLine2.Right + Application.GetRealWidth(36); |
| | | btnSendCode.Gravity = Gravity.CenterVertical; |
| | | var btnSendCode = new NormalViewControl(250, 70, true);
|
| | | btnSendCode.X = btnLine2.Right + Application.GetRealWidth(36);
|
| | | btnSendCode.Gravity = Gravity.CenterVertical;
|
| | | btnSendCode.TextID = R.MyInternationalizationString.SendVerificationCode;
|
| | | btnSendCode.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | btnSendCode.TextAlignment = TextAlignment.Center; |
| | | btnSendCode.TextAlignment = TextAlignment.Center;
|
| | | btnSendCode.IsBold = true;
|
| | | rowVerCode.AddChidren(btnSendCode);
|
| | | btnSendCode.ButtonClickEvent += async (sender, e) =>
|
| | |
| | | };
|
| | |
|
| | | //忘记密码?
|
| | | var btnForgot = new NormalViewControl(250, 90, true); |
| | | btnForgot.Y = rowVerCode.Bottom + Application.GetRealHeight(15); |
| | | btnForgot.X = frameWhiteBack.Width - Application.GetRealWidth(250 + 35); |
| | | btnForgot.TextSize = 12; |
| | | btnForgot.TextColor = UserCenterColor.Current.TextGrayColor3; |
| | | btnForgot.TextAlignment = TextAlignment.CenterRight; |
| | | btnForgot.TextID = R.MyInternationalizationString.ForgotPWD_1; |
| | | var btnForgot = new NormalViewControl(250, 90, true);
|
| | | btnForgot.Y = rowVerCode.Bottom + Application.GetRealHeight(15);
|
| | | btnForgot.X = frameWhiteBack.Width - Application.GetRealWidth(250 + 35);
|
| | | btnForgot.TextSize = 12;
|
| | | btnForgot.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | btnForgot.TextAlignment = TextAlignment.CenterRight;
|
| | | btnForgot.TextID = R.MyInternationalizationString.ForgotPWD_1;
|
| | | frameWhiteBack.AddChidren(btnForgot);
|
| | | btnForgot.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | |
| | | return frameBack;
|
| | | }
|
| | |
|
| | | #endregion |
| | | #endregion
|
| | |
|
| | | #region ■ 服务协议___________________________
|
| | |
|
| | |
| | | private void AddServiceAgreementControl(FrameLayout frameBack)
|
| | | {
|
| | | var frameRow = new FrameLayout();
|
| | | frameRow.Height = Application.GetMinRealAverage(110);
|
| | | frameRow.Height = this.GetPictrueRealSize(110);
|
| | | frameRow.Y = Application.GetRealHeight(959);
|
| | | frameRow.Gravity = Gravity.CenterHorizontal;
|
| | |
|
| | |
| | | btnIcon.SelectedImagePath = "Item/Check1Selected.png";
|
| | |
|
| | | //计算行控件的宽度
|
| | | frameRow.Width = fontWidth + Application.GetMinRealAverage(42) + Application.GetRealWidth(23) - speceilValue * 3;
|
| | | frameRow.Width = fontWidth + this.GetPictrueRealSize(42) + Application.GetRealWidth(23) - speceilValue * 3;
|
| | | frameBack.AddChidren(frameRow);
|
| | |
|
| | | //图标控件初始化
|
| | |
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 账号密码登陆_______________________ |
| | | #region ■ 账号密码登陆_______________________
|
| | |
|
| | | /// <summary>
|
| | | /// 账号密码登陆
|
| | | /// </summary>
|
| | | /// <param name="i_account">账号</param>
|
| | | /// <param name="i_psw">密码</param> |
| | | /// <param name="i_div">1:手机号 2:邮箱</param> |
| | | /// <param name="i_psw">密码</param>
|
| | | /// <param name="i_div">1:手机号 2:邮箱</param>
|
| | | private void LoginByAccountAndPsw(string i_account, string i_psw, int i_div)
|
| | | {
|
| | | //检测账号
|
| | |
| | | });
|
| | | }
|
| | |
|
| | | /// <summary> |
| | | /// 检测输入的账号 |
| | | /// </summary> |
| | | /// <param name="i_areaCode">地区码</param> |
| | | /// <param name="i_account">账号</param> |
| | | /// <param name="i_div">1:手机号 2:邮箱</param> |
| | | /// <returns></returns> |
| | | private bool CheckInputAccount(string i_areaCode, string i_account, int i_div) |
| | | { |
| | | /// <summary>
|
| | | /// 检测输入的账号
|
| | | /// </summary>
|
| | | /// <param name="i_areaCode">地区码</param>
|
| | | /// <param name="i_account">账号</param>
|
| | | /// <param name="i_div">1:手机号 2:邮箱</param>
|
| | | /// <returns></returns>
|
| | | private bool CheckInputAccount(string i_areaCode, string i_account, int i_div)
|
| | | {
|
| | | if (i_div == 1)
|
| | | {
|
| | | //检测手机
|
| | | if (i_areaCode != string.Empty && AccountLogic.Instance.CheckPhoneWithZone(i_account, i_areaCode) == false) |
| | | { |
| | | btnErrorMsg.TextID = R.MyInternationalizationString.ThePhoneError; |
| | | return false; |
| | | if (i_areaCode != string.Empty && AccountLogic.Instance.CheckPhoneWithZone(i_account, i_areaCode) == false)
|
| | | {
|
| | | btnErrorMsg.TextID = R.MyInternationalizationString.ThePhoneError;
|
| | | return false;
|
| | | }
|
| | | //检测手机
|
| | | if (i_areaCode == string.Empty && AccountLogic.Instance.CheckPhone(i_account) == false) |
| | | { |
| | | btnErrorMsg.TextID = R.MyInternationalizationString.ThePhoneError; |
| | | return false; |
| | | if (i_areaCode == string.Empty && AccountLogic.Instance.CheckPhone(i_account) == false)
|
| | | {
|
| | | btnErrorMsg.TextID = R.MyInternationalizationString.ThePhoneError;
|
| | | return false;
|
| | | }
|
| | | } |
| | | else |
| | | }
|
| | | else
|
| | | {
|
| | | //检测邮箱
|
| | | if (AccountLogic.Instance.CheckEmail(i_account) == false) |
| | | { |
| | | btnErrorMsg.TextID = R.MyInternationalizationString.TheEmailError; |
| | | return false; |
| | | if (AccountLogic.Instance.CheckEmail(i_account) == false)
|
| | | {
|
| | | btnErrorMsg.TextID = R.MyInternationalizationString.TheEmailError;
|
| | | return false;
|
| | | }
|
| | | } |
| | | return true; |
| | | }
|
| | | return true;
|
| | | }
|
| | |
|
| | | #endregion |
| | | #endregion
|
| | |
|
| | | #region ■ 微信登陆___________________________ |
| | | #region ■ 微信登陆___________________________
|
| | |
|
| | | /// <summary> |
| | | /// 微信登录 |
| | | /// </summary> |
| | | private void LoginByWechat() |
| | | /// <summary>
|
| | | /// 微信登录
|
| | | /// </summary>
|
| | | private void LoginByWechat()
|
| | | {
|
| | | #if Android
|
| | | com.hdl.home.Application.WXLogin();
|
| | | com.hdl.home.WXEntryActivity.RespAction = (authStr) =>
|
| | | {
|
| | | #endif
|
| | | #if iOS |
| | | #if iOS
|
| | | Home.IOS.AppDelegate.WXLogin();
|
| | | Home.IOS.AppDelegate.RespAction = (authStr) => |
| | | Home.IOS.AppDelegate.RespAction = (authStr) =>
|
| | | {
|
| | | #endif
|
| | | if (authStr == null)
|
| | |
| | | };
|
| | | }
|
| | |
|
| | | /// <summary> |
| | | /// 是否已绑定 |
| | | /// </summary> |
| | | /// <param name="authStr"></param> |
| | | /// <returns></returns> |
| | | private async System.Threading.Tasks.Task<bool> isBindAuthAsync(string authStr) |
| | | { |
| | | var authRes = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.AuthUserRes>(authStr); |
| | | var auth = new SendDataToServer.AuthUser() |
| | | { |
| | | AccessToken = authRes.access_token, |
| | | RefreshToken = authRes.refresh_token, |
| | | OpenID = authRes.openid |
| | | /// <summary>
|
| | | /// 是否已绑定
|
| | | /// </summary>
|
| | | /// <param name="authStr"></param>
|
| | | /// <returns></returns>
|
| | | private async System.Threading.Tasks.Task<bool> isBindAuthAsync(string authStr)
|
| | | {
|
| | | var authRes = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.AuthUserRes>(authStr);
|
| | | var auth = new SendDataToServer.AuthUser()
|
| | | {
|
| | | AccessToken = authRes.access_token,
|
| | | RefreshToken = authRes.refresh_token,
|
| | | OpenID = authRes.openid
|
| | | };
|
| | | //获取微信昵称
|
| | | var strUrl = "https://api.weixin.qq.com/sns/userinfo?access_token=" + authRes.access_token;
|
| | |
| | | }
|
| | | var receipData = System.Text.Encoding.UTF8.GetString(byteData);
|
| | | var nickData = Newtonsoft.Json.JsonConvert.DeserializeObject<UserCenter.NicknameInfo>(receipData);
|
| | | auth.UserName = nickData.nickname; |
| | | |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(auth); |
| | | var revertObj = await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/InsertOrUpdateAuthUser", System.Text.Encoding.UTF8.GetBytes(requestJson)); |
| | | if (revertObj == null) |
| | | { |
| | | return false; |
| | | } |
| | | var stateCodeStr = revertObj.StateCode.ToUpper(); |
| | | if (stateCodeStr == "SUCCESS") |
| | | { |
| | | var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginRes>(revertObj.ResponseData.ToString()); |
| | | auth.UserName = nickData.nickname;
|
| | |
|
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(auth);
|
| | | var revertObj = await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/InsertOrUpdateAuthUser", System.Text.Encoding.UTF8.GetBytes(requestJson));
|
| | | if (revertObj == null)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | var stateCodeStr = revertObj.StateCode.ToUpper();
|
| | | if (stateCodeStr == "SUCCESS")
|
| | | {
|
| | | var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginRes>(revertObj.ResponseData.ToString());
|
| | | var revertData = responseDataObj;
|
| | | //标记上一次是不是同一个账号登陆
|
| | | UserCenter.UserCenterResourse.ResidenceOption.TheSameLoginAccount = Config.Instance.Guid == revertData.Guid; |
| | | Config.Instance.Account = revertData.Account; |
| | | Config.Instance.MD5PWD = revertData.MD5PWD; |
| | | Config.Instance.Guid = revertData.Guid; |
| | | Config.Instance.LoginDateTime = DateTime.Now; |
| | | Config.Instance.Save(); |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | UserCenter.UserCenterResourse.ResidenceOption.TheSameLoginAccount = Config.Instance.Guid == revertData.Guid;
|
| | | Config.Instance.Account = revertData.Account;
|
| | | Config.Instance.MD5PWD = revertData.MD5PWD;
|
| | | Config.Instance.Guid = revertData.Guid;
|
| | | Config.Instance.LoginDateTime = DateTime.Now;
|
| | | Config.Instance.Save();
|
| | | return true;
|
| | | }
|
| | | else
|
| | | {
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion |
| | | #endregion
|
| | |
|
| | | #region ■ 验证码登陆_________________________ |
| | | #region ■ 验证码登陆_________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 验证码登陆
|
| | | /// </summary>
|
| | | /// <param name="i_account">账号</param>
|
| | | /// <param name="i_verCode">验证码</param> |
| | | /// <param name="i_div">1:手机号 2:邮箱</param> |
| | | /// <param name="i_verCode">验证码</param>
|
| | | /// <param name="i_div">1:手机号 2:邮箱</param>
|
| | | private async void LoginByVerCode(string i_account, string i_verCode, int i_div)
|
| | | {
|
| | | var pra = new SendDataToServer.LoginValidCodeOBJ()
|
| | |
| | | var result = await CommonFormResouce.LoginByCode(pra);
|
| | | //处理登陆成功的数据
|
| | | this.AdjustLoginSuccessData(result, pra, i_account, string.Empty, i_div);
|
| | | } |
| | | |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 发送验证码
|
| | | /// </summary>
|
| | | /// <param name="btnSendCode">发送按钮</param>
|
| | | /// <param name="account">账号</param>
|
| | | /// <param name="i_div">1:手机号 2:邮箱</param>
|
| | | /// <returns></returns> |
| | | /// <returns></returns>
|
| | | private async System.Threading.Tasks.Task<bool> SendVerCode(NormalViewControl btnSendCode, string account, int i_div)
|
| | | {
|
| | | //不能再点击
|
| | |
| | | });
|
| | |
|
| | | return false;
|
| | | } |
| | | |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 开启发送验证码的倒计时
|
| | | /// </summary>
|
| | | /// <param name="btnSendCode"></param> |
| | | /// <param name="btnSendCode"></param>
|
| | | private void StartSendVerCodeTimeOutThread(NormalViewControl btnSendCode)
|
| | | {
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | |
| | | btnSendCode.Text = time + "s" + strText;
|
| | | });
|
| | | time--;
|
| | | System.Threading.Thread.Sleep(1000);
|
| | | }
|
| | | //倒计时完成之后,可以再次点击
|
| | | btnSendCode.CanClick = true;
|
| | | btnSendCode.TextID = R.MyInternationalizationString.SendVerificationCode;//获取验证码
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //获取验证码
|
| | | btnSendCode.Text = Language.StringByID(R.MyInternationalizationString.SendVerificationCode);
|
| | | });
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion |
| | | #endregion
|
| | |
|
| | | #region ■ 处理登陆成功的数据_________________ |
| | | #region ■ 处理登陆成功的数据_________________
|
| | |
|
| | | /// <summary>
|
| | | /// 处理登陆成功的数据
|
| | |
| | | /// <param name="revertObj">云端返回的数据</param>
|
| | | /// <param name="pra">接口请求参数</param>
|
| | | /// <param name="i_account">账号</param>
|
| | | /// <param name="i_psw">密码,验证码登陆时,设置为 string.Empty</param> |
| | | /// <param name="i_div">1:手机号 2:邮箱</param> |
| | | /// <param name="i_psw">密码,验证码登陆时,设置为 string.Empty</param>
|
| | | /// <param name="i_div">1:手机号 2:邮箱</param>
|
| | | private async void AdjustLoginSuccessData(Common.ResponseEntity.ResponsePack revertObj, object pra,
|
| | | string i_account, string i_psw, int i_div)
|
| | | {
|
| | |
| | | //该用户属于调试账号,并未启用
|
| | | btnErrorMsg.TextID = R.MyInternationalizationString.NOTENABLE;
|
| | | }
|
| | | else if (stateCodeStr == "PARAMETEROREMPTY") |
| | | { |
| | | //提供的参数错误 |
| | | btnErrorMsg.TextID = R.MyInternationalizationString.PARAMETEROREMPTY; |
| | | else if (stateCodeStr == "PARAMETEROREMPTY")
|
| | | {
|
| | | //提供的参数错误
|
| | | btnErrorMsg.TextID = R.MyInternationalizationString.PARAMETEROREMPTY;
|
| | | }
|
| | | else if (stateCodeStr == "VALIDCODEANDPHONENOEQUAL") |
| | | { |
| | | //验证码错误,请重新输入 |
| | | btnErrorMsg.TextID = R.MyInternationalizationString.VALIDCODEANDPHONENOEQUAL; |
| | | else if (stateCodeStr == "VALIDCODEANDPHONENOEQUAL")
|
| | | {
|
| | | //验证码错误,请重新输入
|
| | | btnErrorMsg.TextID = R.MyInternationalizationString.VALIDCODEANDPHONENOEQUAL;
|
| | | }
|
| | | else if (stateCodeStr == "USERNAMEORPWDERROR")
|
| | | {
|
| | |
| | | //账号不存在
|
| | | btnErrorMsg.TextID = R.MyInternationalizationString.ACCOUNTNOEXISTS;
|
| | | }
|
| | | else if (stateCodeStr == "NORECORD" && i_psw == string.Empty) |
| | | { |
| | | //请先获取验证码 |
| | | btnErrorMsg.TextID = R.MyInternationalizationString.NORECORD; |
| | | else if (stateCodeStr == "NORECORD" && i_psw == string.Empty)
|
| | | {
|
| | | //请先获取验证码
|
| | | btnErrorMsg.TextID = R.MyInternationalizationString.NORECORD;
|
| | | }
|
| | | else if (stateCodeStr == "YOUDATANOISLOCALREGION")
|
| | | {
|
| | |
| | | });
|
| | | }
|
| | |
|
| | | #endregion |
| | | #endregion
|
| | |
|
| | | #region ■ 一般方法___________________________ |
| | | |
| | | #region ■ 一般方法___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 检测隐私协议
|
| | | /// </summary>
|
| | | /// <returns></returns> |
| | | /// <returns></returns>
|
| | | private bool CheckPrivacyPolicy()
|
| | | {
|
| | | if (isAgreePrivacyPolicy == false)
|
| | |
| | | return false;
|
| | | }
|
| | | return true;
|
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | } |
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | | }
|