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/CheckNewPhoneForm.cs |  168 ++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 126 insertions(+), 42 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Password/CheckNewPhoneForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Password/CheckNewPhoneForm.cs
index 0539ccc..ad42b58 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Password/CheckNewPhoneForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Password/CheckNewPhoneForm.cs
@@ -23,10 +23,6 @@
         /// 鏂版墜鏈�(闃叉鎭舵剰鍙樻洿)
         /// </summary>
         private string newPhone = string.Empty;
-        /// <summary>
-        /// 鑳藉惁鍙戦�侀獙璇佺爜
-        /// </summary>
-        private bool canSendCode = true;
 
         #endregion
 
@@ -78,20 +74,20 @@
             //};
 
             //杈撳叆妗�
-            var txtValue = new TextInputControl(Application.GetRealWidth(510), frame.Height - HdlControlResourse.BottomLineHeight, false);
+            var txtValue = new TextInputControl(Application.GetRealWidth(510), frame.Height - ControlCommonResourse.BottomLineHeight, false);
             txtValue.X = btnArea.Right + Application.GetRealWidth(35);
             txtValue.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uPleaseInputNewPhoneNumber);
             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.UserPhone) == false)
+            if (string.IsNullOrEmpty(UserCenterResourse.UserInfo.Phone) == false)
             {
                 //纭韬唤鎴愬姛锛岃缁戝畾鏂版墜鏈哄彿鐮�
                 var btnMsg1 = new NormalViewControl(800, 49, false);
@@ -117,8 +113,12 @@
             };
             btnCodeControl.FinishInputEvent += (value) =>
             {
-                //缁戝畾鏂版墜鏈�
-                this.SaveNewPhoneNumber(btnCodeControl, value);
+                //鏍¢獙楠岃瘉鐮�
+                if (this.CheckVerificationCode(value) == false)
+                {
+                    //娓呯┖楠岃瘉鐮�
+                    btnCodeControl.ClearInputValue();
+                }
             };
 
             //楠岃瘉鐮侀敊璇紝璇烽噸鏂拌緭鍏�
@@ -177,16 +177,16 @@
         /// </summary>
         private void SendCodeToPhone(BottomClickButton btnNext,string areaCode, string phoneNum)
         {
-            var errorMsg = HdlAccountLogic.Current.SendVeriCodeToPhone(areaCode, phoneNum, VerCodeType.A缁戝畾);
-            if (errorMsg != null)
+            var sendCodePra = new SendCodePra();
+            sendCodePra.Account = phoneNum;
+            sendCodePra.AreaCode = Convert.ToInt32(areaCode);
+
+            bool flage = UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/RegisterSendVerCode", false, sendCodePra);
+            if (flage == false)
             {
-                //鏄剧ず閿欒
-                this.btnErrorMsg.Visible = true;
-                this.btnErrorMsg.Text = errorMsg;
                 return;
             }
-            //涓嶈兘鍐嶅彂閫侀獙璇佺爜
-            this.canSendCode = false;
+
             //鍙互寮�濮嬫牎楠岄獙璇佺爜浜�
             this.canCheckCode = true;
             //璁板綍璧疯繖涓墜鏈�,闃叉鎭舵剰鍙樻洿
@@ -201,12 +201,22 @@
 
             HdlThreadLogic.Current.RunThread(() =>
             {
-                while (this.Parent != null && this.canSendCode == false)
+                while (this.Parent != null)
                 {
                     waitime--;
                     System.Threading.Thread.Sleep(1000);
                     if (waitime == 0)
                     {
+                        Application.RunOnMainThread(() =>
+                        {
+                            if (btnNext != null)
+                            {
+                                //鑾峰彇楠岃瘉鐮�
+                                btnNext.TextID = R.MyInternationalizationString.uGetVerificationCode;
+                                //鎸夐敭鍙互鎸変笅
+                                btnNext.CanClick = true;
+                            }
+                        });
                         break;
                     }
                     HdlThreadLogic.Current.RunMain(() =>
@@ -217,44 +227,57 @@
                         }
                     }, ShowErrorMode.NO);
                 }
-                Application.RunOnMainThread(() =>
-                {
-                    if (btnNext != null)
-                    {
-                        //鑾峰彇楠岃瘉鐮�
-                        btnNext.TextID = R.MyInternationalizationString.uGetVerificationCode;
-                        //鎸夐敭鍙互鎸変笅
-                        btnNext.CanClick = true;
-                    }
-                });
             });
         }
 
         #endregion
 
-        #region 鈻� 鍙樻洿鎵嬫満___________________________
+        #region 鈻� 鏍¢獙楠岃瘉鐮乢________________________
 
         /// <summary>
-        /// 鍙樻洿鎵嬫満鍙�
+        /// 楠岃瘉楠岃瘉鐮�
         /// </summary>
-        private void SaveNewPhoneNumber(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.newPhone, code);
-            if (errorMsg != null)
+            var checkCodePra = new CheckCodePra();
+            checkCodePra.Code = code;
+            checkCodePra.Account = newPhone;
+
+            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.SaveNewPhoneNumber();
+            return true;
+        }
+
+        /// <summary>
+        /// 鍙樻洿鎵嬫満鍙�
+        /// </summary>
+        private void SaveNewPhoneNumber()
+        {
+            var pra = new SaveNewPhoneNumPra();
+            pra.Account = newPhone;
+
+            bool flage = UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/BindAccount", false, pra);
+            if (flage == false)
+            {
+                //缁戝畾鎵嬫満澶辫触
+                this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uBindPhoneFail));
                 return;
             }
 
@@ -273,12 +296,12 @@
         private void RefreshUserInfoForm()
         {
             //濡傛灉淇敼鐨勬槸璐﹀彿鐨勮瘽,鍒欓噸鏂扮櫥褰�
-            if (HdlUserCenterResourse.UserInfo.UserPhone == Shared.Common.Config.Instance.Account)
+            if (UserCenterResourse.UserInfo.Phone == Shared.Common.Config.Instance.Account)
             {
-                HdlAccountLogic.Current.ReLoginAgain(newPhone);
+                UserCenterLogic.ReLoginAgain(newPhone);
                 return;
             }
-            HdlUserCenterResourse.UserInfo.UserPhone = newPhone;
+            UserCenterResourse.UserInfo.Phone = newPhone;
             this.CloseForm();
         }
 
@@ -312,5 +335,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 SaveNewPhoneNumPra
+        {
+            /// <summary>
+            /// 鏂扮敤鎴疯处鍙�
+            /// </summary>
+            public string Account = string.Empty;
+        }
+
+        #endregion
     }
 }

--
Gitblit v1.8.0