xm
2019-07-16 b910cb79c9b5bcc204022a3cf9e6950f0a64dfbd
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
using System;
using Shared.Common;
using Shared.Phone.UserView;
 
namespace Shared.Phone.Device.Account
{
    /// <summary>
    /// 注册成功
    /// </summary>
    public class RegisterSuccess:FrameLayout
    {
        /// <summary>
        /// 构造方法
        /// </summary>
        public RegisterSuccess()
        {
            BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
        }
 
        /// <summary>
        /// 显示界面
        /// </summary>
        /// <param name="name">Name.</param>
        /// <param name="password">Password.</param>
        public void Show(string name,string password)
        {
            var midFL = new FrameLayout()
            {
                BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
            };
            AddChidren(midFL);
 
            var tip = new Button()
            {
                TextID = R.MyInternationalizationString.AccountRegisterSuccess,
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                TextSize = 25,
                TextAlignment = TextAlignment.Center,
                Gravity=Gravity.CenterHorizontal,
                Y=Application.GetRealHeight(300),
                Height = Application.GetRealHeight(100),
                Width=Application.GetRealWidth(700)
            };
            midFL.AddChidren(tip);
 
            var logo = new Button()
            {
                Width = Application.GetMinRealAverage(210),
                Height = Application.GetMinRealAverage(210),
                Y = Application.GetRealHeight(200) + tip.Bottom,
                UnSelectedImagePath = "Account/UserIMGSelected.png",
                Gravity = Gravity.CenterHorizontal
            };
            midFL.AddChidren(logo);
 
            var account = new Button()
            {
                Text=name,
                Gravity=Gravity.CenterHorizontal,
                Width=Application.GetRealWidth(500),
                Height=Application.GetRealHeight(80),
                Y=logo.Bottom+Application.GetRealHeight(50),
                TextColor=ZigbeeColor.Current.GXCTextBlackColor,
                TextAlignment=TextAlignment.Center,
                TextSize=10
            };
            midFL.AddChidren(account);
 
            //完成
            //点击后直接登录,不需要用户再次回到登录页面登录了
            var backToLogin = new Button()
            {
                Y = Application.GetRealHeight(1920 - 400),
                Height = Application.GetRealHeight(110),
                Width = Application.GetRealWidth(700),
                Gravity = Gravity.CenterHorizontal,
                BackgroundColor = ZigbeeColor.Current.GXCTextBlueColor,
                TextID = R.MyInternationalizationString.Complete,
                TextColor = ZigbeeColor.Current.GXCTextWhiteColor,
                Radius= (uint)Application.GetRealHeight(55)
            };
            midFL.AddChidren(backToLogin);
 
            backToLogin.MouseUpEventHandler += (sender, e) =>
            {
                //注册成功,直接后台登录,不需要用户再次输入账号密码确认登录
                this.RemoveFromParent();
                CommonPage.Instance.RemoveViewByTag("Register");
 
                try
                {
                    UserPage.Instance.Fresh();
                    CommonPage.Loading.Start(Language.StringByID(R.MyInternationalizationString.Logining));
                    Action action = async () => {
                        var loginSuccess = await HomePage.Instance.LoginByPWDAsync(name, password);
                        if (loginSuccess == 1)
                        {
                            new System.Threading.Thread(async () =>
                            {
                                ZigBee.Common.Application.Init();
 
                                //登录成功
                                var homes = await House.GetHomeLists();
 
                                //刷新个人中心的内存及线程
                                await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread();
 
                                Shared.Common.Room.canInitAllRoom = true;
                                Shared.Common.Room.InitAllRoom();
 
                                Application.RunOnMainThread(() =>
                                {
                                    UserPage.Instance.Fresh();
                                    CommonPage.Loading.Hide();
                                });
                            })
                            { IsBackground = true }.Start();
 
                        }
                        else
                        {
                            //未登录成功弹出登录界面 同时需要标记为未登录状态
                            Config.Instance.LoginDateTime = new DateTime(1970, 1, 1);
                            Config.Instance.Save();
                            var login = new Device.Account.AccountLogin { };
                            CommonPage.Instance.AddChidren(login);
                            login.Show(name, password);
                        }
                    };
                    action();
                }
                catch
                { }
                finally
                {
                    CommonPage.Loading.Hide();
                }
 
            };
        }
    }
}