using System;
using System.Collections.Generic;
using HDL_ON.UI.CSS;
using Shared;
namespace HDL_ON.UI
{
///
/// 我的二维码页面
///
public class DeliveryQrCodePage : FrameLayout
{
FrameLayout bodyView;
public DeliveryQrCodePage()
{
bodyView = this;
}
///
///
///
public void LoadPage()
{
bodyView.BackgroundColor = CSS_Color.BackgroundColor;
new TopViewDiv(bodyView, Language.StringByID(StringId.ResidentialDelivery)).LoadTopView();
int backViewHeight = Application.GetRealHeight(132) + Application.GetRealWidth(266);
FrameLayout backView = new FrameLayout()
{
Y = Application.GetRealHeight(144),
Gravity = Gravity.CenterHorizontal,
Height = Application.GetRealWidth(288),
Width = Application.GetRealWidth(288),
BackgroundColor = CSS_Color.MainBackgroundColor,
Radius = (uint)Application.GetRealWidth(8),
};
bodyView.AddChidren(backView);
var btnHomeName = new Button()
{
Gravity = Gravity.CenterHorizontal,
Y = backView.Bottom + Application.GetRealWidth(12),
Width = Application.GetRealWidth(300),
Height = Application.GetRealHeight(60),
TextAlignment = TextAlignment.Center,
TextColor = CSS_Color.FirstLevelTitleColor,
TextSize = CSS_FontSize.SubheadingFontSize,
Text = Entity.DB_ResidenceData.Instance.CurrentRegion.homeName,
IsBold = true,
IsMoreLines = true,
};
bodyView.AddChidren(btnHomeName);
var waitPage = new Loading();
bodyView.AddChidren(waitPage);
waitPage.Start("");
new System.Threading.Thread(() => {
try
{
var pack = Common.ApiUtlis.Ins.HttpRequest.GetHouseDeliveryUrl();
if (pack != null)
{
if (pack.Code == DAL.Server.StateCode.SUCCESS)
{
var deliveryUrl = pack.Data.ToString();
Application.RunOnMainThread(() => {
//二维码
int codeWidth = Application.GetRealWidth(266);
ImageView codeImage = new ImageView()
{
Gravity = Gravity.Center,
Height = codeWidth,
Width = codeWidth,
ImageBytes = Scan.BytesFromText(deliveryUrl, codeWidth, codeWidth),
};
backView.AddChidren(codeImage);
});
}
}
}
catch (Exception ex)
{
MainPage.Log($"获取住宅交付链接异常:{ex.Message}");
}
finally
{
if(waitPage!= null)
{
Application.RunOnMainThread(() =>
{
waitPage.RemoveFromParent();
});
}
}
})
{ IsBackground = true }.Start();
}
}
}