From dbc23459fdf4e8b74a5f955fbb9fc631b4babc70 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期三, 17 三月 2021 11:56:16 +0800
Subject: [PATCH] Merge branch 'temp-wxr' into WJC

---
 HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/BrandListPage.cs                    |   58 ++++++--------
 HDL-ON_iOS/Resources/Language.ini                                              |    4 +
 HDL-ON_Android/Assets/Language.ini                                             |    5 +
 HDL_ON/Common/R.cs                                                             |    2 
 HDL_ON/DAL/Server/HttpServerRequest.cs                                         |    2 
 HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/DeviceListPage.cs                   |   10 +
 HDL_ON/UI/MainPage.cs                                                          |    2 
 HDL_ON/UI/UI2/4-PersonalCenter/AddDevice/AddMiniRemoteControlDirection1Page.cs |   20 ++++
 HDL_ON/UI/UI2/4-PersonalCenter/AddDevice/AddMiniRemoteControlDirection4Page.cs |   65 ++++++++++++----
 HDL_ON/UI/UI0-Stan/Logic/HdlFormLogic.cs                                       |   26 ++++++
 10 files changed, 139 insertions(+), 55 deletions(-)

diff --git a/HDL-ON_Android/Assets/Language.ini b/HDL-ON_Android/Assets/Language.ini
index a042891..10278a9 100644
--- a/HDL-ON_Android/Assets/Language.ini
+++ b/HDL-ON_Android/Assets/Language.ini
@@ -411,6 +411,7 @@
 426=Air dry time
 427=Disinfect time
 428=Anion Time
+
 429=H
 430=Min
 431=You are currently adding any platform devices to
@@ -418,6 +419,8 @@
 433=Water valve
 434=Time switch
 435=Remote control
+436=Added Devices
+437=Device List
 
 1000=Indoor Humidity
 1001=V-chip
@@ -1178,6 +1181,8 @@
 433=姘撮榾
 434=瀹氭椂寮�鍏�
 435=閬ユ帶鍣�
+436=宸叉坊鍔犲姛鑳�
+437=璁惧鍒楄〃
 
 
 1000=瀹ゅ唴婀垮害
diff --git a/HDL-ON_iOS/Resources/Language.ini b/HDL-ON_iOS/Resources/Language.ini
index 765e310..10278a9 100644
--- a/HDL-ON_iOS/Resources/Language.ini
+++ b/HDL-ON_iOS/Resources/Language.ini
@@ -419,6 +419,8 @@
 433=Water valve
 434=Time switch
 435=Remote control
+436=Added Devices
+437=Device List
 
 1000=Indoor Humidity
 1001=V-chip
@@ -1179,6 +1181,8 @@
 433=姘撮榾
 434=瀹氭椂寮�鍏�
 435=閬ユ帶鍣�
+436=宸叉坊鍔犲姛鑳�
+437=璁惧鍒楄〃
 
 
 1000=瀹ゅ唴婀垮害
