1. 新增加速度传感器设备不稳定错误提示 2. 新增多套密码校验规则与多语言文案 3. 重构个人页面与密码设置面板的校验逻辑 4. 优化设备状态错误展示与UI布局 5. 新增重置密码相关的UI资源与逻辑
168 lines
5.8 KiB
C#
168 lines
5.8 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using Kill.Managers;
|
|
using UnityEngine.UI;
|
|
using Kill.Network;
|
|
using System.Threading.Tasks;
|
|
using Kill.UI.Components;
|
|
namespace Kill.UI.Pages
|
|
{
|
|
|
|
public class SelfInfoPage : MonoBehaviour
|
|
{
|
|
UserInfo userInfo;
|
|
public RawImage avatarImage;
|
|
public Text nicknameText;
|
|
public RenamePage renamePagePrefab;
|
|
public Button renameButton;
|
|
public Button backButton;
|
|
public SelfVerificationCodePanel verificationCodePanelPrefab;
|
|
public SelfSetPasswordPanel setPasswordPanelPrefab;
|
|
public SelectCountry selectCountryPrefab;
|
|
public Text countryText;
|
|
public Button selectCountryButton;
|
|
List<string> passwordSetKeys = new List<string> { "100200", "100201" };
|
|
public Button signoutButton;
|
|
/// <summary>
|
|
/// 0设置 1修改
|
|
/// </summary>
|
|
List<string> passwordSet;
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 0简单密码 1复杂密码
|
|
/// </summary>
|
|
public Button resetPassword;
|
|
public async Task Init(UserInfo userInfo)
|
|
{
|
|
this.userInfo = userInfo;
|
|
UIManager.Instance.RegisterBackAction(OnBack);
|
|
backButton.onClick.RemoveAllListeners();
|
|
backButton.onClick.AddListener(OnBack);
|
|
resetPassword.onClick.RemoveAllListeners();
|
|
resetPassword.onClick.AddListener(OnSetPassword);
|
|
renameButton.onClick.RemoveAllListeners();
|
|
renameButton.onClick.AddListener(() =>
|
|
{
|
|
RenamePage renamePage = Instantiate(renamePagePrefab, transform);
|
|
renamePage.Init(userInfo.username, CloseRenamePage, 1);
|
|
});
|
|
signoutButton.onClick.RemoveAllListeners();
|
|
signoutButton.onClick.AddListener(ClickSignOut);
|
|
// 在这里初始化个人信息页面,显示用户信息
|
|
if (avatarImage != null)
|
|
{
|
|
// 设置头像
|
|
if (userInfo.avatar != null)
|
|
{
|
|
avatarImage.gameObject.SetActive(true);
|
|
await NetworkCtrl.Instance.LoadImageToUIRawImageAsync(userInfo.avatar, avatarImage);
|
|
avatarImage.transform.parent.GetComponent<Mask>().showMaskGraphic = false;
|
|
}
|
|
}
|
|
|
|
if (nicknameText != null)
|
|
{
|
|
nicknameText.text = userInfo.username;
|
|
}
|
|
|
|
// 国家展示与选择
|
|
if (countryText != null)
|
|
UpdateCountryDisplay(userInfo.country_code);
|
|
if (selectCountryButton != null)
|
|
{
|
|
selectCountryButton.onClick.RemoveAllListeners();
|
|
selectCountryButton.onClick.AddListener(OnSelectCountry);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新国家显示文本
|
|
/// </summary>
|
|
private void UpdateCountryDisplay(string code)
|
|
{
|
|
if (string.IsNullOrEmpty(code))
|
|
{
|
|
countryText.text = "";
|
|
return;
|
|
}
|
|
var country = LanguageManager.Instance.countryList.Find(c => c.code == code);
|
|
bool isZh = LanguageManager.Instance.languageType == LanguageManager.LanguageType.Chinese;
|
|
countryText.text = country.code != null ? (isZh ? country.name_zh : country.name_en) : code;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 选择国家
|
|
/// </summary>
|
|
private void OnSelectCountry()
|
|
{
|
|
var selectCountry = Instantiate(selectCountryPrefab, transform);
|
|
selectCountry.Init(userInfo.country_code);
|
|
selectCountry.onConfirm = (code) =>
|
|
{
|
|
if (code != null)
|
|
{
|
|
userInfo.country_code = code;
|
|
UpdateCountryDisplay(code);
|
|
}
|
|
Destroy(selectCountry.gameObject);
|
|
UIManager.Instance.RegisterBackAction(OnBack);
|
|
};
|
|
}
|
|
public void InitLanguageText()
|
|
{
|
|
passwordSet = new List<string>();
|
|
|
|
}
|
|
public void CloseRenamePage(string newNickname)
|
|
{
|
|
if (nicknameText != null)
|
|
{
|
|
nicknameText.text = newNickname;
|
|
}
|
|
DataManager.Instance.userInfo.username = newNickname;
|
|
UIManager.Instance.RegisterBackAction(OnBack);
|
|
}
|
|
SelfVerificationCodePanel verificationCodePanel;
|
|
public void OnSetPassword()
|
|
{
|
|
verificationCodePanel = Instantiate(verificationCodePanelPrefab, transform);
|
|
verificationCodePanel.Init(OnSureVerificationCode);
|
|
}
|
|
SelfSetPasswordPanel setPasswordPanel;
|
|
public void OnSureVerificationCode()
|
|
{
|
|
Destroy(verificationCodePanel.gameObject);
|
|
setPasswordPanel = Instantiate(setPasswordPanelPrefab, transform);
|
|
setPasswordPanel.Init(OnSetPasswordSuccess);
|
|
}
|
|
public void OnSetPasswordSuccess()
|
|
{
|
|
Destroy(setPasswordPanel.gameObject);
|
|
OnSignOut();
|
|
|
|
}
|
|
public void OnBack()
|
|
{
|
|
UIManager.Instance.RegisterBackAction(GetComponentInParent<SelfPage>().OnBack);
|
|
GetComponentInParent<SelfPage>().RefreshAsync();
|
|
Destroy(gameObject);
|
|
}
|
|
public WindowTipCtrl signoutTip;
|
|
public void ClickSignOut()
|
|
{
|
|
signoutTip.gameObject.SetActive(true);
|
|
signoutTip.Init(OnSignOut,()=>{signoutTip.gameObject.SetActive(false);});
|
|
}
|
|
public void OnSignOut()
|
|
{
|
|
// 清除用户数据
|
|
DataManager.Instance.ClearInfo();
|
|
// 返回登录页面
|
|
UIManager.Instance.OpenMainPage(UIManager.PageName.loginPage);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
} |