邮件功能完成
This commit is contained in:
1 parent
b039388a59
commit
01df299251
42 files changed
+5747
-1781
No files matched your search
@@ -0,0 +1,59 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MailDetailController : PFUIPanel
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
ScrollRect scroll;
|
||||
protected override void Awake()
|
||||
{
|
||||
UIManager.AddEvent(transform.Find("Container/Exit").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, async b =>
|
||||
{
|
||||
CloseSelf();
|
||||
});
|
||||
UIManager.AddEvent(transform.Find("Container/BtnDelete").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
UIManager.ShowConfirm(App.GetLocalString("Delete"), App.GetLocalString("Are you sure you want to delete this email?"), async () =>
|
||||
{
|
||||
if (mail != null)
|
||||
{
|
||||
await ConfigHelper.mailApi.Delete(mail.Id);
|
||||
Utils.showToast(null, "Success", type: 1);
|
||||
UIManager.CloseConfirm();
|
||||
CloseSelf();
|
||||
}
|
||||
});
|
||||
});
|
||||
scroll = transform.Find("Container/Content/Scroll View").GetComponent<ScrollRect>();
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
MailModel mail;
|
||||
public async void Initial(MailModel item)
|
||||
{
|
||||
this.mail = item;
|
||||
await ConfigHelper.mailApi.MarkRead(item.Id);
|
||||
transform.Find("Container/Title").GetComponent<Text>().text = item.Title;
|
||||
scroll.content.Find("Text").GetComponent<Text>().text = $"{item.Desc}\n\n{item.SendNickName}";
|
||||
}
|
||||
|
||||
private async void CloseSelf()
|
||||
{
|
||||
Close();
|
||||
await MailReceiver.Instance().GetMessage();
|
||||
UIManager.Instance.MailListController.Show();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 74fe80f225b0aff448f240dde817f640
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,37 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MailItemController : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Initial(MailModel item)
|
||||
{
|
||||
var color = item.IsRead ? Utils.HexToColorHtml("#5C5C6E") : Utils.HexToColorHtml("#ffffff");
|
||||
Text title = transform.Find("Content/Title").GetComponent<Text>(), time = transform.Find("Content/Time").GetComponent<Text>();
|
||||
title.text = item.Title;
|
||||
time.text = item.CreateTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
title.color = color;
|
||||
time.color = color;
|
||||
transform.Find("Content/MailImage").GetComponent<Image>().color = color;
|
||||
UIManager.AddEvent(gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
UIManager.ShowMailDetailPanel(item);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 896523cde19693d4ca337b93a7880c8a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,56 @@
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MailListController : PFUIPanel
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
ScrollRect scroll;
|
||||
GameObject mail;
|
||||
protected override void Awake()
|
||||
{
|
||||
UIManager.AddEvent(transform.Find("Container/Exit").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
Close();
|
||||
});
|
||||
scroll = transform.Find("Container/Content/Right/Scroll View").GetComponent<ScrollRect>();
|
||||
#if UNITY_STANDALONE_WIN
|
||||
mail = Resources.Load<GameObject>("UI/Prefab/Mail/MailItem");
|
||||
#endif
|
||||
}
|
||||
public override void Show()
|
||||
{
|
||||
base.Show();
|
||||
DisplayMails(App.CurrentUserMails);
|
||||
}
|
||||
|
||||
private void DisplayMails(List<MailModel> list)
|
||||
{
|
||||
scroll.content.DetachChildren();
|
||||
if (mail != null)
|
||||
{
|
||||
foreach (var item in list)
|
||||
{
|
||||
var obj = Instantiate(mail);
|
||||
obj.GetComponent<MailItemController>().Initial(item);
|
||||
//obj.SendMessage("Initial", );
|
||||
obj.transform.SetParent(scroll.content.transform);
|
||||
obj.transform.localScale = new Vector3(1, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cdfbce372733cb8438be420f311cb56e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,64 @@
|
||||
using Assets.Scripts;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MailReceiver : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
private static MailReceiver _instance = null;
|
||||
|
||||
public static bool Exists()
|
||||
{
|
||||
return _instance != null;
|
||||
}
|
||||
|
||||
public static MailReceiver Instance()
|
||||
{
|
||||
if (!Exists())
|
||||
{
|
||||
throw new Exception("UnityMainThreadDispatcher could not find the UnityMainThreadDispatcher object. Please ensure you have added the MainThreadExecutor Prefab to your scene.");
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = this;
|
||||
}
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
float timer = 10f;
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
timer -= Time.deltaTime;
|
||||
if (timer < 0)
|
||||
{
|
||||
GetMessage();
|
||||
timer += 10;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task GetMessage()
|
||||
{
|
||||
var res = await ConfigHelper.mailApi.GetList(0, 100, 0);
|
||||
if (res.result)
|
||||
{
|
||||
App.CurrentUserMails = res.data;
|
||||
App.hasNotRead = res.data.Count(x => !x.IsRead) > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 227da2d8b06aad34ca648aa8c2ab5f05
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user