using System;
|
using Shared;
|
using HDL_ON.UI.CSS;
|
|
namespace HDL_ON.UI
|
{
|
public class BindingResidencePage : FrameLayout
|
{
|
public BindingResidencePage()
|
{
|
}
|
|
public void LoadView()
|
{
|
BackgroundColor = CSS_Color.MainBackgroundColor;
|
|
FrameLayout bodyView = new FrameLayout();
|
AddChidren(bodyView);
|
|
Button btnIcon = new Button()
|
{
|
X = Application.GetRealWidth(108),
|
Y = Application.GetRealWidth(102),
|
Width = Application.GetRealWidth(160),
|
Height = Application.GetRealWidth(160),
|
UnSelectedImagePath = "oRobot.png",
|
};
|
bodyView.AddChidren(btnIcon);
|
|
Button btnWelcome = new Button()
|
{
|
Y = btnIcon.Bottom,
|
Height = Application.GetRealHeight(120),
|
TextAlignment = TextAlignment.Center,
|
TextColor = CSS_Color.MainColor,
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
TextID = StringId.WelcomeToOnPlus,
|
};
|
bodyView.AddChidren(btnWelcome);
|
|
|
Button btnAddNewResidence = new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetRealHeight(379),
|
Width = Application.GetRealWidth(220),
|
Height = Application.GetRealWidth(44),
|
Radius = (uint)Application.GetRealWidth(22),
|
BackgroundColor = CSS_Color.MainColor,
|
TextColor = CSS_Color.MainBackgroundColor,
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
TextAlignment = TextAlignment.Center,
|
TextID = StringId.AddNewResidence,
|
IsBold = true,
|
};
|
bodyView.AddChidren(btnAddNewResidence);
|
|
Button btnTobeFamily = new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetRealHeight(439),
|
Width = Application.GetRealWidth(220),
|
Height = Application.GetRealWidth(44),
|
Radius = (uint)Application.GetRealWidth(22),
|
BorderColor = CSS_Color.MainColor,
|
BorderWidth = (uint)Application.GetRealWidth(1),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
TextColor = CSS_Color.MainColor,
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
TextAlignment = TextAlignment.Center,
|
TextID = StringId.TobeFamily,
|
IsBold = true,
|
};
|
bodyView.AddChidren(btnTobeFamily);
|
|
Button btnLogout = new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Y = btnTobeFamily.Bottom + Application.GetRealWidth(10),
|
Width = Application.GetRealWidth(220),
|
Height = Application.GetRealWidth(44),
|
TextAlignment = TextAlignment.Center,
|
TextID = StringId.Logout,
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
TextColor = CSS_Color.TextualColor,
|
IsBold = true,
|
};
|
bodyView.AddChidren(btnLogout);
|
|
|
|
btnAddNewResidence.MouseUpEventHandler = (sender, e) =>
|
{
|
Scan.OpenScan((scanString) =>
|
{
|
//执行绑定住宅
|
this.DoBindResidence(scanString);
|
});
|
};
|
|
btnTobeFamily.MouseUpEventHandler = (sender, e) =>
|
{
|
//我的二维码
|
var page = new MyQRCodePage();
|
AddChidren(page);
|
page.LoadPage();
|
//MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
|
};
|
|
btnLogout.MouseUpEventHandler = (sender, e) =>
|
{
|
MainPage.GoLoginPage(UserInfo.Current);
|
};
|
}
|
|
/// <summary>
|
/// 执行绑定住宅
|
/// </summary>
|
private void DoBindResidence(string scanString)
|
{
|
var pm = new DAL.Server.HttpServerRequest();
|
var result = pm.BindingResidence(scanString);
|
if (result == null) { return; }
|
|
if (result.Code == DAL.Server.StateCode.SUCCESS)
|
{
|
//调用On原来的方法,刷新住宅列表及其缓存
|
pm.GetHomePager();
|
//跳转页面----
|
MainPage.GoUserPage(false, () =>
|
{
|
//显示欢迎回家的弹窗界面
|
var form = new WellcomToHomeForm();
|
form.ShowForm();
|
});
|
}
|
//其他情况全部提示失效
|
else
|
{
|
//显示二维码已经过期的弹窗
|
this.ShowQrCodeTimeOutView();
|
}
|
}
|
|
/// <summary>
|
/// 显示二维码已经过期的弹窗
|
/// </summary>
|
private void ShowQrCodeTimeOutView()
|
{
|
//整个界面的灰色背景
|
var frameBack = new Dialog();
|
frameBack.Show();
|
|
//中间白色区域
|
var frameWite = new FrameLayout();
|
frameWite.Y = Application.GetRealHeight(223);
|
frameWite.Height = Application.GetRealHeight(245);
|
frameWite.Width = Application.GetRealWidth(288);
|
frameWite.BackgroundColor = CSS.CSS_Color.MainBackgroundColor;
|
frameWite.Radius = (uint)Application.GetRealWidth(12);
|
frameWite.Gravity = Gravity.CenterHorizontal;
|
frameBack.AddChidren(frameWite);
|
|
//Icon图标
|
var picIcon = new Button();
|
picIcon.Y = Application.GetRealHeight(152);
|
picIcon.Height = Application.GetRealWidth(160);
|
picIcon.Width = Application.GetRealWidth(160);
|
picIcon.Gravity = Gravity.CenterHorizontal;
|
picIcon.UnSelectedImagePath = "ErrorIcon.png";
|
frameBack.AddChidren(picIcon);
|
|
//二维码失效,请重试
|
var btnText = new Button();
|
btnText.Y = Application.GetRealHeight(98);
|
btnText.Height = Application.GetRealHeight(24);
|
btnText.TextSize = 16;
|
btnText.TextAlignment = TextAlignment.Center;
|
btnText.TextColor = CSS.CSS_Color.FirstLevelTitleColor;
|
btnText.TextID = StringId.QRCodeIsInvalid;
|
frameWite.AddChidren(btnText);
|
|
//取消
|
var btnCancel = new Button();
|
btnCancel.X = Application.GetRealWidth(30);
|
btnCancel.Y = btnText.Bottom + Application.GetRealHeight(48);
|
btnCancel.Height = Application.GetRealHeight(44);
|
btnCancel.Width = Application.GetRealWidth(108);
|
btnCancel.TextSize = 16;
|
btnCancel.IsBold = true;
|
btnCancel.TextAlignment = TextAlignment.Center;
|
btnCancel.TextColor = CSS.CSS_Color.MainColor;
|
btnCancel.BackgroundColor = CSS.CSS_Color.MainBackgroundColor;
|
btnCancel.Radius = (uint)Application.GetRealHeight(22);
|
btnCancel.TextID = StringId.Cancel;
|
btnCancel.BorderWidth = 1;
|
btnCancel.BorderColor = CSS.CSS_Color.MainColor;
|
frameWite.AddChidren(btnCancel);
|
|
btnCancel.MouseUpEventHandler += (sender, e) =>
|
{
|
frameBack.Close();
|
};
|
|
//重试
|
var btnRedo = new Button();
|
btnRedo.Y = btnText.Bottom + Application.GetRealHeight(48);
|
btnRedo.Height = Application.GetRealHeight(44);
|
btnRedo.Width = Application.GetRealWidth(108);
|
btnRedo.TextSize = 16;
|
btnRedo.IsBold = true;
|
btnRedo.TextAlignment = TextAlignment.Center;
|
btnRedo.TextColor = CSS.CSS_Color.MainBackgroundColor;
|
btnRedo.BackgroundColor = CSS.CSS_Color.MainColor;
|
btnRedo.Radius = (uint)Application.GetRealHeight(22);
|
btnRedo.TextID = StringId.Retry;
|
frameWite.AddChidren(btnRedo);
|
btnRedo.X = frameWite.Width - btnRedo.Width - Application.GetRealWidth(30);
|
|
btnRedo.MouseUpEventHandler += (sender, e) =>
|
{
|
Scan.OpenScan((scanString) =>
|
{
|
frameBack.Close();
|
//执行绑定住宅
|
this.DoBindResidence(scanString);
|
});
|
};
|
}
|
}
|
}
|