gxc
2020-01-02 00ab3ddb140ba8bb88b5cf572b004a85e1da85e9
ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UnLockMethod.cs
@@ -28,7 +28,6 @@
                            Application.RunOnMainThread(() =>
                            {
                            });
                        }
                    }
@@ -46,17 +45,20 @@
        }
        #region ◆ 变量申明__________________________
        ZigBee.Device.DoorLock doorLock;
        VerticalRefreshLayout bodyView;
        ZigBee.Device.DoorLock doorLock;//当前门锁
        VerticalListRefreshControl bodyView;//刷新View
        Button currentMethod;// 当前选择的方式
        Shared.Phone.UserCenter.MemberInfoRes curAccountObj;
        Shared.Phone.UserCenter.MemberInfoRes curAccountObj;//当前账户
        Button entryStatusPic;
        Button btnPicTip;
        Button btnPicTip1;
        bool isSecondDel;
        FrameLayout blankFrameLayout;
        bool isSecondDel;//是否二次删除
        FrameLayout blankFrameLayout;//空数据显示布局
        #endregion
        /// <summary>
        /// 读取门锁存储的最新数据
        /// </summary>
        void ReadDoorLockUserInfo()
        {
            System.Threading.Tasks.Task.Run(async () =>
@@ -81,6 +83,7 @@
                        // 类型区分 
                        TypeRefresh();
                        CommonPage.Loading.Hide();
                        bodyView.EndHeaderRefreshing();
                    });
                }
            });
@@ -173,8 +176,9 @@
                Y = Application.GetRealHeight(35),
                X = Application.GetRealWidth(812 - 100),
                TextAlignment = TextAlignment.CenterRight,
                TextColor = Shared.Common.ZigbeeColor.Current.XMTopTitleText,
                TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                TextSize = 12,
                IsBold = true,
            };
            midTopFrameLayout.AddChidren(btnAllMethod);
            // 类型区分 
@@ -223,7 +227,7 @@
            this.midFrameLayout.AddChidren(btnLine);
            #endregion
            bodyView = new VerticalRefreshLayout()
            bodyView = new VerticalListRefreshControl(29)
            {
                Y = btnLine.Bottom,
                Height = Application.GetRealHeight(1921 - 184 - 116),
@@ -233,11 +237,13 @@
            {
                bodyView.BeginHeaderRefreshing();
                ReadDoorLockUserInfo();
                bodyView.EndHeaderRefreshing();
            };
            BlankPicUI();
        }
        /// <summary>
        /// 空数据UI显示
        /// </summary>
        void BlankPicUI()
        {
            blankFrameLayout = new FrameLayout
@@ -264,18 +270,19 @@
                Gravity = Gravity.CenterHorizontal,
                Visible = false,
                Y = Application.GetRealHeight(844),
                TextSize = 12,
            };
            blankFrameLayout.AddChidren(btnPicTip);
            btnPicTip1 = new Button
            {
                X = Application.GetRealWidth(397),
                Y = btnPicTip.Bottom,
                Y = Application.GetRealHeight(844 + 49),
                Text = Language.StringByID(R.MyInternationalizationString.NoPasswordInformation1),
                TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                Gravity = Gravity.CenterHorizontal,
                Visible = false,
                BackgroundColor = 0xff00ff00,
                Visible = true,
                TextSize = 12,
            };
            blankFrameLayout.AddChidren(btnPicTip1);
        }
