From 281f7d0b8a363a3ed4d6f83bb5fa22bb6d0340f3 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期五, 08 一月 2021 16:20:13 +0800
Subject: [PATCH] 2021-01-08 1.更新

---
 Crabtree/SmartHome/UI/SimpleControl/Phone/User/UserMiddle.cs |  139 +++++++++++++++++++++++++---------------------
 1 files changed, 75 insertions(+), 64 deletions(-)

diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/User/UserMiddle.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/User/UserMiddle.cs
index 6299a4e..258f72c 100644
--- a/Crabtree/SmartHome/UI/SimpleControl/Phone/User/UserMiddle.cs
+++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/User/UserMiddle.cs
@@ -24,43 +24,42 @@
 
         public static FrameLayout UserPageView = new FrameLayout ();
 
-        //public static Button LinkStatusTip = new Button () {
-        //    Height = Application.GetRealHeight (36),
-        //    Width = Application.GetRealWidth (640),
-        //    BackgroundColor = SkinStyle.Current.LinkStatusTipColor
-        //};
+        public static Button LinkStatusTip = new Button () {
+            Height = Application.GetRealHeight (Convert.ToInt32 (36 * MainPage.PixelScale)),
+            BackgroundColor = SkinStyle.Current.MainColor
+        };
 
         public static PageLayout FavoritePageView = new PageLayout () {
             IsShowPoint = false,
         };
         public static FrameLayout FavoriteBodyView = new FrameLayout () {
-            Width = Application.GetRealWidth (640),
-            Height = Application.GetRealHeight (1136)
+            //Width = Application.GetRealWidth (Application.DesignWidth),
+            //Height = Application.GetRealHeight (Application.DesignHeight)
         };
         public static UserRoom FavoriteRoom = new UserRoom () {
-            Width = Application.GetRealWidth (640),
-            Height = Application.GetRealHeight (1136 - 90)
+            //Width = Application.GetRealWidth (Application.DesignWidth),
+            Height = Application.GetRealHeight (Application.DesignHeight - userMenuItemHeight)
         };
 
         public static PageLayout DevicePageView = new PageLayout () {
             IsShowPoint = false,
         };
         public static FrameLayout DeviceBodyView = new FrameLayout () {
-            Width = Application.GetRealWidth (640),
-            Height = Application.GetRealHeight (1136)
+            //Width = Application.GetRealWidth (Application.DesignWidth),
+            Height = Application.GetRealHeight (Application.DesignHeight)
         };
         public static VerticalScrolViewLayout DeviceView = new VerticalScrolViewLayout () {
             Y = Application.GetRealHeight (126),
-            Width = Application.GetRealWidth (640),
-            Height = Application.GetRealHeight (1136 - 126 - 90),
+            //Width = Application.GetRealWidth (Application.DesignWidth),
+            Height = Application.GetRealHeight (Application.DesignHeight - 126 - userMenuItemHeight),
         };
 
         public static PageLayout RoomPageView = new PageLayout () {
             IsShowPoint = false,
         };
         public static FrameLayout RoomBodyView = new FrameLayout () {
-            Width = Application.GetRealWidth (640),
-            Height = Application.GetRealHeight (1136)
+            Width = Application.GetRealWidth (Application.DesignWidth),
+            Height = Application.GetRealHeight (Application.DesignHeight)
         };
 
         public static PageLayout SettingPageView = new PageLayout () {
@@ -68,18 +67,18 @@
         };
         public static FrameLayout SettingBodyView = new FrameLayout () {
             BackgroundColor = SkinStyle.Current.MainColor,
-            Height = Application.GetRealHeight (1136)
+            Height = Application.GetRealHeight (Application.DesignHeight)
         };
         public static VerticalScrolViewLayout SettingView = new VerticalScrolViewLayout () {
             Y = Application.GetRealHeight (126),
-            Width = Application.GetRealWidth (640),
-            Height = Application.GetRealHeight (1136 - 126 - 90 - 90),
+            Width = Application.GetRealWidth (Application.DesignWidth),
+            Height = Application.GetRealHeight (Application.DesignHeight - 126 - userMenuItemHeight - 90),
             BackgroundColor = SkinStyle.Current.ViewColor,
             //ScrollEnabled = true
         };
         public static Button btnVersion = new Button () {
-            Y = Application.GetRealHeight (1136 - 90 - 90),
-            Width = Application.GetRealWidth (640),
+            Y = Application.GetRealHeight (Application.DesignHeight - userMenuItemHeight - 90),
+            Width = Application.GetRealWidth (Application.DesignWidth),
             Height = Application.GetRealHeight (90),
             Text = Language.StringByID (R.MyInternationalizationString.Version) + " : " + MainPage.RequestVersion,
             TextColor = SkinStyle.Current.TextColor1,
@@ -88,8 +87,8 @@
         };
 
         public static FrameLayout UserMenuItem = new FrameLayout () {
-            Y = Application.GetRealHeight (Application.DesignHeight - 90),
-            Height = Application.GetRealHeight (95),
+            Y = Application.GetRealHeight (Application.DesignHeight - userMenuItemHeight),
+            Height = Application.GetMinRealAverage (userMenuItemHeight+5),
             BackgroundColor = SkinStyle.Current.MainColor
         };
 
