using System;
|
using Shared;
|
using HDL_ON.UI.CSS;
|
using System.Threading;
|
using System.Text.RegularExpressions;
|
using HDL_ON.DAL.Server;
|
|
|
namespace HDL_ON.UI
|
{
|
/// <summary>
|
/// 新绑定或者换绑--手机或者邮箱发送验证码
|
/// </summary>
|
public partial class NewBindAccountPage : FrameLayout
|
{
|
FrameLayout bodyView;
|
Button btnBind;
|
EditText etContent;
|
Action<string> action;
|
|
/// <summary>
|
/// 标题ID
|
/// </summary>
|
int titleId;
|
/// <summary>
|
/// 是否手机
|
/// </summary>
|
bool isPhone;
|
/// <summary>
|
/// 是否换绑
|
/// </summary>
|
bool isModifyBind;
|
|
/// <summary>
|
/// 手机区号
|
/// </summary>
|
string phoneZoneCode = "86";
|
|
/// <summary>
|
///
|
/// </summary>
|
public NewBindAccountPage()
|
{
|
bodyView = this;
|
}
|
|
/// <summary>
|
/// LoadPage
|
/// </summary>
|
/// <param name="act"></param>
|
/// <param name="isPhone">是否绑定手机</param>
|
public void LoadPage(Action<string> act, bool isPhone = false, bool isModifyBind = false)
|
{
|
action = act;
|
this.isPhone = isPhone;
|
this.isModifyBind = isModifyBind;
|
if (isModifyBind)
|
{
|
//修改绑定
|
titleId = isPhone ? StringId.ModifyBindingPhone : StringId.ModifyBindingEmail;
|
}
|
else
|
{
|
//新绑定
|
titleId = isPhone ? StringId.BoundMobileInfo : StringId.BoundEmailInfo;
|
}
|
|
|
|
bodyView.BackgroundColor = CSS_Color.BackgroundColor;
|
new TopViewDiv(bodyView, Language.StringByID(titleId)).LoadTopView();
|
|
FrameLayout rowView = new FrameLayout()
|
{
|
Y = Application.GetRealHeight(72),
|
Height = Application.GetRealHeight(50),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
};
|
bodyView.AddChidren(rowView);
|
|
//绑定邮箱或者绑定手机号
|
Button btnTitle = new Button()
|
{
|
X = Application.GetRealWidth(16),
|
Width = Application.GetRealWidth(180),
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextID = titleId,
|
};
|
rowView.AddChidren(btnTitle);
|
|
etContent = new EditText()
|
{
|
Width = Application.GetRealWidth(359),
|
TextColor = CSS_Color.PromptingColor1,
|
TextSize = CSS_FontSize.TextFontSize,
|
TextAlignment = TextAlignment.CenterRight,
|
Foucs = true
|
};
|
rowView.AddChidren(etContent);
|
|
btnBind = new Button()
|
{
|
Y = Application.GetRealHeight(213),
|
Gravity = Gravity.CenterHorizontal,
|
Width = Application.GetRealWidth(220),
|
Height = Application.GetRealHeight(44),
|
BackgroundColor = CSS_Color.MainColor,
|
TextAlignment = TextAlignment.Center,
|
TextColor = CSS_Color.MainBackgroundColor,
|
TextID = StringId.GetVerificationCode,
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
IsBold = true,
|
Radius = (uint)Application.GetRealWidth(22),
|
BorderColor = 0x00000000,
|
BorderWidth = 0,
|
};
|
bodyView.AddChidren(btnBind);
|
|
//点击获取验证码
|
LoadEvent_GetVerification(btnBind);
|
|
}
|
}
|
|
|
//--------------------------------------------
|
public partial class NewBindAccountPage
|
{
|
/// <summary>
|
/// 点击获取验证码
|
/// </summary>
|
void LoadEvent_GetVerification(Button button)
|
{
|
button.MouseUpEventHandler = (sender, e) =>
|
{
|
if (button.Text == Language.StringByID(StringId.GetVerificationCode))
|
{
|
Application.HideSoftInput();
|
var account = etContent.Text.Trim();
|
#region 正则表达式
|
//1.检测账号是否合法
|
if (!isPhone)
|
{
|
if (!Utlis.CheckEmail(account))
|
{
|
Utlis.ShowTip(Language.StringByID(StringId.PlsEntryCorrectEmailAddress), bodyView);
|
return;
|
}
|
}
|
else
|
{
|
if (!Utlis.CheckPhoneNumber(account, phoneZoneCode))
|
{
|
Utlis.ShowTip(Language.StringByID(StringId.PlsEntryCorrectMobilNeumber), bodyView);
|
return;
|
}
|
}
|
#endregion
|
int time = 0;
|
//2.检验通过
|
new Thread(() =>
|
{
|
//2.2 获取验证码
|
ResponsePackNew resultObj;
|
if (!isPhone)//邮箱
|
{
|
resultObj = new HttpServerRequest().VerificationCodeSend(VerifyType.REGISTER_USER_SYSTEM, account);
|
}
|
else
|
{
|
resultObj = new HttpServerRequest().VerificationCodeSend(VerifyType.REGISTER_USER_SYSTEM, account, true, phoneZoneCode);
|
}
|
|
if (resultObj.Code != StateCode.SUCCESS)
|
{
|
// 提示错误
|
IMessageCommon.Current.ShowErrorInfoAlter(NewAPI.API_POST_Verification_Send, resultObj.Code);
|
}
|
else
|
{
|
if (time == 0)
|
{
|
time = 60;
|
new Thread(() =>
|
{
|
while (time > 0)
|
{
|
time--;
|
Application.RunOnMainThread(() =>
|
{
|
button.Text = time.ToString() + "s";
|
});
|
Thread.Sleep(1000);
|
}
|
Application.RunOnMainThread(() =>
|
{
|
button.IsSelected = true;
|
button.TextID = StringId.GetVerificationCode;
|
button.BackgroundColor = CSS_Color.MainColor;
|
time = 0;
|
});
|
})
|
{ IsBackground = true }.Start();
|
}
|
Application.RunOnMainThread(() =>
|
{
|
button.BackgroundColor = CSS_Color.PromptingColor1;
|
var vcp = new NewBindVerificationCodePage();
|
vcp.phoneZoneCode = phoneZoneCode;
|
MainPage.BasePageView.AddChidren(vcp);
|
vcp.LoadPage(action, titleId, account, isPhone, time, isModifyBind);
|
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
|
});
|
}
|
|
})
|
{ IsBackground = true }.Start();
|
}
|
|
};
|
}
|
}
|
}
|