| | |
| | | #endregion |
| | | |
| | | #region 局部变量列表 |
| | | /// <summary> |
| | | /// 账号类型 |
| | | /// 0:手机 |
| | | /// 1:邮箱 |
| | | /// </summary> |
| | | int accountType = 0; |
| | | ///// <summary> |
| | | ///// 账号类型 |
| | | ///// 0:手机 |
| | | ///// 1:邮箱 |
| | | ///// </summary> |
| | | //int accountType = 0; |
| | | /// <summary> |
| | | /// 手机号码是否有效 |
| | | /// </summary> |
| | |
| | | /// 0:手机 |
| | | /// 1:邮箱 |
| | | /// </summary> |
| | | int registerType; |
| | | int registerType = 0; |
| | | /// <summary> |
| | | /// 手机区号 |
| | | /// </summary> |
| | |
| | | |
| | | string registerPhone; |
| | | string registerEmail; |
| | | /// <summary> |
| | | /// 是否点击了返回,用于屏蔽EditText失去焦点检测事件 |
| | | /// </summary> |
| | | bool isHitBack; |
| | | #endregion |
| | | public RegisterPage() |
| | | |
| | | /// <summary> |
| | | /// 回调事件 |
| | | /// 账号,密码,是否手机 |
| | | /// account,password,isPhone |
| | | /// </summary> |
| | | Action<string, string, bool> AutoLoginAction; |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="autoLoginAction">注册成功回调事件</param> |
| | | public RegisterPage(Action<string, string, bool> autoLoginAction) |
| | | { |
| | | AutoLoginAction = autoLoginAction; |
| | | |
| | | bodyView = new FrameLayout() |
| | | { |
| | | BackgroundColor = CSS_Color.BackgroundColor, |
| | | BackgroundColor = CSS_Color.MainBackgroundColor, |
| | | }; |
| | | AddChidren(bodyView); |
| | | |
| | | //2020-12-22 增加点击隐藏键盘事件 |
| | | bodyView.MouseDownEventHandler += (sender, e) => { |
| | | Application.HideSoftInput(); |
| | | }; |
| | | |
| | | pm = new HttpServerRequest(); |
| | | } |
| | |
| | | |
| | | public void ShowDialog() |
| | | { |
| | | new TopViewDiv(this, bodyView, Language.StringByID(StringId.Register)).LoadTopView(); |
| | | Action backAction = () => |
| | | { |
| | | isHitBack = true; |
| | | //2020-12-22 增加点击隐藏键盘事件 |
| | | Application.HideSoftInput(); |
| | | }; |
| | | |
| | | new TopViewDiv(this, bodyView, Language.StringByID(StringId.Register)).LoadTopView(backAction); |
| | | //new PublicAssmebly().LoadTopView(this, bodyView, Language.StringByID(StringId.Register)); |
| | | |
| | | #region 注册方式选择 |
| | |
| | | TextSize = CSS_FontSize.TextFontSize, |
| | | }; |
| | | bodyView.AddChidren(btnEmailLogin); |
| | | if(Language.CurrentLanguage!= "Chinese") |
| | | { |
| | | btnPhoneLogin.Width = Application.GetRealWidth(180); |
| | | btnEmailLogin.Width = Application.GetRealWidth(180); |
| | | } |
| | | #endregion |
| | | |
| | | #region 服务器选择 |
| | |
| | | }; |
| | | btnGlobalRoaming.MouseUpEventHandler += eHandler; |
| | | |
| | | if (accountType == 0) |
| | | if (registerType == 0) |
| | | { |
| | | accountView.AddChidren(btnGlobalRoaming); |
| | | } |
| | |
| | | Height = Application.GetMinRealAverage(20), |
| | | UnSelectedImagePath = "LoginIcon/AccountIcon.png", |
| | | }; |
| | | if (accountType == 1) |
| | | if (registerType == 1) |
| | | { |
| | | accountView.AddChidren(btnAccountIcon); |
| | | } |
| | |
| | | TextSize = CSS_FontSize.TextFontSize, |
| | | PlaceholderTextColor = CSS_Color.PromptingColor1, |
| | | PlaceholderText = Language.StringByID(StringId.PlsEntryVerificationCode), |
| | | IsNumberKeyboardType = true |
| | | }; |
| | | verificationCodeView.AddChidren(etVerificationCode); |
| | | |
| | |
| | | Thread.Sleep(1500); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | //创建登录线程 |
| | | var loginThread = LoadThread_Login(account, password); |
| | | waitPage = new Loading(); |
| | | new PublicAssmebly().LoadPage_WaitPage(loginThread, bodyView, waitPage); |
| | | ////创建登录线程 |
| | | //var loginThread = LoadThread_Login(account, password); |
| | | //waitPage = new Loading(); |
| | | //new PublicAssmebly().LoadPage_WaitPage(loginThread, bodyView, waitPage); |
| | | dialog.Close(); |
| | | |
| | | var isPhone = registerType == 0; |
| | | AutoLoginAction?.Invoke(account, password, isPhone); |
| | | }); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | |
| | | #region 登录线程部分 |
| | | /// <summary> |
| | | /// 加载登录线程 |
| | | /// </summary> |
| | | Thread LoadThread_Login(string account,string password) |
| | | { |
| | | var loginThread = new Thread(() => |
| | | { |
| | | try |
| | | { |
| | | //登录 |
| | | var loginResult = LoadMethod_Login(account,password); |
| | | if (loginResult) |
| | | { |
| | | //获取住宅信息 |
| | | var getResidencesResult = LoadMethod_GetResidences(); |
| | | if (getResidencesResult) |
| | | { |
| | | /* |
| | | * Wait : 推送注册 |
| | | */ |
| | | //#region 登录线程部分 |
| | | ///// <summary> |
| | | ///// 加载登录线程 |
| | | ///// </summary> |
| | | //Thread LoadThread_Login(string account,string password) |
| | | //{ |
| | | // var loginThread = new Thread(() => |
| | | // { |
| | | // try |
| | | // { |
| | | // //登录 |
| | | // var loginResult = LoadMethod_Login(account,password); |
| | | // if (loginResult) |
| | | // { |
| | | // //获取住宅信息 |
| | | // var getResidencesResult = LoadMethod_GetResidences(); |
| | | // if (getResidencesResult) |
| | | // { |
| | | // /* |
| | | // * Wait : 推送注册 |
| | | // */ |
| | | |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | waitPage.RemoveFromParent(); |
| | | waitPage = null; |
| | | // Application.RunOnMainThread(() => |
| | | // { |
| | | // waitPage.RemoveFromParent(); |
| | | // waitPage = null; |
| | | |
| | | //跳转页面---- |
| | | MainPage.GoUserPage(); |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"LoginPage : {ex.Message}"); |
| | | } |
| | | }) |
| | | { IsBackground = true }; |
| | | return loginThread; |
| | | } |
| | | // //跳转页面---- |
| | | // MainPage.GoUserPage(); |
| | | // }); |
| | | // } |
| | | // } |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // MainPage.Log($"LoginPage : {ex.Message}"); |
| | | // } |
| | | // }) |
| | | // { IsBackground = true }; |
| | | // return loginThread; |
| | | //} |
| | | |
| | | /// <summary> |
| | | /// 调用登录接口登录 |
| | | /// </summary> |
| | | bool LoadMethod_Login(string account, string password) |
| | | { |
| | | var result = false; |
| | | //调用登录接口 |
| | | var loginResult = pm.LoginByPassword(account, password); |
| | | if (loginResult.Code == StateCode.SUCCESS) |
| | | { |
| | | var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject<UserLoginRes>(loginResult.Data.ToString()); |
| | | // UserInfo.Current = new UserInfo |
| | | //{ |
| | | // userType = revertData.userType, |
| | | // accountString = account, |
| | | // password = password, |
| | | // lastTime = DateTime.Now, |
| | | // ID = revertData.userId, |
| | | // loginTokenString = revertData.headerPrefix + revertData.accessToken, |
| | | // refreshToken = revertData.refreshToken, |
| | | // userName = revertData.name |
| | | //}; |
| | | UserInfo.Current.userType = revertData.userType; |
| | | UserInfo.Current.AccountString = account; |
| | | //UserInfo.Current.password = password; |
| | | UserInfo.Current.LastTime = DateTime.Now; |
| | | UserInfo.Current.ID = revertData.userId; |
| | | UserInfo.Current.LoginTokenString = revertData.headerPrefix + revertData.accessToken; |
| | | UserInfo.Current.refreshToken = revertData.refreshToken; |
| | | UserInfo.Current.userName = revertData.name; |
| | | ///// <summary> |
| | | ///// 调用登录接口登录 |
| | | ///// </summary> |
| | | //bool LoadMethod_Login(string account, string password) |
| | | //{ |
| | | // var result = false; |
| | | // //调用登录接口 |
| | | // var loginResult = pm.LoginByPassword(account, password); |
| | | // if (loginResult.Code == StateCode.SUCCESS) |
| | | // { |
| | | // var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject<UserLoginRes>(loginResult.Data.ToString()); |
| | | // // UserInfo.Current = new UserInfo |
| | | // //{ |
| | | // // userType = revertData.userType, |
| | | // // accountString = account, |
| | | // // password = password, |
| | | // // lastTime = DateTime.Now, |
| | | // // ID = revertData.userId, |
| | | // // loginTokenString = revertData.headerPrefix + revertData.accessToken, |
| | | // // refreshToken = revertData.refreshToken, |
| | | // // userName = revertData.name |
| | | // //}; |
| | | // UserInfo.Current.userType = revertData.userType; |
| | | // UserInfo.Current.AccountString = account; |
| | | // //UserInfo.Current.password = password; |
| | | // UserInfo.Current.LastTime = DateTime.Now; |
| | | // UserInfo.Current.ID = revertData.userId; |
| | | // UserInfo.Current.LoginTokenString = revertData.headerPrefix + revertData.accessToken; |
| | | // UserInfo.Current.RefreshToken = revertData.refreshToken; |
| | | // UserInfo.Current.userName = revertData.name; |
| | | |
| | | UserInfo.Current.SaveUserInfo(); |
| | | MainPage.Log("登录成功。"); |
| | | result = true; |
| | | } |
| | | else |
| | | { |
| | | //登录失败 |
| | | IMessageCommon.Current.ShowErrorInfoAlter(loginResult.Code); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | btnPasswordViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2; |
| | | btnPasswordViewBottomLine.Height = Application.GetRealHeight(2); |
| | | }); |
| | | } |
| | | return result; |
| | | } |
| | | // UserInfo.Current.SaveUserInfo(); |
| | | // MainPage.Log("登录成功。"); |
| | | // result = true; |
| | | // } |
| | | // else |
| | | // { |
| | | // //登录失败 |
| | | // IMessageCommon.Current.ShowErrorInfoAlter(loginResult.Code); |
| | | // Application.RunOnMainThread(() => |
| | | // { |
| | | // btnPasswordViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2; |
| | | // btnPasswordViewBottomLine.Height = Application.GetRealHeight(2); |
| | | // }); |
| | | // } |
| | | // return result; |
| | | //} |
| | | |
| | | /// <summary> |
| | | /// 获取住宅列表 |
| | | /// </summary> |
| | | bool LoadMethod_GetResidences() |
| | | { |
| | | var result = false; |
| | | var responsePack = pm.GetHomePager(); |
| | | if (responsePack == StateCode.SUCCESS) |
| | | { |
| | | //2020-11-13 待确认,没有住宅,不算登录成功 |
| | | if (UserInfo.Current.regionList != null && UserInfo.Current.regionList.Count > 0) |
| | | { |
| | | result = true; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | IMessageCommon.Current.ShowErrorInfoAlter(responsePack); |
| | | } |
| | | return result; |
| | | } |
| | | #endregion |
| | | ///// <summary> |
| | | ///// 获取住宅列表 |
| | | ///// </summary> |
| | | //bool LoadMethod_GetResidences() |
| | | //{ |
| | | // var result = false; |
| | | // var responsePack = pm.GetHomePager(); |
| | | // if (responsePack == StateCode.SUCCESS) |
| | | // { |
| | | // //2020-11-13 待确认,没有住宅,不算登录成功 |
| | | // if (UserInfo.Current.regionList != null && UserInfo.Current.regionList.Count > 0) |
| | | // { |
| | | // result = true; |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // IMessageCommon.Current.ShowErrorInfoAlter(responsePack); |
| | | // } |
| | | // return result; |
| | | //} |
| | | //#endregion |
| | | } |
| | | } |