From 6fa9d69da922c8049f5acfcbb9ce9fd26811024c Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期四, 16 四月 2020 17:10:57 +0800 Subject: [PATCH] 请合并代码 --- ZigbeeApp/Shared/Phone/Login/AccountRegisterSuccess.cs | 186 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 186 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Login/AccountRegisterSuccess.cs b/ZigbeeApp/Shared/Phone/Login/AccountRegisterSuccess.cs new file mode 100755 index 0000000..d7429da --- /dev/null +++ b/ZigbeeApp/Shared/Phone/Login/AccountRegisterSuccess.cs @@ -0,0 +1,186 @@ +锘縰sing System; +using System.Text; +using Shared.Common; +using Shared.Phone.UserView; + +namespace Shared.Phone.Login +{ + public class AccountRegisterSuccess : FrameLayout + { + /// <summary> + /// registerSuccess + /// </summary> + /// <param name="account"></param> + /// <param name="password"></param> + public void Show(string account, string password,string OpenID="") + { + var dialog = new FrameLayout() + { + BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor + }; + AddChidren(dialog); + + 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); + } + + /// <summary> + /// AutoLogin + /// </summary> + /// <param name="account"></param> + /// <param name="password"></param> + private void AutoLogin(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(); + } + + /// <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(); + } + } +} -- Gitblit v1.8.0