wxr
2022-07-29 da40946e8cf2ffb41157f5c388c525ccccaca692
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
using System;
using HDL_ON.DAL.Server;
using HDL_ON.Entity;
using HDL_ON.UI.CSS;
using Shared;
namespace HDL_ON.UI
{
    public class iot_BindTipPage : FrameLayout
    {
        FrameLayout bodyView;
 
        /// <summary>
        /// 解绑回调
        /// </summary>
        public Action unboundAction;
        /// <summary>
        /// 绑定回调
        /// </summary>
        public Action boundAction;
 
        public iot_BindTipPage()
        {
            bodyView = this;
        }
 
 
        public void LoadPage(IntegratedBrand_Iot brand_Iot)
        {
 
 
            new TopViewDiv(bodyView, Language.StringByID(StringId.Bind3thIotAccount)).LoadTopView(CSS_Color.MainBackgroundColor);
 
            bodyView.BackgroundColor = CSS_Color.MainBackgroundColor;
 
            var contentView = new VerticalScrolViewLayout()
            {
                Y = Application.GetRealHeight(64),
                BackgroundColor = CSS_Color.BackgroundColor,
                Height = Application.GetRealHeight(667 - 124)
            };
            bodyView.AddChidren(contentView);
 
            var btnIcon = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(25),
                Width = Application.GetRealWidth(106),
                Height = Application.GetRealWidth(106),
                UnSelectedImagePath = "Public/Logo.png",
            };
            contentView.AddChidren(btnIcon);
 
            var btnTipTitle = new Button()
            {
                X = Application.GetRealWidth(16),
                Y = Application.GetRealHeight(140),
                Width = Application.GetRealWidth(300),
                Height = Application.GetRealHeight(60),
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = 21,
                TextAlignment = TextAlignment.CenterLeft,
                IsBold = true,
                Text = "关于账号绑定的声明"
            };
            contentView.AddChidren(btnTipTitle);
 
            var btnTipText = new Button()
            {
                Padding =new Padding(0, Application.GetRealWidth(16), 0, Application.GetRealWidth(16)),
                Y = Application.GetRealHeight(140),
                Height = Application.GetRealHeight(340),
                IsMoreLines = true,
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = 14,
                TextAlignment = TextAlignment.CenterLeft,
                Text = $"账户绑定品牌:{brand_Iot.brandName} (以下简称第三方品牌)" + "\r\n" + "\r\n" +
"您绑定第三方品牌的账号后,将授权“On Pro”使用您在第三方账号,协同管理设备,On Pro也将自动同步您在第三方品牌中添加的设备。" + "\r\n" + "\r\n" +
 
"为实现设备控制功能,本应用将从第三方中获取以下数据:" + "\r\n" + "\r\n" +
 
"1.第三方品牌上添加的部分设备列表,用于在On Pro中进行智能化控制;" + "\r\n" + "\r\n" +
 
"2.设备及网络信息,包括设备标志符、MAC地址、设备序列号,用于识别当前工作的设备以及进行设备控制功能。" + "\r\n" + "\r\n" +
 
"如果您不同意我们收集以上信息,将无法管理第三方品牌的设备。" + "\r\n" + "\r\n" +
 
"如需终止以上信息的收集与处理,您可以在“我的”> “绑定第三方账户”>“解除”"
            };
            contentView.AddChidren(btnTipText);
 
 
            var optionView = new FrameLayout()
            {
                Y = Application.GetRealHeight(667 - 80),
                Height = Application.GetRealHeight(90),
                Radius = (uint)Application.GetRealWidth(22),
                BackgroundColor = CSS_Color.MainBackgroundColor,
            };
            bodyView.AddChidren(optionView);
 
