using System; using Shared.Common; using System.Text.RegularExpressions; using System.Collections.Generic; using System.Timers; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; namespace Shared.Phone.Device.Account { public class RegistrationByPhone:FrameLayout { public string phoneStr = ""; /// /// 手机号输入是否符合规则 /// public bool IsRightAccount = false; /// /// 下来选择手机区号 默认中国大陆为86 ///发送国际 / 港澳台消息时,接收号码格式为00 + 国际区号 + 号码,如“008615899998888” 调用API时,Company字段请传入整型值:4。 。 ///国内 调用API时,Company字段请传入整型值:0。 /// public List areaCodeList = new List(); public RegistrationByPhone() { BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; } public async void Show() { ShowRegisterView(); CommonPage.Loading.Start(); try { var requestOBJ = new SendDataToServer.GetAreaCodeOBJ() { RequestVersion = CommonPage.RequestVersion }; var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestOBJ); var revertOBJ = await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/GetAreaCode", System.Text.Encoding.UTF8.GetBytes(requestJson)); if (revertOBJ == null) { return; } if (revertOBJ.StateCode.ToUpper() == "SUCCESS") { var responseData = revertOBJ.ResponseData; areaCodeList = Newtonsoft.Json.JsonConvert.DeserializeObject>(responseData.ToString()); } } catch { } finally { CommonPage.Loading.Hide(); } } public void ShowRegisterView() { #region topview var topBGView = new FrameLayout() { Height = Application.GetRealHeight(220), BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor }; AddChidren(topBGView); var topView = new FrameLayout() { Y = Application.GetRealHeight(CommonPage.NavigationTitle_Y), Height = Application.GetRealHeight(220 - CommonPage.NavigationTitle_Y), BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor, }; AddChidren(topView); var titleName = new Button() { TextAlignment = TextAlignment.Center, TextID = R.MyInternationalizationString.RegisterByPhone, TextSize = 19, TextColor = Shared.Common.ZigbeeColor.Current.GXCTextBlackColor, Width=Application.GetRealWidth(600), Gravity=Gravity.CenterHorizontal }; topView.AddChidren(titleName); var loginBtn = new Button() { X = Application.GetRealWidth(1080 - 250), Width = Application.GetRealWidth(200), Height = Application.GetRealHeight(100), TextAlignment=TextAlignment.CenterRight, Gravity = Gravity.CenterVertical, TextColor=ZigbeeColor.Current.GXCTextBlueColor, TextID=R.MyInternationalizationString.Login, TextSize=15 }; topView.AddChidren(loginBtn); var back = new Button() { X = Application.GetRealWidth(CommonPage.Navigation_X), Height = Application.GetMinRealAverage(110), Width = Application.GetMinRealAverage(110), UnSelectedImagePath = "Item/Back.png", SelectedImagePath = "Item/BackSelected.png", Gravity = Gravity.CenterVertical }; topView.AddChidren(back); back.MouseUpEventHandler += (sender, e) => { this.RemoveFromParent(); }; #endregion #region ---midFrameLayout var midFrameLayout = new FrameLayout() { Width = LayoutParams.MatchParent, Height = Application.GetRealHeight(1920 - 220), Y = topView.Bottom, BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, }; this.AddChidren(midFrameLayout); var accountFL = new FrameLayout() { Y = Application.GetRealHeight(150), Width = Application.GetRealWidth(700), Height = Application.GetRealHeight(110), BorderColor = ZigbeeColor.Current.GXCBorderColor, BorderWidth = 1, Radius =(uint)Application.GetRealHeight(55), Gravity=Gravity.CenterHorizontal }; midFrameLayout.AddChidren(accountFL); var accountZoneBtn = new Button() { Width = Application.GetRealWidth(180), Text = "+" + CommonPage.PhoneZoneStr, TextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor, TextAlignment = TextAlignment.Center }; accountFL.AddChidren(accountZoneBtn); var accountZoneLine = new Button() { X = Application.GetRealWidth(10) + accountZoneBtn.Right, Width = 1, Height = Application.GetRealHeight(60), BackgroundColor = ZigbeeColor.Current.GXCLineColor, Gravity=Gravity.CenterVertical }; accountFL.AddChidren(accountZoneLine); var phoneET = new EditText() { X = Application.GetRealWidth(40) + accountZoneLine.Right, Width = Application.GetRealWidth(700-300), TextColor = ZigbeeColor.Current.GXCTextBlackColor, PlaceholderText=Language.StringByID(R.MyInternationalizationString.PleaseInputPhoneNum), PlaceholderTextColor=ZigbeeColor.Current.GXCPlaceHolderTextColor, TextAlignment = TextAlignment.Center }; accountFL.AddChidren(phoneET); var pwdFL = new FrameLayout() { Y = Application.GetRealHeight(80) + accountFL.Bottom, Width = Application.GetRealWidth(700), Height = Application.GetRealHeight(110), BorderColor = ZigbeeColor.Current.GXCBorderColor, BorderWidth = 1, Radius = (uint)Application.GetRealHeight(55), Gravity = Gravity.CenterHorizontal }; midFrameLayout.AddChidren(pwdFL); var pwdET = new EditText() { Width = Application.GetRealWidth(500), Gravity=Gravity.CenterHorizontal, TextColor = ZigbeeColor.Current.GXCTextBlackColor, PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputPWD), PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor, TextAlignment = TextAlignment.Center, SecureTextEntry=true }; pwdFL.AddChidren(pwdET); var hidenPWDbtn = new Button() { X = pwdET.Right + Application.GetRealWidth(20), Width = Application.GetMinReal(72), Height = Application.GetMinReal(72), UnSelectedImagePath = "Account/HidenPWD.png", SelectedImagePath = "Account/UnHidenPWD.png", Gravity=Gravity.CenterVertical }; pwdFL.AddChidren(hidenPWDbtn); var pwdComfirmFL = new FrameLayout() { Y = Application.GetRealHeight(80) + pwdFL.Bottom, Width = Application.GetRealWidth(700), Height = Application.GetRealHeight(110), BorderColor = ZigbeeColor.Current.GXCBorderColor, BorderWidth = 1, Gravity = Gravity.CenterHorizontal, Radius = (uint)Application.GetRealHeight(55) }; midFrameLayout.AddChidren(pwdComfirmFL); var pwdComfirmET = new EditText() { Width = Application.GetRealWidth(500), Gravity=Gravity.CenterHorizontal, TextColor = ZigbeeColor.Current.GXCTextBlackColor, PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseComfirePWD), PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor, TextAlignment = TextAlignment.Center, SecureTextEntry=true }; pwdComfirmFL.AddChidren(pwdComfirmET); var hidenPWDComfirmbtn = new Button() { X = pwdComfirmET.Right + Application.GetRealWidth(20), Width = Application.GetMinReal(72), Height = Application.GetMinReal(72), UnSelectedImagePath = "Account/HidenPWD.png", SelectedImagePath = "Account/UnHidenPWD.png", Gravity = Gravity.CenterVertical }; pwdComfirmFL.AddChidren(hidenPWDComfirmbtn); var verificationCodeFL = new FrameLayout() { Y = Application.GetRealHeight(80) + pwdComfirmFL.Bottom, Width = Application.GetRealWidth(700), Height = Application.GetRealHeight(110), BorderColor = ZigbeeColor.Current.GXCBorderColor, BorderWidth = 1, Gravity = Gravity.CenterHorizontal, Radius = (uint)Application.GetRealHeight(55) }; midFrameLayout.AddChidren(verificationCodeFL); var codeET = new EditText() { X= Application.GetRealWidth(20), Width = Application.GetRealWidth(350), TextColor = ZigbeeColor.Current.GXCTextBlackColor, PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputVerificationCode), PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor, TextAlignment = TextAlignment.Center }; verificationCodeFL.AddChidren(codeET); var codeLine = new Button() { X = Application.GetRealWidth(10) + codeET.Right, Width = 1, Height = Application.GetRealHeight(60), Gravity=Gravity.CenterVertical, BackgroundColor = ZigbeeColor.Current.GXCLineColor }; verificationCodeFL.AddChidren(codeLine); var sendCodeBtn = new Button() { X = codeET.Right+Application.GetRealWidth(20), Width = Application.GetRealWidth(250), TextColor = ZigbeeColor.Current.GXCTextUnselectedColor, SelectedTextColor=ZigbeeColor.Current.GXCTextBlueColor, TextID =R.MyInternationalizationString.SendVerificationCode, TextAlignment=TextAlignment.Center, Enable=false, IsSelected=false }; verificationCodeFL.AddChidren(sendCodeBtn); var comfirmBtn = new Button() { Y = midFrameLayout.Height-Application.GetRealHeight(400), Width = Application.GetRealWidth(700), Height = Application.GetRealHeight(110), TextColor = ZigbeeColor.Current.GXCTextWhiteColor, TextID = R.MyInternationalizationString.Confrim, BackgroundColor = ZigbeeColor.Current.GXCButtonUnselectedColor, SelectedBackgroundColor = ZigbeeColor.Current.GXCButtonBlueColor, Radius =(uint)Application.GetRealHeight(55), Gravity=Gravity.CenterHorizontal, TextAlignment=TextAlignment.Center, Enable=false, IsSelected=false }; midFrameLayout.AddChidren(comfirmBtn); //错误提示Btn var loginErrorBtn = new Button() { Y = comfirmBtn.Bottom + Application.GetRealHeight(50), Width = Application.GetRealWidth(1080 - 100), Height = Application.GetRealHeight(110), TextColor = ZigbeeColor.Current.GXCRedColor, Gravity = Gravity.CenterHorizontal }; midFrameLayout.AddChidren(loginErrorBtn); var t = new Timer(); var dateBegin = new DateTime(); #endregion #region --event-- void TimeBegin() { t.Interval = 1000; t.AutoReset = true; t.Enabled = true; t.Elapsed += TimeOut; //启动计时器倒计时-60s t.Start(); dateBegin = DateTime.Now; } void TimeOut(object source, System.Timers.ElapsedEventArgs e){ var span = DateTime.Now - dateBegin; if(span.TotalSeconds<=61) { Application.RunOnMainThread(() => { sendCodeBtn.Text = Convert.ToInt16((60-span.TotalSeconds))+ "s"+Language.StringByID(R.MyInternationalizationString.SendVerificationCode); sendCodeBtn.Enable = false; }); } else { Application.RunOnMainThread(() => { sendCodeBtn.Enable = true; sendCodeBtn.TextID = R.MyInternationalizationString.SendVerificationCode; t.Stop(); t.Close(); }); } } hidenPWDbtn.MouseUpEventHandler += (sender, e) => { pwdET.SecureTextEntry = !pwdET.SecureTextEntry; hidenPWDbtn.IsSelected = !hidenPWDbtn.IsSelected; }; hidenPWDComfirmbtn.MouseUpEventHandler += (sender, e) => { hidenPWDComfirmbtn.IsSelected = !hidenPWDComfirmbtn.IsSelected; pwdComfirmET.SecureTextEntry = !pwdComfirmET.SecureTextEntry; }; //手机号监听 phoneET.TextChangeEventHandler += (sender, e) => { loginErrorBtn.Text = ""; //校验手机号 if (CommonPage.PhoneZoneStr != "86") { var reg = new Regex(CommonPage.PhoneForForeignRegexStr); var mFalg = reg.Match(phoneET.Text.Trim()); if (!mFalg.Success) { var aler = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.PleaseInputTheCorrectCellPhoneNumber), Language.StringByID(R.MyInternationalizationString.Confrim)); aler.Show(); sendCodeBtn.Enable = sendCodeBtn.IsSelected = false; phoneET.Text = ""; IsRightAccount = false; } else { sendCodeBtn.Enable = sendCodeBtn.IsSelected = true; IsRightAccount = true; } } else { if (phoneET.Text.Trim().Length == 11) { var reg = new Regex(CommonPage.PhoneRegexStr); var mFalg = reg.Match(phoneET.Text.Trim()); if (!mFalg.Success) { var aler = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.PleaseInputTheCorrectCellPhoneNumber), Language.StringByID(R.MyInternationalizationString.Confrim)); aler.Show(); phoneET.Text = ""; sendCodeBtn.Enable = sendCodeBtn.IsSelected = false; IsRightAccount = false; } else { if(pwdComfirmET.Text.Trim().Length >= 6 && pwdComfirmET.Text.Trim().Length <= 16 && pwdET.Text.Trim().Length >= 6 && pwdET.Text.Trim().Length <= 16 && IsRightAccount) { sendCodeBtn.Enable = sendCodeBtn.IsSelected = true; } else { sendCodeBtn.Enable = sendCodeBtn.IsSelected = false; } IsRightAccount = true; } } else if (phoneET.Text.Trim().Length > 11) { phoneET.Text = e.Remove(11); } else { //正则表达式判断是否数字 var reg = new Regex("^[0-9]*$"); if(!reg.IsMatch(phoneET.Text)) { var aler = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.PleaseInputTheCorrectCellPhoneNumber), Language.StringByID(R.MyInternationalizationString.Confrim)); aler.Show(); phoneET.Text = ""; } sendCodeBtn.Enable = sendCodeBtn.IsSelected = false; IsRightAccount = false; } } if (pwdComfirmET.Text.Trim().Length >= 6 && pwdComfirmET.Text.Trim().Length <= 16 && pwdET.Text.Trim().Length >= 6 && pwdET.Text.Trim().Length <= 16 && IsRightAccount) { sendCodeBtn.Enable = sendCodeBtn.IsSelected = true; IsRightAccount = true; } }; //密码监听 pwdET.TextChangeEventHandler += (sender, e) => { loginErrorBtn.Text = ""; if (pwdComfirmET.Text.Trim().Length >= 6 && pwdComfirmET.Text.Trim().Length <= 16 && pwdET.Text.Trim().Length >= 6 && pwdET.Text.Trim().Length <= 16 && IsRightAccount) { sendCodeBtn.Enable = sendCodeBtn.IsSelected = true; } else if (pwdET.Text.Trim().Length > 16) { //sendCodeBtn.Enable = sendCodeBtn.IsSelected = true; pwdET.Text = e.Trim().Remove(16); } else { sendCodeBtn.Enable = sendCodeBtn.IsSelected = false; } }; //确认密码监听 pwdComfirmET.TextChangeEventHandler += (sender, e) => { loginErrorBtn.Text = ""; if (pwdComfirmET.Text.Trim().Length >= 6 && pwdComfirmET.Text.Trim().Length <=16 && pwdET.Text.Trim().Length >= 6 && pwdET.Text.Trim().Length <= 16 && IsRightAccount) { sendCodeBtn.Enable = sendCodeBtn.IsSelected = true; } else if(pwdComfirmET.Text.Trim().Length>16) { //sendCodeBtn.Enable = sendCodeBtn.IsSelected = true; pwdComfirmET.Text = e.Trim().Remove(16); } else { sendCodeBtn.Enable = sendCodeBtn.IsSelected = false; } }; codeET.TextChangeEventHandler += (send, e) => { loginErrorBtn.Text = ""; if (e.Trim().Length > 0 && IsRightAccount && pwdComfirmET.Text.Trim().Length >= 6 && pwdComfirmET.Text .Trim().Length <=16 && pwdET.Text.Trim().Length >= 6 && pwdET.Text.Trim().Length <= 16) { comfirmBtn.Enable = comfirmBtn.IsSelected= true; } else { comfirmBtn.Enable = comfirmBtn.IsSelected = false; } }; Button tempClickZoneImgBtn = new Button(); Button tempClickZoneNameBtn = new Button(); EventHandler phoneZoneHandler = (senderZone, eZone) => { //ZoneListView var phoneZoneSelectedShowView = new Dialog() { Height = Application.GetRealHeight(1000), Width = Application.GetRealWidth(700), BackgroundColor = ZigbeeColor.Current.GXCButtonBlueColor, Radius = (uint)Application.GetRealHeight(30) }; phoneZoneSelectedShowView.Show(); var phoneZoneTitle = new Button() { Height = Application.GetRealHeight(110), TextID = R.MyInternationalizationString.PleaseSelectAreaCode, TextColor = ZigbeeColor.Current.GXCTextWhiteColor, TextSize = 15, BackgroundColor = ZigbeeColor.Current.GXCButtonBlueColor }; phoneZoneSelectedShowView.AddChidren(phoneZoneTitle); var phoneZoneSelectedListView = new VerticalScrolViewLayout() { Y = phoneZoneTitle.Bottom, Height = Application.GetRealHeight(1000 - 110 * 2), BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor }; phoneZoneSelectedShowView.AddChidren(phoneZoneSelectedListView); for (int i = 0; i < areaCodeList.Count; i++) { var zoneItemLName = areaCodeList[i].Name; var zoneItemLCode = areaCodeList[i].Code; var zoneItemFL = new FrameLayout() { Width = phoneZoneSelectedListView.Width, Height = Application.GetRealHeight(110), Tag = i + 10086 }; phoneZoneSelectedListView.AddChidren(zoneItemFL); var zoneIsSelectedBtn = new Button() { Width = Application.GetMinReal(80), Height = Application.GetMinReal(80), UnSelectedImagePath = "Account/Check.png", SelectedImagePath = "Account/CheckSelected.png", Tag = i + 10086, Gravity = Gravity.CenterVertical }; zoneItemFL.AddChidren(zoneIsSelectedBtn); var zoneItemNameBtn = new Button() { X = Application.GetRealWidth(20) + zoneIsSelectedBtn.Right, Width = zoneItemFL.Width - Application.GetRealWidth(100), Height = Application.GetRealHeight(110) - 1, Text = zoneItemLName, TextColor = ZigbeeColor.Current.GXCTextBlackColor, SelectedTextColor = ZigbeeColor.Current.GXCTextBlueColor, TextAlignment = TextAlignment.CenterLeft, Tag = i + 10000 }; zoneItemFL.AddChidren(zoneItemNameBtn); var zoneLine = new Button() { Y = zoneItemFL.Height - 1, Width = zoneItemFL.Width, Height = 1, BackgroundColor = ZigbeeColor.Current.GXCPlaceHolderTextColor }; zoneItemFL.AddChidren(zoneLine); EventHandler selectedZone = (sender, e) => { tempClickZoneImgBtn.IsSelected = false; tempClickZoneNameBtn.IsSelected = false; zoneItemNameBtn.IsSelected = true; zoneIsSelectedBtn.IsSelected = true; tempClickZoneImgBtn = zoneIsSelectedBtn; tempClickZoneNameBtn = zoneItemNameBtn; CommonPage.PhoneZoneStr = zoneItemLCode; }; zoneIsSelectedBtn.MouseUpEventHandler += selectedZone; zoneItemNameBtn.MouseUpEventHandler += selectedZone; //默认 if (zoneItemLCode == CommonPage.PhoneZoneStr) { zoneItemNameBtn.IsSelected = true; zoneIsSelectedBtn.IsSelected = true; tempClickZoneImgBtn = zoneIsSelectedBtn; tempClickZoneNameBtn = zoneItemNameBtn; } } var cancleBtn = new Button() { Y = phoneZoneSelectedListView.Bottom, Height = Application.GetRealHeight(110), Width = Application.GetRealWidth(700 / 2), BackgroundColor = ZigbeeColor.Current.GXCButtonBlueColor, TextID = R.MyInternationalizationString.Cancel, TextSize = 15 }; phoneZoneSelectedShowView.AddChidren(cancleBtn); cancleBtn.MouseUpEventHandler += (sender, e) => { phoneZoneSelectedShowView.Close(); }; cancleBtn.MouseDownEventHandler += (sender, e) => { cancleBtn.IsSelected = true; }; var lineCancleOK = new Button() { X = cancleBtn.Right, Y = phoneZoneSelectedListView.Bottom, Height = Application.GetRealHeight(110), Width = 1, BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor }; phoneZoneSelectedShowView.AddChidren(lineCancleOK); var okBtn = new Button() { X = lineCancleOK.Right + 1, Y = phoneZoneSelectedListView.Bottom, Height = Application.GetRealHeight(110), Width = Application.GetRealWidth(700 / 2) - 1, BackgroundColor = ZigbeeColor.Current.GXCButtonBlueColor, TextID = R.MyInternationalizationString.Confrim, TextSize = 15 }; phoneZoneSelectedShowView.AddChidren(okBtn); okBtn.MouseUpEventHandler += (sender, e) => { accountZoneBtn.Text = "+" + CommonPage.PhoneZoneStr; phoneZoneSelectedShowView.Close(); }; okBtn.MouseDownEventHandler += (sender, e) => { okBtn.IsSelected = true; }; }; accountZoneBtn.MouseUpEventHandler += phoneZoneHandler; //发送验证码 sendCodeBtn.MouseUpEventHandler += async (sender, e) => { //先判断2次密码输入是否一致 if(pwdET.Text.Trim()!=pwdComfirmET.Text.Trim()) { var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.TwoPasswordInconsistency), Language.StringByID(R.MyInternationalizationString.Confrim)); alert.Show(); pwdET.Text = ""; pwdComfirmET.Text = ""; sendCodeBtn.Enable = sendCodeBtn.IsSelected = false; return; } string phoneNum = phoneET.Text.Trim(); CommonPage.Loading.Start(); try { int companyInt = 0; if (CommonPage.PhoneZoneStr == "86") { companyInt = CommonPage.Company; phoneStr = phoneNum; } else { companyInt = CommonPage.CompanyForINTERNETION; phoneStr = phoneNum; } var reqDtoSignPhone = new SendDataToServer.RegisterSendVerCodeObj() { Account = phoneStr, Company = companyInt, AreaCode = int.Parse(CommonPage.PhoneZoneStr), Language = CommonPage.ZigBeeLanguage }; var requesetJson = Newtonsoft.Json.JsonConvert.SerializeObject(reqDtoSignPhone); var requestRevertObj = await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/RegisterSendVerCode", System.Text.Encoding.UTF8.GetBytes(requesetJson)); if (requestRevertObj == null) { CommonPage.Instance.FailureToServer(); return; } var stateCodeStr = requestRevertObj.StateCode.ToUpper(); if (stateCodeStr == "SUCCESS") { TimeBegin(); var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.SendVerificationCodeSuccess), Language.StringByID(R.MyInternationalizationString.Confrim)); alert.Show(); } else if (stateCodeStr == "PARAMETEROREMPTY") { //提供的参数错误 loginErrorBtn.TextID = R.MyInternationalizationString.PARAMETEROREMPTY; CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.PARAMETEROREMPTY); } else if (stateCodeStr == "SENDFAIL") { //验证码发送失败 loginErrorBtn.TextID = R.MyInternationalizationString.SENDFAIL; CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.SENDFAIL); } else if (stateCodeStr == "EXIST") { //账号存在 loginErrorBtn.TextID = R.MyInternationalizationString.AccountHasBeenRegistered; CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.AccountHasBeenRegistered); //phoneET.Text = ""; //IsRightAccount = false; //sendCodeBtn.Enable = sendCodeBtn.IsSelected = false; } else { loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed; CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.RequestServerFailed); } } catch { loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed; } finally { CommonPage.Loading.Hide(); } }; //login loginBtn.MouseUpEventHandler += (sender, e) => { this.RemoveFromParent(); Shared.Common.CommonPage.Instance.RemoveViewByTag("Register"); var accountLogin = new Device.Account.AccountLogin { }; Shared.Common.CommonPage.Instance.AddChidren(accountLogin); accountLogin.Show(); }; //注册-****不需要先验证验证码 comfirmBtn.MouseUpEventHandler +=async (sender, e) => { CommonPage.Loading.Start(); try { var reqDto = new SendDataToServer.RegisterAccountObj() { Account = phoneET.Text.Trim(), Password = pwdET.Text.Trim(), EnterPassword = pwdComfirmET.Text.Trim(), Language = CommonPage.ZigBeeLanguage, Code = codeET.Text.Trim(), RegisterSoruce = CommonPage.RegisterSoruceFromZIGBEE, AreaCode=int.Parse(CommonPage.PhoneZoneStr) }; var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(reqDto); //验证验证码 var requestRevertObj = await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/ValidataCodeAndRegisterAccount", System.Text.Encoding.UTF8.GetBytes(requestJson)); if (requestRevertObj == null) { CommonPage.Instance.FailureToServer(); return; } var stateCodeStr = requestRevertObj.StateCode.ToUpper(); if (stateCodeStr == "SUCCESS") { var registerSuccess = new Account.RegisterSuccess(); this.AddChidren(registerSuccess); registerSuccess.Show(phoneET.Text.Trim(), pwdET.Text.Trim()); } else if (stateCodeStr == "EXIST") { //已注册 loginErrorBtn.TextID = R.MyInternationalizationString.AccountHasBeenRegistered; CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.AccountHasBeenRegistered); } else if (stateCodeStr == "PARAMETEROREMPTY") { //提供的参数错误 loginErrorBtn.TextID = R.MyInternationalizationString.PARAMETEROREMPTY; CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.PARAMETEROREMPTY); } else if (stateCodeStr == "PWDNOCONFIRM") { //两次密码不一样 loginErrorBtn.TextID = R.MyInternationalizationString.TwoPasswordInconsistency; CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TwoPasswordInconsistency); } else if (stateCodeStr == "VALIDCODEANDPHONENOEQUAL") { //验证码错误 comfirmBtn.Enable = comfirmBtn.IsSelected = false; codeET.Text = ""; loginErrorBtn.TextID = R.MyInternationalizationString.VALIDCODEANDPHONENOEQUAL; CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.VALIDCODEANDPHONENOEQUAL); } else { loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed; CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.RequestServerFailed); } } catch { loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed; } finally { CommonPage.Loading.Hide(); } }; #endregion } } }