From 9f326f4000847e6167d8166fa2f6a66f53cb3734 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期四, 17 十二月 2020 09:07:13 +0800
Subject: [PATCH] 新云端Ver1.3

---
 ZigbeeApp/Shared/Phone/UserCenter/UserMain/UserInformationForm.cs |  175 ++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 110 insertions(+), 65 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/UserMain/UserInformationForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/UserMain/UserInformationForm.cs
index 8b2940a..bdb24b3 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/UserMain/UserInformationForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/UserMain/UserInformationForm.cs
@@ -8,6 +8,11 @@
     /// </summary>
     public class UserInformationForm : EditorCommonForm
     {
+        /// <summary>
+        /// 涓儴妗屽竷鎺т欢
+        /// </summary>
+        private NormalFrameLayout frameMiddleBack = null;
+
         #region 鈻� 鍒濆鍖朹____________________________
 
         /// <summary>
@@ -15,6 +20,9 @@
         /// </summary>
         public void ShowForm()
         {
+            //璁颁綇瀹冨師鏉ョ殑鏄电О
+            HdlUserCenterResourse.UserInfo.OldUserName = HdlUserCenterResourse.UserInfo.NickName;
+
             //鍥犱负鍒殑鐢婚潰浼氳皟鐢ㄨ繖涓嚱鏁帮紝鐒跺悗鍒锋柊鐢婚潰
             this.ClearBodyFrame();
 
@@ -47,12 +55,12 @@
 
             //鐢ㄦ埛鍥炬爣
             var btnUserIcon = new ImageView();
-            btnUserIcon.Height = Application.GetMinRealAverage(251);
-            btnUserIcon.Width = Application.GetMinRealAverage(251);
-            btnUserIcon.Radius = (uint)Application.GetMinRealAverage(251) / 2;
+            btnUserIcon.Height = this.GetPictrueRealSize(251);
+            btnUserIcon.Width = this.GetPictrueRealSize(251);
+            btnUserIcon.Radius = (uint)this.GetPictrueRealSize(251) / 2;
             btnUserIcon.Y = Application.GetRealHeight(46);
             btnUserIcon.Gravity = Gravity.CenterHorizontal;
-            btnUserIcon.ImagePath = UserCenterResourse.UserInfo.UserIconFile;
+            btnUserIcon.ImageBytes = Shared.IO.FileUtils.ReadFile(HdlFileNameResourse.UserHeadIconFile);
             specialTopFrame.AddChidren(btnUserIcon);
             btnUserIcon.MouseUpEventHandler += (sender, e) =>
             {
@@ -70,45 +78,68 @@
         /// </summary>
         private void InitMiddleBodyFrame()
         {
-            var frameBack = new FrameLayout();
-            frameBack.Y = Application.GetRealHeight(363);
-            frameBack.Height = Application.GetRealHeight(1008);
-            frameBack.BackgroundColor = UserCenterColor.Current.White;
-            bodyFrameLayout.AddChidren(frameBack);
+            if (this.frameMiddleBack == null)
+            {
+                frameMiddleBack = new NormalFrameLayout();
+                frameMiddleBack.Y = Application.GetRealHeight(363);
+                frameMiddleBack.Height = Application.GetRealHeight(1008) - HdlControlResourse.ListViewRowHeight - Application.GetRealHeight(12);
+                frameMiddleBack.BackgroundColor = UserCenterColor.Current.White;
+                bodyFrameLayout.AddChidren(frameMiddleBack);
+            }
+            else
+            {
+                frameMiddleBack.RemoveAll();
+            }
 
             var listMidFrame = new FrameListControl(12);
             listMidFrame.Y = Application.GetRealHeight(11);
             listMidFrame.Height = Application.GetRealHeight(1008 - 11);
-            frameBack.AddChidren(listMidFrame);
+            frameMiddleBack.AddChidren(listMidFrame);
 
             var rowName = new FrameRowControl(listMidFrame.rowSpace / 2);
             //鍏抽棴鐐瑰嚮鐘舵��
             rowName.UseClickStatu = false;
             listMidFrame.AddChidren(rowName);
             //搴曠嚎
-            rowName.AddBottomLine();
+            var btnNameLine = rowName.AddBottomLine();
             //鍚嶇ОView
             rowName.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uName), 350);
             //鍚嶇О杈撳叆
-            var txtName = new TextInputExControl(700, true);
-            txtName.X = bodyFrameLayout.Width - Application.GetRealWidth(700) - ControlCommonResourse.XXLeft;
+            var txtName = new TextInputControl(700, true);
+            txtName.MaxByte = 36;//闄愬埗36涓瓧鑺�
+            txtName.UseFocusColor = true;
+            txtName.X = bodyFrameLayout.Width - Application.GetRealWidth(700) - HdlControlResourse.XXLeft;
             txtName.Gravity = Gravity.CenterVertical;
             txtName.TextAlignment = TextAlignment.CenterRight;
-            txtName.Text = UserCenterResourse.UserInfo.UserName;
+            txtName.Text = HdlUserCenterResourse.UserInfo.NickName;
             rowName.AddChidren(txtName, ChidrenBindMode.NotBind);
             txtName.Y += listMidFrame.rowSpace / 2;
             //杈撳叆缁撴潫浜嬩欢
             txtName.FinishInputEvent += (() =>
             {
-                if (txtName.Text.Trim() == string.Empty)
-                {
-                    //鎶婂悕绉拌繕鍘熷洖鍘�
-                    txtName.Text = UserCenterResourse.UserInfo.UserName;
-                    return;
-                }
                 //鏇存柊鐢ㄦ埛鍚�
-                this.SaveUserName(txtName.Text.Trim());
+                this.SaveUserName(txtName, true);
             });
+            //杈撳叆鍊兼敼鍙樹簨浠�(2020.04.05:浠ュ墠閮藉畾姝昏鎸夊洖杞﹂敭鎵嶆洿鏂�,鐜板湪鍙堣鍚嶅瓧娌℃湁鍚屾
+            //鎵�浠ユ墠鍑烘涓嬬瓥,娣诲姞杩欎釜浜嬩欢)
+            txtName.TextChangedEvent += (value) =>
+            {
+                HdlUserCenterResourse.UserInfo.NickName = value;
+            };
+            //鍏夋爣鏀瑰彉浜嬩欢(2020.04.05:浠ュ墠閮藉畾姝昏鎸夊洖杞﹂敭鎵嶆洿鏂�,鐜板湪鍙堣鍚嶅瓧娌℃湁鍚屾
+            //鎵�浠ユ墠鍑烘涓嬬瓥,娣诲姞杩欎釜浜嬩欢)
+            txtName.FoucsChanged += (sender, focusEvent) =>
+            {
+                //鍏夋爣绂诲紑鏃�,鎵ц鍚嶅瓧淇敼
+                if (focusEvent.Focus == false)
+                {
+                    //鏇存柊鐢ㄦ埛鍚�
+                    this.SaveUserName(txtName, false);
+                }
+            };
+
+            //鑱斿姩绾跨殑鐘舵��
+            txtName.btnLine = btnNameLine;
 
             var rowQrCode = new FrameRowControl(listMidFrame.rowSpace / 2);
             listMidFrame.AddChidren(rowQrCode);
@@ -133,15 +164,15 @@
             //娣诲姞鍚戝彸鍥炬爣
             rowEmail.AddRightArrow();
             //閭
-            var btnEmail = rowEmail.AddMostRightView(UserCenterResourse.UserInfo.Email, 500);
-            if (string.IsNullOrEmpty(UserCenterResourse.UserInfo.Email) == true)
+            var btnEmail = rowEmail.AddMostRightView(HdlUserCenterResourse.UserInfo.UserEmail, 500);
+            if (string.IsNullOrEmpty(HdlUserCenterResourse.UserInfo.UserEmail) == true)
             {
                 //鏈缃�,璇风粦瀹�
                 btnEmail.TextID = R.MyInternationalizationString.uNotSettionAndPleaseBind;
             }
             rowEmail.ButtonClickEvent += (sender, e) =>
             {
-                if (string.IsNullOrEmpty(UserCenterResourse.UserInfo.Email) == true)
+                if (string.IsNullOrEmpty(HdlUserCenterResourse.UserInfo.UserEmail) == true)
                 {
                     var form = new Password.CheckNewEmailForm();
                     form.AddForm();
@@ -162,19 +193,29 @@
             //娣诲姞鍚戝彸鍥炬爣
             rowPhone.AddRightArrow();
             //鎵嬫満鍙�
-            var btnPhone = rowPhone.AddMostRightView(UserCenterResourse.UserInfo.Phone, 500);
-            if (string.IsNullOrEmpty(UserCenterResourse.UserInfo.Phone) == true)
+            var btnPhone = rowPhone.AddMostRightView(HdlUserCenterResourse.UserInfo.UserPhone, 500);
+            if (string.IsNullOrEmpty(HdlUserCenterResourse.UserInfo.UserPhone) == true)
             {
                 //鏈缃�,璇风粦瀹�
                 btnPhone.TextID = R.MyInternationalizationString.uNotSettionAndPleaseBind;
             }
             else
             {
-                btnPhone.Text = "+" + UserCenterResourse.UserInfo.AreaCode + " " + UserCenterResourse.UserInfo.Phone;
+                string phoneNum = HdlUserCenterResourse.UserInfo.UserPhone;
+                if (phoneNum.Length >= 11)
+                {
+                    phoneNum = phoneNum.Substring(0, 3) + "".PadLeft(phoneNum.Length - 7, '*') + phoneNum.Substring(phoneNum.Length - 4, 4);
+                }
+                else if (phoneNum.Length >= 5)
+                {
+                    //鎴栬杩欐槸鍥藉鐨勬墜鏈哄惂
+                    phoneNum = phoneNum.Substring(0, 3) + "".PadLeft(phoneNum.Length - 5, '*') + phoneNum.Substring(phoneNum.Length - 2, 2);
+                }
+                btnPhone.Text = "+" + HdlUserCenterResourse.UserInfo.PhoneAreaCode + " " + phoneNum;
             }
             rowPhone.ButtonClickEvent += (sender, e) =>
             {
-                if (string.IsNullOrEmpty(UserCenterResourse.UserInfo.Phone) == true)
+                if (string.IsNullOrEmpty(HdlUserCenterResourse.UserInfo.UserPhone) == true)
                 {
                     var form = new Password.CheckNewPhoneForm();
                     form.AddForm();
@@ -188,7 +229,7 @@
 
           
             var rowOther = new FrameRowControl(listMidFrame.rowSpace / 2);
-            listMidFrame.AddChidren(rowOther);
+            //listMidFrame.AddChidren(rowOther);
             //绗笁鏂硅处鍙�
             rowOther.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uAuthenticatedOtherPartyAccount), 400);
             //搴曠嚎
@@ -196,7 +237,8 @@
             //娣诲姞鍚戝彸鍥炬爣
             rowOther.AddRightArrow();
             //寰俊銆丵Q
-            rowOther.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uWebChatAndQQ), 500);
+            //var btnQQ = rowOther.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uWebChatAndQQ), 500);
+            var btnQQ = rowOther.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uWebChat), 500);
             rowOther.ButtonClickEvent += (sender, e) =>
             {
                 var form = new OtherParty.OtherPartyAccountMenuForm();
@@ -212,7 +254,7 @@
             //娣诲姞鍚戝彸鍥炬爣
             rowSysPsw.AddRightArrow();
             //鍘讳慨鏀�
-            rowSysPsw.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uGotoEditor), 350);
+            var btnPsw = rowSysPsw.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uGotoEditor), 350);
             rowSysPsw.ButtonClickEvent += (sender, e) =>
             {
                 var form = new Password.EditorAccountPasswordForm();
@@ -226,7 +268,7 @@
             //娣诲姞鍚戝彸鍥炬爣
             rowSecond.AddRightArrow();
             //瀵嗙爜銆佹墜鍔裤�佹寚绾�
-            rowSecond.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uPasswordGestureFingerPrint), 400);
+            var btnSecand = rowSecond.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uPasswordGestureFingerPrint), 400);
             rowSecond.ButtonClickEvent += (sender, e) =>
             {
                 var form = new SecondAuthenticationForm();
@@ -243,8 +285,8 @@
         private void InitLogoutFrameLayout()
         {
             var specialFrame = new FrameLayout();
-            specialFrame.Height = ControlCommonResourse.ListViewRowHeight;
-            specialFrame.Y = Application.GetRealHeight(1394);
+            specialFrame.Height = HdlControlResourse.ListViewRowHeight;
+            specialFrame.Y = Application.GetRealHeight(1394) - HdlControlResourse.ListViewRowHeight - Application.GetRealHeight(12);
             specialFrame.BackgroundColor = UserCenterColor.Current.White;
             bodyFrameLayout.AddChidren(specialFrame);
 
@@ -263,7 +305,7 @@
                 this.ShowMassage(ShowMsgType.Confirm, msg, () =>
                 {
                     //閫�鍑鸿处鍙�
-                    UserCenterLogic.ReLoginAgain(Common.Config.Instance.Account);
+                    HdlAccountLogic.Current.ReLoginAgain(Common.Config.Instance.Account);
                 });
             };
         }
