From c1de48884fa145a16a0f8bcee93274dcfaa0ff82 Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期四, 07 五月 2020 10:40:28 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/dev-tzy' into dev-2020xm --- ZigbeeApp/Shared/Phone/UserCenter/Password/ForgotAccountPasswordForm.cs | 343 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 343 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Password/ForgotAccountPasswordForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Password/ForgotAccountPasswordForm.cs new file mode 100755 index 0000000..980c379 --- /dev/null +++ b/ZigbeeApp/Shared/Phone/UserCenter/Password/ForgotAccountPasswordForm.cs @@ -0,0 +1,343 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; + +namespace Shared.Phone.UserCenter.Password +{ + /// <summary> + /// 蹇樿璐﹀彿瀵嗙爜鐣岄潰 + /// </summary> + public class ForgotAccountPasswordForm : EditorCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 鏍囪鏄惁鑳藉鏍¢獙楠岃瘉鐮佷簡 + /// </summary> + private bool canCheckCode = false; + /// <summary> + /// 鎵嬫満鎴栬�呴偖绠� + /// </summary> + private string strPhoneEmail = string.Empty; + /// <summary> + /// 閿欒淇℃伅鎺т欢 + /// </summary> + private NormalViewControl btnMsgControl = null; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + public void ShowForm() + { + //璁剧疆澶撮儴淇℃伅 + base.SetTitleText(Language.StringByID(R.MyInternationalizationString.ForgotPassword)); + + //鍒濆鍖栦腑閮ㄤ俊鎭� + this.InitMiddleFrame(); + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄤ俊鎭� + /// </summary> + private void InitMiddleFrame() + { + //娓呯┖bodyFrame + this.ClearBodyFrame(); + + var frameBack = new FrameLayout(); + frameBack.Height = Application.GetRealHeight(323); + frameBack.BackgroundColor = UserCenterColor.Current.White; + bodyFrameLayout.AddChidren(frameBack); + + var rowPhone = new FrameRowControl(); + //鍙宠竟鍋忕Щ閲�->澧炲姞瀹藉害 + rowPhone.RightOffset = -ControlCommonResourse.XXLeft; + rowPhone.Y = Application.GetRealHeight(23); + rowPhone.Width = this.GetPictrueRealSize(628); + bodyFrameLayout.AddChidren(rowPhone); + //璇疯緭鍏ラ偖绠辨垨鎵嬫満鍙� + string phoneValue = string.IsNullOrEmpty(UserCenterResourse.UserInfo.Phone) == true ? string.Empty : "+" + UserCenterResourse.UserInfo.AreaCode + " " + UserCenterResourse.UserInfo.Phone; + var txtPhone = rowPhone.AddLeftCaption(string.IsNullOrEmpty(phoneValue) == true ? UserCenterResourse.UserInfo.Email : phoneValue, 600); + txtPhone.TextColor = UserCenterColor.Current.TextGrayColor2; + //搴曠嚎 + rowPhone.AddBottomLine(); + //褰撳墠閫夋嫨鐨勬柟寮� + this.strPhoneEmail = txtPhone.Text; + + var rowCode = new FrameRowControl(); + rowCode.Y = rowPhone.Bottom + Application.GetRealHeight(20); + rowCode.Width = this.GetPictrueRealSize(628); + bodyFrameLayout.AddChidren(rowCode); + //璇疯緭鍏ラ獙璇佺爜 + var txtCode = rowCode.AddLeftInput("", 600); + txtCode.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uPleaseInputVerificationCode); + txtCode.TextChangeEventHandler += this.txtCodeValueChangedEvent; + + //鑾峰彇楠岃瘉鐮� + var btnCode = new NormalViewControl(302, 127, true); + btnCode.X = rowPhone.Right + Application.GetRealWidth(35); + btnCode.Y = Application.GetRealHeight(23); + btnCode.RadiusEx = 12; + btnCode.TextID = R.MyInternationalizationString.uGetVerificationCode; + btnCode.TextColor = UserCenterColor.Current.White; + btnCode.BackgroundColor = UserCenterColor.Current.TextOrangeColor; + btnCode.TextAlignment = TextAlignment.Center; + bodyFrameLayout.AddChidren(btnCode); + btnCode.ButtonClickEvent += (sender, e) => + { + //鍙戦�侀獙璇佺爜 + this.SetVerificationCode(btnCode); + }; + + //閿欒淇℃伅鎺т欢 + btnMsgControl = new NormalViewControl(800, 58, true); + btnMsgControl.X = ControlCommonResourse.XXLeft; + btnMsgControl.Y = rowCode.Bottom + Application.GetRealHeight(46); + btnMsgControl.TextColor = 0xfff75858; + btnMsgControl.TextID = R.MyInternationalizationString.uVerificationCodeErrorInputAgain; + bodyFrameLayout.AddChidren(btnMsgControl); + btnMsgControl.Visible = false; + + if (string.IsNullOrEmpty(UserCenterResourse.UserInfo.Phone) == true + || string.IsNullOrEmpty(UserCenterResourse.UserInfo.Email) == true) + { + rowPhone.UseClickStatu = false; + return; + } + + //鏄剧ず鍙互鍒囨崲閭->涓�涓彲浠ラ伄浣廈ody鐨勪笢瑗� + var frameTran = new FrameLayoutStatuControl(); + frameTran.UseClickStatu = false; + frameTran.BackgroundColor = UserCenterColor.Current.Transparent; + bodyFrameLayout.AddChidren(frameTran); + frameTran.Visible = false; + frameTran.ButtonClickEvent += (sender, e) => + { + frameTran.Visible = false; + }; + var frameList = new FrameLayout(); + frameList.X = ControlCommonResourse.XXLeft - Application.GetRealWidth(17); + frameList.Y = rowPhone.Bottom - ControlCommonResourse.BottomLineHeight - 1; + frameList.Width = this.GetPictrueRealSize(628); + frameList.Height = this.GetPictrueRealSize(176); + frameTran.AddChidren(frameList); + //鍔ㄧ敾鐢� + var frameAnimate = new FrameLayoutStatuControl(); + frameAnimate.UseClickStatu = false; + frameList.AddChidren(frameAnimate); + + var btnPic = new PicViewControl(frameList.Width, frameList.Height, false); + btnPic.UnSelectedImagePath = "Item/ForgotPswList.png"; + frameAnimate.AddChidren(btnPic); + var btnEmail = new NormalViewControl(450, 58, true); + btnEmail.X = this.GetPictrueRealSize(46); + btnEmail.Y = this.GetPictrueRealSize(32); + btnEmail.TextColor = UserCenterColor.Current.TextGrayColor3; + btnEmail.Text = UserCenterResourse.UserInfo.Email; + frameAnimate.AddChidren(btnEmail); + frameAnimate.ButtonClickEvent += (sender, e) => + { + frameTran.Visible = false; + string oldValue = txtPhone.Text; + txtPhone.Text = btnEmail.Text; + btnEmail.Text = oldValue; + + //褰撳墠閫夋嫨鐨勬柟寮� + this.strPhoneEmail = txtPhone.Text; + }; + rowPhone.ButtonClickEvent += (sender, e) => + { + if (frameTran.Visible == false) + { + frameTran.Visible = true; + } + }; + } + + #endregion + + #region 鈻� 鍙戦�侀獙璇佺爜_________________________ + + /// <summary> + /// 鍙戦�侀獙璇佺爜 + /// </summary> + /// <param name="btnCode"></param> + private async void SetVerificationCode(NormalViewControl btnCode) + { + string account = this.strPhoneEmail.StartsWith("+") == true ? UserCenterResourse.UserInfo.Phone : UserCenterResourse.UserInfo.Email; + var sendCodePra = new SendCodePra(); + sendCodePra.Account = account; + sendCodePra.AreaCode = Convert.ToInt32(UserCenterResourse.UserInfo.AreaCode); + bool flage = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/ForgetPassword", false, sendCodePra); + if (flage == false) + { + return; + } + + //鍙互寮�濮嬫牎楠岄獙璇佺爜浜� + this.canCheckCode = true; + //鎺т欢涓嶈兘鍐嶆鎸変笅 + btnCode.CanClick = false; + btnCode.BackgroundColor = 0xfffebca9; + //?s鍚庨噸鍙� + string repeat = Language.StringByID(R.MyInternationalizationString.RepeatSend1); + //鏈夋晥鏃堕棿60绉� + int waitime = 60; + btnCode.Text = waitime + "s" + repeat; + + HdlThreadLogic.Current.RunThread(() => + { + while (this.Parent != null) + { + waitime--; + System.Threading.Thread.Sleep(1000); + if (waitime == 0) + { + Application.RunOnMainThread(() => + { + if (btnCode != null) + { + //鑾峰彇楠岃瘉鐮� + btnCode.TextID = R.MyInternationalizationString.uGetVerificationCode; + //鎸夐敭鍙互鎸変笅 + btnCode.CanClick = true; + btnCode.BackgroundColor = UserCenterColor.Current.TextOrangeColor; + } + }); + break; + } + Application.RunOnMainThread(() => + { + if (btnCode != null) + { + btnCode.Text = waitime + "s" + repeat; + } + }); + } + }); + } + + #endregion + + #region 鈻� 楠岃瘉鐮佷簨浠禵________________________ + + /// <summary> + /// 楠岃瘉鐮佷簨浠� + /// </summary> + /// <param name="control"></param> + /// <param name="value"></param> + private void txtCodeValueChangedEvent(View control, string value) + { + if (btnMsgControl.Visible == true) + { + btnMsgControl.Visible = false; + } + + //楠岃瘉鐮侀暱搴� + int CodeLength = 6; + if (value.Length < CodeLength) + { + return; + } + if (value.Length == CodeLength) + { + //杩樹笉鑳芥娴嬮獙璇佺爜 + if (this.canCheckCode == false) + { + btnMsgControl.Visible = true; + return; + } + var txtCode = (TextInputControl)control; + //缁堟浜嬩欢 + txtCode.TextChangeEventHandler -= this.txtCodeValueChangedEvent; + //楠岃瘉楠岃瘉鐮� + this.CheckVerificationCode(txtCode, value); + } + } + + #endregion + + #region 鈻� 鏍¢獙楠岃瘉鐮乢________________________ + + /// <summary> + /// 楠岃瘉楠岃瘉鐮� + /// </summary> + /// <returns></returns> + private async void CheckVerificationCode(TextInputControl txtCode, string code) + { + string account = this.strPhoneEmail.StartsWith("+") == true ? UserCenterResourse.UserInfo.Phone : UserCenterResourse.UserInfo.Email; + var checkCodePra = new CheckCodePra(); + checkCodePra.Code = code; + checkCodePra.Account = account; + + bool flage = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/ValidatorCode", false, checkCodePra); + if (flage == false) + { + //楠岃瘉鐮侀敊璇紝璇烽噸鏂拌緭鍏� + this.btnMsgControl.Visible = true; + //浜嬩欢杩樺師 + txtCode.TextChangeEventHandler += this.txtCodeValueChangedEvent; + return; + } + + var from = new ResetAccountPasswordForm(); + base.AddFromAndRemoveNowForm(from); + } + + #endregion + + #region 鈻� 缁撴瀯浣揰____________________________ + + /// <summary> + /// 鍙戦�侀獙璇佺爜鐨勫惎鍔ㄥ弬鏁� + /// </summary> + private class SendCodePra + { + /// <summary> + /// 鐢ㄦ埛璐﹀彿 + /// </summary> + public string Account = UserCenterResourse.UserInfo.Phone; + /// <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 = UserCenterResourse.UserInfo.Phone; + /// <summary> + /// 楠岃瘉鐮� + /// </summary> + public string Code = "0"; + /// <summary> + /// 璇█ + /// </summary> + public string Language = Shared.Language.CurrentLanguage; + /// <summary> + /// 鍥藉鍦板尯浠g爜锛屾墜鏈哄彿鍙戦�侀獙璇佺爜鏃朵娇鐢� + /// </summary> + public int AreaCode = Convert.ToInt32(UserCenterResourse.UserInfo.AreaCode); + } + + #endregion + } +} -- Gitblit v1.8.0