From fe3b2466c68b5db70d38e78039703add3b8b1dfe Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期四, 31 十二月 2020 19:29:43 +0800 Subject: [PATCH] 合并了代码 --- ZigbeeApp/Shared/Phone/UserCenter/Password/CheckNewEmailForm.cs | 167 +++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 125 insertions(+), 42 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Password/CheckNewEmailForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Password/CheckNewEmailForm.cs index 7fa65a7..5107160 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Password/CheckNewEmailForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Password/CheckNewEmailForm.cs @@ -23,10 +23,6 @@ /// 鏍囪鏄惁鑳藉鏍¢獙楠岃瘉鐮佷簡 /// </summary> private bool canCheckCode = false; - /// <summary> - /// 鑳藉惁鍙戦�侀獙璇佺爜 - /// </summary> - private bool canSendCode = true; #endregion @@ -59,20 +55,20 @@ frame.Height = Application.GetRealHeight(127); bodyFrameLayout.AddChidren(frame); //杈撳叆妗� - var txtValue = new TextInputControl(frame.Width - Application.GetRealWidth(20), frame.Height - HdlControlResourse.BottomLineHeight, false); + var txtValue = new TextInputControl(frame.Width - Application.GetRealWidth(20), frame.Height - ControlCommonResourse.BottomLineHeight, false); txtValue.X = Application.GetRealWidth(10); txtValue.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uPleaseInputNewEmailAddress); frame.AddChidren(txtValue); //绾� - var btnLine = new NormalViewControl(frame.Width, HdlControlResourse.BottomLineHeight, false); + var btnLine = new NormalViewControl(frame.Width, ControlCommonResourse.BottomLineHeight, false); btnLine.Y = txtValue.Bottom; btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine; frame.AddChidren(btnLine); //鑱斿姩绾跨殑鐘舵�� txtValue.btnLine = btnLine; - if (string.IsNullOrEmpty(HdlUserCenterResourse.UserInfo.UserEmail) == false) + if (string.IsNullOrEmpty(UserCenterResourse.UserInfo.Email) == false) { //纭韬唤鎴愬姛锛岃缁戝畾鏂伴偖绠� var btnMsg1 = new NormalViewControl(800, 49, false); @@ -98,8 +94,12 @@ }; btnCodeControl.FinishInputEvent += (value) => { - //缁戝畾鏂伴偖绠� - this.SaveNewEmail(btnCodeControl, value); + //鏍¢獙楠岃瘉鐮� + if (this.CheckVerificationCode(value) == false) + { + //娓呯┖楠岃瘉鐮� + btnCodeControl.ClearInputValue(); + } }; //楠岃瘉鐮侀敊璇紝璇烽噸鏂拌緭鍏� @@ -157,16 +157,15 @@ /// </summary> private void SendCodeToEmail(BottomClickButton btnNext, string Email) { - var errorMsg = HdlAccountLogic.Current.SendVeriCodeToEmail(Email, VerCodeType.A缁戝畾); - if (errorMsg != null) + var sendCodePra = new SendCodePra(); + sendCodePra.Account = Email; + + bool falge = UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/RegisterSendVerCode", false, sendCodePra); + if (falge == false) { - //鏄剧ず閿欒 - this.btnErrorMsg.Visible = true; - this.btnErrorMsg.Text = errorMsg; return; } - //涓嶈兘鍐嶅彂閫侀獙璇佺爜 - this.canSendCode = false; + //鍙互寮�濮嬫牎楠岄獙璇佺爜浜� this.canCheckCode = true; //璁板綍璧疯繖涓偖绠�,闃叉鎭舵剰鍙樻洿 @@ -181,12 +180,22 @@ HdlThreadLogic.Current.RunThread(() => { - while (this.Parent != null && this.canSendCode == false) + while (this.Parent != null) { waitime--; System.Threading.Thread.Sleep(1000); if (waitime == 0) { + HdlThreadLogic.Current.RunMain(() => + { + if (btnNext != null) + { + //鑾峰彇楠岃瘉鐮� + btnNext.TextID = R.MyInternationalizationString.uGetVerificationCode; + //鎸夐敭鍙互鎸変笅 + btnNext.CanClick = true; + } + }); break; } HdlThreadLogic.Current.RunMain(() => @@ -197,44 +206,57 @@ } }, ShowErrorMode.NO); } - HdlThreadLogic.Current.RunMain(() => - { - if (btnNext != null) - { - //鑾峰彇楠岃瘉鐮� - btnNext.TextID = R.MyInternationalizationString.uGetVerificationCode; - //鎸夐敭鍙互鎸変笅 - btnNext.CanClick = true; - } - }); }); } #endregion - #region 鈻� 鍙樻洿閭___________________________ + #region 鈻� 鏍¢獙楠岃瘉鐮乢________________________ /// <summary> - /// 鍙樻洿閭 + /// 楠岃瘉楠岃瘉鐮� /// </summary> - private void SaveNewEmail(VerificationCodeControl btnCodeControl, string code) + /// <returns></returns> + private bool CheckVerificationCode(string code) { if (this.canCheckCode == false) { //楠岃瘉鐮侀敊璇紝璇烽噸鏂拌緭鍏� this.btnErrorMsg.Visible = true; this.btnErrorMsg.TextID = R.MyInternationalizationString.uVerificationCodeErrorInputAgain; - //娓呯┖杈撳叆鍊� - btnCodeControl.ClearInputValue(); - return; + return false; } - //鎵ц缁戝畾 - var errorMsg = HdlAccountLogic.Current.BindAccount(this.newEmail, code); - if (errorMsg != null) + var checkCodePra = new CheckCodePra(); + checkCodePra.Code = code; + checkCodePra.Account = newEmail; + + bool flage = UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/ValidatorCode", false, checkCodePra); + if (flage == false) { - this.ShowMassage(ShowMsgType.Tip, errorMsg); - //鍙互閲嶆柊鍙戦�侀獙璇佺爜 - this.canSendCode = true; + //楠岃瘉鐮侀敊璇紝璇烽噸鏂拌緭鍏� + this.btnErrorMsg.Visible = true; + this.btnErrorMsg.TextID = R.MyInternationalizationString.uVerificationCodeErrorInputAgain; + return false; + } + + //鍙樻洿閭 + this.SaveNewEmail(); + return true; + } + + /// <summary> + /// 鍙樻洿閭 + /// </summary> + private void SaveNewEmail() + { + var pra = new SaveNewEmailPra(); + pra.Account = this.newEmail; + + bool flage = UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/BindAccount", false, pra); + if (flage == false) + { + //缁戝畾閭澶辫触 + this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uBindEmailFail)); return; } @@ -253,13 +275,13 @@ private void RefreshUserInfoForm() { //濡傛灉淇敼鐨勬槸璐﹀彿鐨勮瘽,鍒欓噸鏂扮櫥褰� - if (HdlUserCenterResourse.UserInfo.UserEmail == Shared.Common.Config.Instance.Account) + if (UserCenterResourse.UserInfo.Email == Shared.Common.Config.Instance.Account) { - HdlAccountLogic.Current.ReLoginAgain(this.newEmail); + UserCenterLogic.ReLoginAgain(this.newEmail); return; } - HdlUserCenterResourse.UserInfo.UserEmail = this.newEmail; + UserCenterResourse.UserInfo.Email = this.newEmail; this.CloseForm(); } @@ -294,5 +316,66 @@ } #endregion + + #region 鈻� 缁撴瀯浣揰____________________________ + + /// <summary> + /// 鍙戦�侀獙璇佺爜鐨勫惎鍔ㄥ弬鏁� + /// </summary> + private class SendCodePra + { + /// <summary> + /// 鐢ㄦ埛璐﹀彿 + /// </summary> + public string Account = string.Empty; + /// <summary> + /// 鍏徃缂栧彿,鍥藉唴浣跨敤鎵嬫満鐭俊楠岃瘉鐮佹椂锛屾瀛楁濉叆0锛屽浗澶栨墜鏈虹煭淇¢獙璇佺爜锛屾瀛楁濉叆4 + /// </summary> + public int Company = Common.CommonPage.PhoneZoneStr == "86" ? 0 : 4; + /// <summary> + /// 璇█ + /// </summary> + public string Language = Shared.Language.CurrentLanguage; + /// <summary> + /// 鍥藉鍦板尯浠g爜锛屾墜鏈哄彿鍙戦�侀獙璇佺爜鏃朵娇鐢� + /// </summary> + public int AreaCode = 0; + } + + /// <summary> + /// 鍙戦�侀獙璇佺爜鐨勫惎鍔ㄥ弬鏁� + /// </summary> + private class CheckCodePra + { + /// <summary> + /// 鐢ㄦ埛璐﹀彿 + /// </summary> + public string Account = string.Empty; + /// <summary> + /// 楠岃瘉鐮� + /// </summary> + public string Code = "0"; + /// <summary> + /// 璇█ + /// </summary> + public string Language = Shared.Language.CurrentLanguage; + /// <summary> + /// 鍥藉鍦板尯浠g爜锛屾墜鏈哄彿鍙戦�侀獙璇佺爜鏃朵娇鐢� + /// </summary> + public int AreaCode = 0; + } + + /// <summary> + /// 淇濆瓨鏂伴偖绠辩殑鍚姩鍙傛暟 + /// </summary> + private class SaveNewEmailPra + { + /// <summary> + /// 鏂扮敤鎴疯处鍙� + /// </summary> + public string Account = string.Empty; + } + + #endregion } } -- Gitblit v1.8.0