@@ -328,12 +335,7 @@
                btnPicTip.Height = Application.GetRealHeight(0);
                btnPicTip1.Height = Application.GetRealHeight(0);
                blankFrameLayout.Height = Application.GetRealHeight(0);
                var frameLayoutRow = new FrameLayout()
                {
                    Height = Application.GetMinRealAverage(0),
                    BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite,
                };
                bodyView.AddChidren(frameLayoutRow);
                int i = 0;
                foreach (var curUserId in curAccountDoorLockUserList.Keys)
                {
@@ -363,175 +365,46 @@
                    }
                    #region UI
                    var rowFrameLayout = new RowLayout()
                    {
                        Height = Application.GetRealHeight(127 + 23),
                        X = Application.GetRealWidth(58),
                        Y = i * Application.GetRealHeight(150),
                        Width = Application.GetRealWidth(965),
                        LineColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
                        BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite,
                    };
                    frameLayoutRow.AddChidren(rowFrameLayout);
                    var btnPicFrameLayout = new FrameLayout()
                    var rowFrameLayout = new RowLayoutControl(bodyView.rowSpace / 2);
                    rowFrameLayout.BackgroundColor = ZigbeeColor.Current.XMWhite;
                    bodyView.AddChidren(rowFrameLayout);
                    rowFrameLayout.frameTable.UseClickStatu = false;
                    var btnicon = rowFrameLayout.frameTable.AddLeftIcon();
                    btnicon.UnSelectedImagePath = "DoorLock/DoorLockUserPic.png";
                    //上面门锁用户名称一行
                    var memberText = "";
                    if (curAccountObj.UserName == "" || curAccountObj.UserName == null)
                    {
                        Width = Application.GetRealWidth(81),
                        Height = Application.GetRealHeight(81),
                        X = Application.GetRealWidth(40),
                        Y = Application.GetRealHeight(49),
                    };
                    rowFrameLayout.AddChidren(btnPicFrameLayout);
                    var btnPic = new Button()
                        memberText = curAccountObj.Account;
                    }
                    else
                    {
                        Width = Application.GetRealWidth(84),
                        Height = Application.GetRealHeight(84),
                        UnSelectedImagePath = "DoorLock/DoorLockUserPic.png",
                    };
                    btnPicFrameLayout.AddChidren(btnPic);
                        memberText = curAccountObj.UserName;
                    }
                    //成员一行
                    var btnaa = rowFrameLayout.frameTable.AddBottomView(memberText, 800);
                    var btnDoorlockUser = new EditText()
                    {
                        Width = Application.GetRealWidth(1080 - 173),
                        Width = Application.GetRealWidth(800),
                        Height = Application.GetRealHeight(60),
                        X = Application.GetRealWidth(173),
                        Y = Application.GetRealHeight(35),
                        X = btnaa.X,
                        Y = rowFrameLayout.chidrenYaxis + Application.GetRealHeight(12),
                        TextSize = 14,
                        PlaceholderTextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                        TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                        TextAlignment = TextAlignment.CenterLeft,
                    };
                    rowFrameLayout.AddChidren(btnDoorlockUser);
                    var btnMember = new Button()
                    rowFrameLayout.frameTable.AddChidren(btnDoorlockUser, ChidrenBindMode.NotBind);
                    rowFrameLayout.frameTable.AddBottomLine();
                    var btndelete = rowFrameLayout.AddDeleteControl();
                    btndelete.ButtonClickEvent += (sender, e) =>
                    {
                        Width = Application.GetRealWidth(1080 - 173),
                        Height = Application.GetRealHeight(49),
                        X = Application.GetRealWidth(173),
                        Y = Application.GetRealHeight(95),
                        TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                        TextSize = 14,
                        TextAlignment = TextAlignment.CenterLeft,
                    };
                    rowFrameLayout.AddChidren(btnMember);
                    var btnDel = new Button()
                    {
                        Width = Application.GetRealWidth(184),
                        Text = Language.StringByID(R.MyInternationalizationString.DelBindDevice),
                        TextColor = Shared.Common.ZigbeeColor.Current.XMWhite,
                        TextSize = 12,
                        TextAlignment = TextAlignment.Center,
                        BackgroundColor = Shared.Common.ZigbeeColor.Current.XMDel,
                    };
                    rowFrameLayout.AddRightView(btnDel);
                    #endregion
                    #region 数据处理
                    int currentIndex = i;
                    if (currentIndex == curAccountDoorLockUserList.Keys.Count - 1)
                    {
                        rowFrameLayout.LineColor = Shared.Common.ZigbeeColor.Current.XMWhite;
                    }
                    switch (curDoorLockUser.UnlockType)
                    {
                        case 0:
                            if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null)
                            {
                                btnDoorlockUser.Text = curDoorLockUser.UserName;
                            }
                            else
                            {
                                btnDoorlockUser.Text = Language.StringByID(R.MyInternationalizationString.Password) + "ID" + curDoorLockUser.UserID;
                            }
                            break;
                        case 3:
                            if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null)
                            {
                                btnDoorlockUser.Text = curDoorLockUser.UserName;
                            }
                            else
                            {
                                btnDoorlockUser.Text = Language.StringByID(R.MyInternationalizationString.IcCard) + "ID" + curDoorLockUser.UserID;
                            }
                            break;
                        case 15:
                            if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null)
                            {
                                btnDoorlockUser.Text = curDoorLockUser.UserName;
                            }
                            else
                            {
                                btnDoorlockUser.Text = Language.StringByID(R.MyInternationalizationString.Fingerprint) + "ID" + +curDoorLockUser.UserID;
                            }
                            break;
                    }
                    if (curAccountObj.UserName == "" || curAccountObj.UserName == null)
                    {
                        btnMember.Text = curAccountObj.Account;
                    }
                    else
                    {
                        btnMember.Text = curAccountObj.UserName;
                    }
                    Action<Shared.View> action = async (obj) =>
                     {
                         var refreshDoorLockData = new ZigBee.Device.DoorLock.RefreshDoorLockData();
                         if (UserCenterResourse.UserInfo.AuthorityNo != 1)
                         {
                             refreshDoorLockData.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
                             refreshDoorLockData.IsOtherAccountCtrl = true;
                         }
                         if (doorLock.DeviceAddr != null)
                         {
                             refreshDoorLockData.DoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint;
                         }
                         refreshDoorLockData.OpenLockMode = curDoorLockUser.UnlockType;
                         refreshDoorLockData.DoorLockLocalUserId = curDoorLockUser.UserID.ToString();
                         refreshDoorLockData.PrimaryId = curDoorLockUser.PrimaryId;
                         refreshDoorLockData.UserIdRemarks = btnDoorlockUser.Text;
                         var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("DoorLock/UpdateDoorLock", refreshDoorLockData);
                         if (result != null)
                         {
                             if (result.StateCode == "Success")
                             {
                                 if (doorLock.localDoorLockUserList.ContainsKey(curDoorLockUser.UserID))
                                 {
                                     doorLock.localDoorLockUserList.Remove(curDoorLockUser.UserID);
                                     var localDoorLockObj = new ZigBee.Device.DoorLock.LocaDoorLockObj() { };
                                     localDoorLockObj.UserID = curDoorLockUser.UserID;
                                     localDoorLockObj.UnlockType = curDoorLockUser.UnlockType;
                                     localDoorLockObj.EntryTime = curDoorLockUser.EntryTime;
                                     localDoorLockObj.UserName = refreshDoorLockData.UserIdRemarks;
                                     localDoorLockObj.ConnectedAccount = curAccountObj.SubAccountDistributedMark;
                                     doorLock.localDoorLockUserList.Add(curDoorLockUser.UserID, localDoorLockObj);
                                     TypeRefresh();
                                 }
                             }
                             else
                             {
                                 new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.ModigfyFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser);
                             }
                         }
                         else
                         {
                             new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser);
                         }
                     };
                    btnDoorlockUser.EditorEnterAction += action;
                    btnDel.MouseUpEventHandler += (sender, e) =>
                    {
                        var alert = new Alert(Language.StringByID(R.MyInternationalizationString.Tip), Language.StringByID(R.MyInternationalizationString.SureToDelUnlockMethod),
                                                      Language.StringByID(R.MyInternationalizationString.Cancel), Language.StringByID(R.MyInternationalizationString.Confrim));
                        string msg = Language.StringByID(R.MyInternationalizationString.SureToDelUnlockMethod);
                        var alert = new Shared.Phone.UserCenter.ShowMsgControl(ShowMsgType.Confirm, msg, Language.StringByID(R.MyInternationalizationString.DoorlockConfirm));
                        alert.Show();
                        alert.ResultEventHandler += async (sender1, e1) =>
                        {
                            if (e1)
                        //使用确认型弹框时,的回调函数
                        alert.ConfirmClickEvent += async () =>
                            {
                                try
                                {
@@ -641,7 +514,7 @@
                                    }
                                    else
                                    {
                                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnDel);
                                     new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(CommonPage.Instance);
                                    }
                                }
                                catch { }
@@ -649,13 +522,100 @@
                                {
                                    CommonPage.Loading.Hide();
                                }
                            }
                        };
                    };
                    #endregion
                    #region 数据处理
                    int currentIndex = i;
                    if (currentIndex == curAccountDoorLockUserList.Keys.Count - 1)
                    {
                        rowFrameLayout.LineColor = Shared.Common.ZigbeeColor.Current.XMWhite;
                    }
                    switch (curDoorLockUser.UnlockType)
                    {
                        case 0:
                            if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null)
                            {
                                btnDoorlockUser.Text = curDoorLockUser.UserName;
                            }
                            else
                            {
                                btnDoorlockUser.Text = Language.StringByID(R.MyInternationalizationString.Password) + "ID" + curDoorLockUser.UserID;
                            }
                            break;
                        case 3:
                            if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null)
                            {
                                btnDoorlockUser.Text = curDoorLockUser.UserName;
                            }
                            else
                            {
                                btnDoorlockUser.Text = Language.StringByID(R.MyInternationalizationString.IcCard) + "ID" + curDoorLockUser.UserID;
                            }
                            break;
                        case 15:
                            if (curDoorLockUser.UserName != "" && curDoorLockUser.UserName != null)
                            {
                                btnDoorlockUser.Text = curDoorLockUser.UserName;
                            }
                            else
                            {
                                btnDoorlockUser.Text = Language.StringByID(R.MyInternationalizationString.Fingerprint) + "ID" + +curDoorLockUser.UserID;
                            }
                            break;
                    }
                    Action<Shared.View> action = async (obj) =>
                     {
                         var refreshDoorLockData = new ZigBee.Device.DoorLock.RefreshDoorLockData();
                         if (UserCenterResourse.UserInfo.AuthorityNo != 1)
                         {
                             refreshDoorLockData.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
                             refreshDoorLockData.IsOtherAccountCtrl = true;
                         }
                         if (doorLock.DeviceAddr != null)
                         {
                             refreshDoorLockData.DoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint;
                         }
                         refreshDoorLockData.OpenLockMode = curDoorLockUser.UnlockType;
                         refreshDoorLockData.DoorLockLocalUserId = curDoorLockUser.UserID.ToString();
                         refreshDoorLockData.PrimaryId = curDoorLockUser.PrimaryId;
                         refreshDoorLockData.UserIdRemarks = btnDoorlockUser.Text;
                         var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("DoorLock/UpdateDoorLock", refreshDoorLockData);
                         if (result != null)
                         {
                             if (result.StateCode == "Success")
                             {
                                 if (doorLock.localDoorLockUserList.ContainsKey(curDoorLockUser.UserID))
                                 {
                                     doorLock.localDoorLockUserList.Remove(curDoorLockUser.UserID);
                                     var localDoorLockObj = new ZigBee.Device.DoorLock.LocaDoorLockObj() { };
                                     localDoorLockObj.UserID = curDoorLockUser.UserID;
                                     localDoorLockObj.UnlockType = curDoorLockUser.UnlockType;
                                     localDoorLockObj.EntryTime = curDoorLockUser.EntryTime;
                                     localDoorLockObj.UserName = refreshDoorLockData.UserIdRemarks;
                                     localDoorLockObj.ConnectedAccount = curAccountObj.SubAccountDistributedMark;
                                     doorLock.localDoorLockUserList.Add(curDoorLockUser.UserID, localDoorLockObj);
                                     TypeRefresh();
                                 }
                             }
                             else
                             {
                                 new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.ModigfyFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser);
                             }
                         }
                         else
                         {
                             new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnDoorlockUser);
                         }
                     };
                    btnDoorlockUser.EditorEnterAction += action;
                    #endregion
                    i++;
                }
                frameLayoutRow.Height = i * Application.GetRealHeight(150);
            }
        }
