| | |
| | | using System.Collections.Generic; |
| | | using System.Timers; |
| | | using Shared.Phone.UserView; |
| | | using Shared.Phone.Device.CommonForm; |
| | | |
| | | namespace Shared.Phone.Device.Account |
| | | { |
| | | /// <summary> |
| | | /// 验证码登录 |
| | | /// </summary> |
| | | public class AccountLoginByCode: FrameLayout |
| | | public class AccountLoginByCode : FrameLayout |
| | | { |
| | | |
| | | #region ◆ 变量____________________________ |
| | | /// <summary> |
| | | /// 背景视图 |
| | | /// </summary> |
| | | private FrameLayout midFrameLayout; |
| | | /// <summary> |
| | | /// 手机邮箱 |
| | | /// </summary> |
| | | private PhoneEmailForm phoneEmailForm; |
| | | /// <summary> |
| | | /// phoneRowForm |
| | | /// </summary> |
| | | private PhoneRowForm phoneRow; |
| | | /// <summary> |
| | | /// emailRow |
| | | /// </summary> |
| | | private EmailRowForm emailRow; |
| | | /// <summary> |
| | | /// codeRow |
| | | /// </summary> |
| | | private VerificationCodeRowForm codeRow; |
| | | /// <summary> |
| | | /// 账号验证码fl |
| | | /// </summary> |
| | | private FrameLayout accountCodeFL; |
| | | /// <summary> |
| | | /// 登录按钮 |
| | | /// </summary> |
| | | private Button loginBtn; |
| | | /// <summary> |
| | | /// 忘记密码按钮 |
| | | /// </summary> |
| | | private Button forgotPasswordBtn; |
| | | /// <summary> |
| | | /// 注册 |
| | | /// </summary> |
| | | private Button registerBtn; |
| | | /// <summary> |
| | | /// 账号登录 |
| | | /// </summary> |
| | | private Button LoginByAccountPWDBtn; |
| | | /// <summary> |
| | | /// 登录错误提示按钮 |
| | | /// </summary> |
| | | private Button loginErrorBtn; |
| | | /// <summary> |
| | | /// 账号 |
| | | /// </summary> |
| | | private string account; |
| | | /// <summary> |
| | | /// 验证码 |
| | | /// </summary> |
| | | private string code; |
| | | |
| | | private Timer t; |
| | | private DateTime dateBegin; |
| | | |
| | | #endregion |
| | | |
| | | |
| | | /// <summary> |
| | | /// The phone string. |
| | | /// </summary> |
| | | public string phoneStr = ""; |
| | | //public string phoneStr = ""; |
| | | /// <summary> |
| | | /// 手机号输入是否符合规则 |
| | | /// </summary> |
| | | public bool IsRightAccount = false; |
| | | /// <summary> |
| | | /// *****升级分布式后,Account 仅包含手机号,不再包含00区号。密码不再需要MD5加密。language为APP语 |
| | | /// 下来选择手机区号 默认中国大陆为86 |
| | | ///发送国际 / 港澳台消息时,接收号码格式为00 + 国际区号 + 号码,如“008615899998888” 调用API时,Company字段请传入整型值:4。 。 |
| | | ///国内 调用API时,Company字段请传入整型值:0。 |
| | | /// </summary> |
| | | public List<Common.ResponseEntity.AreaCodeOBJ> areaCodeList = new List<Common.ResponseEntity.AreaCodeOBJ>(); |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="T:Shared.Phone.Device.Account.AccountLoginByCode"/> class. |
| | | /// </summary> |
| | |
| | | { |
| | | Tag = "Login"; |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; |
| | | t = new Timer(); |
| | | dateBegin = new DateTime(); |
| | | } |
| | | public override void RemoveFromParent() |
| | | { |
| | | base.RemoveFromParent(); |
| | | } |
| | | /// <summary> |
| | | /// Show this instance. |
| | | /// </summary> |
| | | public async void Show() |
| | | public void Show() |
| | | { |
| | | 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<List<Common.ResponseEntity.AreaCodeOBJ>>(responseData.ToString()); |
| | | } |
| | | } |
| | | catch { } |
| | | finally |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | ShowLoginByCodeView(); |
| | | } |
| | | |
| | | ShowLoginByCodeView(); |
| | | } |
| | | /// <summary> |
| | | /// Shows the login by code view. |
| | | /// </summary> |
| | | public void ShowLoginByCodeView() |
| | | { |
| | | var t = new Timer(); |
| | | var dateBegin = new DateTime(); |
| | | |
| | | #region midFrameLayout |
| | | var midFrameLayout = new FrameLayout() |
| | | midFrameLayout = new FrameLayout() |
| | | { |
| | | Width = LayoutParams.MatchParent, |
| | | Height = Application.GetRealHeight(1920), |
| | | Height = Application.GetRealHeight(CommonPage.AppRealHeight), |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor |
| | | }; |
| | | AddChidren(midFrameLayout); |
| | | #endregion |
| | | |
| | | #region 布局账户 注册 手机验证码登录 |
| | | |
| | | var registerBtn = new Button() |
| | | var logoBG = new Button() |
| | | { |
| | | Width = Application.GetRealWidth(250), |
| | | Height = Application.GetRealHeight(80), |
| | | X = Application.GetRealWidth(1080 - 250 - 50), |
| | | Y = Application.GetRealHeight(100), |
| | | TextID = R.MyInternationalizationString.Register, |
| | | TextSize = 15, |
| | | TextColor = ZigbeeColor.Current.GXCTextBlueColor, |
| | | TextAlignment = TextAlignment.CenterRight |
| | | Height = Application.GetRealHeight(619), |
| | | UnSelectedImagePath = "Account/Logo_loginBG.png" |
| | | }; |
| | | midFrameLayout.AddChidren(registerBtn); |
| | | midFrameLayout.AddChidren(logoBG); |
| | | |
| | | var logoBtn = new Button() |
| | | var phoneEmailBGFL = new FrameLayout() |
| | | { |
| | | Width = Application.GetMinRealAverage(270), |
| | | Height = Application.GetMinRealAverage(270), |
| | | Y = Application.GetRealHeight(150) + registerBtn.Bottom, |
| | | UnSelectedImagePath = "Logo/Logo.png", |
| | | 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(logoBtn); |
| | | midFrameLayout.AddChidren(logo); |
| | | |
| | | var accountFL = new FrameLayout() |
| | | var logoName = new Button() |
| | | { |
| | | Width = Application.GetRealWidth(700), |
| | | Height = Application.GetRealHeight(110), |
| | | Y = Application.GetRealHeight(200) + logoBtn.Bottom, |
| | | Radius = (uint)Application.GetRealHeight(55), |
| | | BorderColor = ZigbeeColor.Current.GXCBorderColor, |
| | | BorderWidth = 1, |
| | | Gravity = Gravity.CenterHorizontal |
| | | }; |
| | | midFrameLayout.AddChidren(accountFL); |
| | | var accountZoneBtn = new Button() |
| | | { |
| | | Width = Application.GetRealWidth(200), |
| | | X = Application.GetRealWidth(20), |
| | | Text = "+" + CommonPage.PhoneZoneStr, |
| | | TextAlignment = TextAlignment.Center, |
| | | TextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor |
| | | }; |
| | | accountFL.AddChidren(accountZoneBtn); |
| | | var accountZoneLine = new Button() |
| | | { |
| | | X = Application.GetRealWidth(10) + accountZoneBtn.Right, |
| | | Width = 1, |
| | | Height = Application.GetRealHeight(60), |
| | | Gravity=Gravity.CenterVertical, |
| | | BackgroundColor = ZigbeeColor.Current.GXCLineColor |
| | | }; |
| | | accountFL.AddChidren(accountZoneLine); |
| | | var accountET = new EditText() |
| | | { |
| | | X = accountZoneLine.Right + Application.GetRealWidth(20), |
| | | Width = Application.GetRealWidth(400), |
| | | PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputPhoneNum), |
| | | TextAlignment = TextAlignment.Center, |
| | | PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor, |
| | | TextColor = ZigbeeColor.Current.GXCTextBlackColor |
| | | }; |
| | | accountFL.AddChidren(accountET); |
| | | |
| | | var verificationCodeFL = new FrameLayout() |
| | | { |
| | | Width = Application.GetRealWidth(700), |
| | | Height = Application.GetRealHeight(110), |
| | | Y = accountFL.Bottom + Application.GetRealHeight(100), |
| | | Radius = (uint)Application.GetRealHeight(55), |
| | | BorderColor = ZigbeeColor.Current.GXCBorderColor, |
| | | BorderWidth = 1, |
| | | Gravity = Gravity.CenterHorizontal |
| | | }; |
| | | midFrameLayout.AddChidren(verificationCodeFL); |
| | | var verificationCodeET = new EditText() |
| | | { |
| | | X = Application.GetRealWidth(20), |
| | | Width = Application.GetRealWidth(350), |
| | | PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputVerificationCode), |
| | | TextAlignment = TextAlignment.Center, |
| | | PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor, |
| | | TextColor = ZigbeeColor.Current.GXCTextBlackColor |
| | | }; |
| | | verificationCodeFL.AddChidren(verificationCodeET); |
| | | |
| | | var sendCodeLine = new Button() |
| | | { |
| | | X = Application.GetRealWidth(10) + verificationCodeET.Right, |
| | | Width = 1, |
| | | Height = Application.GetRealHeight(60), |
| | | Gravity=Gravity.CenterVertical, |
| | | BackgroundColor = ZigbeeColor.Current.GXCLineColor |
| | | }; |
| | | verificationCodeFL.AddChidren(sendCodeLine); |
| | | |
| | | var sendCodeBtn = new Button() |
| | | { |
| | | X = sendCodeLine.Right + Application.GetRealWidth(20), |
| | | Width = Application.GetRealWidth(250), |
| | | TextID = R.MyInternationalizationString.SendVerificationCode, |
| | | TextColor = ZigbeeColor.Current.GXCTextUnselectedColor, |
| | | SelectedTextColor = ZigbeeColor.Current.GXCTextBlueColor, |
| | | TextAlignment = TextAlignment.Center, |
| | | Enable = false, |
| | | IsSelected=false |
| | | }; |
| | | verificationCodeFL.AddChidren(sendCodeBtn); |
| | | |
| | | var loginBtn = new Button() |
| | | { |
| | | Width = Application.GetRealWidth(700), |
| | | Height = Application.GetRealHeight(110), |
| | | Y = Application.GetRealHeight(200) + verificationCodeFL.Bottom, |
| | | TextID = R.MyInternationalizationString.Login, |
| | | TextSize = 15, |
| | | TextColor = Shared.Common.ZigbeeColor.Current.GXCTextWhiteColor, |
| | | Radius = (uint)Application.GetRealHeight(55), |
| | | BorderWidth = 0, |
| | | BackgroundColor = ZigbeeColor.Current.GXCButtonUnselectedColor, |
| | | SelectedBackgroundColor = ZigbeeColor.Current.GXCButtonBlueColor, |
| | | Y = logo.Bottom, |
| | | Height = Application.GetRealHeight(69), |
| | | Width = Application.GetRealWidth(300), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Enable = false, |
| | | IsSelected=false |
| | | TextID = R.MyInternationalizationString.AppName, |
| | | TextColor = ZigbeeColor.Current.GXCTextWhiteColor |
| | | }; |
| | | midFrameLayout.AddChidren(loginBtn); |
| | | midFrameLayout.AddChidren(logoName); |
| | | |
| | | phoneEmailForm = new PhoneEmailForm(); |
| | | phoneEmailForm.Init(midFrameLayout); |
| | | |
| | | //错误提示Btn |
| | | var loginErrorBtn = new Button() |
| | | loginErrorBtn = new Button() |
| | | { |
| | | Y = loginBtn.Bottom + Application.GetRealHeight(50), |
| | | Width = Application.GetRealWidth(1080 - 100), |
| | | Height = Application.GetRealHeight(110), |
| | | TextColor = ZigbeeColor.Current.GXCRedColor, |
| | | Gravity = Gravity.CenterHorizontal |
| | | X = Application.GetRealWidth(242), |
| | | Y = Application.GetRealHeight(740), |
| | | Width = Application.GetRealWidth(700), |
| | | Height = Application.GetRealHeight(58), |
| | | TextColor = ZigbeeColor.Current.GXCTextRed, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | }; |
| | | midFrameLayout.AddChidren(loginErrorBtn); |
| | | |
| | | var LoginByAccountPWDBtn = new Button() |
| | | accountCodeFL = new FrameLayout() |
| | | { |
| | | Width = Application.GetRealWidth(500), |
| | | Height = Application.GetRealHeight(110), |
| | | Y = midFrameLayout.Bottom - Application.GetRealHeight(100 + 110), |
| | | TextID = R.MyInternationalizationString.LoginByAccountPWD, |
| | | TextColor = ZigbeeColor.Current.GXCTextBlueColor, |
| | | TextAlignment = TextAlignment.Center, |
| | | Y = Application.GetRealHeight(801), |
| | | Height = Application.GetRealHeight(553), |
| | | Width = Application.GetRealWidth(942), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | TextSize = 15 |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, |
| | | Radius = (uint)Application.GetRealHeight(30) |
| | | }; |
| | | midFrameLayout.AddChidren(accountCodeFL); |
| | | |
| | | AddPhoneOrEmailFL(accountCodeFL, "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, |
| | | TextSize = CommonFormResouce.loginTextSize, |
| | | TextColor = Shared.Common.ZigbeeColor.Current.GXCTextGrayColor, |
| | | TextAlignment = TextAlignment.CenterRight |
| | | }; |
| | | midFrameLayout.AddChidren(forgotPasswordBtn); |
| | | |
| | | loginBtn = new Button() |
| | | { |
| | | Y = Application.GetRealHeight(1281), |
| | | Width = Application.GetRealWidth(688), |
| | | Height = Application.GetRealHeight(127), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | TextID = R.MyInternationalizationString.Login, |
| | | TextSize = 15, |
| | | TextColor = ZigbeeColor.Current.GXCTextGrayColor, |
| | | SelectedTextColor = ZigbeeColor.Current.GXCTextWhiteColor, |
| | | SelectedBackgroundColor = ZigbeeColor.Current.GXCButtonBlackSelectedColor, |
| | | BackgroundColor = ZigbeeColor.Current.GXCButtonUnSelectedColor, |
| | | Radius = (uint)Application.GetRealHeight(127 / 2), |
| | | Enable = !string.IsNullOrEmpty(codeRow.VerificationCodeET?.Text), |
| | | IsSelected = !string.IsNullOrEmpty(codeRow.VerificationCodeET?.Text) |
| | | }; |
| | | midFrameLayout.AddChidren(loginBtn); |
| | | |
| | | LoginByAccountPWDBtn = new Button() |
| | | { |
| | | X = Application.GetRealWidth(98), |
| | | Y = Application.GetRealHeight(1446), |
| | | Width = Application.GetRealWidth(300), |
| | | Height = Application.GetRealHeight(49), |
| | | TextID = R.MyInternationalizationString.LoginByAccountPWD, |
| | | TextColor = ZigbeeColor.Current.GXCTextGrayColor, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextSize = CommonFormResouce.loginTextSize |
| | | }; |
| | | midFrameLayout.AddChidren(LoginByAccountPWDBtn); |
| | | #endregion |
| | | |
| | | #region event |
| | | accountET.TextChangeEventHandler += (sender, e) => |
| | | registerBtn = new Button() |
| | | { |
| | | loginErrorBtn.Text = ""; |
| | | //校验手机号 |
| | | if (CommonPage.PhoneZoneStr != "86") |
| | | { |
| | | var reg = new Regex(CommonPage.PhoneForForeignRegexStr); |
| | | var mFalg = reg.Match(accountET.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; |
| | | IsRightAccount = false; |
| | | } |
| | | else |
| | | { |
| | | sendCodeBtn.Enable = sendCodeBtn.IsSelected= true; |
| | | IsRightAccount = true; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (accountET.Text.Trim().Length == 11) |
| | | { |
| | | var reg = new Regex(CommonPage.PhoneRegexStr); |
| | | var mFalg = reg.Match(accountET.Text.Trim()); |
| | | if (!mFalg.Success) |
| | | { |
| | | sendCodeBtn.Enable =sendCodeBtn.IsSelected= false; |
| | | IsRightAccount = false; |
| | | var aler = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.PleaseInputTheCorrectCellPhoneNumber), Language.StringByID(R.MyInternationalizationString.OK)); |
| | | aler.Show(); |
| | | } |
| | | else |
| | | { |
| | | sendCodeBtn.Enable = sendCodeBtn.IsSelected= true; |
| | | IsRightAccount = true; |
| | | } |
| | | } |
| | | else if (accountET.Text.Trim().Length > 11) |
| | | { |
| | | accountET.Text = e.Remove(11); |
| | | } |
| | | else |
| | | { |
| | | sendCodeBtn.Enable = sendCodeBtn.IsSelected = false; |
| | | IsRightAccount = false; |
| | | //正则表达式判断是否数字 |
| | | var reg = new Regex("^[0-9]*$"); |
| | | if (!reg.IsMatch(accountET.Text)) |
| | | { |
| | | var aler = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.PleaseInputTheCorrectCellPhoneNumber), Language.StringByID(R.MyInternationalizationString.Confrim)); |
| | | aler.Show(); |
| | | accountET.Text = ""; |
| | | } |
| | | X = Application.GetRealWidth(738), |
| | | Y = Application.GetRealHeight(1446), |
| | | 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); |
| | | |
| | | } |
| | | } |
| | | }; |
| | | verificationCodeET.TextChangeEventHandler += (sender, e) => |
| | | BindEvent(); |
| | | } |
| | | |
| | | #region ◆ 绑定事件_________________________ |
| | | |
| | | /// <summary> |
| | | /// 绑定按钮事件 |
| | | /// </summary> |
| | | private void BindEvent() |
| | | { |
| | | //选择手机邮箱 |
| | | phoneEmailForm.SelectedPhone.MouseUpEventHandler += SelectPhoneOrEmail_MouseUpEvent; |
| | | phoneEmailForm.SelectedEmail.MouseUpEventHandler += SelectPhoneOrEmail_MouseUpEvent; |
| | | //登录事件 |
| | | loginBtn.MouseUpEventHandler += LoginBtnEvent; |
| | | //账号登录 |
| | | LoginByAccountPWDBtn.MouseUpEventHandler += LoginByPWD; |
| | | //注册事件 |
| | | registerBtn.MouseUpEventHandler += Register; |
| | | //忘记密码 |
| | | forgotPasswordBtn.MouseUpEventHandler += ForgetPWD_MouseUpEvent; |
| | | |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | #region ◆ 登录____________________________ |
| | | |
| | | /// <summary> |
| | | /// 登录事件 |
| | | /// </summary> |
| | | /// <param name="sender">Sender.</param> |
| | | /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param> |
| | | private async void LoginBtnEvent(object sender, MouseEventArgs mouseEventArgs) |
| | | { |
| | | CommonPage.Loading.Start(); |
| | | try |
| | | { |
| | | loginErrorBtn.Text = ""; |
| | | if (verificationCodeET.Text.Trim().Length > 0 && IsRightAccount) |
| | | var reqLoginByCode = new SendDataToServer.LoginValidCodeOBJ() |
| | | { |
| | | loginBtn.IsSelected = loginBtn.Enable = true; |
| | | Account = account, |
| | | Code = code, |
| | | Language = CommonPage.ZigBeeLanguage, |
| | | AreaCode = int.Parse(CommonPage.PhoneZoneStr) |
| | | }; |
| | | var requestRevetLoginCodeOBJ = await CommonFormResouce.LoginByCode(reqLoginByCode); |
| | | if (requestRevetLoginCodeOBJ == null) |
| | | { |
| | | CommonPage.Instance.FailureToServer(); |
| | | return; |
| | | } |
| | | else |
| | | var stateCodeStr = requestRevetLoginCodeOBJ.StateCode.ToUpper(); |
| | | if (stateCodeStr == "SUCCESS") |
| | | { |
| | | loginBtn.IsSelected = loginBtn.Enable = false; |
| | | } |
| | | }; |
| | | sendCodeBtn.MouseUpEventHandler += async (sender, e) => |
| | | { |
| | | string phoneNum = accountET.Text.Trim(); |
| | | CommonPage.Loading.Start(); |
| | | try |
| | | { |
| | | int companyInt = 0; |
| | | if (CommonPage.PhoneZoneStr == "86") |
| | | if (requestRevetLoginCodeOBJ.ResponseData == null) |
| | | { |
| | | companyInt = CommonPage.Company; |
| | | phoneStr = phoneNum; |
| | | } |
| | | else |
| | | { |
| | | companyInt = CommonPage.CompanyForINTERNETION; |
| | | phoneStr = phoneNum; |
| | | } |
| | | var reqDtoSignPhone = new SendDataToServer.LoginSendVerCodeObj() |
| | | { |
| | | 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/LoginSendVerCode", System.Text.Encoding.UTF8.GetBytes(requesetJson)); |
| | | if (requestRevertObj == null) |
| | | { |
| | | CommonPage.Instance.FailureToServer(); |
| | | return; |
| | | } |
| | | var stateCodeStr = requestRevertObj.StateCode.ToUpper(); |
| | | if (stateCodeStr == "SUCCESS") |
| | | this.RemoveFromParent(); |
| | | Application.MainPage?.RemoveViewByTag("Login"); |
| | | |
| | | UserPage.Instance.Fresh(); |
| | | |
| | | new System.Threading.Thread(async () => |
| | | { |
| | | 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 == "ACCOUNTNOEXISTS") |
| | | { |
| | | //账号不存在 |
| | | loginErrorBtn.TextID = R.MyInternationalizationString.ACCOUNTNOEXISTS; |
| | | accountET.Text = ""; |
| | | IsRightAccount = false; |
| | | CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.ACCOUNTNOEXISTS); |
| | | } |
| | | else if (stateCodeStr == "SENDFAIL") |
| | | { |
| | | //验证码发送失败 |
| | | loginErrorBtn.TextID = R.MyInternationalizationString.SENDFAIL; |
| | | CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.SENDFAIL); |
| | | } |
| | | else |
| | | { |
| | | loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed; |
| | | CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.RequestServerFailed); |
| | | } |
| | | //启动ZigBee |
| | | ZigBee.Common.Application.Init(); |
| | | var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginRes>(requestRevetLoginCodeOBJ.ResponseData.ToString()); |
| | | var revertData = responseDataObj; |
| | | Config.ReFresh(); |
| | | Config.Instance.Account = revertData.Account; |
| | | Config.Instance.MqttKey = revertData.MqttKey; |
| | | Config.Instance.Guid = revertData.Guid; |
| | | Config.Instance.MD5PWD = revertData.MD5PWD; |
| | | Config.Instance.LoginDateTime = DateTime.Now; |
| | | Config.Instance.ConnectZigbeeMqttBrokerPwd = revertData.ConnectZigbeeMqttBrokerPwd; |
| | | Config.Instance.ConnectZigbeeMqttClientId = revertData.ConnectZigbeeMqttClientId; |
| | | Config.Instance.ZigbeeMqttBrokerLoadSubDomain = revertData.ZigbeeMqttBrokerLoadSubDomain; |
| | | if (Config.Instance.AccountList.Find((obj) => obj == revertData.Account) == null) |
| | | { |
| | | Config.Instance.AccountList.Add(revertData.Account); |
| | | } |
| | | //需要把登录后返回的md5密码 赋值生成Token 因为用户没有输入密码 |
| | | Config.Instance.MD5PWD = revertData.MD5PWD; |
| | | Config.Instance.Save(); |
| | | var resultRegID = await CommonPage.Instance.PushRegID(); |
| | | var homes = await House.GetHomeLists(); |
| | | |
| | | //刷新个人中心的内存及线程 |
| | | await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread(); |
| | | |
| | | Shared.Common.Room.CanInitAllRoom = true; |
| | | Shared.Common.Room.InitAllRoom(); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | UserPage.Instance.Fresh(); |
| | | CommonPage.Loading.Hide(); |
| | | }); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | catch |
| | | { |
| | | loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed; |
| | | } |
| | | finally |
| | | else if (stateCodeStr == "NOTVERIFY") |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | //未激活 |
| | | loginErrorBtn.TextID = R.MyInternationalizationString.NOTVERIFY; |
| | | CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.NOTVERIFY); |
| | | } |
| | | }; |
| | | |
| | | loginBtn.MouseDownEventHandler += (sender, e) => |
| | | { |
| | | loginBtn.IsSelected = true; |
| | | }; |
| | | //login |
| | | loginBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | loginByCode(); |
| | | }; |
| | | void loginByCode() |
| | | { |
| | | Action action = async () => |
| | | else if (stateCodeStr == "NOTENABLE") |
| | | { |
| | | CommonPage.Loading.Start(Language.StringByID(R.MyInternationalizationString.Logining)); |
| | | try |
| | | { |
| | | var reqLoginByCode = new SendDataToServer.LoginValidCodeOBJ() |
| | | { |
| | | Account = accountET.Text.Trim(), |
| | | Code = verificationCodeET.Text.Trim(), |
| | | Language = CommonPage.ZigBeeLanguage, |
| | | AreaCode = int.Parse(CommonPage.PhoneZoneStr) |
| | | }; |
| | | var requesLoginCodeJson = Newtonsoft.Json.JsonConvert.SerializeObject(reqLoginByCode); |
| | | |
| | | var requestRevetLoginCodeOBJ = await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/LoginValidCode", System.Text.Encoding.UTF8.GetBytes(requesLoginCodeJson)); |
| | | if (requestRevetLoginCodeOBJ == null) |
| | | { |
| | | CommonPage.Instance.FailureToServer(); |
| | | return; |
| | | } |
| | | var stateCodeStr = requestRevetLoginCodeOBJ.StateCode.ToUpper(); |
| | | if (stateCodeStr == "SUCCESS") |
| | | { |
| | | if (requestRevetLoginCodeOBJ.ResponseData == null) |
| | | { |
| | | return; |
| | | } |
| | | this.RemoveFromParent(); |
| | | Application.MainPage?.RemoveViewByTag("Login"); |
| | | |
| | | UserPage.Instance.Fresh(); |
| | | |
| | | new System.Threading.Thread(async () => |
| | | { |
| | | var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginRes>(requestRevetLoginCodeOBJ.ResponseData.ToString()); |
| | | var revertData = responseDataObj; |
| | | Config.ReFresh(); |
| | | Config.Instance.UserID = revertData.UserID; |
| | | Config.Instance.MasterID = revertData.MainUserID; |
| | | Config.Instance.AccountType = revertData.UserType; |
| | | Config.Instance.Account = revertData.Account; |
| | | Config.Instance.MqttKey = revertData.MqttKey;
|
| | | Config.Instance.Guid = revertData.Guid; |
| | | Config.Instance.LoginDateTime = DateTime.Now; |
| | | Config.Instance.ConnectZigbeeMqttBrokerPwd = revertData.ConnectZigbeeMqttBrokerPwd; |
| | | Config.Instance.ConnectZigbeeMqttClientId = revertData.ConnectZigbeeMqttClientId; |
| | | Config.Instance.ZigbeeMqttBrokerLoadSubDomain = revertData.ZigbeeMqttBrokerLoadSubDomain; |
| | | if (Config.Instance.AccountList.Find((obj) => obj == revertData.Account) == null) |
| | | { |
| | | Config.Instance.AccountList.Add(revertData.Account); |
| | | } |
| | | //需要把登录后返回的md5密码 赋值生成Token 因为用户没有输入密码 |
| | | Config.Instance.MD5PWD = revertData.MD5PWD; |
| | | Config.Instance.Save(); |
| | | var resultRegID = await CommonPage.Instance.PushRegID(); |
| | | var homes = await House.GetHomeLists(); |
| | | |
| | | //刷新个人中心的内存及线程 |
| | | await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread(); |
| | | |
| | | Shared.Common.Room.canInitAllRoom = true; |
| | | Shared.Common.Room.InitAllRoom(); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | UserPage.Instance.Fresh(); |
| | | CommonPage.Loading.Hide(); |
| | | }); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | else if (stateCodeStr == "NOTVERIFY") |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | //未激活 |
| | | loginErrorBtn.TextID = R.MyInternationalizationString.NOTVERIFY; |
| | | CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.NOTVERIFY); |
| | | } |
| | | else if (stateCodeStr == "NOTENABLE") |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | //该用户属于调试账号,并未启用 |
| | | loginErrorBtn.TextID = R.MyInternationalizationString.NOTENABLE; |
| | | CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.NOTENABLE); |
| | | } |
| | | else if (stateCodeStr == "PARAMETEROREMPTY") |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | //提供的参数错误 |
| | | loginErrorBtn.TextID = R.MyInternationalizationString.PARAMETEROREMPTY; |
| | | CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.PARAMETEROREMPTY); |
| | | } |
| | | else if (stateCodeStr == "VALIDCODEANDPHONENOEQUAL") |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | //验证码错误 |
| | | loginErrorBtn.TextID = R.MyInternationalizationString.VALIDCODEANDPHONENOEQUAL; |
| | | CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.VALIDCODEANDPHONENOEQUAL); |
| | | } |
| | | else if (stateCodeStr == "YOUDATANOISLOCALREGION") |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | //不在本区域,需要重定向区域后再次请求登录 |
| | | if (requestRevetLoginCodeOBJ.ResponseData == null) |
| | | { |
| | | return; |
| | | } |
| | | var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginLocalRegionRes>(requestRevetLoginCodeOBJ.ResponseData.ToString()); |
| | | CommonPage.RequestHttpsHost = responseDataObj.RegionServer; |
| | | //再次登录 |
| | | loginByCode(); |
| | | } |
| | | else |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed; |
| | | CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.RequestServerFailed); |
| | | } |
| | | } |
| | | catch |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | CommonPage.Instance.FailureToServer(); |
| | | } |
| | | finally |
| | | { |
| | | //CommonPage.Loading.Hide(); |
| | | } |
| | | }; |
| | | action(); |
| | | } |
| | | |
| | | //注册事件 |
| | | registerBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | this.RemoveFromParent(); |
| | | var registerPage = new RegistrationPhoneOREmail(); |
| | | Shared.Common.CommonPage.Instance.AddChidren(registerPage); |
| | | registerPage.Show(); |
| | | }; |
| | | //账号密码登录 |
| | | LoginByAccountPWDBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | this.RemoveFromParent(); |
| | | var login = new AccountLogin(); |
| | | Shared.Common.CommonPage.Instance.AddChidren(login); |
| | | login.Show(); |
| | | }; |
| | | |
| | | 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) |
| | | CommonPage.Loading.Hide(); |
| | | //该用户属于调试账号,并未启用 |
| | | loginErrorBtn.TextID = R.MyInternationalizationString.NOTENABLE; |
| | | } |
| | | else if (stateCodeStr == "PARAMETEROREMPTY") |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | CommonPage.Loading.Hide(); |
| | | //提供的参数错误 |
| | | loginErrorBtn.TextID = R.MyInternationalizationString.PARAMETEROREMPTY; |
| | | } |
| | | else if (stateCodeStr == "VALIDCODEANDPHONENOEQUAL") |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | //验证码错误 |
| | | loginErrorBtn.TextID = R.MyInternationalizationString.VALIDCODEANDPHONENOEQUAL; |
| | | } |
| | | else if (stateCodeStr == "YOUDATANOISLOCALREGION") |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | //不在本区域,需要重定向区域后再次请求登录 |
| | | if (requestRevetLoginCodeOBJ.ResponseData == null) |
| | | { |
| | | sendCodeBtn.Text = Convert.ToInt16((60 - span.TotalSeconds)) + "s" + Language.StringByID(R.MyInternationalizationString.SendVerificationCode); |
| | | sendCodeBtn.Enable = false; |
| | | }); |
| | | return; |
| | | } |
| | | var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginLocalRegionRes>(requestRevetLoginCodeOBJ.ResponseData.ToString()); |
| | | CommonPage.RequestHttpsHost = responseDataObj.RegionServer; |
| | | //再次登录 |
| | | //loginByCode(); |
| | | } |
| | | else |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | sendCodeBtn.Enable = true; |
| | | sendCodeBtn.TextID = R.MyInternationalizationString.SendVerificationCode; |
| | | t.Stop(); |
| | | t.Close(); |
| | | }); |
| | | CommonPage.Loading.Hide(); |
| | | loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed; |
| | | } |
| | | } |
| | | |
| | | Button tempClickZoneImgBtn = new Button(); |
| | | Button tempClickZoneNameBtn = new Button(); |
| | | EventHandler<MouseEventArgs> phoneZoneHandler = (senderZone, eZone) => |
| | | catch |
| | | { |
| | | //ZoneListView |
| | | var phoneZoneSelectedShowView = new Dialog() |
| | | { |
| | | Height = Application.GetRealHeight(1000), |
| | | Width = Application.GetRealWidth(700), |
| | | BackgroundColor = ZigbeeColor.Current.GXCButtonBlueColor, |
| | | Radius=(uint)Application.GetRealHeight(30) |
| | | }; |
| | | phoneZoneSelectedShowView.Show(); |
| | | CommonPage.Loading.Hide(); |
| | | CommonPage.Instance.FailureToServer(); |
| | | } |
| | | finally |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | } |
| | | |
| | | 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<MouseEventArgs> 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; |
| | | #endregion |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 通过密码登录 |
| | | /// </summary> |
| | | /// <param name="sender">Sender.</param> |
| | | /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param> |
| | | private void LoginByPWD(object sender, MouseEventArgs mouseEventArgs) |
| | | { |
| | | this.RemoveFromParent(); |
| | | var login = new AccountLogin(); |
| | | Shared.Common.CommonPage.Instance.AddChidren(login); |
| | | login.Show(); |
| | | } |
| | | |
| | | /// <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; |
| | | loginBtn.Enable = loginBtn.IsSelected = false; |
| | | (sender as Button).IsSelected = true; |
| | | if ((sender as Button).Tag.ToString() == "Phone") |
| | | { |
| | | AddPhoneOrEmailFL(accountCodeFL, "Phone"); |
| | | } |
| | | else |
| | | { |
| | | AddPhoneOrEmailFL(accountCodeFL, "Email"); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// AddPhoneOrEmailFL |
| | | /// </summary> |
| | | /// <param name="accountCodeFrameLayout"></param> |
| | | /// <param name="phoneOrEmail"></param> |
| | | private void AddPhoneOrEmailFL(FrameLayout accountCodeFrameLayout, string phoneOrEmail) |
| | | { |
| | | accountCodeFrameLayout.RemoveAll(); |
| | | |
| | | if (phoneOrEmail == "Phone") |
| | | { |
| | | phoneRow = new PhoneRowForm(); |
| | | phoneRow.Init(accountCodeFrameLayout, this, this.account, 29, 29); |
| | | phoneRow.AccountET.TextChangeEventHandler += Account_TextChange; |
| | | } |
| | | else |
| | | { |
| | | emailRow = new EmailRowForm(); |
| | | emailRow.Init(accountCodeFrameLayout, this.account, 29, 29); |
| | | emailRow.AccountET.TextChangeEventHandler += Account_TextChange; |
| | | } |
| | | |
| | | codeRow = new VerificationCodeRowForm(); |
| | | codeRow.Init(accountCodeFrameLayout, 29, 225); |
| | | codeRow.SendCodeBtn.MouseUpEventHandler += SendCode_MouseUpEventAsync; |
| | | codeRow.VerificationCodeET.TextChangeEventHandler += Code_TextChange; |
| | | } |
| | | #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 = ""; |
| | | if ((sender as EditText).Text.Trim().Length > 0) |
| | | { |
| | | IsRightAccount = true; |
| | | codeRow.SendCodeBtn.Enable = codeRow.SendCodeBtn.IsSelected = true; |
| | | } |
| | | else |
| | | { |
| | | IsRightAccount = false; |
| | | codeRow.SendCodeBtn.Enable = codeRow.SendCodeBtn.IsSelected = false; |
| | | } |
| | | account = (sender as EditText).Text.Trim(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// code监听事件 |
| | | /// </summary> |
| | | /// <param name="sender">Sender.</param> |
| | | /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param> |
| | | private void Code_TextChange(object sender, string mouseEventArgs) |
| | | { |
| | | loginErrorBtn.Text = ""; |
| | | if ((sender as EditText).Text.Trim().Length > 0 && IsRightAccount) |
| | | { |
| | | loginBtn.Enable = loginBtn.IsSelected = true; |
| | | } |
| | | else |
| | | { |
| | | loginBtn.Enable = loginBtn.IsSelected = false; |
| | | } |
| | | code = (sender as EditText).Text.Trim(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | void TimeOut(object sender, System.Timers.ElapsedEventArgs e) |
| | | { |
| | | var span = DateTime.Now - dateBegin; |
| | | if (span.TotalSeconds <= 61) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | codeRow.SendCodeBtn.Text = Convert.ToInt16(60 - span.TotalSeconds) + "s" + Language.StringByID(R.MyInternationalizationString.SendVerificationCodeAgain); |
| | | codeRow.SendCodeBtn.Enable = false; |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | codeRow.SendCodeBtn.Enable = true; |
| | | codeRow.SendCodeBtn.TextID = R.MyInternationalizationString.SendVerificationCode; |
| | | t.Stop(); |
| | | t.Close(); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | void TimeBegin() |
| | | { |
| | | t.Interval = 1000; |
| | | t.AutoReset = true; |
| | | t.Enabled = true; |
| | | t.Elapsed += TimeOut; |
| | | //启动计时器倒计时-60s |
| | | t.Start(); |
| | | dateBegin = DateTime.Now; |
| | | } |
| | | |
| | | #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) |
| | | { |
| | | this.RemoveFromParent(); |
| | | var login = new AccountLogin(); |
| | | CommonPage.Instance.AddChidren(login); |
| | | login.Show(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ◆ 忘记密码________________________ |
| | | /// <summary> |
| | | /// 忘记密码 |
| | | /// </summary> |
| | | private void ForgetPWD_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs) |
| | | { |
| | | this.RemoveFromParent(); |
| | | var forgot = new AccountForgetPWD(); |
| | | CommonPage.Instance.AddChidren(forgot); |
| | | forgot.Show(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ◆ 发送验证码________________________ |
| | | /// <summary> |
| | | /// 发送验证码 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="mouseEventArgs"></param> |
| | | private async void SendCode_MouseUpEventAsync(object sender, MouseEventArgs mouseEventArgs) |
| | | { |
| | | (sender as Button).Enable = (sender as Button).IsSelected = false; |
| | | CommonPage.Loading.Start(); |
| | | try |
| | | { |
| | | int companyInt = 0; |
| | | if (CommonPage.PhoneZoneStr == "86" || phoneEmailForm.SelectedEmail.IsSelected) |
| | | { |
| | | companyInt = CommonPage.Company; |
| | | } |
| | | else |
| | | { |
| | | companyInt = CommonPage.CompanyForINTERNETION; |
| | | } |
| | | var reqDtoSignPhone = new SendDataToServer.LoginSendVerCodeObj() |
| | | { |
| | | Account = account, |
| | | Company = companyInt, |
| | | AreaCode = int.Parse(CommonPage.PhoneZoneStr), |
| | | Language = CommonPage.ZigBeeLanguage |
| | | }; |
| | | var requestRevertObj = await CommonFormResouce.LoginSendVerCode(reqDtoSignPhone); |
| | | 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; |
| | | (sender as Button).Enable = (sender as Button).IsSelected = true; |
| | | } |
| | | else if (stateCodeStr == "ACCOUNTNOEXISTS") |
| | | { |
| | | //账号不存在 |
| | | loginErrorBtn.TextID = R.MyInternationalizationString.ACCOUNTNOEXISTS; |
| | | IsRightAccount = false; |
| | | (sender as Button).Enable = (sender as Button).IsSelected = true; |
| | | } |
| | | else if (stateCodeStr == "SENDFAIL") |
| | | { |
| | | //验证码发送失败 |
| | | loginErrorBtn.TextID = R.MyInternationalizationString.SENDFAIL; |
| | | (sender as Button).Enable = (sender as Button).IsSelected = true; |
| | | } |
| | | else |
| | | { |
| | | loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed; |
| | | (sender as Button).Enable = (sender as Button).IsSelected = true; |
| | | } |
| | | } |
| | | catch |
| | | { |
| | | loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed; |
| | | (sender as Button).Enable = (sender as Button).IsSelected = true; |
| | | } |
| | | finally |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region ◆ 验证验证码________________________ |
| | | |
| | | |
| | | |
| | | #endregion |
| | | } |
| | | } |