JLChen
2021-01-07 7ed9cc5bb6a07a8358a2705797bd2b31c6e39fd4
Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountLogin.cs
@@ -1,9 +1,6 @@
using Shared.SimpleControl;
using System;
using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using Shared.SimpleControl.R;
namespace Shared.SimpleControl.Phone
{
@@ -81,7 +78,10 @@
            //etAccount.Text = "18926269190@189.cn";
            //etAccount.Text = "721343314@qq.com";
            //etAccount.Text = "crabtreel12019@gmail.com";
            etAccount.Text = "2791308028@qq.com";
            //etAccount.Text = "2791308028@qq.com";
            etAccount.Text = "551775569@qq.com";
            //etAccount.Text = "cjl@hdlchina.com.cn";
#endif
            accountView.AddChidren (etAccount);
@@ -134,7 +134,8 @@
                Text = password,
            };
#if DEBUG
            etPasswrod.Text = "123456";
            //etPasswrod.Text = "123456";
            etPasswrod.Text = "123456-Aa";
#endif
            passwrodView.AddChidren (etPasswrod);
@@ -267,10 +268,10 @@
                    return;
                }
                //检测账号是否锁定
                if (CommonConfig.Current.CheckIfLock (account)) {
                    return;
                }
                ////检测账号是否锁定
                //if (CommonConfig.Current.CheckIfLock (account)) {
                //    return;
                //}
                System.Threading.Tasks.Task.Run (() => {
                    try {
@@ -284,7 +285,6 @@
                        if (UserConfig.Instance.internetStatus == 0) {
                            Application.RunOnMainThread (() => {
                                Utlis.ShowTip ("Network abnormal, unable to connect to the Internet");
                                //new Tip () { Text = "Network abnormal, unable to connect to the Internet", Direction = AMPopTipDirection.Down, CloseTime = 3 }.Show (btnLogo);
                            });
                            return;
@@ -397,54 +397,6 @@
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="stateCodeStr"></param>
        void ShowGetHomePagerErrorInfo (string stateCodeStr)
        {
            string mes = "";
            //2020-01-06 待补充
            if (stateCodeStr == ErrorCode.NetworkError) {
                mes = ErrorCode.NetworkError;
            } else {
                mes = ErrorCode.OperationFailed + ErrorCode.Reason + stateCodeStr;
            }
            if (!string.IsNullOrEmpty (mes)) {
                Application.RunOnMainThread (() => {
                    new Alert ("", mes, Language.StringByID (R.MyInternationalizationString.Close)).Show ();
                });
            }
        }
        ///// <summary>
        /////
        ///// </summary>
        ///// <param name="stateCodeStr"></param>
        //void ShowGetAllBindGatewarysPaggerErrorInfo (string stateCodeStr)
        //{
        //    string mes = "";
        //    //2020-01-06 待补充
        //    if (stateCodeStr == ErrorCode.NetworkError) {
        //        mes = ErrorCode.NetworkError;
        //    } else {
        //        mes = ErrorCode.OperationFailed + ErrorCode.Reason + stateCodeStr;
        //    }
        //    if (!string.IsNullOrEmpty (mes)) {
        //        Application.RunOnMainThread (() => {
        //            new Alert ("", mes, Language.StringByID (R.MyInternationalizationString.Close)).Show ();
        //        });
        //    }
        //}
        /// <summary>
        /// 登录 2020-01-11 
        /// </summary>
@@ -504,7 +456,6 @@
                            Room.InitAllRoom ();
                        } else {
                            //if (findRoom == null) {
                            if (mHomeLists != null && mHomeLists.Count > 0) {
                                var bFind = false;
                                foreach (var mHome in mHomeLists) {
@@ -514,9 +465,7 @@
                                        break;
                                    }
                                }
                                //if (!bFind) {
                                //    UserConfig.Instance.CurrentRegion = revertRoomData [0];
                                //}
                                if (!bFind) {
                                    var findRoom2 = mHomeLists.Find ((obj) => obj.IsOthreShare == false);
                                    if (findRoom2 != null) {
@@ -528,15 +477,9 @@
                                IO.FileUtils.DeleteAllFile ();
                            }
                            //}else {
                            //    //刷新住宅 解决子账号问题
                            //    UserConfig.Instance.CurrentRegion = findRoom;
                            //    Room.InitAllRoom ();
                            //}
                        }
                    }
                }
                    ////原方案
                    //GetAllBindGatewarysPagger (revertRoomData);
                    ////获取当前住宅网关方案
@@ -547,20 +490,28 @@
                    IMessageCommon.Current.ShowErrorInfoAlter (revertObjCode);
                }
            } else {
                //提示登录锁定
                if (revertObj.Code == StateCode.AccountLoginLock) {
                    Application.RunOnMainThread (() => {
                        ShowAccountLoginLockTip (revertObj);
                    });
                    return;
                }
                IMessageCommon.Current.ShowErrorInfoAlter (revertObj.Code);
            }
        }
        private void SetMqttHost (string URL) {
            string pattern = @"(http|https)://(?<domain>[^(:|/]*)";
        //private void SetMqttHost (string URL) {
        //    string pattern = @"(http|https)://(?<domain>[^(:|/]*)";
            Regex reg = new Regex (pattern, RegexOptions.IgnoreCase);
            Match m = reg.Match (URL);
            string mResult = m.Value;
            if (!string.IsNullOrEmpty (mResult)) {
                MainPage.RequestHttpsHostMqtt = mResult;
            }
        }
        //    Regex reg = new Regex (pattern, RegexOptions.IgnoreCase);
        //    Match m = reg.Match (URL);
        //    string mResult = m.Value;
        //    if (!string.IsNullOrEmpty (mResult)) {
        //        MainPage.RequestHttpsHostMqtt = mResult;
        //    }
        //}
        /// <summary>
        /// 保存数据 并加载页面
