88 lines
2.6 KiB
C#
88 lines
2.6 KiB
C#
using System;
|
|
using asap.core;
|
|
using game;
|
|
using GameCore;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class AccountSwitchConfirmPopupPanel : MonoBehaviour
|
|
{
|
|
public class ChangeLinkAccountData
|
|
{
|
|
// public EAccoutType accoutType;
|
|
public int oldUserId;
|
|
public int newUserId;
|
|
}
|
|
|
|
[SerializeField]
|
|
private Head savedAvatar;
|
|
[SerializeField]
|
|
private TMP_Text savedDisplayName;
|
|
[SerializeField]
|
|
private TMP_Text savedLevel;
|
|
|
|
[SerializeField]
|
|
private Button confirmBtn;
|
|
|
|
[SerializeField]
|
|
private Button cancelBtn;
|
|
|
|
private ChangeLinkAccountData changeLinkAccountData;
|
|
|
|
private void OnEnable()
|
|
{
|
|
confirmBtn.onClick.AddListener(OnConfirm);
|
|
cancelBtn.onClick.AddListener(OnCancel);
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
confirmBtn.onClick.RemoveAllListeners();
|
|
cancelBtn.onClick.RemoveAllListeners();
|
|
}
|
|
|
|
public void SetData(string displayName, Sprite avatar, int otherLevel, ChangeLinkAccountData changeLinkAccountData = null)
|
|
{
|
|
savedDisplayName.text = displayName;
|
|
savedLevel.text = otherLevel.ToString();
|
|
savedAvatar.icon_head.sprite = avatar;
|
|
this.changeLinkAccountData = changeLinkAccountData;
|
|
}
|
|
|
|
private async void OnConfirm()
|
|
{
|
|
// try
|
|
// {
|
|
// UIManager.Instance.DestroyUI(UITypes.AccountSwitchConfirmPopupPanel);
|
|
// if (changeLinkAccountData == null)
|
|
// {
|
|
// QuitStage.Logout = true;
|
|
// await GContext.container.Resolve<IStageService>().SwitchStageAsync("QuitStage");
|
|
// }
|
|
// else
|
|
// {
|
|
// var result = await TYSdkFacade.Instance.ChangeLinkAccount(changeLinkAccountData.accoutType, changeLinkAccountData.oldUserId, changeLinkAccountData.newUserId);
|
|
// if (result.code != 0)
|
|
// {
|
|
// var msg = LocalizationMgr.GetText("UI_BindAccountPopupPanel_101008");
|
|
// ToastPanel.Show($"{msg} [{result.code}]");
|
|
// return;
|
|
// }
|
|
// }
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// Debug.LogError(e);
|
|
// var msg = LocalizationMgr.GetText("UI_BindAccountPopupPanel_101008");
|
|
// ToastPanel.Show($"{msg} [-2]");
|
|
// }
|
|
}
|
|
|
|
private void OnCancel()
|
|
{
|
|
// UIManager.Instance.DestroyUI(UITypes.AccountSwitchConfirmPopupPanel);
|
|
// TYSdkFacade.Instance.CleanLinkTempSnSInfo();
|
|
}
|
|
}
|