@@ -275,32 +317,36 @@
         /// <summary>
         /// 鏇存柊鐢ㄦ埛鍚�
         /// </summary>
-        /// <param name="userName">鏄电О</param>
-        private async void SaveUserName(string userName)
+        /// <param name="txtName"></param>
+        private void SaveUserName(TextInputControl txtName, bool showMsg)
         {
-            if (UserCenterResourse.UserInfo.UserName == userName)
+            if (HdlUserCenterResourse.UserInfo.NickName == string.Empty)
             {
+                //鎶婂悕绉拌繕鍘熷洖鍘�
+                txtName.Text = HdlUserCenterResourse.UserInfo.OldUserName;
+                HdlUserCenterResourse.UserInfo.NickName = HdlUserCenterResourse.UserInfo.OldUserName;
                 return;
             }
-            //鎵撳紑杩涘害鏉�
-            this.ShowProgressBar();
+            if (HdlUserCenterResourse.UserInfo.OldUserName == HdlUserCenterResourse.UserInfo.NickName)
+            {
+                //鏃犻渶淇敼
+                return;
+            }
 
-            var pra = new SaveUserNamePra();
-            pra.UserName = userName;
-
-            bool result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/UpdateUserName", false, pra);
-            //鍏抽棴杩涘害鏉�
-            this.CloseProgressBar();
+            bool result = HdlAccountLogic.Current.EditorUserNikeName(HdlUserCenterResourse.UserInfo.NickName, showMsg == true ? ShowNetCodeMode.YES : ShowNetCodeMode.No);
             if (result == false)
             {
                 return;
             }
 
-            //鐢ㄦ埛鍚嶇О淇敼鎴愬姛!
-            string msg = Language.StringByID(R.MyInternationalizationString.uUserNameSaveSuccess);
-            this.ShowMassage(ShowMsgType.Tip, msg);
+            if (showMsg == true)
+            {
+                //鐢ㄦ埛鍚嶇О淇敼鎴愬姛!
+                string msg = Language.StringByID(R.MyInternationalizationString.uUserNameSaveSuccess);
+                this.ShowMassage(ShowMsgType.Tip, msg);
+            }
 
-            UserCenterResourse.UserInfo.UserName = userName;
+            HdlUserCenterResourse.UserInfo.OldUserName = HdlUserCenterResourse.UserInfo.NickName;
         }
 
         #endregion
