wxr
2022-08-02 66c72ee19b9e3543537621b8dd25685c9b5c03c4
HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/Iot_BrandFunctionListPage.cs
@@ -8,8 +8,10 @@
{
    public class Iot_BrandFunctionListPage :FrameLayout
    {
        FrameLayout bodyView;
        FrameLayout contentView;
        IntegratedBrand_Iot brand_Iot;
@@ -36,7 +38,7 @@
                page.LoadPage(brand_Iot);
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            }; 
            new TopViewDiv(bodyView, "品牌名称").LoadTopView_3tyIot(action);
            new TopViewDiv(bodyView, brand_Iot.brandName).LoadTopView_3tyIot(action);
            bodyView.BackgroundColor = CSS_Color.MainBackgroundColor;
@@ -65,16 +67,43 @@
            };
            bodyView.AddChidren(btnTipText);
            var contentView = new VerticalRefreshLayout()
            contentView = new FrameLayout()
            {
                Y = Application.GetRealHeight(150),
                Height = Application.GetRealHeight(573),
            };
            bodyView.AddChidren(contentView);
            LoadDeviceFunctionControlZone(contentView);
            var waitPage = new Loading();
            contentView.AddChidren(waitPage);
            waitPage.Start("");
            new System.Threading.Thread(() =>
            {
                try
                {
                    var pack = http.Get3tyIotDeviceFunctionList(brand_Iot.companyId);
                    if (pack != null)
                    {
                        if (pack.Code == StateCode.SUCCESS)
                        {
                            var list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Function>>(pack.Data.ToString());
                            Application.RunOnMainThread(() =>
                            {
                                LoadDeviceFunctionControlZone(list);
                            });
                        }
                    }
                }
                catch { }
                finally
                {
                    Application.RunOnMainThread(() => {
                        waitPage.Hide();
                        waitPage.RemoveFromParent();
                    });
                }
            }) { IsBackground = true }.Start();
        }
@@ -82,26 +111,32 @@
        /// <summary>
        /// 加载设备功能显示区域
        /// </summary>
        void LoadDeviceFunctionControlZone(VerticalRefreshLayout deviceFunctionView)
        void LoadDeviceFunctionControlZone(List<Function> list)
        {
            contentView.RemoveAll();
            if (list.Count == 0)
            {
                NotListTipView();
                return;
            }
            VerticalScrolViewLayout deviceFunctionView = new VerticalScrolViewLayout();
            contentView.AddChidren(deviceFunctionView);
            #region ContextView
            var rowView = new FrameLayout();
            try
            {
                int index = 0;
                var list = new List<Function>();
                list.Add(new Function
                {
                    spk = SPK.AcStandard,
                    name = "空调"
                });
                list.Add(new Function
                {
                    spk = SPK.LightDimming,
                    name = "灯光"
                });
                foreach (var function in list)
                {
                    if(function.homeId != DB_ResidenceData.Instance.CurrentRegion.id && function.homeId != "0")
                    {
                        continue;
                    }
                    if (index % 2 == 0)
                    {
                        rowView = new FrameLayout()
@@ -143,24 +178,14 @@
                    var view = new FrameLayout();
                    deviceFunctionView.AddChidren(view);
                    var btnNoCollectionBg = new Button()
                    {
                        Y = Application.GetRealHeight(20),
                        Gravity = Gravity.CenterHorizontal,
                        Width = Application.GetRealWidth(180),
                        Height = Application.GetRealWidth(180),
                        Text = "没有任何设备"
                    };
                    view.AddChidren(btnNoCollectionBg);
                    var btnNoCollectionTip = new Button()
                    {
                        Height = Application.GetRealHeight(42),
                        Y = btnNoCollectionBg.Bottom,
                        Y = Application.GetRealHeight(100),
                        TextAlignment = TextAlignment.Center,
                        TextColor = CSS_Color.PromptingColor1,
                        TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                        TextID = StringId.TipNoFunctionCollcetion,
                        Text = "没有任何设备"
                    };
                    view.AddChidren(btnNoCollectionTip);
                }
@@ -215,20 +240,25 @@
                    function.collect = !function.collect;
                    if (function.collect)
                    {
                        btnName.IsSelected = btnIcon.IsSelected = btnBg.IsSelected = true;
                        var pack = http.Set3tyIotFunctionToHouse(function.deviceId, DB_ResidenceData.Instance.CurrentRegion.id);
                        var pack = http.Set3tyIotFunctionToHouse(function.deviceId, DB_ResidenceData.Instance.CurrentRegion.id,brand_Iot.companyId);
                        if (pack != null)
                        {
                            if(pack.Code == StateCode.SUCCESS)
                            {
                                btnName.IsSelected = btnIcon.IsSelected = btnBg.IsSelected = true;
                            }
                        }
                    }
                    else
                    {
                        btnName.IsSelected = btnIcon.IsSelected = btnBg.IsSelected = false;
                        var pack = http.Set3tyIotFunctionToHouse(function.deviceId, "0");
                        var pack = http.Set3tyIotFunctionToHouse(function.deviceId, "0", brand_Iot.companyId);
                        if (pack != null)
                        {
                            if (pack.Code == StateCode.SUCCESS)
                            {
                                btnName.IsSelected = btnIcon.IsSelected = btnBg.IsSelected = false;
                            }
                        }
                    }
@@ -242,6 +272,59 @@
        }
        void NotListTipView()
        {
            contentView.RemoveAll();
            var btnTip = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(88),
                Width = Application.GetRealWidth(180),
                Height = Application.GetRealWidth(180),
                UnSelectedImagePath = "TipNot.png",
            };
            contentView.AddChidren(btnTip);
            var btnTipText = new Button()
            {
                Y = Application.GetRealHeight(252),
                Height = Application.GetRealHeight(52),
                TextSize = CSS_FontSize.TextFontSize,
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextAlignment = TextAlignment.Center,
                TextID = StringId.TipNotThirdPartyDevice,
            };
            contentView.AddChidren(btnTipText);
            var btnAdd = new Button()
            {
                Y = Application.GetRealHeight(400),
                Gravity = Gravity.CenterHorizontal,
                Width = Application.GetRealWidth(220),
                Height = Application.GetRealWidth(44),
                BackgroundColor = CSS_Color.MainColor,
                TextAlignment = TextAlignment.Center,
                TextColor = CSS_Color.MainBackgroundColor,
                TextSize = CSS_FontSize.SubheadingFontSize,
                IsBold = true,
                Radius = (uint)Application.GetRealWidth(22),
                BorderColor = 0x00000000,
                BorderWidth = 0,
                Text = "查看设备支持范围"
            };
            contentView.AddChidren(btnAdd);
            btnAdd.MouseUpEventHandler = (sender, e) =>
            {
                //var page = new AddThirdPartyBrandListpage(brandList);
                //MainPage.BasePageView.AddChidren(page);
                //page.LoadPage();
                //MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
        }
        HttpServerRequest http = new HttpServerRequest();