黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
ZigbeeApp/Shared/Phone/UserCenter/Member/AddMemberByIdForm.cs
@@ -5,8 +5,14 @@
    /// <summary>
    /// 根据账号名添加成员的画面
    /// </summary>
    public class AddMemberByIdForm : UserCenterCommonForm
    public class AddMemberByIdForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
        #endregion
        #region ■ 初始化_____________________________
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
@@ -24,61 +30,65 @@
        /// </summary>
        private void InitMiddleFrame()
        {
            //请输入需要加入成员的ID
            var btnTitle = new ViewNormalControl(800, true);
            btnTitle.X = ControlCommonResourse.XXLeft;
            btnTitle.TextColor = UserCenterColor.Current.TextGrayColor;
            btnTitle.TextID = R.MyInternationalizationString.uPleaseInputAddMenberID;
            btnTitle.Y = Application.GetRealHeight(40);
            bodyFrameLayout.AddChidren(btnTitle);
            //清空bodyFrame
            this.ClearBodyFrame();
            var rowlayout = new RowLayout();
            rowlayout.Height = ControlCommonResourse.ListViewRowHeight;
            rowlayout.Y = btnTitle.Bottom;
            bodyFrameLayout.AddChidren(rowlayout);
            var frame = new FrameLayout();
            frame.Height = Application.GetRealHeight(248);
            frame.BackgroundColor = UserCenterColor.Current.White;
            bodyFrameLayout.AddChidren(frame);
            //Email/手机号
            var txtCode = new RowCenterEditorText();
            txtCode.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uEmailOrPhoneNumber);
            txtCode.PlaceholderTextColor = UserCenterColor.Current.TextTipColor;
            rowlayout.AddChidren(txtCode);
            var rowAccount = new FrameRowControl();
            rowAccount.UseClickStatu = false;
            rowAccount.Y = Application.GetRealHeight(23);
            frame.AddChidren(rowAccount);
            //底线
            var btnLine = rowAccount.AddBottomLine();
            //提示信息
            var txtMsg = new ViewNormalControl(800, true);
            txtMsg.X = ControlCommonResourse.XXLeft;
            txtMsg.Y = rowlayout.Bottom + Application.GetRealHeight(5);
            txtMsg.TextColor = UserCenterColor.Current.Red;
            bodyFrameLayout.AddChidren(txtMsg);
            //请输入需要加入成员的ID(Email/手机号)
            var txtCode = new TextInputControl(Application.GetRealWidth(900), rowAccount.Height, false);
            txtCode.X = HdlControlResourse.XXLeft;
            txtCode.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uPleaseInputAddMenberID);
            rowAccount.AddChidren(txtCode, ChidrenBindMode.NotBind);
            //联动线的状态
            txtCode.btnLine = btnLine;
            //下一步
            var btnBottom = new BottomClickButton();
            var btnBottom = new BottomClickButton(688);
            btnBottom.Y = Application.GetRealHeight(706);
            btnBottom.TextID = R.MyInternationalizationString.uNextway;
            bodyFrameLayout.AddChidren(btnBottom);
            btnBottom.MouseUpEventHandler += ((sender, e) =>
            btnBottom.ButtonClickEvent += ((sender, e) =>
            {
                //成员ID检测
                if (this.CheckAccountId(txtCode.Text.Trim(), txtMsg) == false)
                if (this.CheckAccountId(txtCode.Text.Trim()) == false)
                {
                    return;
                }
                //检索成员信息
                this.SearchMemberInfo(txtCode.Text.Trim(), txtMsg);
                string strCode = txtCode.Text.Trim();
                HdlThreadLogic.Current.RunThread(() =>
                {
                    this.SearchMemberInfo(strCode);
                });
            });
        }
        #endregion
        #region ■ 搜索ID_____________________________
        /// <summary>
        /// 搜索指定ID的信息
        /// </summary>
        /// <param name="accountId">成员ID</param>
        /// <param name="txtMsg">信息控件</param>
        private async void SearchMemberInfo(string accountId, ViewNormalControl txtMsg)
        private void SearchMemberInfo(string accountId)
        {
            //开启进度条
            this.ShowProgressBar();
            var pra = new AccountInfoPra();
            pra.Account = accountId;
            string result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountInfo", pra);
            var result = HdlMemberLogic.Current.SearchNormalInfoByAccount(accountId);
            //关闭进度条
            this.CloseProgressBar();
@@ -86,14 +96,21 @@
            {
                return;
            }
            if (result.Account == string.Empty)
            {
                HdlThreadLogic.Current.RunMain(() =>
                {
                    //成员不存在
                    var form = new MemberNotEsixtForm();
                    form.AddForm(Language.StringByID(R.MyInternationalizationString.uMemberInformation));
                });
                return;
            }
            var infoResult = Newtonsoft.Json.JsonConvert.DeserializeObject<AccountInfoResult>(result);
            infoResult.Account = accountId;
            Application.RunOnMainThread(() =>
            HdlThreadLogic.Current.RunMain(() =>
            {
                var form = new AddMemberInfoForm();
                this.AddForm(form, infoResult);
                form.AddForm(result);
            });
        }
@@ -101,16 +118,18 @@
        /// 检查输入的成员ID
        /// </summary>
        /// <param name="accountId"></param>
        /// <param name="txtMsg"></param>
        /// <returns></returns>
        private bool CheckAccountId(string accountId, ViewNormalControl txtMsg)
        private bool CheckAccountId(string accountId)
        {
            if (accountId == string.Empty)
            {
                txtMsg.TextID = R.MyInternationalizationString.uPleaseInputEmailOrPhoneNumber;
                //请输入需要加入成员的ID
                this.ShowMassage(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uPleaseInputAddMemberId));
                return false;
            }
            return true;
        }
        #endregion
    }
}