黄学彪
2020-12-16 0d9f64668fd7350d6a21fd157e32009a96d98134
ZigbeeApp/Shared/Phone/UserCenter/UserMain/UserInformationForm.cs
@@ -21,7 +21,7 @@
        public void ShowForm()
        {
            //记住它原来的昵称
            UserCenterResourse.UserInfo.OldUserName = UserCenterResourse.UserInfo.UserName;
            HdlUserCenterResourse.UserInfo.OldUserName = HdlUserCenterResourse.UserInfo.NickName;
            //因为别的画面会调用这个函数,然后刷新画面
            this.ClearBodyFrame();
@@ -60,7 +60,7 @@
            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) =>
            {
@@ -82,7 +82,7 @@
            {
                frameMiddleBack = new NormalFrameLayout();
                frameMiddleBack.Y = Application.GetRealHeight(363);
                frameMiddleBack.Height = Application.GetRealHeight(1008) - ControlCommonResourse.ListViewRowHeight - Application.GetRealHeight(12);
                frameMiddleBack.Height = Application.GetRealHeight(1008) - HdlControlResourse.ListViewRowHeight - Application.GetRealHeight(12);
                frameMiddleBack.BackgroundColor = UserCenterColor.Current.White;
                bodyFrameLayout.AddChidren(frameMiddleBack);
            }
@@ -108,10 +108,10 @@
            var txtName = new TextInputControl(700, true);
            txtName.MaxByte = 36;//限制36个字节
            txtName.UseFocusColor = true;
            txtName.X = bodyFrameLayout.Width - Application.GetRealWidth(700) - ControlCommonResourse.XXLeft;
            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;
            //输入结束事件
@@ -124,7 +124,7 @@
            //所以才出此下策,添加这个事件)
            txtName.TextChangedEvent += (value) =>
            {
                UserCenterResourse.UserInfo.UserName = value;
                HdlUserCenterResourse.UserInfo.NickName = value;
            };
            //光标改变事件(2020.04.05:以前都定死说按回车键才更新,现在又说名字没有同步
            //所以才出此下策,添加这个事件)
@@ -164,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();
@@ -193,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);
@@ -211,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();
@@ -285,8 +285,8 @@
        private void InitLogoutFrameLayout()
        {
            var specialFrame = new FrameLayout();
            specialFrame.Height = ControlCommonResourse.ListViewRowHeight;
            specialFrame.Y = Application.GetRealHeight(1394) - ControlCommonResourse.ListViewRowHeight - Application.GetRealHeight(12);
            specialFrame.Height = HdlControlResourse.ListViewRowHeight;
            specialFrame.Y = Application.GetRealHeight(1394) - HdlControlResourse.ListViewRowHeight - Application.GetRealHeight(12);
            specialFrame.BackgroundColor = UserCenterColor.Current.White;
            bodyFrameLayout.AddChidren(specialFrame);
@@ -305,7 +305,7 @@
                this.ShowMassage(ShowMsgType.Confirm, msg, () =>
                {
                    //退出账号
                    UserCenterLogic.ReLoginAgain(Common.Config.Instance.Account);
                    HdlAccountLogic.Current.ReLoginAgain(Common.Config.Instance.Account);
                });
            };
        }
@@ -320,22 +320,20 @@
        /// <param name="txtName"></param>
        private void SaveUserName(TextInputControl txtName, bool showMsg)
        {
            if (UserCenterResourse.UserInfo.UserName == string.Empty)
            if (HdlUserCenterResourse.UserInfo.NickName == string.Empty)
            {
                //把名称还原回去
                txtName.Text = UserCenterResourse.UserInfo.OldUserName;
                UserCenterResourse.UserInfo.UserName = UserCenterResourse.UserInfo.OldUserName;
                txtName.Text = HdlUserCenterResourse.UserInfo.OldUserName;
                HdlUserCenterResourse.UserInfo.NickName = HdlUserCenterResourse.UserInfo.OldUserName;
                return;
            }
            if (UserCenterResourse.UserInfo.OldUserName == UserCenterResourse.UserInfo.UserName)
            if (HdlUserCenterResourse.UserInfo.OldUserName == HdlUserCenterResourse.UserInfo.NickName)
            {
                //无需修改
                return;
            }
            var pra = new SaveUserNamePra();
            pra.UserName = UserCenterResourse.UserInfo.UserName;
            bool result = UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/UpdateUserName", false, pra);
            bool result = HdlAccountLogic.Current.EditorUserNikeName(HdlUserCenterResourse.UserInfo.NickName, showMsg == true ? ShowNetCodeMode.YES : ShowNetCodeMode.No);
            if (result == false)
            {
                return;
@@ -348,7 +346,7 @@
                this.ShowMassage(ShowMsgType.Tip, msg);
            }
            UserCenterResourse.UserInfo.OldUserName = UserCenterResourse.UserInfo.UserName;
            HdlUserCenterResourse.UserInfo.OldUserName = HdlUserCenterResourse.UserInfo.NickName;
        }
        #endregion
@@ -375,7 +373,7 @@
                        if (this.MoveUserIconFile(imagePath) == true)
                        {
                            //上传用户头像文件
                            this.UpLoadUserIconFile(btnUser, UserCenterResourse.UserInfo.UserIconFile);
                            this.UpLoadUserIconFile(btnUser, HdlFileNameResourse.UserHeadIconFile);
                        }
                    }
                }, "HdlPicture");
@@ -392,7 +390,7 @@
                        if (this.MoveUserIconFile(imagePath) == true)
                        {
                            //上传用户头像文件
                            this.UpLoadUserIconFile(btnUser, UserCenterResourse.UserInfo.UserIconFile);
                            this.UpLoadUserIconFile(btnUser, HdlFileNameResourse.UserHeadIconFile);
                        }
                    }
                }, "HdlPicture");
@@ -406,12 +404,16 @@
        /// <param name="imagePath"></param>
        private void UpLoadUserIconFile(ImageView btnUser, string imagePath)
        {
            var pra = new { HeadImage = Shared.IO.FileUtils.ReadFile(imagePath) };
            var result = 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;
            }
        }
@@ -424,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)