tzy
2021-07-01 536bc8fecd45139bba59d1bafcbe7d4f4e1f4d34
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
using System;
using Shared;
using HDL_ON.UI.CSS;
using HDL_ON.Stan;
using HDL_ON.Entity;
 
namespace HDL_ON.UI
{
    /// <summary>
    /// 管理员权限迁移成员资料确认界面
    /// </summary>
    public class AdminMigrationMemberConfirmPage : EditorCommonForm
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 成员信息
        /// </summary>
        private ResidenceMemberInfo memberInfo = null;
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        /// <param name="i_memberInfo">成员信息</param>
        public void ShowForm(ResidenceMemberInfo i_memberInfo)
        {
            this.memberInfo = i_memberInfo;
 
            //个人资料
            base.SetTitleText(Language.StringByID(StringId.Profile));
 
            //初始化中部信息
            this.InitMiddleFrame();
        }
 
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        private void InitMiddleFrame()
        {
            //清空bodyFrame
            this.ClearBodyFrame();
 
            //上部的白色背景
            var frameBack1 = new FrameLayout();
            frameBack1.BackgroundColor = CSS_Color.MainBackgroundColor;
            frameBack1.Height = Application.GetRealHeight(204);
            bodyFrameLayout.AddChidren(frameBack1);
 
            //头像
            var btnHeadImage = new ImageView();
            btnHeadImage.Y = Application.GetRealHeight(32);
            btnHeadImage.Gravity = Gravity.CenterHorizontal;
            btnHeadImage.Width = Application.GetRealWidth(84);
            btnHeadImage.Height = Application.GetRealWidth(84);
            btnHeadImage.Radius = (uint)Application.GetRealWidth(42);
            btnHeadImage.ImagePath = "LoginIcon/2.png";
            frameBack1.AddChidren(btnHeadImage);
 
            //昵称
            var btnName = new NormalViewControl(frameBack1.Width - HdlControlResourse.XXLeft * 2, Application.GetRealHeight(24), false);
            btnName.Y = btnHeadImage.Bottom + Application.GetRealHeight(11);
            btnName.Gravity = Gravity.CenterHorizontal;
            btnName.IsBold = true;
            btnName.TextSize = CSS_FontSize.SubheadingFontSize;
            btnName.TextColor = CSS_Color.FirstLevelTitleColor;
            btnName.Text = string.IsNullOrEmpty(memberInfo.nickName) == true ? memberInfo.memberName : memberInfo.nickName;
            btnName.TextAlignment = TextAlignment.Center;
            frameBack1.AddChidren(btnName);
 
            //账号
            var btnAccount = new NormalViewControl(frameBack1.Width - HdlControlResourse.XXLeft * 2, Application.GetRealHeight(16), false);
            btnAccount.Y = btnName.Bottom + Application.GetRealHeight(7);
            btnAccount.Gravity = Gravity.CenterHorizontal;
            btnAccount.TextSize = CSS_FontSize.PromptFontSize_FirstLevel;
            btnAccount.TextAlignment = TextAlignment.Center;
            btnAccount.Text = memberInfo.Account;
            frameBack1.AddChidren(btnAccount);
 
            //确认的白色背景
            var frameBack2 = new FrameLayout();
            frameBack2.Y = frameBack1.Bottom + Application.GetRealHeight(8);
            frameBack2.Height = Application.GetRealHeight(50);
            frameBack2.BackgroundColor = CSS_Color.MainBackgroundColor;
            bodyFrameLayout.AddChidren(frameBack2);
            //确认转移
            var btnConform = new NormalViewControl(200, 24, true);
            btnConform.Gravity = Gravity.Center;
            btnConform.TextSize = CSS_FontSize.SubheadingFontSize;
            btnConform.TextAlignment = TextAlignment.Center;
            btnConform.TextColor = CSS_Color.MainColor;
            btnConform.TextID = StringId.ConfirmTransfer2;
            frameBack2.AddChidren(btnConform);
            btnConform.ButtonClickEvent += (sender, e) =>
            {
                //如果设置有安全验证,则需要验证
                HdlCheckLogic.Current.CheckUnlockSecurity(true, (div) =>
                {
                    //如果没有设置有安全验证
                    if (div == 0)
                    {
                        //确认转移{0}的管理员权限给账号{1}
                        string msg = Language.StringByID(StringId.TransferreConfirmMsg3).Replace("{0}", DB_ResidenceData.Instance.CurrentRegion.homeName);
                        msg = msg.Replace("{1}", btnName.Text);
                        HdlMessageLogic.Current.ShowMassage(ShowMsgType.Confirm, msg, () =>
                        {
                            //执行迁移管理员权限
                            this.DoAdminAuthorityMigration();
                        });
                    }
                    else
                    {
                        //执行迁移管理员权限
                        this.DoAdminAuthorityMigration();
                    }
                });
            };
 
            HdlThreadLogic.Current.RunThread(() =>
            {
                //用线程去下载头像
                var headImageBytes = ImageUtlis.Current.DownHeadImageByImageKey(this.memberInfo.memberHeadIcon, true);
                if (headImageBytes != null && headImageBytes.Length > 0)
                {
                    HdlThreadLogic.Current.RunMain(() =>
                    {
                        btnHeadImage.ImageBytes = headImageBytes;
                    }, ShowErrorMode.NO);
                }
            });
        }
 
        #endregion
 
        #region ■ 执行迁移管理员权限_________________
 
        /// <summary>
        /// 执行迁移管理员权限
        /// </summary>
        private void DoAdminAuthorityMigration()
        {
            this.ShowProgressBar();
            HdlThreadLogic.Current.RunThread(() =>
            {
                //瞎玩的一个特效而已
                System.Threading.Thread.Sleep(1000);
                //执行权限迁移
                var result = new DAL.Server.HttpServerRequest().AdminAuthorityMigration(this.memberInfo.childAccountId);
                this.CloseProgressBar();
 
                HdlThreadLogic.Current.RunMain(() =>
                {
                    var form = new AdminMigrationResultPage();
                    form.AddForm(result);
 
                    form.FinishEvent += () =>
                    {
                        if (result == false)
                        {
                            //重试
                            this.DoAdminAuthorityMigration();
                        }
                        else
                        {
                            //成功 -> 刷新App缓存及界面
                            this.RefreshAppMemoryAndForm();
                        }
                    };
                });
            });
        }
 
        /// <summary>
        /// 刷新App缓存及界面
        /// </summary>
        private void RefreshAppMemoryAndForm()
        {
            //刷新缓存(注意,里面既有ui,也有http,也有转圈的那个东西)
            Common.ApiUtlis.Ins.DownloadData();
 
            HdlThreadLogic.Current.RunThread(() =>
            {
                while (Common.ApiUtlis.Ins.DownloadDataComplete == false)
                {
                    //等待DownloadData函数结束
                    System.Threading.Thread.Sleep(300);
                }
                HdlThreadLogic.Current.RunMain(() =>
                {
                    //关闭所有界面
                    HdlFormLogic.Current.CloseAllOpenForm();
                    //获取主页的那个容器
                    var userPage = MainPage.BasePageView.GetChildren(MainPage.BasePageView.ChildrenCount - 1) as UserPage;
                    if (userPage != null)
                    {
                        //刷新个人中心界面
                        MainPage.CurPageIndex = 1;
                        userPage.ChoosePersonalCenter();
                    }
                });
            });
        }
 
        #endregion
    }
}