From acc8caee31c4be90bd38d1af18136b0e84f6fe94 Mon Sep 17 00:00:00 2001
From: wxr <wxr@hdlchina.com.cn>
Date: 星期五, 27 九月 2024 14:01:19 +0800
Subject: [PATCH] Merge branch 'feature/v2.7_迭代' into feature/V2.7_Google

---
 HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs |  138 ++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 128 insertions(+), 10 deletions(-)

diff --git a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs
index 34599ea..53cd5a5 100644
--- a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs
+++ b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs
@@ -1,8 +1,10 @@
 锘縰sing System;
 using System.Collections.Generic;
+using HDL_ON.Common;
 using HDL_ON.DAL.Server;
 using HDL_ON.DriverLayer;
 using HDL_ON.Entity;
+using HDL_ON.UI.CSS;
 using Shared;
 
 namespace HDL_ON.UI
@@ -254,7 +256,89 @@
             }
         }
 
+        void CheckTokenValid()
+        {
+            //Dome妯″紡
+            if (MainPage.NoLoginMode)
+            {
+                return;
+            }
 
+            try
+            {
+                #region 璐﹀彿鐧诲綍鐘舵�侊紙鐧诲綍token鏄惁鏈夋晥锛�
+                if (ApiUtlis.Ins.IsValidToken)
+                {
+                    if (tokenInvalidMsgView == null)
+                    {
+                        tokenInvalidMsgView = new FrameLayout()
+                        {
+                            Y = Application.GetRealHeight(113) - Application.GetRealWidth(24),
+                            Height = Application.GetRealWidth(24),
+                            BackgroundColor = 0xFF69A0F7,
+                        };
+                        topView.AddChidren(tokenInvalidMsgView);
+
+                        Button btnTokenInvalidIcon = new Button()
+                        {
+                            X = Application.GetRealWidth(16),
+                            Gravity = Gravity.CenterVertical,
+                            Width = Application.GetRealWidth(20),
+                            Height = Application.GetRealWidth(20),
+                            UnSelectedImagePath = "Collection/TokenInvalidTipIcon.png"
+                        };
+                        tokenInvalidMsgView.AddChidren(btnTokenInvalidIcon);
+                        var btnTokenInvalidTip = new Button()
+                        {
+                            X = btnTokenInvalidIcon.Right + Application.GetRealWidth(4),
+                            TextAlignment = TextAlignment.CenterLeft,
+                            TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
+                            TextColor = CSS_Color.MainBackgroundColor,
+                            TextID = StringId.TokenInvalidMsg,
+                        };
+                        btnTokenInvalidTip.Width = btnTokenInvalidTip.GetTextWidth() + Application.GetRealWidth(8);
+                        tokenInvalidMsgView.AddChidren(btnTokenInvalidTip);
+                        btnTokenInvalidTip.MouseUpEventHandler = (sender, e) => {
+                            new PublicAssmebly().TipOptionMsg(StringId.Tip, StringId.TokenInvalidTipMsg,StringId.Cancel,StringId.GoLogin, () => {
+                                HDLCommon.Current.Logout();
+                            });
+                        };
+
+                        var btnRight = new Button()
+                        {
+                            X= btnTokenInvalidTip.Right,
+                            Gravity = Gravity.CenterVertical,
+                            Width = Application.GetMinRealAverage(8),
+                            Height = Application.GetMinRealAverage(8),
+                            UnSelectedImagePath = "Public/RightIcon2.png",
+                        };
+
+                        tokenInvalidMsgView.AddChidren(btnRight);
+
+                    }
+                }
+                else
+                {
+                    if (tokenInvalidMsgView != null)
+                    {
+                        if (tokenInvalidMsgView.Parent != null)
+                        {
+                            tokenInvalidMsgView.RemoveAll();
+                            tokenInvalidMsgView.RemoveFromParent();
+                            tokenInvalidMsgView = null;
+                        }
+                    }
+                }
+                #endregion
+                if (bodyView.linkStateMsgView != null){
+                    bodyView.linkStateMsgView.Y = ApiUtlis.Ins.IsValidToken ? Application.GetRealHeight(113) : Application.GetRealHeight(113) - Application.GetRealWidth(24);
+                }
+            }
+            catch (Exception ex)
+            {
+                MainPage.Log("Error", $"HomePage 璐﹀彿鐧诲綍鐘舵�佷俊鎭樉绀哄紓甯�:{ex.StackTrace}");
+            }
+        }
 
         /// <summary>
         /// 鏇存柊杩炴帴鐘舵�佸浘鏍�
