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 |  134 +++++++++++++++++++++++++-------------------
 1 files changed, 77 insertions(+), 57 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/UserMain/UserInformationForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/UserMain/UserInformationForm.cs
index 8998b82..bdb24b3 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/UserMain/UserInformationForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/UserMain/UserInformationForm.cs
@@ -11,7 +11,7 @@
         /// <summary>
         /// 涓儴妗屽竷鎺т欢
         /// </summary>
-        private FrameLayout frameMiddleBack = null;
+        private NormalFrameLayout frameMiddleBack = null;
 
         #region 鈻� 鍒濆鍖朹____________________________
 
@@ -20,6 +20,9 @@
         /// </summary>
         public void ShowForm()
         {
+            //璁颁綇瀹冨師鏉ョ殑鏄电О
+            HdlUserCenterResourse.UserInfo.OldUserName = HdlUserCenterResourse.UserInfo.NickName;
+
             //鍥犱负鍒殑鐢婚潰浼氳皟鐢ㄨ繖涓嚱鏁帮紝鐒跺悗鍒锋柊鐢婚潰
             this.ClearBodyFrame();
 
@@ -52,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.ImageBytes = Shared.IO.FileUtils.ReadFile(UserCenterResourse.UserInfo.UserIconFile);
+            btnUserIcon.ImageBytes = Shared.IO.FileUtils.ReadFile(HdlFileNameResourse.UserHeadIconFile);
             specialTopFrame.AddChidren(btnUserIcon);
             btnUserIcon.MouseUpEventHandler += (sender, e) =>
             {
@@ -77,9 +80,9 @@
         {
             if (this.frameMiddleBack == null)
             {
-                frameMiddleBack = new FrameLayout();
+                frameMiddleBack = new NormalFrameLayout();
                 frameMiddleBack.Y = Application.GetRealHeight(363);
-                frameMiddleBack.Height = Application.GetRealHeight(1008);
+                frameMiddleBack.Height = Application.GetRealHeight(1008) - HdlControlResourse.ListViewRowHeight - Application.GetRealHeight(12);
                 frameMiddleBack.BackgroundColor = UserCenterColor.Current.White;
                 bodyFrameLayout.AddChidren(frameMiddleBack);
             }
@@ -102,25 +105,39 @@
             //鍚嶇О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;
 
@@ -147,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();
@@ -176,15 +193,15 @@
             //娣诲姞鍚戝彸鍥炬爣
             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
             {
-                string phoneNum = 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);
@@ -194,11 +211,11 @@
                     //鎴栬杩欐槸鍥藉鐨勬墜鏈哄惂
                     phoneNum = phoneNum.Substring(0, 3) + "".PadLeft(phoneNum.Length - 5, '*') + phoneNum.Substring(phoneNum.Length - 2, 2);
                 }
-                btnPhone.Text = "+" + UserCenterResourse.UserInfo.AreaCode + " " + phoneNum;
+                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();
@@ -212,7 +229,7 @@
 
           
             var rowOther = new FrameRowControl(listMidFrame.rowSpace / 2);
-            listMidFrame.AddChidren(rowOther);
+            //listMidFrame.AddChidren(rowOther);
             //绗笁鏂硅处鍙�
             rowOther.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uAuthenticatedOtherPartyAccount), 400);
             //搴曠嚎
@@ -268,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);
 
@@ -288,7 +305,7 @@
                 this.ShowMassage(ShowMsgType.Confirm, msg, () =>
                 {
                     //閫�鍑鸿处鍙�
-                    UserCenterLogic.ReLoginAgain(Common.Config.Instance.Account);
+                    HdlAccountLogic.Current.ReLoginAgain(Common.Config.Instance.Account);
                 });
             };
         }
@@ -300,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
@@ -352,7 +373,7 @@
                         if (this.MoveUserIconFile(imagePath) == true)
                         {
                             //涓婁紶鐢ㄦ埛澶村儚鏂囦欢
-                            this.UpLoadUserIconFile(btnUser, UserCenterResourse.UserInfo.UserIconFile);
+                            this.UpLoadUserIconFile(btnUser, HdlFileNameResourse.UserHeadIconFile);
                         }
                     }
                 }, "HdlPicture");
@@ -369,7 +390,7 @@
                         if (this.MoveUserIconFile(imagePath) == true)
                         {
                             //涓婁紶鐢ㄦ埛澶村儚鏂囦欢
-                            this.UpLoadUserIconFile(btnUser, UserCenterResourse.UserInfo.UserIconFile);
+                            this.UpLoadUserIconFile(btnUser, HdlFileNameResourse.UserHeadIconFile);
                         }
                     }
                 }, "HdlPicture");
@@ -381,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.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath);
+                HdlUserCenterResourse.UserInfo.UserIconFileChanged = true;
+                btnUser.ImageBytes = headImage;
             }
         }
 
@@ -401,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)

--
Gitblit v1.8.0