@@ -591,8 +542,36 @@
        }
        /// <summary>
        /// 解析提示用户解锁时间
        /// 密码错误次数过多,账号被锁定!请通过忘记密码找回密码或{0}分钟后重试.
        /// </summary>
        /// <param name="loginResult"></param>
        void ShowAccountLoginLockTip (ResponsePackNew loginResult)
        {
            //密码错误次数过多,账号被锁定!
            var tipStr = Language.StringByID (MyInternationalizationString.AccountLoginLock);
            try {
                if (loginResult.extra != null) {
                    //请通过忘记密码找回密码或{0}分钟后重试.
                    var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject<AccountLoginLockExtraRes> (loginResult.extra.ToString ());
                    string msg = Language.StringByID (MyInternationalizationString.PleaseTryToForgetPassword);
                    //var unlockTime = Utlis.UnixToDateTimeWithFormatMS(revertData.unlockTime, "HH:mm");
                    //msg = msg.Replace("{0}", unlockTime);
                    var unlockDatetime = Utlis.UnixToDateTimeMS (revertData.unlockTime);
                    var unlockTimeInt = unlockDatetime.Minute - DateTime.Now.Minute;
                    if (unlockTimeInt <= 0) {
                        unlockTimeInt = 1;
                    }
                    msg = msg.Replace ("{0}", unlockTimeInt.ToString ());
                    tipStr = tipStr + "\r\n" + msg;
                }
            } catch { }
            Utlis.ShowTip (tipStr);
        }
        ///// <summary>
        ///// 查询当前住宅 网关列表
@@ -643,7 +622,7 @@
        //        Application.RunOnMainThread (() => {
        //            new Alert ("", ErrorCode.FailedGetGatewaysForHome, Language.StringByID (R.MyInternationalizationString.Close)).Show ();
        //        });
        //    }
@@ -692,7 +671,7 @@
        //        ShowGetAllBindGatewarysPaggerErrorInfo (gatewayListRevertObj.StateCode);
        //    }
        //}