邮件功能完成

This commit is contained in:
Caiyanpeng committed 2022-03-02 17:54:06 +08:00
1 parent b039388a59
commit 01df299251
42 files changed
+5747 -1781

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
using Assets.Scripts.Apis.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace Assets.Scripts.Apis
{
public class MailApi : ApiBase
{
public async Task<JsonResult<List<MailModel>>> GetList(int pageIndex,int pageSize, int type)
{
var result = await GetAsync<JsonResult<List<MailModel>>>($"Message/GetList?pageIndex={pageIndex}&pageSize={pageSize}&type={type}");
return result;
}
public async Task<JsonResult<object>> MarkRead(int id)
{
var result = await PostAsync<JsonResult<object>>("Message/MarkRead",new { id});
return result;
}
public async Task<JsonResult<object>> Delete(int id)
{
var result = await PostAsync<JsonResult<object>>("Message/Delete", new { id });
return result;
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 593b04d43282490459537d561d16096d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+1 -2
View File
@@ -1,5 +1,4 @@
using Assets.Scenes.Ride.Scripts.Model;
using Assets.Scenes.Ride.Scripts.Model;
using Assets.Scripts.Apis.Models;
using System;
using System.Collections.Generic;
+20
View File
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Assets.Scripts.Apis.Models
{
public class MailModel
{
public int Id { get; set; }
public string Title { get; set; }
public string Desc { get; set; }
public bool IsRead { get; set; }
public DateTime CreateTime { get; set; }
public int Type { get; set; }
public int SendUserId { get; set; }
public string SendNickName { get; set; }
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3dd81357979eb03468cc496795d1e8fd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+17 -1
View File
@@ -20,7 +20,7 @@ public delegate void ChangeLanguageDelegate();
public static class App
{
public static string Host = "http://192.168.0.101:5083/";
public static string Host = "http://192.168.0.101:5087/";
public static string AppVersion = Application.version;
@@ -191,6 +191,22 @@ public static class App
}
}
public static List<MailModel> CurrentUserMails { get; set; }
//public static event hasNotReadEvent;
public static event EventHandler HasNotReadChanged;
public static bool _hasNotRead;
public static bool hasNotRead
{
get => _hasNotRead;
set
{
_hasNotRead = value;
if (HasNotReadChanged != null)
{
HasNotReadChanged(value, new EventArgs());
}
}
}
public static bool CanOpenAd = false;
public static Dictionary<string, string> websiteDict = new Dictionary<string, string>()
+10
View File
@@ -78,5 +78,15 @@ namespace Assets.Scripts
return _rowerApi;
}
}
private static MailApi _mailApi;
internal static MailApi mailApi
{
get
{
if (_mailApi == null) _mailApi = new MailApi();
return _mailApi;
}
}
}
}
+1
View File
@@ -29,6 +29,7 @@ public class MainController : BaseScene
Loom.Initialize();
msg = transform.Find("GameObject/Message").GetComponent<CanvasGroup>();
InitialMessage();
MailReceiver.Instance().GetMessage();
#if UNITY_ANDROID || UNITY_IOS
transform.GetComponent<CanvasScaler>().referenceResolution = new Vector2(844, 390);
//transform.Find("Panel").GetComponent<RectTransform>().sizeDelta = new Vector2(844, 390);
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1fa036e3dd69a3a4686ffb7a3bfb530a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -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:
+11 -1
View File
@@ -3,6 +3,7 @@ using DG.Tweening;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
@@ -81,7 +82,17 @@ public class MainNav : MonoBehaviour
{
UIManager.ShowFeedBackModal();
});
UIManager.AddEvent(transform.Find("Mail").gameObject, EventTriggerType.PointerClick, x =>
{
UIManager.ShowMailListPanel();
});
App.HasNotReadChanged -= ShowMailDot;
App.HasNotReadChanged += ShowMailDot;
}
private void ShowMailDot(object sender, EventArgs e)
{
transform.Find("Mail/Dot").gameObject.SetActive((bool)sender);
}
public void ShowRowerTab()
@@ -126,7 +137,6 @@ public class MainNav : MonoBehaviour
}
#endif
}
public void ShowExit()
{
if (exit)
+32
View File
@@ -425,7 +425,39 @@ public class UIManager : MonoBehaviour
{
UIManager.Show(UIManager.Instance.AddressController, null, true);
}
#region 邮件相关
MailListController mMailListController;
public MailListController MailListController
{
get
{
return this.GetPanelInstance("MailListPanel", ref this.mMailListController);
}
}
public static void ShowMailListPanel()
{
UIManager.Show(UIManager.Instance.MailListController, null, true);
}
MailDetailController mMailDetailController;
public MailDetailController MailDetailController
{
get
{
return this.GetPanelInstance("MailDetailPanel", ref this.mMailDetailController);
}
}
public static void ShowMailDetailPanel(MailModel item)
{
UIManager.Instance.MailDetailController.Initial(item);
UIManager.Instance.Invoke("ShowMailDetailPanel", 0.1f);
}
public void ShowMailDetailPanel()
{
UIManager.Show(UIManager.Instance.MailDetailController, null, true);
}
#endregion
#region 比赛点击弹窗
private RaceModalScript mRaceModalScript;
public RaceModalScript RaceDetailModal