wxr
2024-04-11 9802cf8c8ad9f392c5c5342a352a17efeef55fc9
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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
using System;
using Shared;
using HDL_ON.UI.CSS;
using Xamarin.Essentials;
using HDL_ON.DAL.Server;
 
namespace HDL_ON.UI
{
    public class CancelAccountPage : FrameLayout
    {
        /// <summary>
        /// 
        /// </summary>
        FrameLayout bodyView;
 
        /// <summary>
        /// 
        /// </summary>
        public CancelAccountPage()
        {
            bodyView = this;
            BackgroundColor = CSS_Color.MainBackgroundColor;
        }
 
        /// <summary>
        /// 
        /// </summary>
        public void LoadPage() {
            var loading = new Loading();
            this.AddChidren(loading);
            loading.Start("");
            new System.Threading.Thread(() => {
                try
                {
                    var pack = new HttpServerRequest().GetUnregisterModel();
                    if (pack.Code == StateCode.SUCCESS)
                    {
                        var data = Newtonsoft.Json.JsonConvert.DeserializeObject<UMode>(pack.Data.ToString());
                        Application.RunOnMainThread(() =>
                        {
                            if (data != null)
                            {
                                if (data.model == "APP")
                                {
                                    InitView_PreRelease();
                                }
                                else
                                {
                                    InitView_Release();
                                }
                            }
                            else
                            {
                                InitView_PreRelease();
                            }
                        });
                    }
                    else
                    {
                        Application.RunOnMainThread(() =>
                        {
                            InitView_PreRelease();
                        });
                    }
                }
                catch
                {
                    Application.RunOnMainThread(() =>
                    {
                        InitView_PreRelease();
                    });
                }
                finally
                {
                    Application.RunOnMainThread(() =>
                    {
                        if (loading != null)
                        {
                            loading.Hide();
                            loading.RemoveFromParent();
                            loading = null;
                        }
                    });
                }
            }) { IsBackground = true }.Start();
        }
 
        public void InitView_PreRelease()
        {
            new TopViewDiv(bodyView, Language.StringByID(StringId.CancelAccount)).LoadTopView(CSS_Color.MainBackgroundColor);
            bodyView.BackgroundColor = CSS_Color.BackgroundColor;
 
            var textView = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(64 + 16),
                Height = Application.GetRealHeight(90),
                Width = Application.GetRealWidth(343),
                Padding = new Padding(Application.GetRealWidth(16), Application.GetRealWidth(16), Application.GetRealWidth(16), Application.GetRealWidth(16)),
                IsMoreLines = true,
                TextSize = CSS_FontSize.TextFontSize,
                TextAlignment = TextAlignment.TopLeft,
                TextColor = CSS_Color.FirstLevelTitleColor,
                Radius = (uint)Application.GetRealHeight(14),
                BackgroundColor = 0x174484F4,
            };
 
            if (Language.CurrentLanguage == "Chinese")
            {
                textView.Text = "*注销账户是不可恢复的操作,注销账户之后,您App所有账户数据(包括昵称、头像、二维码照片等)都会被删除,且无法再找回。";
            }
            else
            {
                textView.Text = "*Account cancellation is an irreversible operation. After account cancellation, all account data (including nickname, avatar, QR code photo, etc.) of your app will be deleted and cannot be retrieved.";
            }
            bodyView.AddChidren(textView);
 
 
            #region 账号填写
            var accountView = new FrameLayout()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(132 + 50),
                Width = Application.GetRealWidth(343),
                Height = Application.GetRealHeight(50),
                BackgroundColor = CSS_Color.MainBackgroundColor,
                Radius = (uint)Application.GetRealHeight(25),
            };
            bodyView.AddChidren(accountView);
 
            var etAccount = new EditText()
            {
                X = Application.GetRealWidth(58),
                Width = Application.GetRealWidth(343 - 68),
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.TextFontSize,
                PlaceholderTextColor = CSS_Color.PromptingColor1,
                PlaceholderText = UserInfo.Current.AccountString,// Language.StringByID(StringId.PlsEntryPhoneNumber),
                TextAlignment = TextAlignment.CenterLeft,
                Enable = false
            };
            accountView.AddChidren(etAccount);
 
            var btnAccountIcon = new Button()
            {
                X = Application.GetRealWidth(26),
                Gravity = Gravity.CenterVertical,
                Width = Application.GetMinRealAverage(20),
                Height = Application.GetMinRealAverage(20),
                UnSelectedImagePath = "LoginIcon/AccountIcon.png",
            };
            accountView.AddChidren(btnAccountIcon);
 
            #endregion
 
