59 lines
1.7 KiB
C#

using Assets.Scripts;
using Assets.Scripts.UI.Control;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class DeleteAccount : PFUIPanel
{
PFUIInputField password;
protected override void Awake()
{
password = transform.Find("Content/Password").GetComponent<PFUIInputField>();
UIManager.AddEvent(transform.Find("Content/Delete").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
Delete(password.Text);
});
UIManager.AddEvent(transform.Find("Content/Cancel").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
Close();
});
}
async void Delete(string pwd)
{
var res = await ConfigHelper.userApi.DeleteAccount(pwd,true);
if (res.result)
{
UIManager.ShowConfirm(App.GetLocalString("Delete Your Account"), App.GetLocalString("Are you sure you want to delete the account?"), async () =>
{
var res1 = await ConfigHelper.userApi.DeleteAccount(pwd, false);
if (res1.result)
{
#if !(UNITY_ANDROID || UNITY_IOS)
SceneManager.LoadScene("Login");
#else
SceneManager.LoadScene("Login-Mobile");
#endif
Close();
UIManager.CloseConfirm();
}
else
{
Utils.showToast(null, res1.errMsg);
}
});
}
else
{
Utils.showToast(null, res.errMsg);
}
}
// Start is called before the first frame update
void Start()
{
}
}