JLChen
2020-12-09 e87985ec1dcb69beedaf9f95e8e7aba14b7c08d6
HDL_ON/UI/UI1-Login/ForgetPasswordPageBLL.cs
@@ -32,6 +32,7 @@
            {
                if (registerType == 0)
                    return;
                etAccount.IsNumberKeyboardType = true;
                etAccount.Text = registerPhone;
                etPassword.Text = "";
                etRepeatPassword.Text = "";
@@ -60,6 +61,7 @@
            {
                if (registerType == 1)
                    return;
                etAccount.IsNumberKeyboardType = false;
                etAccount.Text = registerEmail;
                etPassword.Text = "";
                etRepeatPassword.Text = "";
@@ -92,11 +94,11 @@
        {
            etAccount.TextChangeEventHandler += (sender, e) =>
            {
                Regex reg = new Regex(@"^[1]+\d{10}");
                var mFalg = reg.Match(etAccount.Text.Trim());
                //Regex reg = new Regex(@"^[1]+\d{10}");
                //var mFalg = reg.Match(etAccount.Text.Trim());
                if (registerType == 0)//手机获取验证码按钮生效条件
                {
                    if (btnGlobalRoaming.Text == "+86" && etAccount.Text.Trim().Length != 11)
                    if (!Utlis.CheckPhoneNumber(etAccount.Text.Trim(), phoneZoneCode))
                    {
                        btnGetVerificationCode_Phone.IsSelected = false;
                    }
@@ -108,7 +110,7 @@
                }
                else//邮箱获取验证码按钮生效条件
                {
                    if (!mFalg.Success)
                    if (!Utlis.CheckEmail(etAccount.Text.Trim()))
                    {
                        btnGetVerificationCode_Mail.IsSelected = false;
                    }
@@ -142,10 +144,8 @@
                    //手机方式-验证手机号码是否正确
                    if (registerType == 0)
                    {
                    btnGetVerificationCode_Phone.IsSelected = false;
                        Regex reg = new Regex(@"^[1]+\d{9}");
                        var mFalg = reg.Match(etAccount.Text.Trim());
                        if (!mFalg.Success || (btnGlobalRoaming.Text == "+86" && etAccount.Text.Trim().Length != 11))
                        btnGetVerificationCode_Phone.IsSelected = false;
                        if (!Utlis.CheckPhoneNumber(etAccount.Text.Trim(), phoneZoneCode))
                        {
                            btnAccountViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
                            btnAccountViewBottomLine.Height = Application.GetRealHeight(2);
@@ -169,9 +169,7 @@
                    {
                        btnGetVerificationCode_Mail.IsSelected = false;
                        //邮箱方式-验证邮箱是否正确
                        var reg = new Regex("^\\s*([A-Za-z0-9_-]+(\\.\\w+)*@(\\w+\\.)+\\w{2,5})\\s*$");
                        var mFalg = reg.Match(etAccount.Text.Trim());
                        if (!mFalg.Success )
                        if (!Utlis.CheckEmail(etAccount.Text.Trim()))
                        {
                            btnAccountViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
                            btnAccountViewBottomLine.Height = Application.GetRealHeight(2);
@@ -291,6 +289,25 @@
        }
        /// <summary>
        /// 检测当前配置域名是否一致,不一致则替换
        /// </summary>
        /// <param name="result"></param>
        void CheckAndSetUserRequestHost(ResponsePackNew result) {
            try
            {
                var mGlobalRegionListObj = Newtonsoft.Json.JsonConvert.DeserializeObject<GlobalRegionListRes>(result.Data.ToString());
                if (UserInfo.Current.RequestHttpsHost != mGlobalRegionListObj.regionUrl)
                {
                    UserInfo.Current.RequestHttpsHost = mGlobalRegionListObj.regionUrl;
                    UserInfo.Current.GlobalRegion = mGlobalRegionListObj;
                    UserInfo.Current.SaveUserInfo();
                }
            }
            catch { }
        }
        /// <summary>
        /// 获取验证码
        /// </summary>
        void LoadEvent_GetVerificationCode()
@@ -300,62 +317,89 @@
                var account = etAccount.Text.Trim();
                if ((sender as Button).IsSelected)
                {
                    //加载Loading效果
                    var waitPage = new Loading();
                    bodyView.AddChidren(waitPage);
                    waitPage.Start(Language.StringByID(StringId.PleaseWait));
                    int time = 60;
                    new Thread(() =>
                    {
                        //1.先检查账号是否注册过
                        var result = pm.GetRegionByAccount(account);
                        if (result.Code != HttpUtil.SUCCESS_CODE)
                        try
                        {
                            IMessageCommon.Current.ShowErrorInfoAlter(NewAPI.API_POST_GetRegionByAccount, result.Code);
                            return;
                        }
                        else
                        {
                            //2.已经注册过,发送验证码找回密码
                            Application.RunOnMainThread(() =>
                            //1.先检查账号是否注册过
                            var result = pm.GetRegionByAccount(account);
                            if (result.Code != StateCode.SUCCESS)
                            {
                                //短信发送间隔60s
                                (sender as Button).IsSelected = false;
                                etVerificationCode.Foucs = true;
                            });
                            //2.1获取验证码倒计时
                            new Thread(() =>
                            {
                                while (time > 0)
                                {
                                    time--;
                                    Application.RunOnMainThread(() =>
                                    {
                                        (sender as Button).Text = time.ToString() + "s";
                                    });
                                    Thread.Sleep(1000);
                                }
                                Application.RunOnMainThread(() =>
                                {
                                    //回复获取短信按钮事件
                                    (sender as Button).IsSelected = true;
                                    (sender as Button).TextID = StringId.GetVerificationCode;
                                });
                            })
                            { IsBackground = true }.Start();
                            ResponsePackNew resultObj;
                            //2.1请求获取验证码
                            if (registerType == 1)//邮箱
                            {
                                resultObj = pm.VerificationCodeSend(VerifyType.FORGOTPASSWORD, account);
                                IMessageCommon.Current.ShowErrorInfoAlter(result.Code);
                                return;
                            }
                            else
                            {
                                resultObj = pm.VerificationCodeSend(VerifyType.FORGOTPASSWORD, account, true, phoneZoneCode);
                            }
                            if (resultObj.Code != HttpUtil.SUCCESS_CODE)
                            {
                                // 提示错误
                                IMessageCommon.Current.ShowErrorInfoAlter(NewAPI.API_POST_Verification_Send, resultObj.Code);
                                //2.1检测当前配置域名是否一致,不一致则替换
                                CheckAndSetUserRequestHost(result);
                                //2.2已经注册过,发送验证码找回密码
                                ResponsePackNew resultObj;
                                //2.3请求获取验证码
                                if (registerType == 1)//邮箱
                                {
                                    resultObj = pm.VerificationCodeSend(VerifyType.FIND_PASSWORD, account);
                                }
                                else
                                {
                                    resultObj = pm.VerificationCodeSend(VerifyType.FIND_PASSWORD, account, true, phoneZoneCode);
                                }
                                if (resultObj.Code != StateCode.SUCCESS)
                                {
                                    // 提示错误
                                    IMessageCommon.Current.ShowErrorInfoAlter(resultObj.Code);
                                }
                                else
                                {
                                    //3.发送验证码成功,开始计时
                                    Application.RunOnMainThread(() =>
                                    {
                                    //短信发送间隔60s
                                    (sender as Button).IsSelected = false;
                                        etVerificationCode.Foucs = true;
                                    });
                                    //2.1获取验证码倒计时
                                    new Thread(() =>
                                    {
                                        while (time > 0)
                                        {
                                            time--;
                                            Application.RunOnMainThread(() =>
                                            {
                                                (sender as Button).Text = time.ToString() + "s";
                                            });
                                            Thread.Sleep(1000);
                                        }
                                        Application.RunOnMainThread(() =>
                                        {
                                        //回复获取短信按钮事件
                                        (sender as Button).IsSelected = true;
                                            (sender as Button).TextID = StringId.GetVerificationCode;
                                        });
                                    })
                                    { IsBackground = true }.Start();
                                }
                            }
                        }
                        catch { }
                        finally
                        {
                            Application.RunOnMainThread(() =>
                            {
                                if (waitPage != null)
                                {
                                    waitPage.RemoveFromParent();
                                    waitPage = null;
                                }
                            });
                        }
                    })
                    { IsBackground = true }.Start();
@@ -404,26 +448,36 @@
                // 忘记密码
                var isPhone = registerType == 0;
                var resultObj = pm.ForgetPassword(account, password, verCode, isPhone);
                if (resultObj.Code == HttpUtil.SUCCESS_CODE)
                if (resultObj.Code == StateCode.SUCCESS)
                {
                    Application.RunOnMainThread(() =>
                    {
                        LoadEvent_AutoLogin();
                        callbackAction?.Invoke(account);
                        if (waitPage != null)
                        {
                            waitPage.Hide();
                        }
                        ShowAutoLoginDialog(account, password, isPhone);
                    });
                }
                else
                {
                    // 2020-11-13 待修改 验证码错误 警告提示
                    //btnVerificationCodeViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
                    //btnVerificationCodeViewBottomLine.Height = Application.GetRealHeight(2);
                    Application.RunOnMainThread(() =>
                    {
                        waitPage.Hide();
                        if (waitPage != null)
                        {
                            waitPage.Hide();
                        }
                        // 验证码错误 警告提示
                        if (resultObj.Code == StateCode.VERIFICATION_CODE_WRONG)
                        {
                            btnVerificationCodeViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
                            btnVerificationCodeViewBottomLine.Height = Application.GetRealHeight(2);
                        }
                    });
                    // 提示错误
                    IMessageCommon.Current.ShowErrorInfoAlter(NewAPI.API_POST_Member_ForgetPwd, resultObj.Code);
                    IMessageCommon.Current.ShowErrorInfoAlter(resultObj.Code);
                }
            });
        }
@@ -444,89 +498,99 @@
        }
        /// <summary>
        /// 住宅成功之后自动登录
        /// 显示自动自动登录事件
        /// </summary>
        void LoadEvent_AutoLogin()
        void ShowAutoLoginDialog(string account, string password, bool isPhone)
        {
            Dialog dialog = new Dialog();
            FrameLayout frame = new FrameLayout()
            FrameLayout dialogView = new FrameLayout();
            dialogView.MouseUpEventHandler = (sender, e) =>
            {
                dialog.Close();
            };
            dialog.AddChidren(dialogView);
            FrameLayout contentView = new FrameLayout()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(198),
                Y =  Application.GetRealWidth(200),
                Width = Application.GetRealWidth(288),
                Height = Application.GetRealHeight(206),
                Height = Application.GetRealWidth(270),
                Radius = (uint)Application.GetRealWidth(6),
                BackgroundColor = CSS_Color.MainBackgroundColor,
                Radius = (uint)Application.GetRealWidth(12),
                BorderWidth = 0,
                BorderColor = 0x00000000,
            };
            dialog.AddChidren(frame);
            dialogView.AddChidren(contentView);
            Button btnAccountText = new Button()
            contentView.Y = (dialogView.Height - contentView.Height) / 2;
            Button btnTitleIcon = new Button()
            {
                X = Application.GetRealWidth(108),
                Y = contentView.Y - Application.GetRealWidth(71),
                Width = Application.GetRealWidth(160),
                Height = Application.GetRealWidth(160),
                UnSelectedImagePath = "Public/Dialog/DialogTipTitleIcon_1.png"
            };
            dialogView.AddChidren(btnTitleIcon);
            btnTitleIcon.MouseUpEventHandler = (sender, e) =>
            {
                dialog.Close();
            };
            Button btnMsg = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(40),
                Height = Application.GetRealHeight(17 + 14 + 14),
                IsMoreLines = true,
                TextAlignment = TextAlignment.Center,
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.TextFontSize,
                //Text = "s是生生世世",
            };
            frame.AddChidren(btnAccountText);
            Button btnTipRegisterSuccess = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(123),
                Height = Application.GetRealHeight(30),
                TextAlignment = TextAlignment.Center,
                Y = Application.GetRealWidth(88),
                Width = Application.GetRealWidth(220),
                Height = Application.GetRealWidth(44),
                TextColor = CSS_Color.MainColor,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextID = StringId.PasswordChangeSuccessfully,
                TextID = StringId.ModifySuccess
            };
            frame.AddChidren(btnTipRegisterSuccess);
            contentView.AddChidren(btnMsg);
            Button btnAutoLoginTip = new Button()
            Button btnMsg2 = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = btnTipRegisterSuccess.Bottom,
                Height = Application.GetRealHeight(17 + 8),
                TextAlignment = TextAlignment.Center,
                Y = btnMsg.Bottom + Application.GetRealWidth(8),
                Width = Application.GetRealWidth(220),
                Height = Application.GetRealWidth(60),
                TextColor = CSS_Color.PromptingColor1,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                TextID = StringId.AutomaticallyLogin,
                TextID = StringId.YourPasswordHasBeenChanged,
                TextAlignment = TextAlignment.TopCenter,
                IsMoreLines = true
            };
            //frame.AddChidren(btnAutoLoginTip);
            contentView.AddChidren(btnMsg2);
            Button btnHeadImage = new Button()
            Button btnSkipBindPage = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(150),
                Width = Application.GetRealWidth(84),
                Height = Application.GetRealWidth(84),
                Radius = (uint)Application.GetRealWidth(42),
                BorderColor = 0x00000000,
                BorderWidth = 0,
                UnSelectedImagePath = "LoginIcon/2.png",
                Y = Application.GetRealWidth(194),
                Width = Application.GetRealWidth(220),
                Height = Application.GetRealWidth(44),
                TextAlignment = TextAlignment.Center,
                Radius = (uint)Application.GetRealWidth(22),
                BackgroundColor = CSS_Color.MainColor,
                TextID = StringId.Login,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextColor = CSS_Color.MainBackgroundColor,
            };
            dialog.AddChidren(btnHeadImage);
            contentView.AddChidren(btnSkipBindPage);
            btnSkipBindPage.MouseUpEventHandler = (sender, e) =>
            {
                dialog.Close();
                this.Close();
                AutoLoginAction?.Invoke(account, password, isPhone);
            };
            dialog.Show();
            new Thread(() =>
            {
                Thread.Sleep(1500);
                Application.RunOnMainThread(() =>
                {
                    dialog.Close();
                    this.Close();
                });
            })
            { IsBackground = true }.Start();
        }
    }
}