            var btnCannel = new Button()
            {
                X = Application.GetRealWidth(17),
                Y = Application.GetRealHeight(14),
                Width = Application.GetRealWidth(164),
                Height = Application.GetRealHeight(44),
                BorderColor = CSS_Color.MainColor,
                BackgroundColor = CSS_Color.MainBackgroundColor,
                BorderWidth = (uint)Application.GetRealWidth(1),
                TextAlignment = TextAlignment.Center,
                TextColor = CSS_Color.MainColor,
                TextSize = CSS_FontSize.SubheadingFontSize,
                Text = "返回",
                Radius = (uint)Application.GetRealHeight(22)
            };
            optionView.AddChidren(btnCannel);
            btnCannel.MouseUpEventHandler = (sender, e) => {
                this.RemoveFromParent();
            };
 
 
            var btnComfirm = new Button()
            {
                X = Application.GetRealWidth(196),
                Y = Application.GetRealHeight(14),
                Width = Application.GetRealWidth(164),
                Height = Application.GetRealHeight(44),
                TextAlignment = TextAlignment.Center,
                BackgroundColor= CSS_Color.MainColor,
                TextColor = CSS_Color.MainBackgroundColor,
                TextSize = CSS_FontSize.SubheadingFontSize,
                Text = "同意授权",
                Radius = (uint)Application.GetRealHeight(22)
            };
            optionView.AddChidren(btnComfirm);
 
 
            if (!brand_Iot.hasAuthorization)
            {
                btnComfirm.MouseUpEventHandler = (sender, e) =>
                {
                    brand_Iot.hasAuthorization = true;
                    boundAction?.Invoke();
                    this.RemoveFromParent();
                    var page = new Iot_BrandFunctionListPage(brand_Iot);
                    page.unboundAction = unboundAction;
                    MainPage.BasePageView.AddChidren(page);
                    page.LoadPage();
                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                };
            }
            else
            {
                btnComfirm.Text = "解除授权";
                btnComfirm.MouseUpEventHandler = (sender, e) =>
                {
                    Dialog dialog = new Dialog()
                    {
                        BackgroundColor = CSS_Color.DialogTransparentColor1,
                    };
 
                    FrameLayout contentView = new FrameLayout()
                    {
                        Gravity = Gravity.Center,
                        Width = Application.GetRealWidth(305),
                        Height = Application.GetRealHeight(180),
                        BackgroundColor = CSS.CSS_Color.MainBackgroundColor,
                        BorderColor = 0x00000000,
                        BorderWidth = 0,
                        Radius = (uint)Application.GetMinRealAverage(10),
                    };
                    dialog.AddChidren(contentView);
 
                    Button btnMsg = new Button()
                    {
                        Gravity = Gravity.CenterHorizontal,
                        Height = Application.GetRealHeight(70),
                        Y = Application.GetRealHeight(30),
                        TextAlignment = TextAlignment.Center,
                        TextColor = CSS_Color.FirstLevelTitleColor,
                        TextSize = CSS_FontSize.SubheadingFontSize,
                        Padding = new Padding(0,Application.GetRealWidth(16),0,Application.GetRealWidth(16)),
                        Text = "撤销授权后,该品牌关联在On Pro中的设备将全部被解绑,相关使用信息合设备值也将失效",
                        IsMoreLines = true,
                    };
                    contentView.AddChidren(btnMsg);
 
                    Button btnLine = new Button()
                    {
                        Y = Application.GetRealHeight(125),
                        Height = Application.GetRealHeight(1),
                        BackgroundColor = CSS.CSS_Color.DividingLineColor,
                    };
                    contentView.AddChidren(btnLine);
 
                    Button btnConfirm = new Button()
                    {
                        Y = btnLine.Bottom,
                        Height = Application.GetRealHeight(55),
                        TextAlignment = TextAlignment.Center,
                        TextColor = CSS_Color.MainColor,
                        TextSize = CSS_FontSize.SubheadingFontSize,
                        SelectedTextColor = CSS_Color.MainBackgroundColor,
                        SelectedBackgroundColor = CSS_Color.MainColor,
                        Text = "确定撤回授权",
                    };
                    btnConfirm.SetCornerWithSameRadius(Application.GetMinRealAverage(10), HDLUtils.RectCornerBottomLeft);
                    btnConfirm.SetCornerWithSameRadius(Application.GetMinRealAverage(10), HDLUtils.RectCornerBottomRight);
                    contentView.AddChidren(btnConfirm);
 
                    dialog.Show();
 
                    btnConfirm.MouseDownEventHandler += (sender, e) =>
                    {
                        btnConfirm.IsSelected = true;
                    };
                    btnConfirm.MouseUpEventHandler += (sender, e) =>
                    {
                        var http = new HttpServerRequest();
                        var waitPage = new Loading();
                        this.AddChidren(waitPage);
                        waitPage.Start("");
                        new System.Threading.Thread(() =>
                        {
                            try
                            {
                                var pack = http.Unbound3tyIotAccount(brand_Iot.companyId);
                                if (pack != null)
                                {
                                    if (pack.Code == StateCode.SUCCESS)
                                    {
                                        Application.RunOnMainThread(() =>
                                        {
                                            btnConfirm.IsSelected = false;
                                            dialog.Close();
                                            this.RemoveFromParent();
                                            brand_Iot.hasAuthorization = false;
                                            unboundAction?.Invoke();
                                        });
                                    }
                                }
                            }
                            catch { }
                            finally
                            {
                                Application.RunOnMainThread(() => {
                                    waitPage.Hide();
                                    waitPage.RemoveFromParent();
                                });
 
                            }
                        })
                        { IsBackground = true }.Start();
                    };
 
                };
            }
 
 
 
 
 
        }
    }
}