@@ -267,17 +351,15 @@
                 return;
             }
 
+            bodyView.linkStateMsgView.Y = ApiUtlis.Ins.IsValidToken ? Application.GetRealHeight(113) : Application.GetRealHeight(113) - Application.GetRealWidth(24);
+
             if (!Control.Ins.GatewayOnline_Local && !Control.Ins.GatewayOnline_Cloud)
             {
-                bodyView.divLinkStateTip.Visible = true;
+                bodyView.linkStateMsgView.Visible = true;
             }
-            //else if ()
-            //{
-            //    bodyView.divLinkStateTip.Visible = true;
-            //}
             else
             {
-                bodyView.divLinkStateTip.Visible = false;
+                bodyView.linkStateMsgView.Visible = false;
             }
         }
 
@@ -297,6 +379,26 @@
                 }catch(Exception ex)
                 {
                     MainPage.Log($"LoadEvent_CheckLinkStatus : {ex.Message}");
+                }
+            });
+        }
+        /// <summary>
+        /// 纭Token鏄惁鏈夋晥
+        /// </summary>
+        public static void LoadEvent_CheckTokenValid()
+        {
+            Application.RunOnMainThread(() =>
+            {
+                try
+                {
+                    if (bodyView != null)
+                    {
+                        bodyView.CheckTokenValid();
+                    }
+                }
+                catch (Exception ex)
+                {
+                    MainPage.Log("Error",$"LoadEvent_CheckTokenValid : {ex.StackTrace}");
                 }
             });
         }
@@ -430,12 +532,28 @@
                                         }
                                     }
                                 }
-                                else if(function.spk == SPK.SensorHelp)
+                                else if (function.spk == SPK.SensorHelp)
                                 {
                                     var tempStatus = function.attributes.Find((sta) => sta.key == FunctionAttributeKey.AlarmStatus);
-                                    if(tempStatus != null)
+                                    if (tempStatus != null)
                                     {
                                         state = tempStatus.curValue.ToString() == "alarm";
+                                    }
+                                }
+                                else if (function.spk == SPK.SensorPir || function.spk == SPK.SensorPirHold)
+                                {
+                                    var tempStatus = function.attributes.Find((sta) => sta.key == "people_status");
+                                    if (tempStatus != null)
+                                    {
+                                        state = tempStatus.curValue.ToString() == "true";
+                                    }
+                                }
+                                else if (function.spk == SPK.SensorDryContact || function.spk == SPK.SensorDryContact2)
+                                {
+                                    var tempStatus = function.attributes.Find((sta) => sta.key == "contact_status");
+                                    if (tempStatus != null)
+                                    {
+                                        state = tempStatus.curValue.ToString() == "open";
                                     }
                                 }
                                 else
@@ -682,7 +800,6 @@
                 d.Add(FunctionAttributeKey.OnOff, curtain.trait_on_off.curValue.ToString());
                 Control.Ins.SendWriteCommand(curtain, d);
             };
-
             btnOpen.MouseUpEventHandler = (sender, e) =>
             {
                 //if (!curtain.isOnline())//绂荤嚎涓嶅厑璁告搷浣�
@@ -696,9 +813,10 @@
                 //    return;
                 //}
                 btnOpen.IsSelected = true;
+                Dictionary<string, string> d = new Dictionary<string, string>();
+
                 curtain.trait_on_off.curValue = "on";
                 curtain.SetAttrState(FunctionAttributeKey.Percent, 100);
-                Dictionary<string, string> d = new Dictionary<string, string>();
                 d.Add(FunctionAttributeKey.OnOff, curtain.trait_on_off.curValue.ToString());
                 Control.Ins.SendWriteCommand(curtain, d);
             };

--
Gitblit v1.8.0