HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2020-09-22 ade5917841b0fdcb1df7353ef7c56b1a1bdc9282
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
using System;
using Shared.Common;
using Shared.Phone.UserView;
using Shared.Phone.Device.CommonForm;
using Shared.Phone.UserCenter;
 
namespace Shared.Phone.Login
{
    /// <summary>
    /// 登录界面
    /// </summary>
    public class AccountLoginForm : FrameLayoutBase
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 错误提示控件
        /// </summary>
        private NormalViewControl btnErrorMsg = null;
        /// <summary>
        /// 是否同意隐私协议
        /// </summary>
        private bool isAgreePrivacyPolicy = true;
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 界面显示
        /// </summary>
        /// <param name="account">登陆账号</param>
        public void ShowForm(string account = "")
        {
            if (account == string.Empty)
            {
                //使用上一次登陆的账号
                account = Common.Config.Instance.Account;
            }
            CommonPage.Instance.IsDrawerLockMode = true;
            this.Tag = "Login";
 
            //界面上部的黑色图片
            var btnTopBlackPic = new NormalViewControl(this.Width, Application.GetRealHeight(619), false);
            btnTopBlackPic.UnSelectedImagePath = "Account/Logo_loginBG.png";
            this.AddChidren(btnTopBlackPic);
 
            //中间浅白色的背景
            var frameMidBack = new FrameLayout();
            frameMidBack.Y = btnTopBlackPic.Bottom;
            frameMidBack.Height = this.Height - btnTopBlackPic.Bottom;
            frameMidBack.BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor;
            this.AddChidren(frameMidBack);
 
            //HdlHome的图标
            var btnLogoIcon = new PicViewControl(184, 184);
            btnLogoIcon.Y = Application.GetRealHeight(230);
            btnLogoIcon.UnSelectedImagePath = "Account/Logo_White.png";
            btnLogoIcon.Gravity = Gravity.CenterHorizontal;
            this.AddChidren(btnLogoIcon);
            //Hdl Home
            var btnLogoName = new NormalViewControl(300, 69, true);
            btnLogoName.Y = btnLogoIcon.Bottom;
            btnLogoName.Gravity = Gravity.CenterHorizontal;
            btnLogoName.TextID = R.MyInternationalizationString.AppName;
            btnLogoName.TextColor = ZigbeeColor.Current.GXCTextWhiteColor;
            btnLogoName.TextAlignment = TextAlignment.Center;
            btnLogoName.TextSize = 16;
            this.AddChidren(btnLogoName);
 
            //1:手机号  2:邮箱
            int selectIndex = account.Contains("@") == false ? 1 : 2;
 
            //初始化 手机账号登陆窗口
            var frameAccLoginPhoneback = this.InitAccoutLoginWindow(frameMidBack, selectIndex == 1 ? account : string.Empty, 1);
            //初始化 邮箱账号登陆窗口
            var frameEmailLoginPhoneback = this.InitAccoutLoginWindow(frameMidBack, selectIndex == 1 ? string.Empty : account, 2);
            //初始化 手机账号验证码登陆窗口
            var frameAccCodeLoginPhoneback = this.InitCodeLoginWindow(frameMidBack, selectIndex == 1 ? account : string.Empty, 1);
            //初始化 邮箱账号验证码登陆窗口
            var frameEmailCodeLoginPhoneback = this.InitCodeLoginWindow(frameMidBack, selectIndex == 1 ? string.Empty : account, 2);
 
            //定义这两个东西,是为了减少判断的代码
            var framePhone = frameAccLoginPhoneback;
            var frameEmail = frameEmailLoginPhoneback;
 
            //邮箱,手机号的切换控件
            var sitchControl = new Controls.PhoneEmailSelectControl();
            sitchControl.Y = Application.GetRealHeight(559);
            this.AddChidren(sitchControl);
            sitchControl.SelectMenuEvent += (selectMenu) =>
            {
                selectIndex = selectMenu;
                //手机号
                if (selectIndex == 1)
                {
                    framePhone.Visible = true;
                    frameEmail.Visible = false;
                }
                //邮箱
                else if (selectIndex == 2)
                {
                    framePhone.Visible = false;
                    frameEmail.Visible = true;
                }
            };
            //执行初始化
            sitchControl.InitControl(ZigbeeColor.Current.GXCButtonSelectedColor, selectIndex);
 
            //错误提示控件
            this.btnErrorMsg = new NormalViewControl(700, 60, true);
            btnErrorMsg.Y = frameAccLoginPhoneback.Y - Application.GetRealHeight(60 + 3);
            btnErrorMsg.X = Application.GetRealWidth(288);
            btnErrorMsg.TextColor = ZigbeeColor.Current.GXCTextRed;
            btnErrorMsg.IsBold = true;
            frameMidBack.AddChidren(btnErrorMsg);
 
            //验证码登陆
            //1:账号登陆  2:验证码登陆
            int codeDiv = 1;
            var btnLoginByCode = new NormalViewControl(300, 100, true);
            btnLoginByCode.X = Application.GetRealWidth(98);
            btnLoginByCode.Y = frameAccLoginPhoneback.Bottom + Application.GetRealHeight(21);
            btnLoginByCode.TextID = R.MyInternationalizationString.LoginByCode;
            btnLoginByCode.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnLoginByCode.TextSize = 12;
            frameMidBack.AddChidren(btnLoginByCode);
            btnLoginByCode.ButtonClickEvent += (sender, e) =>
            {
                if (codeDiv == 1)
                {
                    //验证码登陆
                    codeDiv = 2;
                    btnLoginByCode.TextID = R.MyInternationalizationString.LoginByAccountPWD; //账号登陆
                    //账号登陆的两个东西隐藏
                    frameAccLoginPhoneback.Visible = false;
                    frameEmailLoginPhoneback.Visible = false;
                    //替换这两个东西
                    framePhone = frameAccCodeLoginPhoneback;
                    frameEmail = frameEmailCodeLoginPhoneback;
                }
                else
                {
                    //账号登陆
                    codeDiv = 1;
                    btnLoginByCode.TextID = R.MyInternationalizationString.LoginByCode;//验证码登陆
                    //验证码登陆的两个东西隐藏
                    frameAccCodeLoginPhoneback.Visible = false;
                    frameEmailCodeLoginPhoneback.Visible = false;
                    //替换这两个东西
                    framePhone = frameAccLoginPhoneback;
                    frameEmail = frameEmailLoginPhoneback;
                }
                //刷新菜单
                sitchControl.SetSelectIndex(1);
            };
 
            //注册用户
            var btnRegister = new NormalViewControl(300, 100, true);
            btnRegister.Y = btnLoginByCode.Y;
            btnRegister.X = frameMidBack.Width - Application.GetRealWidth(98 + 300);
            btnRegister.TextID = R.MyInternationalizationString.Register;
            btnRegister.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnRegister.TextSize = 12;
            btnRegister.TextAlignment = TextAlignment.CenterRight;
            frameMidBack.AddChidren(btnRegister);
            btnRegister.ButtonClickEvent += (sender, e) =>
            {
                var registerPage = new AccountRegister();
                CommonPage.Instance.AddChidren(registerPage);
                registerPage.Show();
            };
 
            //微信图标
            var btnWebChat = new IconViewControl(115);
            btnWebChat.Y = frameMidBack.Height - Application.GetRealHeight(69) - btnWebChat.IconSize;
            btnWebChat.UnSelectedImagePath = "Account/Wechat.png";
            btnWebChat.Gravity = Gravity.CenterHorizontal;
            frameMidBack.AddChidren(btnWebChat);
            btnWebChat.ButtonClickEvent += (sender, e) =>
            {
                //微信登陆
                this.LoginByWechat();
            };
 
            //添加服务协议控件
            //this.AddServiceAgreementControl(frameMidBack);
 
            //游客体验
            var btnTiyan = new NormalViewControl(300, 100, true);
            btnTiyan.Y = btnLoginByCode.Y;
            btnTiyan.TextAlignment = TextAlignment.Center;
            btnTiyan.TextColor = UserCenterColor.Current.TextOrangeColor;
            btnTiyan.TextSize = 12;
            btnTiyan.Gravity = Gravity.CenterHorizontal;
            btnTiyan.TextID = R.MyInternationalizationString.uExperienceAccount;
            frameMidBack.AddChidren(btnTiyan);
            btnTiyan.ButtonClickEvent += (sender, e) =>
            {
                btnTiyan.CanClick = false;
                //显示启动页
                HomePage.Instance.ShowLoginLoadView();
                HdlThreadLogic.Current.RunThread(() =>
                {
                    //初始化全部体验数据
                    HdlExperienceAccountLogic.Current.InitAllExperienceData();
                    HdlThreadLogic.Current.RunMain(() =>
                    {
                        this.RemoveFromParent();
                        CommonPage.Instance.RemoveViewByTag("Login");
                        UserPage.Instance.ReFreshControl();
                    });
                });
            };
        }
 
