HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2019-10-10 2ed75b8b337048e5d75e6d9ec8307633134f02fd
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
using Shared.Common;
using System;
 
namespace Shared.Phone.UserCenter.UserMain
{
    /// <summary>
    /// 个人信息画面
    /// </summary>
    public class UserInformationForm : EditorCommonForm
    {
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        public void ShowForm()
        {
            //因为别的画面会调用这个函数,然后刷新画面
            this.ClearBodyFrame();
 
            //设置头部信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uPersonalInfo));
 
            //初始化上部的信息
            this.InitTopBodyFrame();
 
            //初始化中部的信息
            this.InitMiddleBodyFrame();
 
            //初始化退出账号的FrameLayout
            this.InitLogoutFrameLayout();
        }
 
        #endregion
 
        #region ■ 初始化上段控件_____________________
 
        /// <summary>
        /// 初始化上部的信息
        /// </summary>
        private void InitTopBodyFrame()
        {
            var specialTopFrame = new FrameLayout();
            specialTopFrame.Height = Application.GetRealHeight(340);
            specialTopFrame.BackgroundColor = UserCenterColor.Current.White;
            bodyFrameLayout.AddChidren(specialTopFrame);
 
            //用户图标
            var btnUserIcon = new IconViewControl(251);
            btnUserIcon.Y = Application.GetRealHeight(46);
            btnUserIcon.Gravity = Gravity.CenterHorizontal;
            btnUserIcon.UnSelectedImagePath = UserCenterResourse.UserInfo.UserIconFile;
            specialTopFrame.AddChidren(btnUserIcon);
        }
 
        #endregion
 
        #region ■ 初始化中段控件_____________________
 
        /// <summary>
        /// 初始化中部的信息
        /// </summary>
        private void InitMiddleBodyFrame()
        {
            var frameBack = new FrameLayout();
            frameBack.Y = Application.GetRealHeight(363);
            frameBack.Height = Application.GetRealHeight(1008);
            frameBack.BackgroundColor = UserCenterColor.Current.White;
            bodyFrameLayout.AddChidren(frameBack);
 
            var listMidFrame = new FrameListControl(12);
            listMidFrame.Y = Application.GetRealHeight(11);
            listMidFrame.Height = Application.GetRealHeight(1008 - 11);
            frameBack.AddChidren(listMidFrame);
 
            var rowName = new FrameRowControl(listMidFrame.rowSpace / 2);
            //关闭点击状态
            rowName.UseClickStatu = false;
            listMidFrame.AddChidren(rowName);
            //底线
            rowName.AddBottomLine();
            //名称View
            rowName.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uName), 350);
            //名称输入
            var txtName = new TextInputExControl(700, true);
            txtName.X = bodyFrameLayout.Width - Application.GetRealWidth(700) - ControlCommonResourse.XXLeft;
            txtName.Gravity = Gravity.CenterVertical;
            txtName.TextAlignment = TextAlignment.CenterRight;
            txtName.Text = UserCenterResourse.UserInfo.UserName;
            rowName.AddChidren(txtName, ChidrenBindMode.NotBind);
            txtName.Y += listMidFrame.rowSpace / 2;
            //输入结束事件
            txtName.FinishInputEvent += (() =>
            {
                if (txtName.Text.Trim() == string.Empty)
                {
                    //把名称还原回去
                    txtName.Text = UserCenterResourse.UserInfo.UserName;
                    return;
                }
                //更新用户名
                this.SaveUserName(txtName.Text.Trim());
            });
 
