lss
2020-05-20 b5b3f2bf5b04de190acea40790537b9e96649188
ZigbeeApp/Shared/Phone/UserCenter/SmartSound/Forms/SmartSoundListForm.cs
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
using Shared.Common;
using Shared.Phone.UserCenter.Device;
using ZigBee.Device;
@@ -13,7 +15,8 @@
        {
        }
        private List<SmartSound> smartSoundList = null;
        //private List<SmartSoundInfo> smartSoundList = null;
        private SmartSoundInfo smartSoundInfo = null;
        /// <summary>
        /// 列表控件
@@ -24,6 +27,8 @@
        /// </summary>
        private RowLayoutControl oldShowRightMuneRow = null;
        private static string dataString = "";
        #region ■ 初始化_____________________________
@@ -32,7 +37,7 @@
        /// </summary>
        public void ShowForm()
        {
            iniData();//先加载模拟数据
            // iniData();//先加载模拟数据
            this.ScrollEnabled = false;
@@ -58,11 +63,7 @@
                //这里是加载帮组的界面
            };
            string room_id = Common.Config.Instance.Home.Id;//住宅 ID
            string gu_id = Common.Config.Instance.Guid;
            Console.WriteLine("room_id =" + room_id);
            Console.WriteLine("gu_id =" + gu_id);
        }
@@ -70,7 +71,7 @@
        /// 初始化中部控件(外部可以调用)
        /// </summary>
        /// <param name="i_reGetDeviceOnlineStatu">重新获取设备的在线状态</param>
        public void InitMiddleFrame()
        public async void InitMiddleFrame()
        {
            // show出没有设备的图标文字提示
            this.ShowNotDataImage(bodyFrameLayout, new string[] { "还没有音箱哦,", "绑定智能音箱请前往第三方 APP 进行操作" });
@@ -88,8 +89,9 @@
            frame.AddChidren(listView);
            listView.BeginHeaderRefreshingAction += () =>
            {
                HdlThreadLogic.Current.RunThread(() =>
                HdlThreadLogic.Current.RunThread(async () =>
                {
                    await getData();
                    //下拉刷新
                    iniView();
@@ -102,7 +104,23 @@
                });
            };
            this.ShowProgressBar();
            await getData();
            this.CloseProgressBar( ShowReLoadMode.YES);
            iniView();
        }
        private async Task getData()
        {
            SmartSoundInfo.Auth auth = new SmartSoundInfo.Auth();
            auth.HomeID = Common.Config.Instance.Home.Id;
            auth.UserID = Common.Config.Instance.Guid;
            auth.Platform = "";
            dataString = await UserCenterLogic.GetResponseDataByRequestHttps("zigbeespeakerservice/Auth", true, auth);
            smartSoundInfo = (SmartSoundInfo)Newtonsoft.Json.JsonConvert.DeserializeObject(dataString);
        }
        private void iniView()
@@ -110,33 +128,21 @@
            //
            listView.RemoveAll();
            if (smartSoundList == null)
            if (smartSoundInfo==null)
                return;
            for (int i = 0; i < smartSoundList.Count; i++)
            for (int i = 0; i < smartSoundInfo.ResponseData.Data.Count; i++)
            {
                //
                var smartSound = smartSoundList[i];
                var smartSound = smartSoundInfo.ResponseData.Data[i];
                var row = new SoundRowLayout();
                listView.AddChidren(row);
                switch (smartSound.Type)
                if (smartSound.Platform == "Xiaodu")
                {
                    case SmartSound.SMARTSOUND_XIAODU:
                        row.Account = "小度:" + smartSound.UserName;
                        row.ImagePath = "SmartSound/Xiaodu.png";
                        row.Remark = smartSound.Remark;
                        break;
                    case SmartSound.SMARTSOUND_XIAOAI:
                        row.Account = "小爱:" + smartSound.UserName;
                        row.ImagePath = "SmartSound/Xiaoai.png";
                        row.Remark = smartSound.Remark;
                        break;
                    case SmartSound.SMARTSOUND_TIANMAO:
                        row.Account = "天猫精灵:" + smartSound.UserName;
                        row.ImagePath = "SmartSound/Tianmao.png";
                        row.Remark = smartSound.Remark;
                        break;
                }
                row.InitControl();
@@ -148,7 +154,7 @@
                {
                    //
                    int index = (int)(((NormalViewControl)sender).GetTagByKey("index"));
                    var smartSound = smartSoundList[index];
                    var smartSound = smartSoundInfo.ResponseData.Data[index];
                    ShowRenameDialog(row, smartSound);
                };
@@ -177,8 +183,8 @@
        {
            this.ShowMassage(ShowMsgType.Confirm, "接触绑定需要第三方 APP 进行操作", () =>
            {
                //
                smartSoundList.RemoveAt(index);
                // 移除绑定的逻辑
                //smartSoundList.RemoveAt(index);
                listView.RemoveAt(index);
            },"跳转至小度 APP");
        }
@@ -187,7 +193,7 @@
        /// 重命名弹窗
        /// </summary>
        /// <returns></returns>
        private void ShowRenameDialog(SoundRowLayout soundRowLayout, SmartSound smartSound)
        private void ShowRenameDialog(SoundRowLayout soundRowLayout, SmartSoundInfo.SoundInfo smartSound)
        {
            //生成一个弹窗画面
            var dialogForm = new DialogInputControl();
@@ -207,35 +213,6 @@
                smartSound.Remark = textValue;
                soundRowLayout.btnRemark.Text= textValue;
            });
        }
        /// <summary>
        /// 初始化模拟一些数据,用来加载界面用的
        /// </summary>
        private void iniData()
        {
            smartSoundList = new List<SmartSound>();
            // 增加小度音箱
            SmartSound smartSound = new SmartSound();
            smartSound.Remark = "我的音箱";
            smartSound.UserName = "123456@qq.com";
            smartSound.Type = SmartSound.SMARTSOUND_XIAODU;
            smartSoundList.Add(smartSound);
            // 增加小爱音箱
            smartSound = new SmartSound();
            smartSound.Remark = "我的音箱";
            smartSound.UserName = "234567@qq.com";
            smartSound.Type = SmartSound.SMARTSOUND_XIAOAI;
            smartSoundList.Add(smartSound);
            // 增加天猫精灵
            smartSound = new SmartSound();
            smartSound.Remark = "我的音箱";
            smartSound.UserName = "345678@qq.com";
            smartSound.Type = SmartSound.SMARTSOUND_TIANMAO;
            smartSoundList.Add(smartSound);
        }
        #endregion