using System;
|
using System.Collections.Generic;
|
using Shared.Common;
|
|
namespace Shared.Phone.Device.Login
|
{
|
public class PhoneZone : UserCenter.FrameLayoutBase
|
{
|
#region ◆ 变量____________________________
|
/// <summary>
|
/// 选择的区号
|
/// </summary>
|
public Action<string> ActionSelectedZone;
|
/// <summary>
|
/// *****升级分布式后,Account 仅包含手机号,不再包含00区号。密码不再需要MD5加密。language为APP语
|
/// 下来选择手机区号 默认中国大陆为86
|
///发送国际 / 港澳台消息时,接收号码格式为00 + 国际区号 + 号码,如“008615899998888” 调用API时,Company字段请传入整型值:4。 。
|
///国内 调用API时,Company字段请传入整型值:0。
|
/// </summary>
|
public List<Common.ResponseEntity.AreaCodeOBJ> areaCodeList = new List<Common.ResponseEntity.AreaCodeOBJ>();
|
/// <summary>
|
/// 选择区号视图
|
/// </summary>
|
private FrameLayout phoneZoneSelectedShowView;
|
/// <summary>
|
/// 区号视图
|
/// </summary>
|
private VerticalScrolViewLayout phoneZoneListView;
|
/// <summary>
|
/// tempClickZoneCodeBtn
|
/// </summary>
|
Button tempClickZoneCodeBtn = new Button();
|
/// <summary>
|
/// tempClickZoneNameBtn
|
/// </summary>
|
Button tempClickZoneNameBtn = new Button();
|
/// <summary>
|
/// tempClickZoneItemFL
|
/// </summary>
|
FrameLayout tempClickZoneItemFL = new FrameLayout();
|
#endregion
|
/// <summary>
|
/// PhoneZone
|
/// </summary>
|
public PhoneZone()
|
{
|
|
}
|
/// <summary>
|
/// Show
|
/// </summary>
|
public void Show()
|
{
|
Init();
|
}
|
/// <summary>
|
/// Init
|
/// </summary>
|
private void Init()
|
{
|
CommonPage.Loading.Start();
|
ShowZoneList();
|
new System.Threading.Thread(async () =>
|
{
|
var zoneList = await GetZoneListAsync();
|
if (zoneList == null)
|
{
|
Application.RunOnMainThread(() =>
|
{
|
CommonPage.Loading.Hide();
|
|
});
|
}
|
else
|
{
|
Application.RunOnMainThread(() =>
|
{
|
foreach (var areaCode in zoneList)
|
{
|
AddZone(areaCode, phoneZoneListView);
|
}
|
CommonPage.Loading.Hide();
|
});
|
}
|
})
|
{ IsBackground = true }.Start();
|
}
|
/// <summary>
|
/// GetZoneListAsync
|
/// </summary>
|
/// <returns></returns>
|
private async System.Threading.Tasks.Task<List<Common.ResponseEntity.AreaCodeOBJ>> GetZoneListAsync()
|
{
|
try
|
{
|
var requestOBJ = new SendDataToServer.GetAreaCodeOBJ()
|
{
|
RequestVersion = CommonPage.RequestVersion
|
};
|
var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestOBJ);
|
var revertOBJ = await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/GetAreaCode", System.Text.Encoding.UTF8.GetBytes(requestJson));
|
if (revertOBJ == null)
|
{
|
return null;
|
}
|
if (revertOBJ.StateCode.ToUpper() == "SUCCESS")
|
{
|
|
var responseData = revertOBJ.ResponseData;
|
return Newtonsoft.Json.JsonConvert.DeserializeObject<List<Common.ResponseEntity.AreaCodeOBJ>>(responseData.ToString());
|
}
|
else
|
{
|
return null;
|
}
|
}
|
catch
|
{
|
return null;
|
}
|
}
|
/// <summary>
|
/// ShowZoneList
|
/// </summary>
|
private void ShowZoneList()
|
{
|
//ZoneListView
|
var phoneZoneDialog = new FrameLayout()
|
{
|
BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor
|
};
|
AddChidren(phoneZoneDialog);
|
|
phoneZoneSelectedShowView = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(1342),
|
Width = Application.GetRealWidth(850),
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
|
Radius = (uint)Application.GetRealHeight(30),
|
Gravity = Gravity.Center
|
};
|
phoneZoneDialog.AddChidren(phoneZoneSelectedShowView);
|
|
var phoneZoneTitle = new Button()
|
{
|
X = Application.GetRealWidth(CommonPage.XLeft),
|
Y = Application.GetRealHeight(69),
|
Height = Application.GetRealHeight(60),
|
Width = Application.GetRealWidth(250),
|
TextID = R.MyInternationalizationString.PleaseSelectAreaCode,
|
TextColor = ZigbeeColor.Current.GXCTextDeepBlackColor,
|
TextAlignment = TextAlignment.CenterLeft
|
};
|
phoneZoneSelectedShowView.AddChidren(phoneZoneTitle);
|
|
var searchBorder = new FrameLayout()
|
{
|
X = phoneZoneTitle.Right + Application.GetRealWidth(CommonPage.XLeft),
|
Y = Application.GetRealHeight(46),
|
Height = Application.GetRealHeight(104),
|
Width = Application.GetRealWidth(400),
|
BorderWidth = 1,
|
BorderColor = ZigbeeColor.Current.GXCBorderColor,
|
Radius = (uint)Application.GetRealHeight(46 / 2)
|
};
|
phoneZoneSelectedShowView.AddChidren(searchBorder);
|
|
var phoneZoneSearch = new EditText()
|
{
|
X = phoneZoneTitle.Right + Application.GetRealWidth(CommonPage.XLeft + 10),
|
Y = Application.GetRealHeight(46),
|
Height = Application.GetRealHeight(104),
|
Width = Application.GetRealWidth(400),
|
PlaceholderText = Language.StringByID(R.MyInternationalizationString.Search),
|
PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor,
|
TextColor = ZigbeeColor.Current.GXCTextDeepBlackColor
|
};
|
phoneZoneSelectedShowView.AddChidren(phoneZoneSearch);
|
|
phoneZoneListView = new VerticalScrolViewLayout()
|
{
|
Y = phoneZoneSearch.Bottom + Application.GetRealHeight(10),
|
Height = Application.GetRealHeight(986),
|
};
|
phoneZoneSelectedShowView.AddChidren(phoneZoneListView);
|
|
var btnOk = new UserCenter.BottomClickButton(668);
|
btnOk.Y = Application.GetRealHeight(1166);
|
btnOk.TextID = R.MyInternationalizationString.Complete;
|
phoneZoneSelectedShowView.AddChidren(btnOk);
|
btnOk.ButtonClickEvent += (sender, e) =>
|
{
|
ActionSelectedZone?.Invoke(CommonPage.PhoneZoneStr);
|
ActionSelectedZone = null;
|
RemoveFromParent();
|
};
|
var cancleBtn = new Button()
|
{
|
Y = Application.GetRealHeight(1719),
|
Height = this.GetPictrueRealSize(86),
|
Width = this.GetPictrueRealSize(86),
|
UnSelectedImagePath = "Account/Cancle.png",
|
Gravity = Gravity.CenterHorizontal
|
};
|
phoneZoneDialog.AddChidren(cancleBtn);
|
|
cancleBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
this.RemoveFromParent();
|
};
|
}
|
/// <summary>
|
/// AddZone
|
/// </summary>
|
/// <param name="areaCode"></param>
|
/// <param name="phoneZoneSelectedListView"></param>
|
private void AddZone(Common.ResponseEntity.AreaCodeOBJ areaCode, VerticalScrolViewLayout phoneZoneSelectedListView)
|
{
|
var zoneItemLName = areaCode.Name;
|
var zoneItemLCode = areaCode.Code;
|
var zoneItemFL = new FrameLayout()
|
{
|
Width = phoneZoneSelectedListView.Width,
|
Height = Application.GetRealHeight(110),
|
};
|
phoneZoneSelectedListView.AddChidren(zoneItemFL);
|
|
var zoneItemNameBtn = new Button()
|
{
|
X = Application.GetRealWidth(58),
|
Width = zoneItemFL.Width - Application.GetRealWidth(300),
|
Height = Application.GetRealHeight(110) - 1,
|
Text = zoneItemLName,
|
TextColor = ZigbeeColor.Current.GXCTextColor,
|
SelectedTextColor = ZigbeeColor.Current.GXCTextBlackColor,
|
TextAlignment = TextAlignment.CenterLeft,
|
};
|
zoneItemFL.AddChidren(zoneItemNameBtn);
|
|
var zoneCode = new Button()
|
{
|
X = Application.GetRealWidth(58) + zoneItemNameBtn.Right,
|
Width = Application.GetRealWidth(150),
|
Height = Application.GetRealHeight(80),
|
Gravity = Gravity.CenterVertical,
|
Text = $"+{zoneItemLCode}",
|
TextAlignment = TextAlignment.CenterRight,
|
TextColor = ZigbeeColor.Current.GXCTextColor,
|
SelectedTextColor = ZigbeeColor.Current.GXCTextBlackColor,
|
};
|
zoneItemFL.AddChidren(zoneCode);
|
|
EventHandler<MouseEventArgs> selectedZone = (sender, e) =>
|
{
|
tempClickZoneCodeBtn.IsSelected = false;
|
tempClickZoneNameBtn.IsSelected = false;
|
tempClickZoneItemFL.BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
|
zoneItemNameBtn.IsSelected = true;
|
zoneCode.IsSelected = true;
|
tempClickZoneCodeBtn = zoneCode;
|
tempClickZoneNameBtn = zoneItemNameBtn;
|
tempClickZoneItemFL = zoneItemFL;
|
zoneItemFL.BackgroundColor = ZigbeeColor.Current.GXCRowSelectedColor;
|
CommonPage.PhoneZoneStr = zoneItemLCode;
|
};
|
|
zoneCode.MouseUpEventHandler += selectedZone;
|
zoneItemNameBtn.MouseUpEventHandler += selectedZone;
|
//默认
|
if (zoneItemLCode == CommonPage.PhoneZoneStr)
|
{
|
zoneItemNameBtn.IsSelected = true;
|
zoneCode.IsSelected = true;
|
zoneItemFL.BackgroundColor = ZigbeeColor.Current.GXCRowSelectedColor;
|
tempClickZoneCodeBtn = zoneCode;
|
tempClickZoneNameBtn = zoneItemNameBtn;
|
tempClickZoneItemFL = zoneItemFL;
|
}
|
}
|
}
|
}
|