黄学彪
2020-09-18 c7df85937f73fb347ee0b19e9c052d2d00a6df6c
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()
        {
            //记住它原来的昵称
            UserCenterResourse.UserInfo.OldUserName = UserCenterResourse.UserInfo.UserName;
            //因为别的画面会调用这个函数,然后刷新画面
            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(UserCenterResourse.UserInfo.UserIconFile);
            specialTopFrame.AddChidren(btnUserIcon);
            btnUserIcon.MouseUpEventHandler += (sender, e) =>
            {
@@ -70,27 +78,36 @@
        /// </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) - ControlCommonResourse.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);
            var txtName = new TextInputControl(700, true);
            txtName.MaxByte = 36;//限制36个字节
            txtName.UseFocusColor = true;
            txtName.X = bodyFrameLayout.Width - Application.GetRealWidth(700) - ControlCommonResourse.XXLeft;
            txtName.Gravity = Gravity.CenterVertical;
            txtName.TextAlignment = TextAlignment.CenterRight;
@@ -100,15 +117,29 @@
            //输入结束事件
            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) =>
            {
                UserCenterResourse.UserInfo.UserName = 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);
@@ -170,7 +201,17 @@
            }
            else
            {
                btnPhone.Text = "+" + UserCenterResourse.UserInfo.AreaCode + " " + UserCenterResourse.UserInfo.Phone;
                string phoneNum = UserCenterResourse.UserInfo.Phone;
                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 = "+" + UserCenterResourse.UserInfo.AreaCode + " " + phoneNum;
            }
            rowPhone.ButtonClickEvent += (sender, e) =>
            {
@@ -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();
            //微信、QQ
            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();
@@ -244,7 +286,7 @@
        {
            var specialFrame = new FrameLayout();
            specialFrame.Height = ControlCommonResourse.ListViewRowHeight;
            specialFrame.Y = Application.GetRealHeight(1394);
            specialFrame.Y = Application.GetRealHeight(1394) - ControlCommonResourse.ListViewRowHeight - Application.GetRealHeight(12);
            specialFrame.BackgroundColor = UserCenterColor.Current.White;
            bodyFrameLayout.AddChidren(specialFrame);
@@ -275,32 +317,38 @@
        /// <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 (UserCenterResourse.UserInfo.UserName == string.Empty)
            {
                //把名称还原回去
                txtName.Text = UserCenterResourse.UserInfo.OldUserName;
                UserCenterResourse.UserInfo.UserName = UserCenterResourse.UserInfo.OldUserName;
                return;
            }
            //打开进度条
            this.ShowProgressBar();
            if (UserCenterResourse.UserInfo.OldUserName == UserCenterResourse.UserInfo.UserName)
            {
                //无需修改
                return;
            }
            var pra = new SaveUserNamePra();
            pra.UserName = userName;
            pra.UserName = UserCenterResourse.UserInfo.UserName;
            bool result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/UpdateUserName", false, pra);
            //关闭进度条
            this.CloseProgressBar();
            bool result = UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/UpdateUserName", false, pra);
            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;
            UserCenterResourse.UserInfo.OldUserName = UserCenterResourse.UserInfo.UserName;
        }
        #endregion
@@ -356,14 +404,14 @@
        /// </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 result = UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/UpdateHeadImage", false, pra);
            if (result == true)
            {
                UserCenterResourse.UserInfo.UserIconFileChanged = true;
                btnUser.ImagePath = imagePath;
                btnUser.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath);
            }
        }
@@ -404,8 +452,8 @@
        /// </summary>
        public override int FormActionAgainEvent()
        {
            //重新刷新界面
            this.ShowForm();
            //初始化中部的信息
            this.InitMiddleBodyFrame();
            return 1;
        }