@@ -697,6 +657,8 @@
                var rowFrameLayout = new RowLayout()
                {
                    Height = Application.GetRealHeight(150),
                    LineColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
                    X = Application.GetRealWidth(81),
                };
                sidelipVerticalScrolViewLayout.AddChidren(rowFrameLayout);
@@ -704,8 +666,7 @@
                {
                    Width = Application.GetRealWidth(81),
                    Height = Application.GetRealHeight(81),
                    X = Application.GetRealWidth(81),
                    Y = Application.GetRealHeight(55),
                    Y = Application.GetRealHeight(35),
                };
                rowFrameLayout.AddChidren(btnAllMethod);
@@ -713,8 +674,8 @@
                {
                    Width = Application.GetRealWidth(311),
                    Height = Application.GetRealHeight(58),
                    X = Application.GetRealWidth(173),
                    Y = Application.GetRealHeight(69),
                    X = Application.GetRealWidth(92),
                    Y = Application.GetRealHeight(49),
                    TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                    TextSize = 14,
                    TextAlignment = TextAlignment.CenterLeft,
@@ -739,6 +700,7 @@
                        doorLock.ReSave();
                        btnAllMethod.IsSelected = true;
                        oldbuttonText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                        oldbuttonText.IsBold = true;
                        TypeRefresh();
                    }
                    dialog.Close();
@@ -775,6 +737,7 @@
                {
                    btnAllMethod.IsSelected = true;
                    btnMethodText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                    btnMethodText.IsBold = true;
                    oldbutton = btnAllMethod;
                    oldbuttonText = btnMethodText;
                }
@@ -782,6 +745,7 @@
                {
                    btnAllMethod.IsSelected = true;
                    btnMethodText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                    btnMethodText.IsBold = true;
                    oldbutton = btnAllMethod;
                    oldbuttonText = btnMethodText;
                }
@@ -789,6 +753,7 @@
                {
                    btnAllMethod.IsSelected = true;
                    btnMethodText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                    btnMethodText.IsBold = true;
                    oldbutton = btnAllMethod;
                    oldbuttonText = btnMethodText;
                }
@@ -796,6 +761,7 @@
                {
                    btnAllMethod.IsSelected = true;
                    btnMethodText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                    btnMethodText.IsBold = true;
                    oldbutton = btnAllMethod;
                    oldbuttonText = btnMethodText;
                }
@@ -803,6 +769,7 @@
                {
                    btnAllMethod.IsSelected = true;
                    btnMethodText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                    btnMethodText.IsBold = true;
                    oldbutton = btnAllMethod;
                    oldbuttonText = btnMethodText;
                }