黄学彪
2020-12-16 0d9f64668fd7350d6a21fd157e32009a96d98134
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
using System;
using Shared.Common;
 
namespace Shared.Phone.UserView
{
    /// <summary>
    /// Home page.第二版呀
    /// </summary>
    public class HomePage : PageLayout
    {
        static HomePage homePage;
        /// <summary>
        /// Gets the instance.
        /// </summary>
        /// <value>The instance.</value>
        public static HomePage Instance
        {
            get
            {
                if (homePage == null)
                {
                    homePage = new HomePage { IsShowPoint = false };
                }
                return homePage;
            }
        }
        /// <summary>
        /// Inits the page.
        /// </summary>
        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();
            }
        }
    }
}