黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
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
315
316
317
318
319
320
using Shared.Common;
using System;
using System.Collections.Generic;
using System.Text;
 
namespace Shared.Phone.UserCenter.Transfer
{
    /// <summary>
    /// 执行过户操作的界面
    /// </summary>
    public class TransferingResidenceForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 1:移交给用户  2:授权给调试人员
        /// </summary>
        private int TransferDiv = 0;
        /// <summary>
        /// 成员信息
        /// </summary>
        private AccountInfoResult memberResult = null;
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        /// <param name="i_memberResult">账号信息</param>
        /// <param name="i_TransferDiv">1:移交给用户  2:授权给调试人员</param>
        public void ShowForm(AccountInfoResult i_memberResult, int i_TransferDiv)
        {
            this.ScrollEnabled = false;
 
            this.TransferDiv = i_TransferDiv;
            this.memberResult = i_memberResult;
 
            //设置头部信息
            base.SetTitleText(i_TransferDiv == 1
               ? Language.StringByID(R.MyInternationalizationString.HandoverToUser).Replace("{0}", string.Empty)
               : Language.StringByID(R.MyInternationalizationString.AuthorizedToCommissioningPersonnel).Replace("{0}", string.Empty));
 
 
            //初始化中部信息
            this.InitMiddleFrame();
        }
 
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        private void InitMiddleFrame()
        {
            //清空bodyFrame
            this.ClearBodyFrame();
 
            //住宅的图标
            var btnIcon1 = new PicViewControl(268, 268);
            btnIcon1.Y = Application.GetRealHeight(366);
            btnIcon1.X = Application.GetRealWidth(139);
            btnIcon1.UnSelectedImagePath = "Item/TransferOfResidenceIcon.png";
            bodyFrameLayout.AddChidren(btnIcon1);
            //住宅名字  (以中间为基准,左右间距50)
            var btnHouseName = new NormalViewControl(bodyFrameLayout.Width / 2 - Application.GetRealWidth(100), Application.GetRealHeight(110), false);
            btnHouseName.X = Application.GetRealWidth(50);
            btnHouseName.Y = btnIcon1.Bottom + Application.GetRealHeight(23);
            btnHouseName.IsBold = true;
            btnHouseName.IsMoreLines = true;
            btnHouseName.TextAlignment = TextAlignment.Center;
            btnHouseName.TextSize = 16;
            btnHouseName.Text = Config.Instance.Home.Name;
            bodyFrameLayout.AddChidren(btnHouseName);
 
            //头像
            var btnUserIcon = new ImageView();
            btnUserIcon.Height = this.GetPictrueRealSize(268);
            btnUserIcon.Width = this.GetPictrueRealSize(268);
            btnUserIcon.Radius = (uint)this.GetPictrueRealSize(268) / 2;
            if (memberResult.HeadImage != null)
            {
                btnUserIcon.ImageBytes = memberResult.HeadImage;
            }
            else
            {
                btnUserIcon.ImagePath = "Center/Admin.png";
            }
            btnUserIcon.Y = btnIcon1.Y;
            btnUserIcon.X = bodyFrameLayout.Width - Application.GetRealWidth(139) - this.GetPictrueRealSize(268);
            bodyFrameLayout.AddChidren(btnUserIcon);
 
            //昵称  (以中间为基准,左右间距50)
            var btnName = new NormalViewControl(btnHouseName.Width, btnHouseName.Height, false);
            btnName.X = btnHouseName.Right + Application.GetRealWidth(100);
            btnName.Y = btnHouseName.Y;
            btnName.IsBold = true;
            btnName.IsMoreLines = true;
            btnName.TextAlignment = TextAlignment.Center;
            btnName.TextSize = 16;
            btnName.Text = memberResult.MemberName;
            bodyFrameLayout.AddChidren(btnName);
 
            //开启连接的假想动画效果线程
            this.StartConcetionAnimeteThread(btnIcon1.Right + Application.GetRealWidth(49));
 
            //终止
            var btnCancel = new BottomClickButton();
            btnCancel.TextID = R.MyInternationalizationString.uTermination;
            bodyFrameLayout.AddChidren(btnCancel);
            btnCancel.ButtonClickEvent += (sender, e) =>
            {
                this.CloseForm();
            };
 
            //初始化消息控件
            this.InitMsgControl(btnCancel);
 
        }
 
        #endregion
 
        #region ■ 假想动画___________________________
 