            var rowQrCode = new FrameRowControl(listMidFrame.rowSpace / 2);
            listMidFrame.AddChidren(rowQrCode);
            //底线
            rowQrCode.AddBottomLine();
            //二维码
            rowQrCode.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uQRCode), 350);
            var btnQrCode = rowQrCode.AddMostRightEmptyIcon(92, 92);
            btnQrCode.UnSelectedImagePath = "Item/QRCode.png";
            rowQrCode.ButtonClickEvent += (sender, e) =>
            {
                var form = new QRCodeForm();
                form.AddForm();
            };
 
            var rowEmail = new FrameRowControl(listMidFrame.rowSpace / 2);
            listMidFrame.AddChidren(rowEmail);
            //底线
            rowEmail.AddBottomLine();
            //邮箱View
            rowEmail.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uEmail), 350);
            //添加向右图标
            rowEmail.AddRightArrow();
            //邮箱
            var btnEmail = rowEmail.AddMostRightView(UserCenterResourse.UserInfo.Email, 500);
            if (string.IsNullOrEmpty(UserCenterResourse.UserInfo.Email) == true)
            {
                //未设置,请绑定
                btnEmail.TextID = R.MyInternationalizationString.uNotSettionAndPleaseBind;
            }
            rowEmail.ButtonClickEvent += (sender, e) =>
            {
                if (string.IsNullOrEmpty(UserCenterResourse.UserInfo.Email) == true)
                {
                    var form = new Password.CheckNewEmailForm();
                    form.AddForm();
                }
                else
                {
                    var form = new Password.CheckOldEmailForm();
                    form.AddForm();
                }
            };
 
            var rowPhone = new FrameRowControl(listMidFrame.rowSpace / 2);
            listMidFrame.AddChidren(rowPhone);
            //底线
            rowPhone.AddBottomLine();
            //手机号View
            rowPhone.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uPhone), 350);
            //添加向右图标
            rowPhone.AddRightArrow();
            //手机号
            var btnPhone = rowPhone.AddMostRightView(UserCenterResourse.UserInfo.Phone, 500);
            if (string.IsNullOrEmpty(UserCenterResourse.UserInfo.Phone) == true)
            {
                //未设置,请绑定
                btnPhone.TextID = R.MyInternationalizationString.uNotSettionAndPleaseBind;
            }
            else
            {
                btnPhone.Text = "+" + UserCenterResourse.UserInfo.AreaCode + " " + UserCenterResourse.UserInfo.Phone;
            }
            rowPhone.ButtonClickEvent += (sender, e) =>
            {
                if (string.IsNullOrEmpty(UserCenterResourse.UserInfo.Phone) == true)
                {
                    var form = new Password.CheckNewPhoneForm();
                    form.AddForm();
                }
                else
                {
                    var form = new Password.CheckOldPhoneForm();
                    form.AddForm();
                }
            };
 
          
            var rowOther = new FrameRowControl(listMidFrame.rowSpace / 2);
            listMidFrame.AddChidren(rowOther);
            //第三方账号
            rowOther.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uAuthenticatedOtherPartyAccount), 400);
            //底线
            rowOther.AddBottomLine();
            //添加向右图标
            rowOther.AddRightArrow();
            //微信、QQ
            rowOther.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uWebChatAndQQ), 500);
            rowOther.ButtonClickEvent += (sender, e) =>
            {
                var form = new OtherParty.OtherPartyAccountMenuForm();
                form.AddForm();
            };
 
            var rowSysPsw = new FrameRowControl(listMidFrame.rowSpace / 2);
            listMidFrame.AddChidren(rowSysPsw);
            //添加底线
            rowSysPsw.AddBottomLine();
            //系统密码
            rowSysPsw.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uSystemPassword), 350);
            //添加向右图标
            rowSysPsw.AddRightArrow();
            //去修改
            rowSysPsw.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uGotoEditor), 350);
            rowSysPsw.ButtonClickEvent += (sender, e) =>
            {
                var form = new Password.EditorAccountPasswordForm();
                form.AddForm();
            };
 
            var rowSecond = new FrameRowControl(listMidFrame.rowSpace / 2);
            listMidFrame.AddChidren(rowSecond);
            //二次安全验证
            rowSecond.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uSecondAuthentication), 350);
            //添加向右图标
            rowSecond.AddRightArrow();
            //密码、手势、指纹
            rowSecond.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uPasswordGestureFingerPrint), 400);
            rowSecond.ButtonClickEvent += (sender, e) =>
            {
                var form = new SecondAuthenticationForm();
                form.AddForm();
            };
        }
        #endregion
 
        #region ■ 初始化下段控件_____________________
 
        /// <summary>
        /// 初始化退出账号的FrameLayout
        /// </summary>
        private void InitLogoutFrameLayout()
        {
            var specialFrame = new FrameLayout();
            specialFrame.Height = ControlCommonResourse.ListViewRowHeight;
            specialFrame.Y = Application.GetRealHeight(1394);
            specialFrame.BackgroundColor = UserCenterColor.Current.White;
            bodyFrameLayout.AddChidren(specialFrame);
 
            //退出登陆
            var btnLogout = new NormalClickButton(specialFrame.Width, specialFrame.Height);
            btnLogout.TextID = R.MyInternationalizationString.uLogoutAccount;
            btnLogout.TextColor = 0xff666666;
            btnLogout.BackgroundColor = UserCenterColor.Current.White;
            specialFrame.AddChidren(btnLogout);
 
            btnLogout.ButtonClickEvent += (sender, e) =>
            {
                //确定退出当前账号?
                string msg = Language.StringByID(R.MyInternationalizationString.uLogoutAccountMsg);
                this.ShowMassage(ShowMsgType.Confirm, msg, () =>
                {
                    //退出账号
                    UserCenterLogic.ReLoginAgain(Common.Config.Instance.Account);
                });
            };
        }
 
        #endregion
 
        #region ■ 更新用户名_________________________
 
        /// <summary>
        /// 更新用户名
        /// </summary>
        /// <param name="userName">昵称</param>
        private async void SaveUserName(string userName)
        {
            if (UserCenterResourse.UserInfo.UserName == userName)
            {
                return;
            }
            //打开进度条
            this.ShowProgressBar();
 
            var pra = new SaveUserNamePra();
            pra.UserName = userName;
 
            bool result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/UpdateUserName", false, pra);
            //关闭进度条
            this.CloseProgressBar();
            if (result == false)
            {
                return;
            }
 
            //用户名称修改成功!
            string msg = Language.StringByID(R.MyInternationalizationString.uUserNameSaveSuccess);
            this.ShowMassage(ShowMsgType.Tip, msg);
 
            UserCenterResourse.UserInfo.UserName = userName;
        }
 
        #endregion
 
        #region ■ 界面重新激活事件___________________
 
        /// <summary>
        /// 自身的上层界面关闭后,它自身处于最上层时,触发的事件
        /// </summary>
        public override int FormActionAgainEvent()
        {
            //重新刷新界面
            this.ShowForm();
 
            return 1;
        }
 
        #endregion
    }
}