@@ -102,14 +101,15 @@
 
         public static Button btnLinkStatus = new Button () {
             Y = Application.GetRealHeight (10),
-            Width = Application.GetRealWidth (131),
-            Height = Application.GetRealHeight (80),
+            Width = Application.GetMinRealAverage (131),
+            Height = Application.GetMinRealAverage (80),
             UnSelectedImagePath = MainPage.WiFiStatus,
         };
 
         #region ---Bottom Button----
         public static Button btnFavorite = new Button () {
             Width = Application.GetRealWidth (160),
+            Height = MainPage.GetDesignHeight (90),
             TextID = R.MyInternationalizationString.Favorite,
             TextColor = SkinStyle.Current.TextColor1,
             SelectedTextColor = SkinStyle.Current.SelectedColor,
@@ -125,6 +125,7 @@
         public static Button btnDevice = new Button () {
             X = Application.GetRealWidth (160),
             Width = Application.GetRealWidth (160),
+            Height = MainPage.GetDesignHeight (90),
             TextID = R.MyInternationalizationString.Category,
             SelectedTextColor = SkinStyle.Current.SelectedColor,
             TextColor = SkinStyle.Current.TextColor1,
@@ -138,6 +139,7 @@
         public static Button btnRoom = new Button () {
             X = Application.GetRealWidth (160 * 2),
             Width = Application.GetRealWidth (160),
+            Height = MainPage.GetDesignHeight (90),
             TextID = R.MyInternationalizationString.Rooms,
             SelectedTextColor = SkinStyle.Current.SelectedColor,
             TextColor = SkinStyle.Current.TextColor1,
@@ -151,6 +153,7 @@
         public static Button btnSetting = new Button () {
             X = Application.GetRealWidth (160 * 3),
             Width = Application.GetRealWidth (160),
+            Height = MainPage.GetDesignHeight (90),
             TextID = R.MyInternationalizationString.Setting,
             SelectedTextColor = SkinStyle.Current.SelectedColor,
             TextColor = SkinStyle.Current.TextColor1,
@@ -256,22 +259,28 @@
                 //鍚庡彴楠岃瘉璐﹀彿
                 System.Threading.Tasks.Task.Run (() => {
                     try {
-                        var requestObj = new LoginObj () { Account = MainPage.LoginUser.AccountString, Password = MainPage.LoginUser.Password, Company = MainPage.SoftSmsType };
-                        var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj);
-                        var revertObj = MainPage.RequestHttps (API.Login, requestJson);
+                        var revertObj = HttpServerRequest.Current.LoginByPassword (MainPage.LoginUser.AccountString, MainPage.LoginUser.Password);
                         if (revertObj != null) {
                             Application.RunOnMainThread (() => {
-                                if (revertObj.StateCode.ToUpper () == "SUCCESS") {
-                                    var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject<UserLoginRes> (revertObj.ResponseData.ToString ());
-                                    MainPage.LoginUser.AllVisionRegisterDevUserNameGuid = revertData.AllVisionRegisterDevUserNameGuid;
+                                if (revertObj.Code == StateCode.SUCCESS) {
+                                    var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject<UserLoginRes> (revertObj.Data.ToString ());
+                                    //MainPage.LoginUser.AllVisionRegisterDevUserNameGuid = revertData.AllVisionRegisterDevUserNameGuid;
+                                    MainPage.LoginUser.LoginTokenString = revertData.headerPrefix + revertData.accessToken;
+                                    MainPage.LoginUser.RefreshToken = revertData.refreshToken;
                                     MainPage.LoginUser.LastTime = DateTime.Now;
                                     MainPage.LoginUser.SaveUserInfo ();
-                                    //2020-01-14 鐧诲綍鎴愬姛鍚庯紝鍒锋柊涓�娆″綋鍓嶄綇瀹呯綉鍏�
-                                    GetNowHomeGatewayAfterLoginSuccess ();
-                                } else if (!string.IsNullOrEmpty (revertObj.StateCode)) {
-                                    MainPage.LoginUser.LastTime = DateTime.Now.AddDays (-30);
-                                    MainPage.LoginUser.SaveUserInfo ();
-                                    new AccountLogin ().Show ();
+                                    //2020-01-14 楠岃瘉璐﹀彿閫氳繃鍚�
+                                    if (!bFromLogin) {
+                                        HttpServerRequest.Current.GetHomeGatewayList ();
+                                    }
+                                } else if (!string.IsNullOrEmpty (revertObj.Code)) {
+                                    if (revertObj.Code != StateCode.NETWORK_ERROR && revertObj.Code != StateCode.DATA_EXCEPTION) {
+                                        MainPage.LoginUser.LastTime = DateTime.Now.AddDays (-30);
+                                        MainPage.LoginUser.SaveUserInfo ();
+                                        //鎻愮ず閿欒鍘熷洜
+                                        IMessageCommon.Current.ShowErrorInfoAlter (revertObj.Code);
+                                        new AccountLogin ().Show ();
+                                    }
                                 }
                             });
                         }
@@ -319,6 +328,8 @@
         }
 
 
+
+
         /// <summary>
         /// 鍔犺浇鐢ㄦ埛鐣岄潰
         /// </summary>
@@ -359,8 +370,8 @@
             //IO.FileUtils.SaveEquipmentMessage (mCurtainModel1, mCurtainModel1.LoopID.ToString ());
             ////var mCurtainModel2 = new CurtainModel () { LoopID = 2, DeviceID = 9, SubnetID = 42, Name = "绐楀笜2" };
             ////IO.FileUtils.SaveEquipmentMessage (mCurtainModel2, mCurtainModel2.LoopID.ToString ());
-            ////var mCurtainModel3 = new CurtainModel () { LoopID = 1, DeviceID = 2, SubnetID = 42, Name = "绐楀笜3" };
-            ////IO.FileUtils.SaveEquipmentMessage (mCurtainModel3, mCurtainModel3.LoopID.ToString ());
+            //var mCurtainModel3 = new CurtainModel () { LoopID = 1, DeviceID = 2, SubnetID = 42, Name = "绐楀笜3" };
+            //IO.FileUtils.SaveEquipmentMessage (mCurtainModel3, mCurtainModel3.LoopID.ToString ());
 
             //var mCurtainRoller = new CurtainRoller () { LoopID = 1, DeviceID = 88, SubnetID = 42, Name = "绐楀笜CurtainRoller" };
             //IO.FileUtils.SaveEquipmentMessage (mCurtainRoller, mCurtainRoller.LoopID.ToString ());
@@ -369,7 +380,7 @@
             //IO.FileUtils.SaveEquipmentMessage (mCurtainTrietex, mCurtainTrietex.LoopID.ToString ());
 
 
-            
+
 
             //var s1 = new LightEnergySocket () { LoopID = 1, DeviceID = 1, SubnetID = 44, Name = "EnergySocket" };
             //IO.FileUtils.SaveEquipmentMessage (s1, s1.LoopID.ToString ());
@@ -413,7 +424,7 @@
             //IO.FileUtils.SaveEquipmentMessage (ud3, "3");
 #endif
             UserHomePage.FrameLayoutMain.AddChidren (UserPageView);
-            //UserHomePage.FrameLayoutMain.AddChidren (LinkStatusTip);
+            UserHomePage.FrameLayoutMain.AddChidren (LinkStatusTip);
 
             UserPageView.AddChidren (FavoritePageView);
             FavoritePageView.AddChidren (FavoriteBodyView);
@@ -541,32 +552,32 @@
 
      
 
-        /// <summary>
-        /// 鐧诲綍鎴愬姛鍚庯紝鏌ヨ鍒锋柊涓�娆″綋鍓嶄綇瀹� 缃戝叧鍒楄〃
-        /// 2020-01-11
-        /// </summary>
-        static void GetNowHomeGatewayAfterLoginSuccess ()
-        {
-            var requestObj3 = new GetSingleHomeGatewayPaggerObj ();
-            requestObj3.ReqDto.LoginAccessToken = MainPage.LoginUser.LoginTokenString;
-            requestObj3.ReqDto.HomeId = UserConfig.Instance.CurrentRegion.Id;
-            requestObj3.ReqDto.PageSetting.Page = 1;
-            requestObj3.ReqDto.PageSetting.PageSize = 10;
-            string urlHead = MainPage.RequestHttpsHost;
-            if (requestObj3.IsOtherAccountCtrl) {
-                urlHead = UserConfig.Instance.MasterAccountRequestBaseUrl;
-                requestObj3.ReqDto.LoginAccessToken = UserConfig.Instance.MasterAccountToken;
-            }
+        ///// <summary>
+        ///// 鐧诲綍鎴愬姛鍚庯紝鏌ヨ鍒锋柊涓�娆″綋鍓嶄綇瀹� 缃戝叧鍒楄〃
+        ///// 2020-01-11
+        ///// </summary>
+        //static void GetNowHomeGatewayAfterLoginSuccess ()
+        //{
+        //    var requestObj3 = new GetSingleHomeGatewayPaggerObj ();
+        //    requestObj3.ReqDto.LoginAccessToken = MainPage.LoginUser.LoginTokenString;
+        //    requestObj3.ReqDto.HomeId = UserConfig.Instance.CurrentRegion.Id;
+        //    requestObj3.ReqDto.PageSetting.Page = 1;
+        //    requestObj3.ReqDto.PageSetting.PageSize = 10;
+        //    string urlHead = MainPage.RequestHttpsHost;
+        //    if (requestObj3.IsOtherAccountCtrl) {
+        //        urlHead = UserConfig.Instance.MasterAccountRequestBaseUrl;
+        //        requestObj3.ReqDto.LoginAccessToken = UserConfig.Instance.MasterAccountToken;
+        //    }
 
-            var requestJson3 = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj3);
-            var revertObj3 = MainPage.RequestHttps (API.GetSingleHomeGatewayPagger, requestJson3, urlHead);
-            if (revertObj3.StateCode.ToUpper () == "SUCCESS") {
-                var infoResult = Newtonsoft.Json.JsonConvert.DeserializeObject<GetGatewayResult> (revertObj3.ResponseData.ToString ());
-                //2020-01-11
-                UserConfig.Instance.SetNowHomeGateways (infoResult.PageData);
+        //    var requestJson3 = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj3);
+        //    var revertObj3 = MainPage.RequestHttps (API.GetSingleHomeGatewayPagger, requestJson3, urlHead);
+        //    if (revertObj3.StateCode.ToUpper () == StateCode.SUCCESS) {
+        //        var infoResult = Newtonsoft.Json.JsonConvert.DeserializeObject<GetGatewayResult> (revertObj3.ResponseData.ToString ());
+        //        //2020-01-11
+        //        UserConfig.Instance.SetNowHomeGateways (infoResult.PageData);
 
-            }
-        }
+        //    }
+        //}
 
     }
 }

--
Gitblit v1.8.0