@@ -327,7 +373,7 @@
                         if (this.MoveUserIconFile(imagePath) == true)
                         {
                             //涓婁紶鐢ㄦ埛澶村儚鏂囦欢
-                            this.UpLoadUserIconFile(btnUser, UserCenterResourse.UserInfo.UserIconFile);
+                            this.UpLoadUserIconFile(btnUser, HdlFileNameResourse.UserHeadIconFile);
                         }
                     }
                 }, "HdlPicture");
@@ -344,7 +390,7 @@
                         if (this.MoveUserIconFile(imagePath) == true)
                         {
                             //涓婁紶鐢ㄦ埛澶村儚鏂囦欢
-                            this.UpLoadUserIconFile(btnUser, UserCenterResourse.UserInfo.UserIconFile);
+                            this.UpLoadUserIconFile(btnUser, HdlFileNameResourse.UserHeadIconFile);
                         }
                     }
                 }, "HdlPicture");
@@ -356,14 +402,18 @@
         /// </summary>
         /// <param name="btnUser"></param>
         /// <param name="imagePath"></param>
-        private async void UpLoadUserIconFile(ImageView btnUser, string imagePath)
+        private void UpLoadUserIconFile(ImageView btnUser, string imagePath)
         {
-            var pra = new { HeadImage = Shared.IO.FileUtils.ReadFile(imagePath) };
-            var result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/UpdateHeadImage", false, pra);
+            var headImage = Shared.IO.FileUtils.ReadFile(imagePath);
+            if (headImage == null)
+            {
+                return;
+            }
+            var result = HdlAccountLogic.Current.UpLoadUserIconImage(headImage);
             if (result == true)
             {
-                UserCenterResourse.UserInfo.UserIconFileChanged = true;
-                btnUser.ImagePath = imagePath;
+                HdlUserCenterResourse.UserInfo.UserIconFileChanged = true;
+                btnUser.ImageBytes = headImage;
             }
         }
 
@@ -376,12 +426,7 @@
         {
             try
             {
-                if (System.IO.File.Exists(UserCenterResourse.UserInfo.UserIconFile) == true)
-                {
-                    System.IO.File.Delete(UserCenterResourse.UserInfo.UserIconFile);
-                }
-                //绉诲姩鏂囦欢
-                System.IO.File.Move(imagePath, UserCenterResourse.UserInfo.UserIconFile);
+                HdlFileLogic.Current.MoveFile(imagePath, HdlFileNameResourse.UserHeadIconFile);
                 return true;
             }
             catch (Exception ex)
@@ -404,8 +449,8 @@
         /// </summary>
         public override int FormActionAgainEvent()
         {
-            //閲嶆柊鍒锋柊鐣岄潰
-            this.ShowForm();
+            //鍒濆鍖栦腑閮ㄧ殑淇℃伅
+            this.InitMiddleBodyFrame();
 
             return 1;
         }

--
Gitblit v1.8.0