using System;
using Shared;
using HDL_ON.Entity;
using HDL_ON.DAL.Server;
using HDL_ON.UI.CSS;
namespace HDL_ON.UI
{
public class Iot_AuthorizedPage
{
HttpServerRequest http = new HttpServerRequest();
IntegratedBrand_Iot brand_Iot;
Action boudedAction;
public Iot_AuthorizedPage(IntegratedBrand_Iot brand,Action action)
{
brand_Iot = brand;
boudedAction = action;
}
public void LoadView()
{
//高胜说不需要拼接url 2023年08月22日10:19:50
//string url = brand_Iot.authorizationUrl + $"?companyId={brand_Iot.companyId}&openUId={UserInfo.Current.ID}&client_id={brand_Iot.clientId}";
string url = brand_Iot.authorizationUrl;
var dd = new WebViewDialog(()=> {
UnsubscribeAsync3tyIotbind();
});
dd.LoadPage("", url);
DAL.Mqtt.MqttClient.Bind3tyIotAction = () => {
UnsubscribeAsync3tyIotbind();
Application.RunOnMainThread(() =>
{
//http.Search3tyIotDevice(brand_Iot.companyId);
boudedAction?.Invoke();
dd.Close();
{
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 btnTitle = new Button()
{
Gravity = Gravity.CenterHorizontal,
Y = Application.GetRealHeight(10),
Height = Application.GetRealHeight(38),
TextAlignment = TextAlignment.Center,
IsBold = true,
TextColor = 0xFF222222,
TextSize = CSS_FontSize.SubheadingFontSize,
TextID = StringId.Tip
};
contentView.AddChidren(btnTitle);
Button btnMsg = new Button()
{
Gravity = Gravity.CenterHorizontal,
Height = Application.GetRealHeight(70),
Y = Application.GetRealHeight(55),
TextAlignment = TextAlignment.TopCenter,
TextColor = CSS_Color.FirstLevelTitleColor,
TextSize = CSS_FontSize.SubheadingFontSize,
Padding = new Padding(0, Application.GetRealWidth(16), 0, Application.GetRealWidth(16)),
TextID = StringId.BindIotAccountTip,
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,
TextID = StringId.Confirm,
};
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) =>
{
dialog.Close();
};
}
});
};
SubscribeAsync3tyIotbind();
}
///
/// 订阅绑定第三方iot账号结果
///
private void SubscribeAsync3tyIotbind()
{
new System.Threading.Thread(async () =>
{
try
{
var result = await DAL.Mqtt.MqttClient.SubscribeAsync3tyIotbind();
}
catch { }
finally
{
}
})
{ IsBackground = true }.Start();
}
///
/// 取消订阅绑定第三方iot账号结果
///
private void UnsubscribeAsync3tyIotbind()
{
new System.Threading.Thread(async () =>
{
try
{
var result = await DAL.Mqtt.MqttClient.UnsubscribeAsync3tyIotbind();
}
catch { }
finally
{
}
})
{ IsBackground = true }.Start();
}
/////
///// 搜索第三方设备
/////
//private void SearchDevice()
//{
// var pack = http.Search3tyIotDevice(brand_Iot.companyId);
// if(pack!= null)
// {
// }
//}
///
/// 获取第三方功能列表
///
private void GetFunction()
{
var pack = http.Get3tyIotDeviceFunctionList(brand_Iot.companyId);
if(pack != null)
{
}
}
}
}