59 lines
1.7 KiB
C#
Raw Normal View History

2022-07-15 14:27:05 +08:00
using Assets.Scripts;
using Assets.Scripts.UI.Control;
2022-07-15 13:34:43 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2022-07-15 14:27:05 +08:00
using UnityEngine.SceneManagement;
2022-07-15 13:34:43 +08:00
public class DeleteAccount : PFUIPanel
{
2022-07-18 17:07:02 +08:00
PFUIInputField password;
2022-07-15 13:34:43 +08:00
protected override void Awake()
{
2022-07-18 17:07:02 +08:00
password = transform.Find("Content/Password").GetComponent<PFUIInputField>();
2022-07-15 13:34:43 +08:00
UIManager.AddEvent(transform.Find("Content/Delete").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
2022-07-15 14:27:05 +08:00
Delete(password.Text);
2022-07-15 13:34:43 +08:00
});
UIManager.AddEvent(transform.Find("Content/Cancel").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
Close();
});
}
2022-07-15 14:27:05 +08:00
async void Delete(string pwd)
{
2022-07-18 17:07:02 +08:00
var res = await ConfigHelper.userApi.DeleteAccount(pwd,true);
2022-07-15 14:27:05 +08:00
if (res.result)
{
2022-07-18 17:07:02 +08:00
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)
{
2022-07-15 14:27:05 +08:00
#if !(UNITY_ANDROID || UNITY_IOS)
SceneManager.LoadScene("Login");
#else
2022-07-18 17:07:02 +08:00
SceneManager.LoadScene("Login-Mobile");
2022-07-15 14:27:05 +08:00
#endif
2022-07-18 17:07:02 +08:00
Close();
UIManager.CloseConfirm();
}
else
{
Utils.showToast(null, res1.errMsg);
}
});
2022-07-15 14:27:05 +08:00
}
else
{
Utils.showToast(null, res.errMsg);
}
}
2022-07-15 13:34:43 +08:00
// Start is called before the first frame update
void Start()
{
}
}