            #region 密码填写
            var passwordView = new FrameLayout()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(211 + 40),
                Width = Application.GetRealWidth(343),
                Height = Application.GetRealHeight(50),
                Radius = (uint)Application.GetRealHeight(25),
                BackgroundColor = CSS_Color.MainBackgroundColor,
            };
            bodyView.AddChidren(passwordView);
 
 
            var btnPasswordIcon = new Button()
            {
                X = Application.GetRealWidth(26),
                Gravity = Gravity.CenterVertical,
                Width = Application.GetMinRealAverage(20),
                Height = Application.GetMinRealAverage(20),
                UnSelectedImagePath = "LoginIcon/PasswordIcon.png",
            };
            passwordView.AddChidren(btnPasswordIcon);
 
            var etPassword = new EditText()
            {
                X = Application.GetRealWidth(58),
                Width = Application.GetRealWidth(343 - 68),
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.TextFontSize,
                PlaceholderTextColor = CSS_Color.PromptingColor1,
                PlaceholderText = Language.StringByID(StringId.PlsEntryPassword),
                SecureTextEntry = true,
                TextAlignment = TextAlignment.CenterLeft,
            };
            passwordView.AddChidren(etPassword);
 
 
            #endregion
 
 
 
            var btnLogin = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(353),
                Width = Application.GetRealWidth(220),
                Height = Application.GetRealWidth(44),
                Radius = (uint)Application.GetRealWidth(22),
                SelectedBackgroundColor = CSS_Color.MainColor,
                BackgroundColor = CSS_Color.PromptingColor1,
                TextID = StringId.Cancellation,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextColor = CSS_Color.MainBackgroundColor,
                TextAlignment = TextAlignment.Center,
            };
            bodyView.AddChidren(btnLogin);
 
            etPassword.TextChangeEventHandler += (sender, e) =>
            {
                if ( etPassword.Text.Trim().Length > 0)
                {
                    btnLogin.IsSelected = true;
                }
                else
                {
                    btnLogin.IsSelected = false;
                }
            };
 
            btnLogin.MouseUpEventHandler = (sender,e) =>{
                if (btnLogin.IsSelected)
                {
                    var tipMsg = "*您当前正在注销账户,注销完成后,您的所有数据均会被删除,请谨慎操作。";
                    if(Language.CurrentLanguage!= "Chinese")
                    {
                        tipMsg = "*You are currently canceling your account. After completing the cancellation, all your data will be deleted.Please operate with caution.";
                    }
                    Action action = () => {
                        var loading = new Loading();
                        this.AddChidren(loading);
                        loading.Start("");
                        var pwd = etPassword.Text.Trim();
                        new System.Threading.Thread(() => {
                            try
                            {
                                var pack = new HttpServerRequest().Unregister(pwd);
                                Application.RunOnMainThread(() =>
                                {
                                    if (pack.Code == StateCode.SUCCESS)
                                    {
                                        //Action okAction = () =>
                                        //{
                                            HDLCommon.Current.Logout();
                                        //};
                                        //new ConfirmDialog().ShowDialog(StringId.Tip, StringId.IfConfirmLogout, okAction);
                                    }
                                    else
                                    {
                                        var tip = new Tip()
                                        {
                            MaxWidth = Application.GetRealWidth(300),
                                            Text = pack.message,
                                            CloseTime = 3,
                                            Direction = AMPopTipDirection.None
                                        };
                                        tip.Show(bodyView);
                                    }
                                });
                            }
                            catch
                            {
                            }
                            finally
                            {
                                Application.RunOnMainThread(() =>
                                {
                                    if (loading != null)
                                    {
                                        loading.Hide();
                                        loading.RemoveFromParent();
                                        loading = null;
                                    }
                                });
                            }
                        })
                        { IsBackground = true }.Start();
 
 
                    };
                    new PublicAssmebly().TipOptionMsg(StringId.CancelAccount, tipMsg, action, 20);
 
                }
            };
 
        }
        public void InitView_Release()
        {
            new TopViewDiv(bodyView, Language.StringByID(StringId.CancelAccount)).LoadTopView();
 
            var textView = new Button()
            {
                Y = Application.GetRealHeight(64),
                Height = Application.GetRealHeight(150),
                Padding = new Padding( Application.GetRealWidth(16), Application.GetRealWidth(16), Application.GetRealWidth(16), Application.GetRealWidth(16)),
                IsMoreLines = true,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextAlignment = TextAlignment.TopLeft,
                TextColor = CSS_Color.FirstLevelTitleColor,
            };
 
            if(Language.CurrentLanguage == "Chinese")
            {
                textView.Text = "您可通过电话专线与电子邮件的形式向我们申请注销账户,我们收到您的申请后,会第一时间安排工程人员对您App应用账户数据、以及智能家居智能硬件本地数据全部删除!";
            }
            else
            {
                textView.Text = "You can apply to us for cancellation of your account through special telephone line and e-mail. After receiving your application, we will arrange engineers to delete all your app account data and local data of smart home smart hardware at the first time!";
            }
            bodyView.AddChidren(textView);
 
            #region 投诉联系
            FrameLayout phoneRow = new FrameLayout()
            {
                Y = Application.GetRealHeight(214),
                Height = Application.GetRealWidth(50),
            };
            bodyView.AddChidren(phoneRow);
 
            Button btnPhoneTitle = new Button()
            {
                X = Application.GetRealWidth(16),
                Width = Application.GetRealWidth(48),
                TextID = StringId.Telephone,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = CSS_Color.FirstLevelTitleColor,
            };
            phoneRow.AddChidren(btnPhoneTitle);
            if (Language.CurrentLanguage == "English")
            {
                btnPhoneTitle.Text = "Tel.:";
            }
 
            Button btnPhoneText = new Button()
            {
                X = btnPhoneTitle.Right,
                Width = Application.GetRealWidth(266),
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = CSS_FontSize.TextFontSize,
                TextColor = CSS_Color.FirstLevelTitleColor,
                Text = "400 855 8535",
            };
            phoneRow.AddChidren(btnPhoneText);
            /// <summary>
            /// 前进图标
            /// </summary>
            var btnImage = new Button()
            {
                X = Application.GetRealWidth(343),
                Gravity = Gravity.CenterVertical,
                Width = Application.GetRealWidth(16),
                Height = Application.GetRealWidth(16),
                UnSelectedImagePath = "Public/Right.png",
            };
            phoneRow.AddChidren(btnImage);
            phoneRow.AddChidren(new Button() { X = Application.GetRealWidth(16), Y = Application.GetRealWidth(49), Height = Application.GetRealHeight(1), BackgroundColor = CSS_Color.DividingLineColor });
 
            EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
            {
                PhoneDialer.Open(Constant.SUPPORT_TELEPHONENUMBER);
            };
 
            phoneRow.MouseUpEventHandler = eventHandler;
            btnPhoneText.MouseUpEventHandler = eventHandler;
            btnImage.MouseUpEventHandler = eventHandler;
            #endregion
 
            #region 联系邮箱
            FrameLayout emailRow = new FrameLayout()
            {
                Y = phoneRow.Bottom,
                Height = Application.GetRealWidth(54),
            };
            bodyView.AddChidren(emailRow);
 
            Button btnEmailTitle = new Button()
            {
                X = Application.GetRealWidth(16),
                Width = Application.GetRealWidth(48),
                TextID = StringId.Email_,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = CSS_Color.FirstLevelTitleColor,
            };
            emailRow.AddChidren(btnEmailTitle);
 
            Button btnEmailText = new Button()
            {
                X = btnEmailTitle.Right,
                Y = Application.GetRealWidth(8),
                Height = Application.GetRealWidth(20),
                Width = Application.GetRealWidth(266),
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = CSS_FontSize.TextFontSize,
                TextColor = CSS_Color.FirstLevelTitleColor,
                Text = Constant.SUPPORT_EMAIL,
            };
            emailRow.AddChidren(btnEmailText);
 
            Button btnEmailTipText = new Button()
            {
                X = btnEmailTitle.Right,
                Y = btnEmailText.Bottom + Application.GetRealWidth(4),
                Height = Application.GetRealWidth(25),
                Width = Application.GetRealWidth(266),
                TextAlignment = TextAlignment.TopLeft,
                TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
                TextColor = CSS_Color.PromptingColor1,
                TextID = StringId.WillGivePriorityToTheTreatmen,
            };
            emailRow.AddChidren(btnEmailTipText);
 
            if (Language.CurrentLanguage == "English")
            {
                btnEmailTitle.Width = Application.GetRealWidth(80);
                emailRow.Height = Application.GetRealWidth(65);
                btnEmailTipText.IsMoreLines = true;
            }
 
            /// <summary>
            /// 前进图标
            /// </summary>
            var btnImage2 = new Button()
            {
                X = Application.GetRealWidth(343),
                Gravity = Gravity.CenterVertical,
                Width = Application.GetRealWidth(16),
                Height = Application.GetRealWidth(16),
                UnSelectedImagePath = "Public/Right.png",
            };
            emailRow.AddChidren(btnImage2);
 
            emailRow.AddChidren(new Button() { X = Application.GetRealWidth(16), Y = emailRow.Height - Application.GetRealHeight(1), Height = Application.GetRealHeight(1), BackgroundColor = CSS_Color.DividingLineColor });
 
            EventHandler<MouseEventArgs> eventHandler2 = (sender, e) =>
            {
                CopyToClipboard(Constant.SUPPORT_EMAIL);
            };
 
            emailRow.MouseUpEventHandler = eventHandler2;
            btnEmailText.MouseUpEventHandler = eventHandler2;
            btnImage2.MouseUpEventHandler = eventHandler2;
            #endregion
        }
 
 
 
        /// <summary>
        /// 复制到剪切板
        /// </summary>
        /// <param name="text"></param>
        void CopyToClipboard(string text)
        {
            Clipboard.SetTextAsync(text);
            Utlis.ShowTip(text + "\n" + Language.StringByID(StringId.CopySuccess));
        }
 
 
        bool isPublishingMode()
        {
            DAL.Server.HttpServerRequest http = new DAL.Server.HttpServerRequest();
            
            return true;
        }
 
    }
 
    class UMode
    {
        public string appCode;
        public string version;
        public string releaseSystem;
        /// <summary>
        /// APP :用户在app上自助注销
        /// APPLY : 用户发邮件给公司申请注销
        /// </summary>
        public string model;
    }
 
}