using System;
using Shared;
using HDL_ON.UI.CSS;
using HDL_ON.Stan;
using HDL_ON.Entity;
namespace HDL_ON.UI
{
///
/// 管理员权限迁移成员资料确认界面
///
public class AdminMigrationMemberConfirmPage : EditorCommonForm
{
#region ■ 变量声明___________________________
///
/// 成员信息
///
private ResidenceMemberInfo memberInfo = null;
#endregion
#region ■ 初始化_____________________________
///
/// 画面显示(底层会固定调用此方法,借以完成画面创建)
///
/// 成员信息
public void ShowForm(ResidenceMemberInfo i_memberInfo)
{
this.memberInfo = i_memberInfo;
//个人资料
base.SetTitleText(Language.StringByID(StringId.Profile));
//初始化中部信息
this.InitMiddleFrame();
}
///
/// 初始化中部信息
///
private void InitMiddleFrame()
{
//清空bodyFrame
this.ClearBodyFrame();
//上部的白色背景
var frameBack1 = new FrameLayout();
frameBack1.BackgroundColor = CSS_Color.MainBackgroundColor;
frameBack1.Height = Application.GetRealHeight(204);
bodyFrameLayout.AddChidren(frameBack1);
//头像
var btnHeadImage = new ImageView();
btnHeadImage.Y = Application.GetRealHeight(32);
btnHeadImage.Gravity = Gravity.CenterHorizontal;
btnHeadImage.Width = Application.GetRealWidth(84);
btnHeadImage.Height = Application.GetRealWidth(84);
btnHeadImage.Radius = (uint)Application.GetRealWidth(42);
btnHeadImage.ImagePath = "LoginIcon/2.png";
frameBack1.AddChidren(btnHeadImage);
//昵称
var btnName = new NormalViewControl(frameBack1.Width - HdlControlResourse.XXLeft * 2, Application.GetRealHeight(24), false);
btnName.Y = btnHeadImage.Bottom + Application.GetRealHeight(11);
btnName.Gravity = Gravity.CenterHorizontal;
btnName.IsBold = true;
btnName.TextSize = CSS_FontSize.SubheadingFontSize;
btnName.TextColor = CSS_Color.FirstLevelTitleColor;
btnName.Text = string.IsNullOrEmpty(memberInfo.nickName) == true ? memberInfo.memberName : memberInfo.nickName;
btnName.TextAlignment = TextAlignment.Center;
frameBack1.AddChidren(btnName);
//账号
var btnAccount = new NormalViewControl(frameBack1.Width - HdlControlResourse.XXLeft * 2, Application.GetRealHeight(16), false);
btnAccount.Y = btnName.Bottom + Application.GetRealHeight(7);
btnAccount.Gravity = Gravity.CenterHorizontal;
btnAccount.TextSize = CSS_FontSize.PromptFontSize_FirstLevel;
btnAccount.TextAlignment = TextAlignment.Center;
btnAccount.Text = memberInfo.Account;
frameBack1.AddChidren(btnAccount);
//确认的白色背景
var frameBack2 = new FrameLayout();
frameBack2.Y = frameBack1.Bottom + Application.GetRealHeight(8);
frameBack2.Height = Application.GetRealHeight(50);
frameBack2.BackgroundColor = CSS_Color.MainBackgroundColor;
bodyFrameLayout.AddChidren(frameBack2);
//确认转移
var btnConform = new NormalViewControl(200, 24, true);
btnConform.Gravity = Gravity.Center;
btnConform.TextSize = CSS_FontSize.SubheadingFontSize;
btnConform.TextAlignment = TextAlignment.Center;
btnConform.TextColor = CSS_Color.MainColor;
btnConform.TextID = StringId.ConfirmTransfer2;
frameBack2.AddChidren(btnConform);
btnConform.ButtonClickEvent += (sender, e) =>
{
//如果设置有安全验证,则需要验证
HdlCheckLogic.Current.CheckUnlockSecurity(true, (div) =>
{
//如果没有设置有安全验证
if (div == 0)
{
//确认转移{0}的管理员权限给账号{1}
string msg = Language.StringByID(StringId.TransferreConfirmMsg3).Replace("{0}", DB_ResidenceData.Instance.CurrentRegion.homeName);
msg = msg.Replace("{1}", btnName.Text);
HdlMessageLogic.Current.ShowMassage(ShowMsgType.Confirm, msg, () =>
{
//执行迁移管理员权限
this.DoAdminAuthorityMigration();
});
}
else
{
//执行迁移管理员权限
this.DoAdminAuthorityMigration();
}
});
};
HdlThreadLogic.Current.RunThread(() =>
{
//用线程去下载头像
var headImageBytes = ImageUtlis.Current.DownHeadImageByImageKey(this.memberInfo.memberHeadIcon, true);
if (headImageBytes != null && headImageBytes.Length > 0)
{
HdlThreadLogic.Current.RunMain(() =>
{
btnHeadImage.ImageBytes = headImageBytes;
}, ShowErrorMode.NO);
}
});
}
#endregion
#region ■ 执行迁移管理员权限_________________
///
/// 执行迁移管理员权限
///
private void DoAdminAuthorityMigration()
{
this.ShowProgressBar();
HdlThreadLogic.Current.RunThread(() =>
{
//瞎玩的一个特效而已
System.Threading.Thread.Sleep(1000);
//执行权限迁移
var result = new DAL.Server.HttpServerRequest().AdminAuthorityMigration(this.memberInfo.childAccountId);
this.CloseProgressBar();
HdlThreadLogic.Current.RunMain(() =>
{
var form = new AdminMigrationResultPage();
form.AddForm(result);
form.FinishEvent += () =>
{
if (result == false)
{
//重试
this.DoAdminAuthorityMigration();
}
else
{
//成功 -> 刷新App缓存及界面
this.RefreshAppMemoryAndForm();
}
};
});
});
}
///
/// 刷新App缓存及界面
///
private void RefreshAppMemoryAndForm()
{
//刷新缓存(注意,里面既有ui,也有http,也有转圈的那个东西)
Common.ApiUtlis.Ins.DownloadData();
HdlThreadLogic.Current.RunThread(() =>
{
while (Common.ApiUtlis.Ins.DownloadDataComplete == false)
{
//等待DownloadData函数结束
System.Threading.Thread.Sleep(300);
}
HdlThreadLogic.Current.RunMain(() =>
{
//关闭所有界面
HdlFormLogic.Current.CloseAllOpenForm();
//获取主页的那个容器
var userPage = MainPage.BasePageView.GetChildren(MainPage.BasePageView.ChildrenCount - 1) as UserPage;
if (userPage != null)
{
//刷新个人中心界面
MainPage.CurPageIndex = 1;
userPage.ChoosePersonalCenter();
}
});
});
}
#endregion
}
}