        /// <summary>
        /// 开启连接的假想动画效果线程
        /// </summary>
        private void StartConcetionAnimeteThread(int XX)
        {
            //生成点号图样
            int pointXX = XX;
            for (int i = 0; i < 7; i++)
            {
                var btnPoint = new NormalViewControl(14, 8, true);
                btnPoint.Radius = (uint)Application.GetRealHeight(8) / 2;
                btnPoint.BackgroundColor = 0xffd5d5d5;
                btnPoint.Y = Application.GetRealHeight(498);
                btnPoint.X = pointXX;
                bodyFrameLayout.AddChidren(btnPoint);
                pointXX = btnPoint.Right + Application.GetRealWidth(14);
            }
 
            int iconSize = this.GetPictrueRealSize(24);
 
            var listPoint = new List<int>();
            //跳动的间距
            int intSpace = Application.GetRealWidth(14 + 14);
            for (int i = 0; i < 7; i++)
            {
                //X轴+Index*(图标大小+间距)
                listPoint.Add(XX + i * intSpace);
            }
 
            var btnRound = new PicViewControl(iconSize, iconSize, false);
            btnRound.Radius = (uint)iconSize / 2;
            btnRound.BackgroundColor = UserCenterColor.Current.ConcetionRoundColor;
            btnRound.X = listPoint[0];
            btnRound.Y = Application.GetRealHeight(490);
            bodyFrameLayout.AddChidren(btnRound);
 
            HdlThreadLogic.Current.RunThread(() =>
            {
                int index = 1;
                while (this.Parent != null)
                {
                    System.Threading.Thread.Sleep(500);
                    HdlThreadLogic.Current.RunMain(() =>
                    {
                        if (btnRound != null)
                        {
                            btnRound.X = listPoint[index];
                            index++;
                            if (index == listPoint.Count)
                            {
                                index = 0;
                            }
                        }
                    });
                }
            });
        }
 
        #endregion
 
        #region ■ 执行过户___________________________
 
        /// <summary>
        /// 执行过户
        /// </summary>
        private void DoTransferResidence()
        {
            this.ShowProgressBar();
            System.Threading.Thread.Sleep(1500);
 
            var pra2 = new
            {
                RequestVersion = CommonPage.RequestVersion,
                RequestSource = 0,
                LoginAccessToken = Config.Instance.Token,
                HomeId = Config.Instance.Home.Id,
                TargetAccount = this.memberResult.Account
            };
            //☆マーク☆
            //var result = HdlUserCenterLogic.GetResultCodeByRequestHttps("App/SellHome", false, pra2, new List<string> { "NotCheck" });
            //bool success = result.ToLower() == "success";
            bool success = false;
 
            this.CloseProgressBar();
            HdlThreadLogic.Current.RunMain(() =>
            {
                var form = new TransferResidenceResultForm();
                form.AddForm(this.memberResult, success);
                form.FinishEvent += () =>
                {
                    if (success == false)
                    {
                        //重试
                        HdlThreadLogic.Current.RunThread(() =>
                        {
                            //执行过户
                            this.DoTransferResidence();
                        });
                    }
                    else
                    {
                        //成功过户 则切换住宅
                        var listLocalHouse = HdlResidenceLogic.Current.GetAllLocalResidenceListByDirectory();
                        if (listLocalHouse.Count == 1)
                        {
                            //如果只有一个住宅,则过户之后,直接退到登陆界面
                            HdlAccountLogic.Current.ReLoginAgain(Config.Instance.Account);
                            return;
                        }
                        else
                        {
                            HdlThreadLogic.Current.RunThread(() =>
                            {
                                this.ShowProgressBar();
                                //取一个住宅id
                                string houseId = string.Empty;
                                foreach (var myHouse in listLocalHouse)
                                {
                                    houseId = myHouse.Id;
                                    if (houseId != Config.Instance.Home.Id)
                                    {
                                        //随便取一个和当前住宅不相等的ID
                                        break;
                                    }
                                }
                                //当前住宅ID
                                string nowHouseId = Config.Instance.Home.Id;
                                //切换住宅
                                bool result2 = HdlResidenceLogic.Current.SwitchResidence(houseId);
                                //删掉这个文件夹
                                HdlResidenceLogic.Current.DeleteHouseMemmory(nowHouseId);
 
                                if (result2 == true)
                                {
                                    HdlThreadLogic.Current.RunMain(() =>
                                    {
                                        //关闭全部的界面.直到住宅列表界面
                                        HdlFormLogic.Current.CloseAllOpenForm("ResidenceListMainForm");
                                    });
                                }
                                this.CloseProgressBar();
                            });
                           
                        }
                    }
                };
            });
        }
 
        #endregion
 
        #region ■ 一般方法___________________________
 
        /// <summary>
        /// 初始化消息控件
        /// </summary>
        private void InitMsgControl(BottomClickButton btnCancel)
        {
            string msg = this.TransferDiv == 1
                ? Language.StringByID(R.MyInternationalizationString.uHandoverToUserPleaseWaitting)
                : Language.StringByID(R.MyInternationalizationString.uAuthorizingToDebuggingPersonnelPleaseWaitting);
 
            //正在移交给用户,请稍后...         正在授权给调试人员,请稍后...
            var btnMsg = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(60), false);
            btnMsg.Y = Application.GetRealHeight(916);
            btnMsg.TextAlignment = TextAlignment.Center;
            btnMsg.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnMsg.Text = msg;
            bodyFrameLayout.AddChidren(btnMsg);
 
            HdlThreadLogic.Current.RunThread(() =>
            {
                int timeOut = 15;
                while (timeOut >= 0 && this.Parent != null)
                {
                    HdlThreadLogic.Current.RunMain(() =>
                    {
                        btnMsg.Text = msg + timeOut + "s";
                        if (timeOut == 0)
                        {
                            btnMsg.Text = msg;
                        }
                    }, ShowErrorMode.NO);
                    System.Threading.Thread.Sleep(1000);
                    timeOut--;
                }
                if (timeOut <= 0)
                {
                    //执行过户操作
                    this.DoTransferResidence();
                }
            });
        }
 
        #endregion
    }
}