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; /// /// 解绑回调 /// public Action unboundAction; /// /// 绑定回调 /// public Action boundAction; public iot_BindTipPage() { bodyView = this; } public void LoadPage(IntegratedBrand_Iot brand_Iot) { new TopViewDiv(bodyView, brand_Iot.brandName).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); if (Language.CurrentLanguage != "Chinese") { btnTipTitle.Text = "Statement on account binding"; } 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); if (Language.CurrentLanguage != "Chinese") { btnTipText.Text = $"account binding brand: {brand_Iot.brandName} (hereinafter referred to as the third party brand)" + "\r\n" + "\r\n" + "After you bind the account of the third-party brand, you will authorize 'on Pro' to use your account of the third-party to jointly manage the device. On Pro will also automatically synchronize the device you added in the third-party brand." + "\r\n" + "\r\n" + "To realize the device control function, this application will obtain the following data from a third party:" + "\r\n" + "\r\n" + "1. List of some devices added on the third-party brand for intelligent control in on Pro;" + "\r\n" + "\r\n" + "2. Equipment and network information, including equipment identifier, MAC address and equipment serial number, is used to identify the currently working equipment and perform equipment control functions." + "\r\n" + "\r\n" + "If you do not agree with our collection of the above information, you will not be able to manage third-party branded devices." + "\r\n" + "\r\n" + "To terminate the collection and processing of the above information, you can click my > bind third party account > cancel"; } 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, TextID= StringId.fanhui, 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 (Language.CurrentLanguage != "Chinese") { btnComfirm.Text = "Consent authorization"; } if (!brand_Iot.hasAuthorization) { btnComfirm.MouseUpEventHandler = (sender, e) => { Action action = () => { 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; }; var page2 = new Iot_AuthorizedPage(brand_Iot,action); page2.LoadView(); }; } else { btnComfirm.Text = "解除授权"; if (Language.CurrentLanguage != "Chinese") { btnComfirm.Text = "Cancel authorization"; } btnComfirm.MouseUpEventHandler = (sender, e) => { Dialog dialog = new Dialog() { BackgroundColor = CSS_Color.DialogTransparentColor1, }; FrameLayout contentView2 = 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(contentView2); 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, }; contentView2.AddChidren(btnMsg); if (Language.CurrentLanguage != "Chinese") { btnMsg.Text = "After the authorization is revoked, all the devices associated with the brand in on Pro will be unbound, and the relevant use information and device value will also become invalid"; } Button btnLine = new Button() { Y = Application.GetRealHeight(125), Height = Application.GetRealHeight(1), BackgroundColor = CSS.CSS_Color.DividingLineColor, }; contentView2.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 = "确定撤回授权", }; if (Language.CurrentLanguage != "Chinese") { btnConfirm.Text = "Confirm to withdraw authorization"; } btnConfirm.SetCornerWithSameRadius(Application.GetMinRealAverage(10), HDLUtils.RectCornerBottomLeft); btnConfirm.SetCornerWithSameRadius(Application.GetMinRealAverage(10), HDLUtils.RectCornerBottomRight); contentView2.AddChidren(btnConfirm); dialog.Show(); btnConfirm.MouseDownEventHandler += (sender2, e2) => { btnConfirm.IsSelected = true; }; btnConfirm.MouseUpEventHandler += (sender2, e2) => { var http = new HttpServerRequest(); var waitPage = new Loading(); this.AddChidren(waitPage); dialog.Close(); 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(); }); } } else { if (Language.CurrentLanguage != "Chinese") { new Alert("", "Operation failed", "").Show(); } else { new Alert("", "操作失败", "").Show(); } } } catch { } finally { Application.RunOnMainThread(() => { waitPage.Hide(); waitPage.RemoveFromParent(); }); } }) { IsBackground = true }.Start(); }; }; } } } }