| | |
| | | using System; |
| | | using System.Text; |
| | | using Shared.Common; |
| | | using Shared.Phone.UserCenter;
|
| | | using Shared.Phone.UserView; |
| | | |
| | | namespace Shared.Phone.Login |
| | | { |
| | | /// <summary>
|
| | | /// 账号注册成功的提示界面
|
| | | /// </summary> |
| | | public class AccountRegisterSuccess : FrameLayout |
| | | { |
| | | {
|
| | | #region ■ 初始化_____________________________
|
| | |
|
| | | /// <summary> |
| | | /// registerSuccess |
| | | /// 初始化 |
| | | /// </summary> |
| | | /// <param name="account"></param> |
| | | /// <param name="password"></param> |
| | | public void Show(string account, string password,string OpenID="") |
| | | /// <param name="account">账号</param> |
| | | /// <param name="password">密码</param> |
| | | /// <param name="OpenID">第三方绑定的id</param> |
| | | public void ShowForm(string account, string password, string OpenID = "") |
| | | { |
| | | var dialog = new FrameLayout() |
| | | { |
| | | BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor |
| | | }; |
| | | AddChidren(dialog); |
| | | //整个背景 |
| | | var frameBack = new FrameLayout();
|
| | | frameBack.BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor; |
| | | this.AddChidren(frameBack); |
| | | //上部黑色部分 |
| | | var frameBlack = new FrameLayout(); |
| | | frameBlack.Y = Application.GetRealHeight(527);
|
| | | frameBlack.Width = Application.GetRealWidth(688);
|
| | | frameBlack.Height = Application.GetRealHeight(274);
|
| | | frameBlack.Gravity = Gravity.CenterHorizontal;
|
| | | frameBlack.BackgroundColor = ZigbeeColor.Current.GXCBlackBackgroundColor; |
| | | frameBlack.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight); |
| | | this.AddChidren(frameBlack); |
| | | //下部白色部分 |
| | | var frameWhite = new FrameLayout();
|
| | | frameWhite.Y = frameBlack.Bottom;
|
| | | frameWhite.Width = Application.GetRealWidth(688);
|
| | | frameWhite.Height = Application.GetRealHeight(579);
|
| | | frameWhite.Gravity = Gravity.CenterHorizontal;
|
| | | frameWhite.BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; |
| | | frameWhite.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerBottomLeft | HDLUtils.RectCornerBottomRight); |
| | | this.AddChidren(frameWhite); |
| | | //账号头像 |
| | | var btnAccountIcon = new PicViewControl(294, 316);
|
| | | btnAccountIcon.Y = Application.GetRealHeight(648);
|
| | | btnAccountIcon.Gravity = Gravity.CenterHorizontal;
|
| | | btnAccountIcon.UnSelectedImagePath = "Account/Cat.png"; |
| | | this.AddChidren(btnAccountIcon); |
| | | //账号 |
| | | var btnAccount = new NormalViewControl(500, 80, true);
|
| | | btnAccount.Y = btnAccountIcon.Bottom;
|
| | | btnAccount.Gravity = Gravity.CenterHorizontal;
|
| | | btnAccount.Text = account;
|
| | | btnAccount.TextColor = ZigbeeColor.Current.GXCTextGrayColor2;
|
| | | btnAccount.TextAlignment = TextAlignment.Center; |
| | | this.AddChidren(btnAccount); |
| | | //恭喜注册成功! |
| | | var btnTip = new NormalViewControl(500, 80, true);
|
| | | btnTip.Y = Application.GetRealHeight(1143);
|
| | | btnTip.Gravity = Gravity.CenterHorizontal;
|
| | | btnTip.TextID = R.MyInternationalizationString.RegisterSuccessTip;
|
| | | btnTip.TextColor = ZigbeeColor.Current.GXCTextBlackColor2;
|
| | | btnTip.TextAlignment = TextAlignment.Center;
|
| | | btnTip.TextSize = 16; |
| | | btnTip.IsBold = true; |
| | | this.AddChidren(btnTip); |
| | | //即将自动登录 |
| | | var btnWillLogin = new NormalViewControl(500, 80, true);
|
| | | btnWillLogin.Y = btnTip.Bottom + Application.GetRealHeight(15);
|
| | | btnWillLogin.Gravity = Gravity.CenterHorizontal;
|
| | | btnWillLogin.TextID = R.MyInternationalizationString.WillAutoLogin;
|
| | | btnWillLogin.TextColor = ZigbeeColor.Current.GXCTextGrayColor; |
| | | btnWillLogin.TextAlignment = TextAlignment.Center; |
| | | AddChidren(btnWillLogin); |
| | | |
| | | var blackBG = new FrameLayout() |
| | | { |
| | | Y = Application.GetRealHeight(527), |
| | | Width = Application.GetRealWidth(688), |
| | | Height = Application.GetRealHeight(274), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | BackgroundColor = ZigbeeColor.Current.GXCBlackBackgroundColor |
| | | }; |
| | | AddChidren(blackBG); |
| | | |
| | | var whiteBG = new FrameLayout() |
| | | { |
| | | Y = blackBG.Bottom, |
| | | Width = Application.GetRealWidth(688), |
| | | Height = Application.GetRealHeight(579), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor |
| | | }; |
| | | AddChidren(whiteBG); |
| | | |
| | | var accountImg = new Button() |
| | | { |
| | | Y = Application.GetRealHeight(648), |
| | | Width = Application.GetMinRealAverage(294), |
| | | Height = Application.GetMinRealAverage(316), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | UnSelectedImagePath = "Account/Cat.png" |
| | | }; |
| | | AddChidren(accountImg); |
| | | |
| | | var accountBtn = new Button() |
| | | { |
| | | Y = accountImg.Bottom, |
| | | Width = Application.GetRealWidth(500), |
| | | Height = Application.GetRealHeight(80), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Text = account, |
| | | TextColor = ZigbeeColor.Current.GXCTextGrayColor2, |
| | | TextSize = 14, |
| | | }; |
| | | AddChidren(accountBtn); |
| | | |
| | | var tip = new Button() |
| | | { |
| | | Y = Application.GetRealHeight(1143), |
| | | Width = Application.GetRealWidth(500), |
| | | Height = Application.GetRealHeight(80), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | TextID = R.MyInternationalizationString.RegisterSuccessTip, |
| | | TextColor = ZigbeeColor.Current.GXCTextBlackColor2, |
| | | TextSize = 16, |
| | | }; |
| | | AddChidren(tip); |
| | | |
| | | var willLogin = new Button() |
| | | { |
| | | Y = tip.Bottom + Application.GetRealHeight(15), |
| | | Width = Application.GetRealWidth(500), |
| | | Height = Application.GetRealHeight(80), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | TextID = R.MyInternationalizationString.WillAutoLogin, |
| | | TextColor = ZigbeeColor.Current.GXCTextGrayColor, |
| | | TextSize = 14, |
| | | }; |
| | | AddChidren(willLogin); |
| | | |
| | | AutoLogin(account, password,OpenID); |
| | | } |
| | | |
| | | HdlThreadLogic.Current.RunThread(() => |
| | | {
|
| | | System.Threading.Thread.Sleep(2000);
|
| | | //2秒后自动登录
|
| | | this.LoginByAccountAndPsw(account, password, OpenID);
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion |
| | |
|
| | | #region ■ 自动登录___________________________
|
| | |
|
| | | /// <summary> |
| | | /// AutoLogin |
| | | /// </summary> |
| | | /// <param name="account"></param> |
| | | /// <param name="password"></param> |
| | | private void AutoLogin(string account, string password, string OpenID = "") |
| | | private void LoginByAccountAndPsw(string account, string password, string OpenID = "") |
| | | { |
| | | new System.Threading.Thread(() => |
| | | { |
| | | System.Threading.Thread.Sleep(1500); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | try |
| | | { |
| | | HomePage.Instance.ShowLoginLoadView(); |
| | | |
| | | CommonPage.Loading.Start(Language.StringByID(R.MyInternationalizationString.Logining)); |
| | | Action action = async () => { |
| | | var loginSuccess = await HomePage.Instance.LoginByPWDAsync(account, password);
|
| | | if (loginSuccess==1) |
| | | { |
| | | new System.Threading.Thread(async () => |
| | | { |
| | | if (string.IsNullOrEmpty(OpenID)==false) |
| | | { |
| | | BindAuthUser(Config.Instance.Guid, OpenID); |
| | | } |
| | | //登录成功 |
| | | var homes = await House.GetHomeLists();
|
| | | |
| | | //刷新个人中心的内存及线程 |
| | | await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread();
|
| | | //启动ZigBee |
| | | ZigBee.Common.Application.Init(); |
| | | |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | this.RemoveFromParent(); |
| | | CommonPage.Instance.RemoveViewByTag("Register"); |
| | | CommonPage.Instance.RemoveViewByTag("Login"); |
| | | UserPage.Instance.Fresh(); |
| | | }); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | |
| | | } |
| | | else |
| | | { |
| | | //未登录成功弹出登录界面 同时需要标记为未登录状态 |
| | | Config.Instance.LoginDateTime = new DateTime(1970, 1, 1); |
| | | Config.Instance.Save(); |
| | | var login = new AccountLogin { }; |
| | | CommonPage.Instance.AddChidren(login); |
| | | login.Show(account); |
| | | } |
| | | }; |
| | | action(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | var errMsg = ex.Message; |
| | | } |
| | | finally |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | } |
| | | }); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | HdlThreadLogic.Current.RunMain(() => |
| | | {
|
| | | //打开启动页
|
| | | HomePage.Instance.ShowLoginLoadView();
|
| | | CommonPage.Loading.Start(Language.StringByID(R.MyInternationalizationString.Logining));
|
| | | |
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | {
|
| | | //账号密码登陆
|
| | | var loginSuccess = await HomePage.Instance.LoginByPWDAsync(account, password);
|
| | | if (loginSuccess == 1)
|
| | | {
|
| | | if (string.IsNullOrEmpty(OpenID) == false)
|
| | | {
|
| | | //绑定第三方
|
| | | await BindAuthUser(Config.Instance.Guid, OpenID);
|
| | | }
|
| | | var homes = await House.GetHomeLists();
|
| | |
|
| | | //刷新个人中心的内存及线程
|
| | | await UserCenterLogic.InitUserCenterMenmoryAndThread();
|
| | | //启动ZigBee
|
| | | ZigBee.Common.Application.Init();
|
| | |
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | CommonPage.Loading.Hide();
|
| | | this.RemoveFromParent();
|
| | | CommonPage.Instance.RemoveViewByTag("Register");
|
| | | CommonPage.Instance.RemoveViewByTag("Login");
|
| | | UserPage.Instance.Fresh();
|
| | | });
|
| | | }
|
| | | else
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //未登录成功弹出登录界面 同时需要标记为未登录状态
|
| | | Config.Instance.LoginDateTime = new DateTime(1970, 1, 1);
|
| | | Config.Instance.Save();
|
| | | var login = new AccountLogin();
|
| | | CommonPage.Instance.AddChidren(login);
|
| | | login.ShowForm(account);
|
| | | });
|
| | | }
|
| | | });
|
| | | }); |
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 绑定第三方_________________________ |
| | | |
| | | /// <summary> |
| | | /// 绑定 |
| | | /// </summary> |
| | | /// <param name="guid"></param> |
| | | /// <param name="openId"></param> |
| | | private void BindAuthUser(string guid, string openId) |
| | | { |
| | | new System.Threading.Thread(async () => |
| | | { |
| | | var auth = new SendDataToServer.BindAuthUser |
| | | { |
| | | AccountGuid = guid, |
| | | OpenID = openId |
| | | }; |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(auth); |
| | | var revert = await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/BindAuthUserToAccount", Encoding.UTF8.GetBytes(requestJson)); |
| | | }) |
| | | { |
| | | IsBackground = true |
| | | }.Start(); |
| | | } |
| | | private async System.Threading.Tasks.Task BindAuthUser(string guid, string openId) |
| | | {
|
| | | var auth = new SendDataToServer.BindAuthUser();
|
| | | auth.AccountGuid = guid;
|
| | | auth.OpenID = openId;
|
| | |
|
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(auth);
|
| | | await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/BindAuthUserToAccount", Encoding.UTF8.GetBytes(requestJson)); |
| | | }
|
| | |
|
| | | #endregion |
| | | } |
| | | } |