wxr
2024-09-24 691dbe24f5724f153e07947c7b75bdfea5f0b6d5
HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs
@@ -1,8 +1,10 @@
using 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,87 @@
            }
        }
        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
                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,13 +349,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
            {
                bodyView.divLinkStateTip.Visible = false;
                bodyView.linkStateMsgView.Visible = false;
            }
        }
@@ -296,6 +380,26 @@
                }
            });
        }
        /// <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}");
                }
            });
        }
        /// <summary>
        /// 加载功能收藏按钮事件