1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
using System;
 
namespace Shared.Phone.UserCenter.Member
{
    /// <summary>
    /// 根据账号名添加成员的画面
    /// </summary>
    public class AddMemberByIdForm : UserCenterCommonForm
    {
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        public void ShowForm()
        {
            //设置标题信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddMember));
 
            //初始化中部控件
            this.InitMiddleFrame();
        }
 
        /// <summary>
        /// 初始化中部控件
        /// </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);
 
            var rowlayout = new RowLayout();
            rowlayout.Height = ControlCommonResourse.ListViewRowHeight;
            rowlayout.Y = btnTitle.Bottom;
            bodyFrameLayout.AddChidren(rowlayout);
 
            //Email/手机号
            var txtCode = new RowCenterEditorText();
            txtCode.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uEmailOrPhoneNumber);
            txtCode.PlaceholderTextColor = UserCenterColor.Current.TextTipColor;
            rowlayout.AddChidren(txtCode);
 
            //提示信息
            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);
 
            //下一步
            var btnBottom = new BottomClickButton();
            btnBottom.TextID = R.MyInternationalizationString.uNextway;
            bodyFrameLayout.AddChidren(btnBottom);
            btnBottom.MouseUpEventHandler += ((sender, e) =>
            {
                //成员ID检测
                if (this.CheckAccountId(txtCode.Text.Trim(), txtMsg) == false)
                {
                    return;
                }
                //检索成员信息
                this.SearchMemberInfo(txtCode.Text.Trim(), txtMsg);
            });
        }
 
        /// <summary>
        /// 搜索指定ID的信息
        /// </summary>
        /// <param name="accountId">成员ID</param>
        /// <param name="txtMsg">信息控件</param>
        private async void SearchMemberInfo(string accountId, ViewNormalControl txtMsg)
        {
            //开启进度条
            this.ShowProgressBar();
 
            var pra = new AccountInfoPra();
            pra.Account = accountId;
            string result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountInfo", pra);
            //关闭进度条
            this.CloseProgressBar();
 
            if (result == null)
            {
                return;
            }
 
            var infoResult = Newtonsoft.Json.JsonConvert.DeserializeObject<AccountInfoResult>(result);
            infoResult.Account = accountId;
 
            Application.RunOnMainThread(() =>
            {
                var form = new AddMemberInfoForm();
                this.AddForm(form, infoResult);
            });
        }
 
        /// <summary>
        /// 检查输入的成员ID
        /// </summary>
        /// <param name="accountId"></param>
        /// <param name="txtMsg"></param>
        /// <returns></returns>
        private bool CheckAccountId(string accountId, ViewNormalControl txtMsg)
        {
            if (accountId == string.Empty)
            {
                txtMsg.TextID = R.MyInternationalizationString.uPleaseInputEmailOrPhoneNumber;
                return false;
            }
            return true;
        }
    }
}