diff --git a/HDL_ON/Common/R.cs b/HDL_ON/Common/R.cs
index 3d2d9c9..8a16b35 100644
--- a/HDL_ON/Common/R.cs
+++ b/HDL_ON/Common/R.cs
@@ -4,6 +4,8 @@
 {
     public static class StringId
     {
+        public const int DeviceList = 437;
+        public const int AddedDevice = 436;
         public const int RemoteControl = 435;
         public const int TimeSwitch = 434;
         public const int WaterValve = 433;
diff --git a/HDL_ON/DAL/Server/HttpServerRequest.cs b/HDL_ON/DAL/Server/HttpServerRequest.cs
index 7dd8e14..6720c2b 100644
--- a/HDL_ON/DAL/Server/HttpServerRequest.cs
+++ b/HDL_ON/DAL/Server/HttpServerRequest.cs
@@ -1808,6 +1808,8 @@
             d.Add("categoryType", 1);
             d.Add("productPlatform", productPlatform);
             d.Add("productBrand", productBrand);
+            d.Add("networkConfig", true);
+            
 
             var requestJson = HttpUtil.GetSignRequestJson(d);
             return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_Get3tyBrandDevcieList, requestJson);
diff --git a/HDL_ON/UI/MainPage.cs b/HDL_ON/UI/MainPage.cs
index 1850d6b..227e21f 100644
--- a/HDL_ON/UI/MainPage.cs
+++ b/HDL_ON/UI/MainPage.cs
@@ -192,7 +192,7 @@
                         waitPage.RemoveFromParent();
                         BaseView.RemoveAll();
                         BasePageView = new PageLayout();
-                        BasePageView.ScrollEnabled = false;
+                        BasePageView.ScrollEnabled = true;
                         BasePageView.IsShowPoint = false;
                         BasePageView.PageChange = (sender, e) =>
                         {
diff --git a/HDL_ON/UI/UI0-Stan/Logic/HdlFormLogic.cs b/HDL_ON/UI/UI0-Stan/Logic/HdlFormLogic.cs
index dd40fac..5d9902c 100644
--- a/HDL_ON/UI/UI0-Stan/Logic/HdlFormLogic.cs
+++ b/HDL_ON/UI/UI0-Stan/Logic/HdlFormLogic.cs
@@ -163,6 +163,32 @@
         #region 鈻� 涓�鑸柟娉昣__________________________
 
         /// <summary>
+        /// 鍏抽棴鎵�鏈夋墦寮�浜嗙殑鐣岄潰
+        /// </summary>
+        /// <param name="tagetFrom">鐩爣鐣岄潰,濡傛灉鎸囧畾浜嗙殑璇�,鍒欏叧闂洰鏍囩晫闈笂灞傜殑鍏ㄩ儴鐣岄潰(瀹冭嚜韬笉鍏抽棴)</param>
+        public void CloseAllOpenForm(string tagetFrom = null)
+        {
+            //鏈�鍚庝竴涓槸瑁呰浇涓婚〉鐨勫鍣�,鎵�浠ヤ笉鑳藉垹闄�
+            while (MainPage.BasePageView.ChildrenCount > 1)
+            {
+                var view = MainPage.BasePageView.GetChildren(MainPage.BasePageView.ChildrenCount - 1);
+                if (view is CommonFormBase)
+                {
+                    if (((CommonFormBase)view).FormID == tagetFrom)
+                    {
+                        //鍙叧闂埌鎸囧畾鐩爣鐣岄潰
+                        return;
+                    }
+                    ((CommonFormBase)view).CloseForm();
+                }
+                else
+                {
+                    view.RemoveFromParent();
+                }
+            }
+        }
+
+        /// <summary>
         /// 鑾峰彇褰撳墠姝e湪婵�娲荤殑鐣岄潰
         /// </summary>
         /// <returns></returns>
diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/AddDevice/AddMiniRemoteControlDirection1Page.cs b/HDL_ON/UI/UI2/4-PersonalCenter/AddDevice/AddMiniRemoteControlDirection1Page.cs
index 17c9dc1..f80aa7a 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/AddDevice/AddMiniRemoteControlDirection1Page.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/AddDevice/AddMiniRemoteControlDirection1Page.cs
@@ -13,6 +13,11 @@
     {
         #region 鈻� 鍙橀噺澹版槑___________________________
 
+        /// <summary>
+        /// 娣诲姞璁惧瀹屾垚涔嬪悗鐨勫洖璋冧簨浠�(娓╂�昏浠栬嚜宸辫杩欎釜涓滆タ)
+        /// </summary>
+        public Action<Entity.Function> AddDeviceEvent = null;
+
         #endregion
 
         #region 鈻� 鍒濆鍖朹____________________________
@@ -64,7 +69,7 @@
                     btnNext.CanClick = true;
                     if (result == true)
                     {
-                        this.CloseForm();
+                        //娉ㄦ剰锛氳繖涓晫闈笉鑳藉叧闂�,瀹冪敤鏉ュ洖璋冩俯鎬荤殑鐣岄潰鐢ㄧ殑
                         var form = new AddMiniRemoteControlDirection2Page();
                         //鍒濆wifi鍜屽瘑鐮佷负绌�
                         form.AddForm(string.Empty, string.Empty);
@@ -74,5 +79,18 @@
         }
 
         #endregion
+
+        #region 鈻� 鍏抽棴鐣岄潰___________________________
+
+        /// <summary>
+        /// 鍏抽棴鐣岄潰
+        /// </summary>
+        public override void CloseFormBefore()
+        {
+            this.AddDeviceEvent = null;
+            base.CloseFormBefore();
+        }
+
+        #endregion
     }
 }
diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/AddDevice/AddMiniRemoteControlDirection4Page.cs b/HDL_ON/UI/UI2/4-PersonalCenter/AddDevice/AddMiniRemoteControlDirection4Page.cs
index 60a4762..ef5b20c 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/AddDevice/AddMiniRemoteControlDirection4Page.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/AddDevice/AddMiniRemoteControlDirection4Page.cs
@@ -22,6 +22,10 @@
         /// </summary>
         private string wifiPsw = string.Empty;
         /// <summary>
+        /// 鏂拌澶囩殑sid(鐢ㄦ潵鍖归厤鍝竴涓澶囨槸鏂扮殑)
+        /// </summary>
+        private string newDeviceSid = string.Empty;
+        /// <summary>
         /// 瓒呮椂绾跨▼鏄惁杩愯
         /// </summary>
         private bool timeoutThreadActivity = false;
@@ -176,7 +180,7 @@
         /// <summary>
         /// 鏄剧ず鎴愬姛鐣岄潰
         /// </summary>
-        private void ShowSuccessView()
+        private void ShowSuccessView(Entity.Function newDevice)
         {
             //娓呯┖body
             this.ClearBodyFrame();
@@ -209,19 +213,38 @@
             bodyFrameLayout.AddChidren(btnUse);
             btnUse.ButtonClickEvent += (sender, e) =>
             {
-                //鍏虫帀鐣岄潰
-                this.CloseForm();
-                HdlFormLogic.Current.CloseFormByFormName("AddThirdPartyDeviceMenuListPage");
-                HDL_ON.UI.UI2.PersonalCenter.PirDevice.Method.GetPirDeviceList(this, () =>
+                if (newDevice == null)
                 {
-                    Application.RunOnMainThread(() =>
+                    //鍏抽棴鎺夊叏閮ㄧ殑鐣岄潰,搴旇涓嶄細鍙戠敓
+                    HdlFormLogic.Current.CloseAllOpenForm();
+                    return;
+                }
+                var form = HdlFormLogic.Current.GetFormByName("AddMiniRemoteControlDirection1Page") as AddMiniRemoteControlDirection1Page;
+                if (form.AddDeviceEvent != null)
+                {
+                    //浠h〃杩欎釜鏄敱娓╂�婚偅杈硅皟鐢ㄧ殑,鐩存帴鍥炶皟鍑芥暟
+                    form.AddDeviceEvent.Invoke(newDevice);
+                    //鍏抽棴鎺夎繖涓晫闈�
+                    this.CloseForm();
+                    //鍐嶆妸AddMiniRemoteControlDirection1Page鐣岄潰鍏充簡
+                    HdlFormLogic.Current.CloseFormByFormName("AddMiniRemoteControlDirection1Page");
+                }
+                else
+                {
+                    //浠h〃杩欏苟涓嶆槸鐢辨俯鎬荤殑鐣岄潰璋冪敤鐨�,鍒欏叧闂帀鍏ㄩ儴鐨勭晫闈�
+                    HdlFormLogic.Current.CloseAllOpenForm();
+                    //鐒跺悗鍐嶆妸娓╂�荤殑鐣岄潰new璧锋潵
+                    HDL_ON.UI.UI2.PersonalCenter.PirDevice.Method.GetPirDeviceList(this, () =>
                     {
-                        var page = new UI2.PersonalCenter.PirDevice.PirMain();
-                        MainPage.BasePageView.AddChidren(page);
-                        page.Show(null);
-                        MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+                        Application.RunOnMainThread(() =>
+                        {
+                            var page = new UI2.PersonalCenter.PirDevice.PirMain();
+                            MainPage.BasePageView.AddChidren(page);
+                            page.Show();
+                            MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+                        });
                     });
-                });
+                }
             };
         }
 
@@ -311,11 +334,13 @@
                     //鏁扮粍绫诲瀷
                     if (linqArry.Count == 0) { return false; }
                     strSpk = linqArry[0]["spk"].ToString();
+                    this.newDeviceSid = linqArry[0]["sid"].ToString();
                 }
                 else
                 {
                     //闈炴暟缁勭被鍨�
                     strSpk = json["objects"]["spk"].ToString();
+                    this.newDeviceSid = json["objects"]["sid"].ToString();
                 }
                 if (strSpk != Entity.SPK.IrModule)
                 {
@@ -331,7 +356,7 @@
         /// 鍒锋柊绾㈠瀹濅俊鎭�
         /// </summary>
         /// <param name="successEvent">鎴愬姛鐨勫洖璋冧簨浠�</param>
-        private void RefreshMiniRemoteControlInfo(Action successEvent)
+        private void RefreshMiniRemoteControlInfo(Action<Entity.Function> successEvent)
         {
             var pra = new Dictionary<string, object>();
             pra.Add("homeId", Entity.DB_ResidenceData.Instance.CurrentRegion.RegionID);
@@ -357,14 +382,20 @@
                             continue;
                         }
                         var listDevice = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.DevcieApiPack>(result.Data.ToString());
+                        Entity.Function newDevice = null;
                         foreach (var newFunction in listDevice.list)
                         {
                             //娣诲姞鍒扮紦瀛樺綋涓�
                             newFunction.SaveFunctionFile();
                             Entity.FunctionList.List.IniFunctionList(newFunction.savePath, true);
+                            if (newFunction.sid == this.newDeviceSid)
+                            {
+                                //杩欎釜璁惧鏄柊杩藉姞鐨�
+                                newDevice = newFunction;
+                            }
                         }
                         //璋冪敤鍥炶皟鍑芥暟
-                        successEvent?.Invoke();
+                        successEvent?.Invoke(newDevice);
                         return;
                     }
                     catch
