From 9a4b76398009cf76c508d61f7e48fb6f5cb7ac2d Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期二, 21 七月 2020 09:46:53 +0800
Subject: [PATCH] 请合并最新多功能面板代码

---
 ZigbeeApp/Shared/Phone/UserCenter/Safety/CoercePswAddContactForm.cs |  256 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 256 insertions(+), 0 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Safety/CoercePswAddContactForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Safety/CoercePswAddContactForm.cs
new file mode 100755
index 0000000..367fc18
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Safety/CoercePswAddContactForm.cs
@@ -0,0 +1,256 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Text;
+using ZigBee.Device;
+
+namespace Shared.Phone.UserCenter.Safety
+{
+    /// <summary>
+    /// 娣诲姞鑳佽揩鑱旂郴浜�
+    /// </summary>
+    public class CoercePswAddContactForm : EditorCommonForm
+    {
+        #region 鈻� 鍙橀噺澹版槑___________________________
+
+        /// <summary>
+        /// 娣诲姞鑱旂郴鏂瑰紡鐨勪簨浠�
+        /// </summary>
+        public Action AddPhoneEvent = null;
+        /// <summary>
+        /// 淇℃伅鎻愮ず鎺т欢
+        /// </summary>
+        private NormalViewControl btnErrorMsg = null;
+        /// <summary>
+        /// 鐢佃瘽鍒楄〃
+        /// </summary>
+        private List<Safeguard.PushTargetInfo> listPhoneData = null;
+
+        #endregion
+
+        #region 鈻� 鍒濆鍖朹____________________________
+
+        /// <summary>
+        /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓)
+        /// </summary>
+        /// <param name="listData"></param>
+        public void ShowForm(List<Safeguard.PushTargetInfo> listData)
+        {
+            this.listPhoneData = listData;
+
+            //璁剧疆澶撮儴淇℃伅
+            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddContactPersion));
+
+            var btnIcon = new MostRightIconControl(69, 69);
+            btnIcon.UnSelectedImagePath = "Item/PhoneBook.png";
+            topFrameLayout.AddChidren(btnIcon);
+            btnIcon.InitControl();
+            btnIcon.ButtonClickEvent += ((sender, e) =>
+            {
+                Contacts.ContactAction = (phoneName, phoneNum) =>
+                {
+                    if (string.IsNullOrEmpty(phoneName) == true)
+                    {
+                        return;
+                    }
+                    //鎵嬫満鍙锋娴�
+                    if (this.CheckPhoneNumber("86", phoneNum, phoneName) == false)
+                    {
+                        return;
+                    }
+                    //淇濆瓨鑱旂郴浜�
+                    this.SaveCoercePhoneNumber("86", phoneNum, phoneName);
+                };
+                Contacts.Open();
+            });
+
+            //鍒濆鍖栦腑閮ㄤ俊鎭�
+            this.InitMiddleFrame();
+
+            //閲嶅啓搴曞眰杩斿洖鎸夐敭浜嬩欢
+            this.BackButtonClickEvent = (sender) =>
+            {
+                this.AddPhoneEvent = null;
+                this.CloseForm();
+            };
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栦腑閮ㄤ俊鎭�
+        /// </summary>
+        private void InitMiddleFrame()
+        {
+            //娓呯┖bodyFrame
+            this.ClearBodyFrame();
+
+            var frameBack = new FrameLayout();
+            frameBack.Height = Application.GetRealHeight(328);
+            frameBack.BackgroundColor = UserCenterColor.Current.White;
+            bodyFrameLayout.AddChidren(frameBack);
+
+            //鍦板尯鐮�
+            var btnArea = new NormalViewControl(127, 60, true);
+            btnArea.X = ControlCommonResourse.XXLeft;
+            btnArea.Y = Application.GetRealHeight(57);
+            btnArea.Text = "+86";
+            btnArea.TextAlignment = TextAlignment.Center;
+            btnArea.TextColor = UserCenterColor.Current.TextGrayColor1;
+            frameBack.AddChidren(btnArea);
+            //鐩墠鍙拡瀵�+86
+            //btnArea.ButtonClickEvent += (sender, e) =>
+            //{
+            //    var form = new AreaCodeSelectForm();
+            //    form.AddForm();
+            //    form.FinishSelectEvent += (code) =>
+            //    {
+            //        btnArea.Text = "+" + code;
+            //    };
+            //};
+            //鐢佃瘽杈撳叆妗�
+            var txtPhone = new TextInputControl(Application.GetRealWidth(634), btnArea.Height, false);
+            txtPhone.X = btnArea.Right + Application.GetRealWidth(35);
+            txtPhone.Y = btnArea.Y;
+            txtPhone.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uPleaseInputPhoneNumber);
+            frameBack.AddChidren(txtPhone);
+            //鍙栨秷鍥炬爣
+            var btnCancel1 = new MostRightIconControl(69, 69);
+            btnCancel1.Gravity = Gravity.Frame;
+            btnCancel1.Y = Application.GetRealHeight(23);
+            btnCancel1.UnSelectedImagePath = "Item/CancelIcon.png";
+            frameBack.AddChidren(btnCancel1);
+            btnCancel1.InitControl();
+            btnCancel1.ButtonClickEvent += (sender, e) =>
+            {
+                txtPhone.Text = string.Empty;
+            };
+            //绾�
+            var btnLine = new NormalViewControl(Application.GetRealWidth(965), ControlCommonResourse.BottomLineHeight, false);
+            btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
+            btnLine.Y = Application.GetRealHeight(150);
+            btnLine.Gravity = Gravity.CenterHorizontal;
+            frameBack.AddChidren(btnLine);
+            //鑱斿姩绾跨殑鐘舵��
+            txtPhone.btnLine = btnLine;
+
+            //澶囨敞
+            var txtNote = new TextInputControl(Application.GetRealWidth(740), txtPhone.Height, false);
+            txtNote.X = ControlCommonResourse.XXLeft;
+            txtNote.Y = btnLine.Bottom + Application.GetRealHeight(60);
+            txtNote.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uPlesaeInputNoteInformation);
+            frameBack.AddChidren(txtNote);
+            //鍙栨秷鍥炬爣
+            var btnCancel2 = new MostRightIconControl(69, 69);
+            btnCancel2.Gravity = Gravity.Frame;
+            btnCancel2.Y = btnLine.Bottom + Application.GetRealHeight(29);
+            btnCancel2.UnSelectedImagePath = "Item/CancelIcon.png";
+            frameBack.AddChidren(btnCancel2);
+            btnCancel2.InitControl();
+            btnCancel2.ButtonClickEvent += (sender, e) =>
+            {
+                txtNote.Text = string.Empty;
+            };
+
+            //淇℃伅鎻愮ず
+            this.btnErrorMsg = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(60), false);
+            btnErrorMsg.X = ControlCommonResourse.XXLeft;
+            btnErrorMsg.Y = frameBack.Bottom + Application.GetRealHeight(29);
+            btnErrorMsg.TextColor = 0xfff75858;
+            btnErrorMsg.TextSize = 12;
+            bodyFrameLayout.AddChidren(btnErrorMsg);
+
+            //瀹屾垚
+            var btnFinish = new BottomClickButton();
+            btnFinish.TextID = R.MyInternationalizationString.uFinish;
+            bodyFrameLayout.AddChidren(btnFinish);
+            btnFinish.ButtonClickEvent += (sender, e) =>
+            {
+                //鎵嬫満鍙锋娴�
+                if (this.CheckPhoneNumber(btnArea.Text.Substring(1), txtPhone.Text.Trim(), txtNote.Text.Trim()) == false)
+                {
+                    return;
+                }
+                //鎵ц淇濆瓨鎵嬫満鎿嶄綔
+                this.SaveCoercePhoneNumber(btnArea.Text.Substring(1), txtPhone.Text.Trim(), txtNote.Text.Trim());
+            };
+        }
+
+        #endregion
+
+        #region 鈻� 娣诲姞鑱旂郴浜烘柟寮廮____________________
+
+        /// <summary>
+        /// 鍙樻洿鑱旂郴浜烘柟寮�
+        /// </summary>
+        /// <param name="areaCode"></param>
+        /// <param name="phoneNum"></param>
+        /// <param name="strNote"></param>
+        private async void SaveCoercePhoneNumber(string areaCode, string phoneNum, string strNote)
+        {
+            var listPhone = new List<string>();
+            listPhone.Add(areaCode + "-" + phoneNum);
+            var listNote = new List<string>();
+            listNote.Add(strNote);
+
+            //鍙樻洿
+            var result = await HdlSafeguardLogic.Current.SetCoercePhoneNumber(listPhone, listNote);
+            if (result == false)
+            {
+                return;
+            }
+            this.CloseForm();
+
+            //璋冪敤鍥炶皟鍑芥暟
+            this.AddPhoneEvent?.Invoke();
+            this.AddPhoneEvent = null;
+        }
+
+        #endregion
+
+        #region 鈻� 涓�鑸柟娉昣__________________________
+
+        /// <summary>
+        /// 妫�娴嬫墜鏈哄彿
+        /// </summary>
+        /// <param name="areaCode"></param>
+        /// <param name="phone"></param>
+        /// <param name="strNote"></param>
+        private bool CheckPhoneNumber(string areaCode, string phone,string strNote)
+        {
+            //杈撳叆涓虹┖
+            if (phone == string.Empty)
+            {
+                //璇疯緭鍏ユ墜鏈哄彿
+                btnErrorMsg.Text = Language.StringByID(R.MyInternationalizationString.uPleaseInputPhoneNumber);
+                return false;
+            }
+            if (strNote == string.Empty)
+            {
+                //璇疯緭鍏ュ娉ㄥ唴瀹�
+                btnErrorMsg.Text = Language.StringByID(R.MyInternationalizationString.uPlesaeInputNoteInformation);
+                return false;
+            }
+
+            //妫�娴嬫墜鏈哄彿鏍煎紡
+            if (HdlCheckLogic.Current.CheckPhoneNumber(phone, areaCode) == false)
+            {
+                //杩欎笉鏄竴涓湁鏁堢殑鎵嬫満鍙�
+                btnErrorMsg.Text = Language.StringByID(R.MyInternationalizationString.uThisIsNotPhoneNumberType);
+                return false;
+            }
+            foreach (var data in this.listPhoneData)
+            {
+                if (data.PushNumber == areaCode + "-" + phone)
+                {
+                    //鑱旂郴鏂瑰紡宸茬粡瀛樺湪
+                    btnErrorMsg.Text = Language.StringByID(R.MyInternationalizationString.uThePhoneNumIsRepeat);
+                    return false;
+                }
+            }
+
+            btnErrorMsg.Text = string.Empty;
+
+            return true;
+        }
+
+        #endregion
+    }
+}

--
Gitblit v1.8.0