using System; using Shared.Common; using Shared.Phone.UserView; using Shared.Phone.Device.CommonForm; using Shared.Phone.UserCenter; namespace Shared.Phone.Login { /// /// 登录界面 /// public class AccountLogin : FrameLayout { #region ◆ 变量____________________________ /// /// 背景视图 /// private FrameLayout midFrameLayout; /// /// 手机邮箱 /// private PhoneEmailForm phoneEmailForm; /// /// phoneRowForm /// private PhoneLoginRowForm phoneRow; /// /// emailRow /// private EmailLoginRowForm emailRow; /// /// phonePwdRow /// private PwdLoginRowForm phonePwdRow; /// /// emailPwdRow /// private PwdLoginRowForm emailPwdRow; /// /// 账号密码fl /// private FrameLayout accountPwdFL; /// /// 登录错误提示按钮 /// private Button loginErrorBtn; /// /// 忘记密码按钮 /// private Button forgotPasswordBtn; /// /// 登录按钮 /// private Button loginBtn; /// /// 验证码登录按钮 /// private Button loginByCodeBtn; /// /// 注册按钮 /// private Button registerBtn; /// /// wechat /// private Button wechatBtn; /// /// qq /// private Button qqBtn; /// /// 输入的登陆账号(重新登陆时使用) /// private string oldInputPhone = string.Empty; /// /// 输入的登陆账号(重新登陆时使用) /// private string oldInputEmail = string.Empty; #endregion #region ◆ 构造方法_________________________ /// /// 构造方法 /// public AccountLogin() { CommonPage.Instance.IsDrawerLockMode = true; BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; Tag = "Login"; } public override void RemoveFromParent() { base.RemoveFromParent(); } #endregion #region ◆ 显示界面_________________________ /// /// 显示界面 /// /// Account. /// Password. public void Show(string account = "", string password = "") { if (Config.Instance.IsLogin) { } else { LoginViewShow(account); } } /// /// Logins the view show. /// /// Account. 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); #endregion BindEvent(); if (account.Contains("@") == true) { SelectPhoneOrEmail_MouseUpEvent(phoneEmailForm.SelectedEmail, null); } } #endregion #region ◆ 绑定事件_________________________ /// /// 绑定按钮事件 /// 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 ◆ 登录____________________________ /// /// 登录事件 /// /// Sender. /// The ${ParameterType} instance containing the event data. private void LoginBtnEvent(object sender,MouseEventArgs mouseEventArgs) { if (phoneEmailForm.SelectedPhone.IsSelected) { Login(phoneRow.AccountET.Text.Trim(), phonePwdRow.PasswrodET.Text.Trim()); } else { Login(emailRow.AccountET.Text.Trim(), emailPwdRow.PasswrodET.Text.Trim()); } } /// /// 登录 /// /// Account. /// Password. private void Login(string accountStr, string passwordStr) { //Application.RunOnMainThread( () => //{ Action action = async () => { try { 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; } HomePage.Instance.ShowLoginLoadView(); new System.Threading.Thread(async () => { //存储数据 var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject(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; 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(); 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(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(); } /// /// CheckAccount /// /// /// 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; } /// /// 通过验证码登录 /// /// Sender. /// The ${ParameterType} instance containing the event data. private void LoginByCode(object sender,MouseEventArgs mouseEventArgs) { //this.RemoveFromParent(); var loginByCodePage = new AccountLoginByCode(); CommonPage.Instance.AddChidren(loginByCodePage); loginByCodePage.Show(); } /// /// wechat登录 /// /// /// private void LoginByWechat(object sender, MouseEventArgs mouseEventArgs) { #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(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(authStr); Application.RunOnMainThread(() => { var registerPage = new AccountRegister(); Shared.Common.CommonPage.Instance.AddChidren(registerPage); registerPage.OpenID = authRes.openid; registerPage.Show(); }); } }) { IsBackground = true }.Start(); } }; #endif } /// /// qq登录 /// /// /// private void LoginByQQ(object sender, MouseEventArgs mouseEventArgs) { } /// /// 是否已绑定 /// /// /// private async System.Threading.Tasks.Task isBindAuthAsync(string authStr) { var authRes = Newtonsoft.Json.JsonConvert.DeserializeObject(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; strUrl += "&openid=" + authRes.openid; var byteData = await Common.CommonPage.Instance.DoRequestZigbeeHttpsInterface(strUrl, null, null, "GET"); if (byteData == null) { return false; } var receipData = System.Text.Encoding.UTF8.GetString(byteData); var nickData = Newtonsoft.Json.JsonConvert.DeserializeObject(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(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; if (Config.Instance.AccountList.Find((obj) => obj == revertData.Account) == null) { Config.Instance.AccountList.Add(revertData.Account); } Config.Instance.Save(); return true; } else { return false; } } /// /// phone/email 选择 /// /// /// 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"); } } /// /// AddPhoneOrEmailFL /// /// /// 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 ◆ 忘记密码________________________ /// /// 忘记密码 /// private void ForgetPWD_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs) { var forgot = new AccountForgetPWD(); CommonPage.Instance.AddChidren(forgot); forgot.Show(); } #endregion #region ◆ 注册_____________________________ /// /// 注册 /// /// Sender. /// The ${ParameterType} instance containing the event data. private void Register(object sender,MouseEventArgs mouseEventArgs) { var registerPage = new AccountRegister(); CommonPage.Instance.AddChidren(registerPage); registerPage.Show(); } #endregion #region ◆ 账号密码监听______________________ /// /// 账号监听 /// /// Sender. /// The ${ParameterType} instance containing the event data. private void Account_TextChange(object sender,string mouseEventArgs) { loginErrorBtn.Text = string.Empty; } /// /// 密码监听事件 /// /// Sender. 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 ■ 变量声明___________________________ /// /// 手机账号登陆的控件容器 /// private FrameLayout frameAccLoginPhoneback = null; /// /// 邮箱账号登陆的控件容器 /// private FrameLayout frameEmailLoginPhoneback = null; #endregion #region ■ 初始化_____________________________ /// /// 界面显示 /// /// 登陆账号 public void ShowForm(string account = "") { if (Config.Instance.IsLogin == true) { 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"; btnLogoIcon.Gravity = Gravity.CenterHorizontal; 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.TextSize = 16; this.AddChidren(btnLogoName); //手机号,邮箱的菜单控件 int defultIndex = account.Contains("@") == false ? 1 : 2; var sitchControl = new Controls.PhoneEmailSelectControl(); sitchControl.Y = Application.GetRealHeight(559); this.AddChidren(sitchControl); sitchControl.SelectMenuEvent += (selectIndex) => { //手机号 if (selectIndex == 1) { } //邮箱 else if (selectIndex == 2) { } }; //执行初始化 sitchControl.InitControl(ZigbeeColor.Current.GXCButtonSelectedColor, defultIndex); 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); BindEvent(); if (account.Contains("@") == true) { SelectPhoneOrEmail_MouseUpEvent(phoneEmailForm.SelectedEmail, null); } } #endregion #region ■ 初始化账号登陆窗口_________________ /// /// 初始化账号登陆窗口 /// /// 中间浅色的背景容器 /// 登陆账号 /// 1:手机号 2:邮箱 private void InitAccoutLoginWindow(FrameLayout frameMidBack, string i_account, int i_div) { //容器 var frameBack = new FrameLayout(); frameBack.Height = Application.GetRealHeight(620); frameBack.Y = Application.GetRealHeight(181); frameMidBack.AddChidren(frameBack); //白色背景 var frameWhiteBack = new FrameLayout(); frameWhiteBack.Width = Application.GetRealWidth(942); frameWhiteBack.Height = Application.GetRealHeight(553); frameWhiteBack.BackgroundColor = UserCenterColor.Current.White; frameWhiteBack.Radius = (uint)Application.GetRealHeight(17); frameWhiteBack.Gravity = Gravity.CenterHorizontal; frameBack.AddChidren(frameWhiteBack); //账号行 var rowAccount = new FrameLayout(); rowAccount.Y = Application.GetRealHeight(29); rowAccount.Width = Application.GetRealWidth(884); rowAccount.Height = Application.GetRealHeight(138); rowAccount.Gravity = Gravity.CenterHorizontal; frameWhiteBack.AddChidren(rowAccount); //账号图标 var btnAccountIcon = new IconViewControl(92); btnAccountIcon.X = Application.GetRealWidth(69); btnAccountIcon.Gravity = Gravity.CenterVertical; btnAccountIcon.UnSelectedImagePath = "Account/Account.png"; rowAccount.AddChidren(btnAccountIcon); //账号输入框 var txtAccount = new TextInputControl(600, 92, true); txtAccount.X = btnAccountIcon.Right + Application.GetRealWidth(35); txtAccount.Gravity = Gravity.CenterVertical; if (i_div == 1) { //手机号 txtAccount.IsNumberKeyboardType = true; txtAccount.PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputPhoneNum); } else { //邮箱 txtAccount.PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputEmail); } txtAccount.PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor; txtAccount.Text = i_account; rowAccount.AddChidren(txtAccount); //底线 var btnAccountLine = new NormalViewControl(rowAccount.Width, 1, false); btnAccountLine.BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor; btnAccountLine.Y = rowAccount.Height - 1; rowAccount.AddChidren(btnAccountLine); //密码行 var rowPassword = new FrameLayout(); rowPassword.Y = rowAccount.Bottom + Application.GetRealHeight(58); rowPassword.Width = rowAccount.Width; rowPassword.Height = rowAccount.Height; rowPassword.Gravity = Gravity.CenterHorizontal; frameWhiteBack.AddChidren(rowPassword); //账号图标 var btnPswIcon = new IconViewControl(92); btnPswIcon.X = btnAccountIcon.X; btnPswIcon.Gravity = Gravity.CenterVertical; btnPswIcon.UnSelectedImagePath = "Account/Password.png"; rowPassword.AddChidren(btnPswIcon); //账号输入框 var txtPsw = new TextInputControl(600, 92, true); txtPsw.X = txtAccount.X; txtPsw.Gravity = Gravity.CenterVertical; txtPsw.PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputPWD); txtPsw.PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor; txtPsw.SecureTextEntry = true; rowPassword.AddChidren(txtPsw); //底线 var btnPswLine = new NormalViewControl(rowPassword.Width, 1, false); btnPswLine.BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor; btnPswLine.Y = rowPassword.Height - 1; rowPassword.AddChidren(btnPswLine); } #endregion } }