@@ -392,7 +423,7 @@
                 return;
             }
             //鍒锋柊绾㈠瀹濅俊鎭�
-            this.RefreshMiniRemoteControlInfo(() =>
+            this.RefreshMiniRemoteControlInfo((Entity.Function newDevice) =>
             {
                 //绉婚櫎杩欎釜浜嬩欢
                 HdlCloudReceiveLogic.Current.RemoveCloudReceiveEvent("AddMiniRemoteControlDirection4Page");
@@ -400,14 +431,14 @@
                 this.timeoutThreadActivity = false;
 
                 //娣诲姞璁惧鎴愬姛涔嬪悗,澶勭悊涓�浜涗笢瑗�
-                this.DoSomethingAfterAddDeviceSuccess();
+                this.DoSomethingAfterAddDeviceSuccess(newDevice);
             });
         }
 
         /// <summary>
         /// 娣诲姞璁惧鎴愬姛涔嬪悗,澶勭悊涓�浜涗笢瑗�
         /// </summary>
-        private void DoSomethingAfterAddDeviceSuccess()
+        private void DoSomethingAfterAddDeviceSuccess(Entity.Function newDevice)
         {
             HdlThreadLogic.Current.RunThread(() =>
             {
@@ -438,7 +469,7 @@
                         HdlThreadLogic.Current.RunMain(() =>
                         {
                             //鏄剧ず鎴愬姛鐣岄潰
-                            this.ShowSuccessView();
+                            this.ShowSuccessView(newDevice);
                         });
                     }
                 }
diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/BrandListPage.cs b/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/BrandListPage.cs
index ae8c28d..b8f0a39 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/BrandListPage.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/BrandListPage.cs
@@ -21,13 +21,7 @@
 
         public void LoadPage()
         {
-            Action<string,string> action = (s,a) => {
-                var page = new AddThirdPartyBrandListpage(brandList);
-                MainPage.BasePageView.AddChidren(page);
-                page.LoadPage();
-                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
-            };
-            new TopViewDiv(bodyView, Language.StringByID(StringId.FunctionBrand)).LoadTopView_AddIcon("3ty",action);
+            new TopViewDiv(bodyView, Language.StringByID(StringId.FunctionBrand)).LoadTopView();//.LoadTopView_AddIcon("3ty",action);
 
             bodyView.BackgroundColor = CSS_Color.BackgroundColor;
 
@@ -193,32 +187,30 @@
             };
             contentView.AddChidren(btnTipText1);
 
-            var btnAdd = new Button()
-            {
-                Y = Application.GetRealHeight(500),
-                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,
-                TextID = StringId.Add,
-            };
-            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;
-                this.RemoveFromParent();
-            };
+            //var btnAdd = new Button()
+            //{
+            //    Y = Application.GetRealHeight(500),
+            //    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,
+            //    TextID = StringId.Add,
+            //};
+            //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;
+            //    this.RemoveFromParent();
+            //};
 
 
 
diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/DeviceListPage.cs b/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/DeviceListPage.cs
index 5a540a0..00535c1 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/DeviceListPage.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/DeviceListPage.cs
@@ -20,7 +20,13 @@
 
         public void LoadPage()
         {
-            new TopViewDiv(bodyView, Language.StringByID(StringId.AddDevice)).LoadTopView();
+            Action<string,string> action = (s,a) => {
+                var page = new AddDevciePage(brand);
+                MainPage.BasePageView.AddChidren(page);
+                page.LoadPage();
+                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+            };
+            new TopViewDiv(bodyView, Language.StringByID(StringId.Devices)).LoadTopView_AddIcon("3ty",action);
             bodyView.BackgroundColor = CSS_Color.BackgroundColor;
 
             contentView = new VerticalRefreshLayout()
@@ -69,8 +75,6 @@
 
         void LoadRow(List<Function> deviceList)
         {
-            deviceList.Add(new Function() { name ="娴嬭瘯绾㈠瀹�",spk = SPK.IrModule});
-
             contentView.RemoveAll();
             bool isFrist = true;
             foreach (var device in deviceList)

--
Gitblit v1.8.0