From d6fb0646531172f23648441c224cdcccd721b894 Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期一, 14 十二月 2020 09:59:01 +0800
Subject: [PATCH] 请合并代码,完成晾衣架最终功能。
---
ZigbeeApp/Shared/Phone/UserCenter/Password/CheckNewEmailForm.cs | 381 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 381 insertions(+), 0 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Password/CheckNewEmailForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Password/CheckNewEmailForm.cs
new file mode 100755
index 0000000..5107160
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Password/CheckNewEmailForm.cs
@@ -0,0 +1,381 @@
+锘� using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace Shared.Phone.UserCenter.Password
+{
+ /// <summary>
+ /// 楠岃瘉鏂伴偖绠辩殑鐢婚潰
+ /// </summary>
+ public class CheckNewEmailForm : EditorCommonForm
+ {
+ #region 鈻� 鍙橀噺澹版槑___________________________
+
+ /// <summary>
+ /// 閿欒淇℃伅鎺т欢
+ /// </summary>
+ private NormalViewControl btnErrorMsg = null;
+ /// <summary>
+ /// 鏂伴偖绠�(闃叉鎭舵剰鍙樻洿)
+ /// </summary>
+ private string newEmail = string.Empty;
+ /// <summary>
+ /// 鏍囪鏄惁鑳藉鏍¢獙楠岃瘉鐮佷簡
+ /// </summary>
+ private bool canCheckCode = false;
+
+ #endregion
+
+ #region 鈻� 鍒濆鍖朹____________________________
+
+ /// <summary>
+ /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓)
+ /// </summary>
+ public void ShowForm()
+ {
+ //璁剧疆澶撮儴淇℃伅
+ base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uEditorEmail));
+
+ //鍒濆鍖栦腑閮ㄤ俊鎭�
+ this.InitMiddleFrame();
+ }
+
+ /// <summary>
+ /// 鍒濆鍖栦腑閮ㄤ俊鎭�
+ /// </summary>
+ private void InitMiddleFrame()
+ {
+ //娓呯┖bodyFrame
+ this.ClearBodyFrame();
+
+ var frame = new FrameLayout();
+ frame.Y = Application.GetRealHeight(161);
+ frame.Gravity = Gravity.CenterHorizontal;
+ frame.Width = Application.GetRealWidth(688);
+ frame.Height = Application.GetRealHeight(127);
+ bodyFrameLayout.AddChidren(frame);
+ //杈撳叆妗�
+ 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, ControlCommonResourse.BottomLineHeight, false);
+ btnLine.Y = txtValue.Bottom;
+ btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
+ frame.AddChidren(btnLine);
+ //鑱斿姩绾跨殑鐘舵��
+ txtValue.btnLine = btnLine;
+
+ if (string.IsNullOrEmpty(UserCenterResourse.UserInfo.Email) == false)
+ {
+ //纭韬唤鎴愬姛锛岃缁戝畾鏂伴偖绠�
+ var btnMsg1 = new NormalViewControl(800, 49, false);
+ btnMsg1.X = Application.GetRealWidth(196);
+ btnMsg1.Y = frame.Bottom + Application.GetRealHeight(40);
+ btnMsg1.TextSize = 12;
+ btnMsg1.TextColor = UserCenterColor.Current.TextGrayColor1;
+ btnMsg1.TextID = R.MyInternationalizationString.uAuthenticationSuccessAndBindNewEmail;
+ bodyFrameLayout.AddChidren(btnMsg1);
+ }
+
+ //鍒濆鍖栭獙璇佺爜鎺т欢
+ var btnCodeControl = new VerificationCodeControl(6);
+ btnCodeControl.Y = Application.GetRealHeight(475);
+ bodyFrameLayout.AddChidren(btnCodeControl);
+ btnCodeControl.InitControl();
+ btnCodeControl.TxtCodeChangeEvent += (sender, e) =>
+ {
+ if (btnErrorMsg.Visible == true)
+ {
+ btnErrorMsg.Visible = false;
+ }
+ };
+ btnCodeControl.FinishInputEvent += (value) =>
+ {
+ //鏍¢獙楠岃瘉鐮�
+ if (this.CheckVerificationCode(value) == false)
+ {
+ //娓呯┖楠岃瘉鐮�
+ btnCodeControl.ClearInputValue();
+ }
+ };
+
+ //楠岃瘉鐮侀敊璇紝璇烽噸鏂拌緭鍏�
+ this.btnErrorMsg = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(58), false);
+ btnErrorMsg.Y = Application.GetRealHeight(677);
+ btnErrorMsg.TextAlignment = TextAlignment.Center;
+ btnErrorMsg.TextColor = 0xfff75858;
+ btnErrorMsg.TextID = R.MyInternationalizationString.uVerificationCodeErrorInputAgain;
+ btnErrorMsg.IsBold = true;
+ bodyFrameLayout.AddChidren(btnErrorMsg);
+ btnErrorMsg.Visible = false;
+
+ var btnOk = new BottomClickButton(688);
+ btnOk.Y = Application.GetRealHeight(792);
+ btnOk.TextID = R.MyInternationalizationString.uGetVerificationCode;
+ bodyFrameLayout.AddChidren(btnOk);
+ btnOk.oldBackgroundColor = UserCenterColor.Current.ClickButtonDefultColor;
+ btnOk.CanClick = false;
+ btnOk.ButtonClickEvent += (sender, e) =>
+ {
+ //娓呯┖杈撳叆鐨勫��
+ btnCodeControl.ClearInputValue();
+
+ this.btnErrorMsg.Visible = false;
+ //妫�娴嬮偖绠辩殑鍦板潃
+ if (this.CheckEmail(txtValue.Text.Trim()) == false)
+ {
+ return;
+ }
+ //鍙戦�侀獙璇佺爜鍒伴偖绠�
+ this.SendCodeToEmail(btnOk, txtValue.Text.Trim());
+ };
+
+ txtValue.TextChangeEventHandler += (sender, value) =>
+ {
+ if (value == string.Empty)
+ {
+ //鎸夐敭涓嶅彲鐢�
+ btnOk.CanClick = false;
+ }
+ else if (btnOk.CanClick == false)
+ {
+ //鎸夐敭鍙敤
+ btnOk.CanClick = true;
+ }
+ };
+ }
+
+ #endregion
+
+ #region 鈻� 鍙戦�侀獙璇佺爜鍒伴偖绠盻__________________
+
+ /// <summary>
+ /// 鍙戦�侀獙璇佺爜鍒伴偖绠�
+ /// </summary>
+ private void SendCodeToEmail(BottomClickButton btnNext, string Email)
+ {
+ var sendCodePra = new SendCodePra();
+ sendCodePra.Account = Email;
+
+ bool falge = UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/RegisterSendVerCode", false, sendCodePra);
+ if (falge == false)
+ {
+ return;
+ }
+
+ //鍙互寮�濮嬫牎楠岄獙璇佺爜浜�
+ this.canCheckCode = true;
+ //璁板綍璧疯繖涓偖绠�,闃叉鎭舵剰鍙樻洿
+ this.newEmail = Email;
+ //鎺т欢涓嶈兘鍐嶆鎸変笅
+ btnNext.CanClick = false;
+ //?s鍚庨噸鍙�
+ string repeat = Language.StringByID(R.MyInternationalizationString.RepeatSend1);
+ //鏈夋晥鏃堕棿60绉�
+ int waitime = 60;
+ btnNext.Text = waitime + "s" + repeat;
+
+ HdlThreadLogic.Current.RunThread(() =>
+ {
+ 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(() =>
+ {
+ if (btnNext != null)
+ {
+ btnNext.Text = waitime + "s" + repeat;
+ }
+ }, ShowErrorMode.NO);
+ }
+ });
+ }
+
+ #endregion
+
+ #region 鈻� 鏍¢獙楠岃瘉鐮乢________________________
+
+ /// <summary>
+ /// 楠岃瘉楠岃瘉鐮�
+ /// </summary>
+ /// <returns></returns>
+ private bool CheckVerificationCode(string code)
+ {
+ if (this.canCheckCode == false)
+ {
+ //楠岃瘉鐮侀敊璇紝璇烽噸鏂拌緭鍏�
+ this.btnErrorMsg.Visible = true;
+ this.btnErrorMsg.TextID = R.MyInternationalizationString.uVerificationCodeErrorInputAgain;
+ return false;
+ }
+ var checkCodePra = new CheckCodePra();
+ checkCodePra.Code = code;
+ checkCodePra.Account = newEmail;
+
+ bool flage = UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/ValidatorCode", false, checkCodePra);
+ if (flage == false)
+ {
+ //楠岃瘉鐮侀敊璇紝璇烽噸鏂拌緭鍏�
+ 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;
+ }
+
+ //鎴愬姛缁戝畾鏂伴偖绠�
+ string msg = Language.StringByID(R.MyInternationalizationString.uBindEmailSuccess);
+ this.ShowMassage(ShowMsgType.Normal, msg, () =>
+ {
+ //鍒锋柊涓汉淇℃伅鐢婚潰
+ this.RefreshUserInfoForm();
+ });
+ }
+
+ /// <summary>
+ /// 鍒锋柊涓汉淇℃伅鐢婚潰
+ /// </summary>
+ private void RefreshUserInfoForm()
+ {
+ //濡傛灉淇敼鐨勬槸璐﹀彿鐨勮瘽,鍒欓噸鏂扮櫥褰�
+ if (UserCenterResourse.UserInfo.Email == Shared.Common.Config.Instance.Account)
+ {
+ UserCenterLogic.ReLoginAgain(this.newEmail);
+ return;
+ }
+
+ UserCenterResourse.UserInfo.Email = this.newEmail;
+ this.CloseForm();
+ }
+
+ #endregion
+
+ #region 鈻� 涓�鑸柟娉昣__________________________
+
+ /// <summary>
+ /// 妫�鏌ラ偖绠�
+ /// </summary>
+ /// <param name="Email"></param>
+ /// <returns></returns>
+ private bool CheckEmail(string Email)
+ {
+ //杈撳叆涓虹┖
+ if (Email == string.Empty)
+ {
+ this.btnErrorMsg.Visible = true;
+ this.btnErrorMsg.TextID = R.MyInternationalizationString.uPleaseInputNewEmailAddress;
+ return false;
+ }
+
+ //妫�娴嬮偖绠辨牸寮�
+ if (HdlCheckLogic.Current.CheckEmail(Email) == false)
+ {
+ this.btnErrorMsg.Visible = true;
+ this.btnErrorMsg.TextID = R.MyInternationalizationString.uThisIsNotEmailType;
+ return false;
+ }
+
+ return true;
+ }
+
+ #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