using System; using Shared.Common; namespace Shared.Phone.UserView { /// /// Home page.第二版呀 /// public class HomePage : PageLayout { static HomePage homePage; /// /// Gets the instance. /// /// The instance. public static HomePage Instance { get { if (homePage == null) { homePage = new HomePage { IsShowPoint = false }; } return homePage; } } /// /// Inits the page. /// public void InitPage() { if (0 < ChildrenCount) { return; } AddChidren(UserPage.Instance); UserPage.Instance.InitPage(); this.PageChange += (sender, e) => { while (e < this.ChildrenCount - 1) { this.GetChildren(this.ChildrenCount - 1).RemoveFromParent(); } if (e == 0) { this.ScrollEnabled = true; } }; //直接登录 if (Config.Instance.CanAutoLogin) { //显示启动页 CommonPage.Loading.Start(); HdlThreadLogic.Current.RunThread(() => { //登录 var loginSuccess = HdlAccountLogic.Current.AutoLoginByRefreshToken(); //登录成功,或者没有网络都可以登录 if (loginSuccess == AccountStatu.Sucess || loginSuccess == AccountStatu.NotNetWork) { //刷新个人中心的内存及线程 bool result = HdlUserCenterLogic.Current.InitUserCenterMenmoryAndThread(true); //启动ZigBee ZigBee.Common.Application.Init(); HdlThreadLogic.Current.RunMain(() => { CommonPage.Instance.RemoveViewByTag("Login"); CommonPage.Loading.Hide(); if (result == true) { //false:开启了调试功能 UserPage.Instance.ReFreshControl(); } }); } else { //设定一个时间 Config.Instance.LoginDateTime = new DateTime(1970, 1, 1); Config.Instance.Save(); HdlThreadLogic.Current.RunMain(() => { CommonPage.Loading.Hide(); CommonPage.Instance.RemoveViewByTag("Login"); //登录弹出登录界面 var accountLogin = new Login.AccountLoginForm { }; Shared.Common.CommonPage.Instance.AddChidren(accountLogin); accountLogin.ShowForm(); }); } }); } else { //未登录弹出登录界面 var accountLogin = new Login.AccountLoginForm { }; Shared.Common.CommonPage.Instance.AddChidren(accountLogin); accountLogin.ShowForm(); } } } }