wxr
2020-11-12 a715181089be0d31cd737a5367ffd02690b9d77f
HDL_ON/UI/UI2/4-PersonalCenter/PersonalDataPageBLL.cs
@@ -1,4 +1,5 @@
using System;
using HDL_ON.Entity;
using Shared;
namespace HDL_ON.UI
@@ -14,6 +15,9 @@
            LoadEvent_Logout();
            LoadEvent_EditUserName();
            LoadEvent_SkipInterpretationSettings();
            LoadEvent_ChangeBindEmail();
            LoadEvent_ChangeBindPhone();
            LoadEvent_SkipModifyPassword();
        }
        /// <summary>
@@ -21,7 +25,8 @@
        /// </summary>
        void LoadEvent_ChangeHeadImageView()
        {
            userHeadImageView.MouseUpEventHandler = (sender, e) => {
            userHeadImageView.MouseUpEventHandler = (sender, e) =>
            {
                LoadPictureOptionView();
            };
        }
@@ -31,31 +36,69 @@
        /// </summary>
        void LoadEvent_Logout()
        {
            btnLogout.MouseUpEventHandler += (sender, e) => {
            btnLogout.MouseUpEventHandler += (sender, e) =>
            {
                #region 保存本地数据至文件夹
                string oldRegionRootPath = FileUtils.CreateRegionBackup(DB_ResidenceData.residenceData.CurReginID.ToString());
                new System.Threading.Thread(() =>
                {
                    try
                    {
                        var backuplist = FileUtils.ReadFiles();
                        FileUtils.DeleteRegionFiles(oldRegionRootPath);
                        //移动文件
                        foreach (var fileName in backuplist)
                        {
                            System.IO.FileInfo fileInfo = new System.IO.FileInfo(FileUtils.RootPath + fileName);
                            if (fileInfo.Exists)
                            {
                                fileInfo.MoveTo(oldRegionRootPath + fileName);
                                MainPage.Log("move file : " + fileName);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MainPage.Log($"xxx:{ex.Message}");
                    }
                    finally
                    {
                        FileUtils.DeleteAllFile();
                    }
                }).Start();
                #endregion
                MainPage.LoginUser.lastTime = DateTime.MinValue;
                MainPage.LoginUser.SaveUserInfo();
                MainPage.GoLoginPage(MainPage.LoginUser.accountString);
                MainPage.GoLoginPage(MainPage.LoginUser);
                DB_ResidenceData.residenceData.EixtAccount();
            };
        }
        /// <summary>
        /// 加载背景图选择区域事件列表
        /// </summary>
        void LoadEvent_PictureOptionViewEventList()
        void LoadEvent_PictureOptionViewEventList(FrameLayout baseView)
        {
            pictureOptionView.MouseUpEventHandler = (sender, e) =>
            {
                pictureOptionView.RemoveFromParent();
                baseView.RemoveFromParent();
            };
            baseView.MouseUpEventHandler = (sender, e) => {
                baseView.RemoveFromParent();
            };
            btnCancel.MouseUpEventHandler = (sender, e) =>
            {
                pictureOptionView.RemoveFromParent();
                baseView.RemoveFromParent();
            };
            btnTakePicture.MouseUpEventHandler = (sender, e) =>
            {
                btnTakePicture.IsSelected = true;
            };
            btnTakePicture.MouseUpEventHandler = (sender, e) =>
            {
                btnTakePicture.IsSelected = false;
                var pid = Guid.NewGuid();
                CropImage.TakePicture((Action<string>)((imagePath) =>
                {
@@ -74,10 +117,17 @@
                    }
                }), pid.ToString(), 1, 1);
                pictureOptionView.RemoveFromParent();
                baseView.RemoveFromParent();
            };
            btnAlbum.MouseUpEventHandler = (sender, e) =>
            {
                btnAlbum.IsSelected = true;
            };
            btnAlbum.MouseUpEventHandler = (sender, e) =>
            {
                btnAlbum.IsSelected = false;
                var pid = Guid.NewGuid();
                CropImage.SelectPicture((imagePath) =>
                {
@@ -96,6 +146,7 @@
                    }
                }, pid.ToString(), 1, 1);
                pictureOptionView.RemoveFromParent();
                baseView.RemoveFromParent();
            };
        }
@@ -112,10 +163,14 @@
                    {
                        new Tip()
                        {
                            CloseTime = 3,
                            CloseTime = 1,
                            Text = Language.StringByID(StringId.UesrNameCannotBeEmpty),
                            Direction = AMPopTipDirection.None,
                        }.Show(bodyView);
                        return;
                    }
                    if(str == MainPage.LoginUser.userName)
                    {
                        return;
                    }
                    var waitPage = new Loading();
@@ -149,35 +204,79 @@
                                }
                                Application.RunOnMainThread(() =>
                                {
                                //提示原因
                                var tip = new Tip()
                                    //提示原因
                                    var tip = new Tip()
                                    {
                                        Text = tipStr,
                                        CloseTime = 3,
                                        CloseTime = 1,
                                        Direction = AMPopTipDirection.None
                                    };
                                    tip.Show(bodyView);
                                });
                            }
                        }catch (Exception ex)
                        }
                        catch (Exception ex)
                        {
                            MainPage.Log($"update user name error : {ex.Message}");
                        }
                        finally
                        {
                            Application.RunOnMainThread(() => {
                            Application.RunOnMainThread(() =>
                            {
                                waitPage.Hide();
                            });
                        }
                    })
                    { IsBackground = true }.Start();
                };
                new PublicAssmebly().LoadDialog_EditParater(StringId.UesrName, MainPage.LoginUser.userName, callBack,StringId.UesrNameCannotBeEmpty,0,new System.Collections.Generic.List<string>());
                new PublicAssmebly().LoadDialog_EditParater(StringId.ChangeName, MainPage.LoginUser.userName, callBack, StringId.UesrNameCannotBeEmpty, 0, new System.Collections.Generic.List<string>());
            };
            btnUserName.MouseUpEventHandler = eventHandler;
            btnEditUserNameIcon.MouseUpEventHandler = eventHandler;
        }
        #region 修改绑定邮箱
        /// <summary>
        /// 修改绑定邮箱
        /// </summary>
        void LoadEvent_ChangeBindEmail()
        {
            EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
                Action<string> action = (email) =>
                {
                    btnUserEmailInfo.Text = email;
                };
                var aep = new AccountBindInfoPage();
                MainPage.BasePageView.AddChidren(aep);
                aep.LoadPage(action,1,StringId.EmailAddress);
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
            btnUserEmailInfo.MouseUpEventHandler = eventHandler;
            btnUserEmailRight.MouseUpEventHandler = eventHandler;
            userEmailInfoView.MouseUpEventHandler = eventHandler;
        }
        /// <summary>
        /// 修改绑定手机
        /// </summary>
        void LoadEvent_ChangeBindPhone()
        {
            EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
                Action<string> action = (phone) =>
                {
                    btnUserPhoneInfo.Text = phone;
                };
                var aep = new AccountBindInfoPage();
                MainPage.BasePageView.AddChidren(aep);
                aep.LoadPage(action, 2, StringId.PhoneInfo);
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
            btnUserPhoneInfo.MouseUpEventHandler = eventHandler;
            btnUserPhoneRight.MouseUpEventHandler = eventHandler;
            userPhoneInfoView.MouseUpEventHandler = eventHandler;
        }
        #endregion
        #region 解锁设置区域
        void LoadEvent_SkipInterpretationSettings()
@@ -197,5 +296,21 @@
        #endregion
        /// <summary>
        /// 跳转修改密码界面
        /// </summary>
        void LoadEvent_SkipModifyPassword()
        {
            EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
                var page = new ResetPasswordOptionPage();
                MainPage.BasePageView.AddChidren(page);
                page.LoadPage();
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
            btnResetPasswordRight.MouseUpEventHandler = eventHandler;
            btnResetPasswordText.MouseUpEventHandler = eventHandler;
            resetPasswordView.MouseUpEventHandler = eventHandler;
        }
    }
}
}