HDL Home App 第二版本 旧平台金堂用 正在使用
hxb
2022-08-30 25429f085093d89d543a0b90e30d0d62d1b7dac9
ZigbeeApp/Shared/Phone/Device/VideoIntercom/VideoMachine.cs
@@ -11,6 +11,9 @@
        public VideoMachine()
        {
        }
        public static TempPassword tempPassword = null;
        public void Show(List<VideoCalss> videoInfosLists)
        {
            TopView view = new TopView();
@@ -40,7 +43,7 @@
                    Width = Application.GetMinRealAverage(81),
                    Height = Application.GetMinRealAverage(81),
                    X = Application.GetRealWidth(58),
                    Y = Application.GetRealHeight(55),
                    Y = Application.GetRealHeight(40),
                    UnSelectedImagePath = "Item/videoIntercom.png",
                };
                fLayout.AddChidren(iconBtn);
@@ -120,7 +123,73 @@
            }
            addQRCodeLayout(middle);
        }
        private void addQRCodeLayout(VerticalRefreshLayout middle)
        {
            //
            var fLayout = new FrameLayout
            {
                Height = Application.GetRealHeight(160),
                BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
            };
            //二维码icon
            var iconBtn = new Button
            {
                Width = Application.GetMinRealAverage(81),
                Height = Application.GetMinRealAverage(81),
                X = Application.GetRealWidth(58),
                Y = Application.GetRealHeight(40),
                UnSelectedImagePath = "Item/QRCode.png",
            };
            fLayout.AddChidren(iconBtn);
            // 名称
            var nameBtn = new Button
            {
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                TextSize = 15,
                Y = Application.GetRealHeight(50),
                X = Application.GetRealWidth(176),
                Height = Application.GetRealHeight(60),
                Width = Application.GetRealWidth(400),
                Text = "二维码/临时密码",
            };
            fLayout.AddChidren(nameBtn);
            //右箭头
            var nextBtn = new Button
            {
                Width = Application.GetMinRealAverage(104),
                Height = Application.GetMinRealAverage(104),
                UnSelectedImagePath = "Item/videoIntercomNext.png",
                X = Application.GetRealWidth(743 + 176),
                Y = Application.GetRealHeight(30),
            };
            fLayout.AddChidren(nextBtn);
            var clickBtn = new Button
            {
                Height = Application.GetRealHeight(160),
            };
            fLayout.AddChidren(clickBtn);
            clickBtn.MouseUpEventHandler += (sen, e) =>
            {
                var qrCode = new TempQRCode();
                UserView.HomePage.Instance.AddChidren(qrCode);
                UserView.HomePage.Instance.PageIndex += 1;
                qrCode.Show();
            };
            middle.AddChidren(fLayout);
        }
        /// <summary>
        /// 判断账号是否支持可视对讲
        /// </summary>
@@ -176,12 +245,14 @@
                catch { }
            }
        }
        /// <summary>
        /// 获取可视对讲列表
        /// </summary>
        static async System.Threading.Tasks.Task<List<VideoCalss>> GetVideoInfoList(CloudsVideo clouds)
        {
            List<VideoCalss> eSVideoInfosList = new List<VideoCalss>();
            tempPassword = new TempPassword();
            var jobject = new JObject();
            jobject.Add("cmtID", clouds.FLCommunityID);
            jobject.Add("unitno", clouds.FLBuildingID);
@@ -225,9 +296,57 @@
                }
                eSVideoInfosList.Add(eSVideoInfo);
            }
            // 初始化tempPassword对象
            tempPassword.CommunityID = clouds.FLCommunityID;
            tempPassword.FromTime = GetCurrentTimeStamp();
            tempPassword.ValidTime = GetTomorrowTimeStamp();
            tempPassword.Unitno = clouds.FLBuildingID;
            tempPassword.Roomno = clouds.FLRoomID;
            tempPassword.Code = getCode();
            tempPassword.NumTimes = "5";
            tempPassword.UserKey = clouds.UserKey;
            tempPassword.SecretKey= clouds.FLSecretKey;
            return eSVideoInfosList;
        }
        /// <summary>
        /// 获取当前时间戳
        /// </summary>
        /// <returns></returns>
        public static string GetCurrentTimeStamp()
        {
            //TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
            //return Convert.ToInt64(ts.TotalSeconds).ToString();
            System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); // 当地时区
            return ((long)(DateTime.Now - startTime).TotalSeconds).ToString(); // 相差秒数
        }
        /// <summary>
        /// 获取当前时间戳
        /// </summary>
        /// <returns></returns>
        public static string GetTomorrowTimeStamp()
        {
            //TimeSpan ts = DateTime.Now.AddDays(1) - new DateTime(1970, 1, 1, 0, 0, 0, 0);
            //return Convert.ToInt64(ts.TotalSeconds).ToString();
            System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); // 当地时区
            return ((long)(DateTime.Now.AddDays(1) - startTime).TotalSeconds).ToString(); // 相差秒数
        }
        private static string getCode()
        {
            Random rand = new Random();
            string code = "";
            for (int ctr = 0; ctr < 6; ctr++)
            {
                code += rand.Next(10).ToString();
            }
            return code;
        }
    }
    public class VideoCalss
    {
        /// <summary>
@@ -252,6 +371,7 @@
        public string RoomName = string.Empty;
    }
    public class CloudsVideo
    {
        /// <summary>
@@ -277,5 +397,11 @@
        public string FLSecretKey = string.Empty;
        /// <summary>
        /// 丰林可视对讲 UserKey
        /// </summary>
        public string UserKey = string.Empty;
    }
}