        #endregion
 
        #region ■ 初始化账号登陆窗口_________________
 
        /// <summary>
        /// 初始化账号登陆窗口
        /// </summary>
        /// <param name="frameMidBack">中间浅色的背景容器</param>
        /// <param name="i_account">登陆账号</param>
        /// <param name="i_div">1:手机号 2:邮箱</param>
        private FrameLayout InitAccoutLoginWindow(FrameLayout frameMidBack, string i_account, int i_div)
        {
            //登陆按钮
            BottomClickButton btnLogin = null;
            //账号输入框
            TextInputControl txtAccount = null;
            //密码输入框
            TextInputControl txtPsw = null;
            //容器
            var frameBack = new FrameLayout();
            frameBack.Height = Application.GetRealHeight(620);
            frameBack.Y = Application.GetRealHeight(181);
            frameMidBack.AddChidren(frameBack);
            frameBack.Visible = false;
            //白色背景
            var frameWhiteBack = new FrameLayout();
            frameWhiteBack.Width = Application.GetRealWidth(942);
            frameWhiteBack.Height = Application.GetRealHeight(553);
            frameWhiteBack.BackgroundColor = UserCenterColor.Current.White;
            frameWhiteBack.Radius = (uint)Application.GetRealHeight(17);
            frameWhiteBack.Gravity = Gravity.CenterHorizontal;
            frameBack.AddChidren(frameWhiteBack);
 
            //账号行
            var rowAccount = new FrameLayout();
            rowAccount.Y = Application.GetRealHeight(29);
            rowAccount.Width = Application.GetRealWidth(884);
            rowAccount.Height = Application.GetRealHeight(138);
            rowAccount.Gravity = Gravity.CenterHorizontal;
            frameWhiteBack.AddChidren(rowAccount);
            //账号图标
            var btnAccountIcon = new IconViewControl(92);
            btnAccountIcon.X = Application.GetRealWidth(69);
            btnAccountIcon.Gravity = Gravity.CenterVertical;
            btnAccountIcon.UnSelectedImagePath = "Account/Account.png";
            rowAccount.AddChidren(btnAccountIcon);
            //账号输入框
            txtAccount = new TextInputControl(600, 92, true);
            txtAccount.X = btnAccountIcon.Right + Application.GetRealWidth(35);
            txtAccount.Gravity = Gravity.CenterVertical;
            if (i_div == 1)
            {
                //手机号
                txtAccount.IsNumberKeyboardType = true;
                txtAccount.PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputPhoneNum);
            }
            else
            {
                //邮箱
                txtAccount.PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputEmail);
            }
            txtAccount.PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor;
            txtAccount.Text = i_account;
            rowAccount.AddChidren(txtAccount);
            txtAccount.TextChangeEventHandler += (sender, e) =>
            {
                //隐藏错误提示
                this.btnErrorMsg.Text = string.Empty;
                if (txtAccount.Text.Trim().Length > 0 && txtPsw.Text.Length > 0)
                {
                    //能够登陆
                    if (btnLogin.CanClick == false) { btnLogin.CanClick = true; }
                    return;
                }
                //不能点击
                if (btnLogin.CanClick == true) { btnLogin.CanClick = false; }
            };
 
            //底线
            var btnAccountLine = new NormalViewControl(rowAccount.Width, 1, false);
            btnAccountLine.BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor;
            btnAccountLine.Y = rowAccount.Height - 2;
            rowAccount.AddChidren(btnAccountLine);
            txtAccount.FoucsChanged += (sender, focusEvent) =>
            {
                //焦点进入时,底线颜色变更
                if (focusEvent.Focus)
                {
                    btnAccountLine.BackgroundColor = ZigbeeColor.Current.GXCSelectedLineColor;
                    btnAccountLine.Height = 2;
                }
                else
                {
                    btnAccountLine.BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor;
                    btnAccountLine.Height = 1;
                }
            };
 
            //密码行
            var rowPassword = new FrameLayout();
            rowPassword.Y = rowAccount.Bottom + Application.GetRealHeight(58);
            rowPassword.Width = rowAccount.Width;
            rowPassword.Height = rowAccount.Height;
            rowPassword.Gravity = Gravity.CenterHorizontal;
            frameWhiteBack.AddChidren(rowPassword);
            //账号图标
            var btnPswIcon = new IconViewControl(92);
            btnPswIcon.X = btnAccountIcon.X;
            btnPswIcon.Gravity = Gravity.CenterVertical;
            btnPswIcon.UnSelectedImagePath = "Account/Password.png";
            rowPassword.AddChidren(btnPswIcon);
            //密码输入框
            txtPsw = new TextInputControl(600, 92, true);
            txtPsw.X = txtAccount.X;
            txtPsw.Gravity = Gravity.CenterVertical;
            txtPsw.PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputPWD);
            txtPsw.PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor;
            txtPsw.SecureTextEntry = true;
            rowPassword.AddChidren(txtPsw);
            txtPsw.TextChangeEventHandler += (sender, e) =>
            {
                txtAccount.TextChangeEventHandler(sender, e);
            };
            //隐藏或者显示密码的图标
            var btnHiden = new IconViewControl(92);
            btnHiden.X = rowPassword.Width - Application.GetRealWidth(46) - btnHiden.IconSize;
            btnHiden.SelectedImagePath = "Account/UnhidePwd.png";
            btnHiden.UnSelectedImagePath = "Account/HidePwd.png";
            btnHiden.Gravity = Gravity.CenterVertical;
            rowPassword.AddChidren(btnHiden);
            btnHiden.ButtonClickEvent += (sender, e) =>
            {
                txtPsw.SecureTextEntry = !txtPsw.SecureTextEntry;
                btnHiden.IsSelected = !btnHiden.IsSelected;
            };
 
            //底线
            var btnPswLine = new NormalViewControl(rowPassword.Width, 1, false);
            btnPswLine.BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor;
            btnPswLine.Y = rowPassword.Height - 2;
            rowPassword.AddChidren(btnPswLine);
            txtPsw.FoucsChanged += (sender, focusEvent) =>
            {
                //焦点进入时,底线颜色变更
                if (focusEvent.Focus)
                {
                    btnPswLine.BackgroundColor = ZigbeeColor.Current.GXCSelectedLineColor;
                    btnPswLine.Height = 2;
                }
                else
                {
                    btnPswLine.BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor;
                    btnPswLine.Height = 1;
                }
            };
 
            //忘记密码?
            var btnForgot = new NormalViewControl(250, 90, true);
            btnForgot.Y = rowPassword.Bottom + Application.GetRealHeight(15);
            btnForgot.X = frameWhiteBack.Width - Application.GetRealWidth(250 + 35);
            btnForgot.TextSize = 12;
            btnForgot.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnForgot.TextAlignment = TextAlignment.CenterRight;
            btnForgot.TextID = R.MyInternationalizationString.ForgotPWD_1;
            frameWhiteBack.AddChidren(btnForgot);
            btnForgot.ButtonClickEvent += (sender, e) =>
            {
                var forgot = new AccountForgetPWD();
                CommonPage.Instance.AddChidren(forgot);
                forgot.Show();
            };
 
            //登陆按钮
            btnLogin = new BottomClickButton(688);
            btnLogin.Gravity = Gravity.BottomCenter;
            btnLogin.TextID = R.MyInternationalizationString.Login;
            btnLogin.oldBackgroundColor = btnLogin.BackgroundColor;
            frameBack.AddChidren(btnLogin);
            btnLogin.CanClick = false;
            btnLogin.ButtonClickEvent += (sender, e) =>
            {
                //账号密码登陆
                this.LoginByAccountAndPsw(txtAccount.Text.Trim(), txtPsw.Text, i_div);
            };
 
            return frameBack;
        }
 
        #endregion
 
        #region ■ 初始化验证码登陆窗口_______________
 
        /// <summary>
        /// 初始化验证码登陆窗口
        /// </summary>
        /// <param name="frameMidBack">中间浅色的背景容器</param>
        /// <param name="i_account">登陆账号</param>
        /// <param name="i_div">1:手机号 2:邮箱</param>
        private FrameLayout InitCodeLoginWindow(FrameLayout frameMidBack, string i_account, int i_div)
        {
            //登陆按钮
            BottomClickButton btnLogin = null;
            //账号输入框
            TextInputControl txtAccount = null;
            //密码输入框
            TextInputControl txtVerCode = null;
            //当前输入的账号(防止发送验证码之后,修改账号)
            string nowInputAccount = string.Empty;
            //是否已经发送了验证码
            bool hadSendCode = false;
 
            //容器
            var frameBack = new FrameLayout();
            frameBack.Height = Application.GetRealHeight(620);
            frameBack.Y = Application.GetRealHeight(181);
            frameMidBack.AddChidren(frameBack);
            frameBack.Visible = false;
            //白色背景
            var frameWhiteBack = new FrameLayout();
            frameWhiteBack.Width = Application.GetRealWidth(942);
            frameWhiteBack.Height = Application.GetRealHeight(553);
            frameWhiteBack.BackgroundColor = UserCenterColor.Current.White;
            frameWhiteBack.Radius = (uint)Application.GetRealHeight(17);
            frameWhiteBack.Gravity = Gravity.CenterHorizontal;
            frameBack.AddChidren(frameWhiteBack);
 
            //账号行
            var rowAccount = new FrameLayout();
            rowAccount.Y = Application.GetRealHeight(29);
            rowAccount.Width = Application.GetRealWidth(884);
            rowAccount.Height = Application.GetRealHeight(138);
            rowAccount.Gravity = Gravity.CenterHorizontal;
            frameWhiteBack.AddChidren(rowAccount);
            if (i_div == 2)
            {
                //账号图标
                var btnAccountIcon = new IconViewControl(92);
                btnAccountIcon.X = Application.GetRealWidth(69);
                btnAccountIcon.Gravity = Gravity.CenterVertical;
                btnAccountIcon.UnSelectedImagePath = "Account/Account.png";
                rowAccount.AddChidren(btnAccountIcon);
            }
            else
            {
                //地区码
                var btnArea = new NormalViewControl(139, 60, true);
                btnArea.TextColor = UserCenterColor.Current.TextGrayColor1;
                btnArea.TextAlignment = TextAlignment.CenterRight;
                btnArea.Text = "+86";
                btnArea.Gravity = Gravity.CenterVertical;
                rowAccount.AddChidren(btnArea);
            }
            //账号输入框
            txtAccount = new TextInputControl(600, 92, true);
            txtAccount.X = Application.GetRealWidth(193);
            txtAccount.Gravity = Gravity.CenterVertical;
            if (i_div == 1)
            {
                //手机号
                txtAccount.IsNumberKeyboardType = true;
                txtAccount.PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputPhoneNum);
            }
            else
            {
                //邮箱
                txtAccount.PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputEmail);
            }
            txtAccount.PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor;
            txtAccount.Text = i_account;
            rowAccount.AddChidren(txtAccount);
            txtAccount.TextChangeEventHandler += (sender, e) =>
            {
                //隐藏错误提示
                this.btnErrorMsg.Text = string.Empty;
                //必须要发送成功才行
                if (hadSendCode == true && txtAccount.Text.Trim().Length > 0 && txtVerCode.Text.Length > 0)
                {
                    //能够登陆
                    if (btnLogin.CanClick == false) { btnLogin.CanClick = true; }
                    return;
                }
                //不能点击
                if (btnLogin.CanClick == true) { btnLogin.CanClick = false; }
            };
            //底线
            var btnAccountLine = new NormalViewControl(rowAccount.Width, 1, false);
            btnAccountLine.BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor;
            btnAccountLine.Y = rowAccount.Height - 2;
            rowAccount.AddChidren(btnAccountLine);
            txtAccount.FoucsChanged += (sender, focusEvent) =>
            {
                //焦点进入时,底线颜色变更
                if (focusEvent.Focus)
                {
                    btnAccountLine.BackgroundColor = ZigbeeColor.Current.GXCSelectedLineColor;
                    btnAccountLine.Height = 2;
                }
                else
                {
                    btnAccountLine.BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor;
                    btnAccountLine.Height = 1;
                }
            };
 
            //验证码行
            var rowVerCode = new FrameLayout();
            rowVerCode.Y = rowAccount.Bottom + Application.GetRealHeight(58);
            rowVerCode.Width = rowAccount.Width;
            rowVerCode.Height = rowAccount.Height;
            rowVerCode.Gravity = Gravity.CenterHorizontal;
            frameWhiteBack.AddChidren(rowVerCode);
            //账号图标
            var btnCodeIcon = new IconViewControl(92);
            btnCodeIcon.X = Application.GetRealWidth(69);
            btnCodeIcon.Gravity = Gravity.CenterVertical;
            btnCodeIcon.UnSelectedImagePath = "Account/Code.png";
            rowVerCode.AddChidren(btnCodeIcon);
            //验证码输入框
            txtVerCode = new TextInputControl(350, 92, true);
            txtVerCode.X = btnCodeIcon.Right + Application.GetRealWidth(35);
            txtVerCode.Gravity = Gravity.CenterVertical;
            txtVerCode.PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputVerificationCode);
            txtVerCode.PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor;
            rowVerCode.AddChidren(txtVerCode);
            txtVerCode.TextChangeEventHandler += (sender, e) =>
            {
                txtAccount.TextChangeEventHandler(sender, e);
            };
            //竖线
            var btnLine2 = new NormalViewControl(1, Application.GetRealHeight(66), false);
            btnLine2.X = Application.GetRealWidth(611);
            btnLine2.Gravity = Gravity.CenterVertical;
            btnLine2.BackgroundColor = ZigbeeColor.Current.GXCLineColor;
            rowVerCode.AddChidren(btnLine2);
            //获取验证码
            var btnSendCode = new NormalViewControl(250, 70, true);
            btnSendCode.X = btnLine2.Right + Application.GetRealWidth(36);
            btnSendCode.Gravity = Gravity.CenterVertical;
            btnSendCode.TextID = R.MyInternationalizationString.SendVerificationCode;
            btnSendCode.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnSendCode.TextAlignment = TextAlignment.Center;
            btnSendCode.IsBold = true;
            rowVerCode.AddChidren(btnSendCode);
            btnSendCode.ButtonClickEvent += (sender, e) =>
            {
                //检测输入的账号
                nowInputAccount = txtAccount.Text.Trim();
                if (this.CheckInputAccount("86", nowInputAccount, i_div) == false)
                {
                    return;
                }
                //发送验证码
                hadSendCode = this.SendVerCode(btnSendCode, nowInputAccount, i_div);
            };
 
            //底线
            var btnCodeLine = new NormalViewControl(rowVerCode.Width, 1, false);
            btnCodeLine.BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor;
            btnCodeLine.Y = rowVerCode.Height - 2;
            rowVerCode.AddChidren(btnCodeLine);
            txtVerCode.FoucsChanged += (sender, focusEvent) =>
            {
                //焦点进入时,底线颜色变更
                if (focusEvent.Focus)
                {
                    btnCodeLine.BackgroundColor = ZigbeeColor.Current.GXCSelectedLineColor;
                    btnCodeLine.Height = 2;
                }
                else
                {
                    btnCodeLine.BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor;
                    btnCodeLine.Height = 1;
                }
            };
 
            //忘记密码?
            var btnForgot = new NormalViewControl(250, 90, true);
            btnForgot.Y = rowVerCode.Bottom + Application.GetRealHeight(15);
            btnForgot.X = frameWhiteBack.Width - Application.GetRealWidth(250 + 35);
            btnForgot.TextSize = 12;
            btnForgot.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnForgot.TextAlignment = TextAlignment.CenterRight;
            btnForgot.TextID = R.MyInternationalizationString.ForgotPWD_1;
            frameWhiteBack.AddChidren(btnForgot);
            btnForgot.ButtonClickEvent += (sender, e) =>
            {
                var forgot = new AccountForgetPWD();
                CommonPage.Instance.AddChidren(forgot);
                forgot.Show();
            };
 
            //登陆按钮
            btnLogin = new BottomClickButton(688);
            btnLogin.Gravity = Gravity.BottomCenter;
            btnLogin.TextID = R.MyInternationalizationString.Login;
            btnLogin.oldBackgroundColor = btnLogin.BackgroundColor;
            frameBack.AddChidren(btnLogin);
            btnLogin.CanClick = false;
            btnLogin.ButtonClickEvent += (sender, e) =>
            {
                //验证码登陆
                this.LoginByVerCode(nowInputAccount, txtVerCode.Text.Trim(), i_div);
            };
            return frameBack;
        }
 
        #endregion
 
        #region ■ 服务协议___________________________
 
        /// <summary>
        /// 添加服务协议控件
        /// </summary>
        /// <param name="frameBack"></param>
        private void AddServiceAgreementControl(FrameLayout frameBack)
        {
            var frameRow = new FrameLayout();
            frameRow.Height = this.GetPictrueRealSize(110);
            frameRow.Y = Application.GetRealHeight(959);
            frameRow.Gravity = Gravity.CenterHorizontal;
 
            //字体总宽度
            int fontWidth = 0;
            int btnWidth = 0;
 
            //特殊的误差值
            int speceilValue = ControlCommonResourse.TwoTextSpace;
 
            //我已阅读并同意
            var btnMsg1 = new NormalViewControl(100, 90, true);
            btnMsg1.Gravity = Gravity.CenterVertical;
            btnMsg1.Y = Application.GetRealHeight(968);
            btnMsg1.TextSize = 12;
            btnMsg1.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnMsg1.TextID = R.MyInternationalizationString.uMyHadReadAndAgree;
            //计算真实宽度
            btnWidth = btnMsg1.GetRealWidthByText();
            btnMsg1.Width = btnWidth;
            fontWidth += btnWidth;
 
            //《隐私权政策》
            var btnMsg2 = new NormalViewControl(100, 90, true);
            btnMsg2.Gravity = Gravity.CenterVertical;
            btnMsg2.TextSize = 12;
            btnMsg2.TextColor = 0xFF4A90E2;
            btnMsg2.Text = "《" + Language.StringByID(R.MyInternationalizationString.uPrivacyPolicy) + "》";
            //计算真实宽度
            btnWidth = btnMsg2.GetRealWidthByText();
            btnMsg2.Width = btnWidth;
            fontWidth += btnWidth;
            btnMsg2.ButtonClickEvent += (sender, e) =>
            {
                var form = new UserCenter.Abount.SLAForm();
                this.AddChidren(form);
                form.InitTopFrameLayout();
                form.InitBodyFrameLayout();
                form.ShowForm();
            };
 
            //和
            var btnMsg3 = new NormalViewControl(100, 90, true);
            btnMsg3.Gravity = Gravity.CenterVertical;
            btnMsg3.TextSize = 12;
            btnMsg3.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnMsg3.TextID = R.MyInternationalizationString.uAnd;
            //计算真实宽度
            btnWidth = btnMsg3.GetRealWidthByText();
            btnMsg3.Width = btnWidth;
            fontWidth += btnWidth;
 
            //《服务条款》
            var btnMsg4 = new NormalViewControl(100, 90, true);
            btnMsg4.Gravity = Gravity.CenterVertical;
            btnMsg4.TextSize = 12;
            btnMsg4.TextColor = 0xFF4A90E2;
            btnMsg4.Text = "《" + Language.StringByID(R.MyInternationalizationString.uTermsOfService) + "》";
            //计算真实宽度
            btnWidth = btnMsg4.GetRealWidthByText();
            btnMsg4.Width = btnWidth;
            fontWidth += btnWidth;
            btnMsg4.ButtonClickEvent += (sender, e) =>
            {
                btnMsg2.ButtonClickEvent(null, null);
            };
 
            //图标
            var btnIcon = new IconBigViewControl(42, 42);
            btnIcon.UnSelectedImagePath = "Item/Check1.png";
            btnIcon.SelectedImagePath = "Item/Check1Selected.png";
 
            //计算行控件的宽度
            frameRow.Width = fontWidth + this.GetPictrueRealSize(42) + Application.GetRealWidth(23) - speceilValue * 3;
            frameBack.AddChidren(frameRow);
 
            //图标控件初始化
            frameRow.AddChidren(btnIcon);
            btnIcon.InitControl();
            btnIcon.X = -btnIcon.XOffset;
            btnIcon.UseClickStatu = false;
            btnIcon.ButtonClickEvent += (sender, e) =>
            {
                btnIcon.IsSelected = !btnIcon.IsSelected;
                isAgreePrivacyPolicy = btnIcon.IsSelected;
            };
 
            btnMsg1.X = btnIcon.btnIcon.Width + Application.GetRealWidth(23);
            frameRow.AddChidren(btnMsg1);
            btnMsg2.Y = btnMsg1.Y;
            btnMsg2.X = btnMsg1.Right - speceilValue;
            frameRow.AddChidren(btnMsg2);
            btnMsg3.X = btnMsg2.Right - speceilValue;
            btnMsg3.Y = btnMsg1.Y;
            frameRow.AddChidren(btnMsg3);
            btnMsg4.X = btnMsg3.Right - speceilValue;
            btnMsg4.Y = btnMsg1.Y;
            frameRow.AddChidren(btnMsg4);
        }
 
        #endregion
 
        #region ■ 账号密码登陆_______________________
 
        /// <summary>
        /// 账号密码登陆
        /// </summary>
        /// <param name="i_account">账号</param>
        /// <param name="i_psw">密码</param>
        /// <param name="i_div">1:手机号 2:邮箱</param>
        private void LoginByAccountAndPsw(string i_account, string i_psw, int i_div)
        {
            //检测账号
            if (this.CheckInputAccount(string.Empty, i_account, i_div) == false)
            {
                return;
            }
 
            //登陆中....
            CommonPage.Loading.Start(Language.StringByID(R.MyInternationalizationString.Logining));
 
            HdlThreadLogic.Current.RunThread(() =>
            {
                //登陆参数
                var pra = new SendDataToServer.LoginObj();
                pra.Account = i_account;
                pra.Password = i_psw;
                pra.Source = CommonPage.Source;
                pra.Company = CommonPage.Company;
 
                //访问接口
                var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(pra);
                var result = CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/Login", System.Text.Encoding.UTF8.GetBytes(requestJson));
 
                //处理登陆成功的数据
                this.AdjustLoginSuccessData(result, pra, i_account, i_psw, i_div);
            });
        }
 
        /// <summary>
        /// 检测输入的账号
        /// </summary>
        /// <param name="i_areaCode">地区码</param>
        /// <param name="i_account">账号</param>
        /// <param name="i_div">1:手机号 2:邮箱</param>
        /// <returns></returns>
        private bool CheckInputAccount(string i_areaCode, string i_account, int i_div)
        {
            if (i_div == 1)
            {
                //检测手机
                if (i_areaCode != string.Empty && AccountLogic.Instance.CheckPhoneWithZone(i_account, i_areaCode) == false)
                {
                    btnErrorMsg.TextID = R.MyInternationalizationString.ThePhoneError;
                    return false;
                }
                //检测手机
                if (i_areaCode == string.Empty && AccountLogic.Instance.CheckPhone(i_account) == false)
                {
                    btnErrorMsg.TextID = R.MyInternationalizationString.ThePhoneError;
                    return false;
                }
            }
            else
            {
                //检测邮箱
                if (AccountLogic.Instance.CheckEmail(i_account) == false)
                {
                    btnErrorMsg.TextID = R.MyInternationalizationString.TheEmailError;
                    return false;
                }
            }
            return true;
        }
 
        #endregion
 
        #region ■ 微信登陆___________________________
 
        /// <summary>
        /// 微信登录
        /// </summary>
        private void LoginByWechat()
        {
#if Android
            com.hdl.home.Application.WXLogin();
            com.hdl.home.WXEntryActivity.RespAction = (authStr) =>
            {
#endif
#if iOS
            Home.IOS.AppDelegate.WXLogin();
            Home.IOS.AppDelegate.RespAction = (authStr) =>
            {
#endif
                if (authStr == null)
                {
                    return;
                }
                HdlThreadLogic.Current.RunThread(() =>
                {
                    //是否已经绑定
                    var re = isBindAuthAsync(authStr);
                    if (re)
                    {
                        Application.RunOnMainThread(() =>
                        {
                            //直接登录
                            HomePage.Instance.ShowLoginLoadView();
                        });
                        var resultRegID = Shared.Common.CommonPage.Instance.PushRegID();
                        var homes = HdlResidenceLogic.Current.GetHomeListsFromDb();
                        //刷新个人中心的内存及线程
                        UserCenterLogic.InitUserCenterMenmoryAndThread();
                        //启动ZigBee
                        ZigBee.Common.Application.Init();
 
                        HdlThreadLogic.Current.RunMain(() =>
                        {
                            this.RemoveFromParent();
                            CommonPage.Instance.RemoveViewByTag("Login");
                            UserPage.Instance.ReFreshControl();
                        });
                    }
                    else
                    {
                        var authRes = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.AuthUserRes>(authStr);
                        HdlThreadLogic.Current.RunMain(() =>
                        {
                            var registerPage = new AccountRegister();
                            CommonPage.Instance.AddChidren(registerPage);
                            registerPage.OpenID = authRes.openid;
                            registerPage.Show();
                        });
                    }
                });
            };
        }
 
        /// <summary>
        /// 是否已绑定
        /// </summary>
        /// <param name="authStr"></param>
        /// <returns></returns>
        private bool isBindAuthAsync(string authStr)
        {
            var authRes = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.AuthUserRes>(authStr);
            var auth = new SendDataToServer.AuthUser()
            {
                AccessToken = authRes.access_token,
                RefreshToken = authRes.refresh_token,
                OpenID = authRes.openid
            };
            //获取微信昵称
            var strUrl = "https://api.weixin.qq.com/sns/userinfo?access_token=" + authRes.access_token;
            strUrl += "&openid=" + authRes.openid;
            var byteData = Common.CommonPage.Instance.DoRequestZigbeeHttpsInterface(strUrl, null, null, "GET");
            if (byteData == null)
            {
                return false;
            }
            var receipData = System.Text.Encoding.UTF8.GetString(byteData);
            var nickData = Newtonsoft.Json.JsonConvert.DeserializeObject<UserCenter.NicknameInfo>(receipData);
            auth.UserName = nickData.nickname;
 
            var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(auth);
            var revertObj = CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/InsertOrUpdateAuthUser", System.Text.Encoding.UTF8.GetBytes(requestJson));
            if (revertObj == null)
            {
                return false;
            }
            var stateCodeStr = revertObj.StateCode.ToUpper();
            if (stateCodeStr == "SUCCESS")
            {
                var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginRes>(revertObj.ResponseData.ToString());
                var revertData = responseDataObj;
                //标记上一次是不是同一个账号登陆
                Config.Instance.TheSameLoginAccount = Config.Instance.Guid == revertData.Guid;
                Config.Instance.Account = revertData.Account;
                Config.Instance.MD5PWD = revertData.MD5PWD;
                Config.Instance.Guid = revertData.Guid;
                Config.Instance.LoginDateTime = DateTime.Now;
                Config.Instance.Save();
                return true;
            }
            else
            {
                return false;
            }
        }
 
        #endregion
 
        #region ■ 验证码登陆_________________________
 
        /// <summary>
        /// 验证码登陆
        /// </summary>
        /// <param name="i_account">账号</param>
        /// <param name="i_verCode">验证码</param>
        /// <param name="i_div">1:手机号 2:邮箱</param>
        private void LoginByVerCode(string i_account, string i_verCode, int i_div)
        {
            //登陆中....
            CommonPage.Loading.Start(Language.StringByID(R.MyInternationalizationString.Logining));
 
            HdlThreadLogic.Current.RunThread(() =>
            {
                var pra = new SendDataToServer.LoginValidCodeOBJ()
                {
                    Account = i_account,
                    Code = i_verCode,
                    Language = CommonPage.ZigBeeLanguage,
                    AreaCode = int.Parse(CommonPage.PhoneZoneStr)
                };
                var result = CommonFormResouce.LoginByCode(pra);
                //处理登陆成功的数据
                this.AdjustLoginSuccessData(result, pra, i_account, string.Empty, i_div);
            });
        }
 
        /// <summary>
        /// 发送验证码
        /// </summary>
        /// <param name="btnSendCode">发送按钮</param>
        /// <param name="account">账号</param>
        /// <param name="i_div">1:手机号 2:邮箱</param>
        /// <returns></returns>
        private bool SendVerCode(NormalViewControl btnSendCode, string account, int i_div)
        {
            //不能再点击
            btnSendCode.CanClick = false;
 
            int companyInt = 0;
            if (CommonPage.PhoneZoneStr == "86" || i_div == 2)
            {
                companyInt = CommonPage.Company;
            }
            else
            {
                companyInt = CommonPage.CompanyForINTERNETION;
            }
            var reqDtoSignPhone = new SendDataToServer.LoginSendVerCodeObj()
            {
                Account = account,
                Company = companyInt,
                AreaCode = int.Parse(CommonPage.PhoneZoneStr),
                Language = CommonPage.ZigBeeLanguage
            };
            var requestRevertObj = CommonFormResouce.LoginSendVerCode(reqDtoSignPhone);
            if (requestRevertObj == null)
            {
                //请求服务器失败
                CommonPage.Instance.FailureToServer();
                return false;
            }
            var stateCodeStr = requestRevertObj.StateCode.ToUpper();
            if (stateCodeStr == "SUCCESS")
            {
                //开启发送验证码的倒计时
                this.StartSendVerCodeTimeOutThread(btnSendCode);
                return true;
            }
            if (stateCodeStr == "PARAMETEROREMPTY")
            {
                //提供的参数错误
                btnErrorMsg.TextID = R.MyInternationalizationString.PARAMETEROREMPTY;
            }
            else if (stateCodeStr == "ACCOUNTNOEXISTS")
            {
                //账号不存在
                btnErrorMsg.TextID = R.MyInternationalizationString.ACCOUNTNOEXISTS;
            }
            else if (stateCodeStr == "SENDFAIL")
            {
                //验证码发送失败
                btnErrorMsg.TextID = R.MyInternationalizationString.SENDFAIL;
            }
            else
            {
                //请求服务器失败
                btnErrorMsg.TextID = R.MyInternationalizationString.RequestServerFailed;
                //写Log
                IMessageCommon.Current.GetMsgByRequestName("ZigbeeUsers/LoginSendVerCode", requestRevertObj, reqDtoSignPhone);
            }
 
            HdlThreadLogic.Current.RunThread(() =>
            {
                //发送失败后,5秒之后才能再次发送
                int i = 0;
                while (i <= 5)
                {
                    i++;
                    System.Threading.Thread.Sleep(1000);
                }
                btnSendCode.CanClick = true;
            });
 
            return false;
        }
 
        /// <summary>
        /// 开启发送验证码的倒计时
        /// </summary>
        /// <param name="btnSendCode"></param>
        private void StartSendVerCodeTimeOutThread(NormalViewControl btnSendCode)
        {
            HdlThreadLogic.Current.RunThread(() =>
            {
                //后重发
                string strText = Language.StringByID(R.MyInternationalizationString.SendVerificationCodeAgain);
                int time = 60;
                while (time > 0 && btnSendCode.Parent != null)
                {
                    HdlThreadLogic.Current.RunMain(() =>
                    {
                        btnSendCode.Text = time + "s" + strText;
                    });
                    time--;
                    System.Threading.Thread.Sleep(1000);
                }
                //倒计时完成之后,可以再次点击
                btnSendCode.CanClick = true;
                HdlThreadLogic.Current.RunMain(() =>
                {
                    //获取验证码
                    btnSendCode.Text = Language.StringByID(R.MyInternationalizationString.SendVerificationCode);
                });
            });
        }
 
        #endregion
 
        #region ■ 处理登陆成功的数据_________________
 
        /// <summary>
        /// 处理登陆成功的数据
        /// </summary>
        /// <param name="revertObj">云端返回的数据</param>
        /// <param name="pra">接口请求参数</param>
        /// <param name="i_account">账号</param>
        /// <param name="i_psw">密码,验证码登陆时,设置为 string.Empty</param>
        /// <param name="i_div">1:手机号 2:邮箱</param>
        private void AdjustLoginSuccessData(Common.ResponseEntity.ResponsePack revertObj, object pra,
            string i_account, string i_psw, int i_div)
        {
            if (revertObj == null)
            {
                HdlThreadLogic.Current.RunMain(() =>
                {
                    //请求服务器失败
                    CommonPage.Instance.FailureToServer();
                    CommonPage.Loading.Hide();
                });
                return;
            }
            var stateCodeStr = revertObj.StateCode.ToUpper();
            //Error 不能直接从服务器取,只能根据状态码逐一判断
            if (stateCodeStr == "SUCCESS")
            {
                HdlThreadLogic.Current.RunMain(() =>
                {
                    //显示启动页
                    HomePage.Instance.ShowLoginLoadView();
                });
                //存储数据
                var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginRes>(revertObj.ResponseData.ToString());
                var revertData = responseDataObj;
                Config.ReFresh();
                //标记上一次是不是同一个账号登陆
                Config.Instance.TheSameLoginAccount = Config.Instance.Guid == revertData.Guid;
                Config.Instance.Account = revertData.Account;
                Config.Instance.Password = i_psw;
                Config.Instance.MD5PWD = revertData.MD5PWD;
                Config.Instance.Guid = revertData.Guid;
                Config.Instance.LoginDateTime = DateTime.Now;
                Config.Instance.LoginToken = revertData.Token;
                Config.Instance.Save();
 
                var resultRegID = CommonPage.Instance.PushRegID();
                var homes = HdlResidenceLogic.Current.GetHomeListsFromDb();
                //刷新个人中心的内存及线程
                UserCenterLogic.InitUserCenterMenmoryAndThread();
                //启动ZigBee
                ZigBee.Common.Application.Init();
 
                HdlThreadLogic.Current.RunMain(() =>
                {
                    CommonPage.Loading.Hide();
                    this.RemoveFromParent();
                    CommonPage.Instance.RemoveViewByTag("Login");
                    UserPage.Instance.ReFreshControl();
                });
                return;
            }
            //关闭转圈的
            HdlThreadLogic.Current.RunMain(() =>
            {
                CommonPage.Loading.Hide();
                if (stateCodeStr == "NOTVERIFY")
                {
                    //未激活
                    btnErrorMsg.TextID = R.MyInternationalizationString.NOTVERIFY;
                }
                else if (stateCodeStr == "NOTENABLE")
                {
                    //该用户属于调试账号,并未启用
                    btnErrorMsg.TextID = R.MyInternationalizationString.NOTENABLE;
                }
                else if (stateCodeStr == "PARAMETEROREMPTY")
                {
                    //提供的参数错误
                    btnErrorMsg.TextID = R.MyInternationalizationString.PARAMETEROREMPTY;
                }
                else if (stateCodeStr == "VALIDCODEANDPHONENOEQUAL")
                {
                    //验证码错误,请重新输入
                    btnErrorMsg.TextID = R.MyInternationalizationString.VALIDCODEANDPHONENOEQUAL;
                }
                else if (stateCodeStr == "USERNAMEORPWDERROR")
                {
                    //账号或密码错误
                    btnErrorMsg.TextID = R.MyInternationalizationString.USERNAMEORPWDERROR;
                }
                else if (stateCodeStr == "ACCOUNTNOEXISTS")
                {
                    //账号不存在
                    btnErrorMsg.TextID = R.MyInternationalizationString.ACCOUNTNOEXISTS;
                }
                else if (stateCodeStr == "NORECORD" && i_psw == string.Empty)
                {
                    //请先获取验证码
                    btnErrorMsg.TextID = R.MyInternationalizationString.NORECORD;
                }
                else if (stateCodeStr == "YOUDATANOISLOCALREGION")
                {
                    //不在本区域,需要重定向区域后再次请求登录
                    var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginLocalRegionRes>(revertObj.ResponseData.ToString());
                    CommonPage.RequestHttpsHost = responseDataObj.RegionServer;
                    if (i_psw != string.Empty)
                    {
                        //再次登录
                        this.LoginByAccountAndPsw(i_account, i_psw, i_div);
                    }
                }
                else
                {
                    btnErrorMsg.TextID = R.MyInternationalizationString.RequestServerFailed;
                    //写Log
                    if (pra is SendDataToServer.LoginObj)
                    {
                        ((SendDataToServer.LoginObj)pra).Password = "*********";
                        IMessageCommon.Current.GetMsgByRequestName("ZigbeeUsers/Login", revertObj, pra);
                    }
                    else
                    {
                        IMessageCommon.Current.GetMsgByRequestName("ZigbeeUsers/LoginValidCode", revertObj, pra);
                    }
                }
            });
        }
 
        #endregion
 
        #region ■ 一般方法___________________________
 
        /// <summary>
        /// 检测隐私协议
        /// </summary>
        /// <returns></returns>
        private bool CheckPrivacyPolicy()
        {
            if (isAgreePrivacyPolicy == false)
            {
                //请先阅读并同意《隐私权政策》和《服务条款》
                var btnMsg = new ShowMsgControl(ShowMsgType.Remind, Language.StringByID(R.MyInternationalizationString.uPleaseReadAndAgreePrivacyPolicyMsg));
                btnMsg.Show();
                return false;
            }
            return true;
        }
 
        #endregion
    }
}