2021-04-20 13:58:00 +08:00
|
|
|
require("Base/BasePanel")
|
2020-05-09 13:31:21 +08:00
|
|
|
MailMainPanel = Inherit(BasePanel)
|
|
|
|
local this=MailMainPanel
|
|
|
|
local allMail
|
|
|
|
local openPanel
|
|
|
|
local allGetMail
|
|
|
|
local allDrop = {}
|
2021-01-15 22:11:38 +08:00
|
|
|
local isPlayAnim = true
|
2020-05-09 13:31:21 +08:00
|
|
|
--初始化组件(用于子类重写)
|
|
|
|
function MailMainPanel:InitComponent()
|
|
|
|
|
|
|
|
allGetMail={}
|
|
|
|
this.closeBtn = Util.GetGameObject(self.gameObject, "bg/closeBtn")
|
|
|
|
this.mialNum = Util.GetGameObject(self.gameObject, "bg/mialNum"):GetComponent("Text")
|
|
|
|
this.DeleMialText = Util.GetGameObject(self.gameObject, "bg/DeleMialText"):GetComponent("Text")
|
|
|
|
this.mailPre=Util.GetGameObject(self.gameObject, "mailPre")
|
|
|
|
this.GetAllMailBtn=Util.GetGameObject(self.gameObject, "GetAllMailBtn")
|
|
|
|
this.DelReadMailBtn=Util.GetGameObject(self.gameObject, "DelReadMailBtn")
|
|
|
|
this.ScrollBar=Util.GetGameObject(self.gameObject, "Scrollbar"):GetComponent("Scrollbar")
|
|
|
|
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.gameObject.transform,
|
2020-06-28 17:48:49 +08:00
|
|
|
this.mailPre, this.ScrollBar, Vector2.New(940, 1160), 1, 1, Vector2.New(19.32,15))
|
|
|
|
this.ScrollView.gameObject:GetComponent("RectTransform").anchoredPosition = Vector2.New(10,-30)
|
2020-05-09 13:31:21 +08:00
|
|
|
this.ScrollView.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5)
|
|
|
|
this.ScrollView.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5)
|
|
|
|
this.ScrollView.moveTween.MomentumAmount = 1
|
|
|
|
this.ScrollView.moveTween.Strength = 1
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--绑定事件(用于子类重写)
|
|
|
|
function MailMainPanel:BindEvent()
|
|
|
|
|
|
|
|
Util.AddClick(this.closeBtn, function()
|
2021-01-15 22:11:38 +08:00
|
|
|
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
2020-05-09 13:31:21 +08:00
|
|
|
self:ClosePanel()
|
|
|
|
end)
|
|
|
|
Util.AddClick(this.GetAllMailBtn, function()
|
|
|
|
allGetMail={}
|
|
|
|
for i = 1, #allMail do
|
|
|
|
if allMail[i].state<3 and allMail[i].mailItem ~= "" then
|
|
|
|
table.insert(allGetMail,allMail[i].mailId)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if allGetMail and #allGetMail>0 then
|
|
|
|
this.GetMailData3()
|
|
|
|
else
|
2021-04-09 12:26:35 +08:00
|
|
|
PopupTipPanel.ShowTip(Language[11165])
|
2020-05-09 13:31:21 +08:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
Util.AddClick(this.DelReadMailBtn, function()
|
|
|
|
local DelMails={}
|
|
|
|
for i = 1, #allMail do
|
|
|
|
if allMail[i].state >= 1 and allMail[i].mailItem=="" then--已读取 未领取 无附件
|
|
|
|
table.insert(DelMails,allMail[i].mailId)
|
|
|
|
elseif allMail[i].state >= 3 then--已领取
|
|
|
|
table.insert(DelMails,allMail[i].mailId)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if DelMails and #DelMails>0 then
|
|
|
|
this.DelMailData(DelMails)
|
|
|
|
else
|
2021-04-09 12:26:35 +08:00
|
|
|
PopupTipPanel.ShowTip(Language[11166])
|
2020-05-09 13:31:21 +08:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
function this.DelMailData(DelMails)
|
|
|
|
if DelMails and #DelMails > 0 then
|
|
|
|
NetManager.DelMailData(DelMails,function ()
|
|
|
|
for i = 1, #DelMails do
|
|
|
|
MailManager.DelSingleMial(DelMails[i])
|
|
|
|
end
|
|
|
|
this.UpdateMailData()
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
function this.GetMailData(index)
|
|
|
|
if index > 0 then
|
|
|
|
NetManager.GetSingleMailRewardData({allGetMail[index]},function (_drop)
|
|
|
|
MailManager.UpdataMialIsReadState(allGetMail[index],3)
|
|
|
|
UIManager.OpenPanel(UIName.RewardItemPopup,_drop,1,function()
|
|
|
|
if UIManager.IsOpen(UIName.PatFacePanel) then--如果弹星级成长礼 就会打断所有邮件的领取
|
|
|
|
this.UpdateMailData()
|
|
|
|
else
|
|
|
|
this.GetMailData(index-1)
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
else
|
|
|
|
this.UpdateMailData()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function this.GetMailData3()
|
|
|
|
NetManager.GetSingleMailRewardData(allGetMail,function (_drop)
|
2021-01-25 16:00:57 +08:00
|
|
|
-- for index = 1, #allGetMail do
|
|
|
|
-- MailManager.UpdataMialIsReadState(allGetMail[index],3)
|
|
|
|
-- end
|
|
|
|
NetManager.GetAllMailData(function ()
|
2021-02-26 14:52:59 +08:00
|
|
|
this.OnShowMailListData(MailManager.mialDataList, true,true)
|
2021-01-25 16:00:57 +08:00
|
|
|
end)
|
|
|
|
UIManager.OpenPanel(UIName.RewardItemPopup,_drop,1,function ()
|
|
|
|
this.UpdateMailData()
|
|
|
|
end)
|
2021-02-20 17:05:22 +08:00
|
|
|
CheckRedPointStatus(RedPointType.Mail_Local)
|
2020-05-09 13:31:21 +08:00
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
|
|
|
--添加事件监听(用于子类重写)
|
|
|
|
function MailMainPanel:AddListener()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
|
|
|
function MailMainPanel:RemoveListener()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
|
|
function MailMainPanel:OnOpen(...)
|
|
|
|
|
|
|
|
local data={...}
|
|
|
|
openPanel=data[1]
|
|
|
|
end
|
|
|
|
function MailMainPanel:OnShow()
|
|
|
|
Log("MailMainPanel:OnShow")
|
2021-01-15 22:11:38 +08:00
|
|
|
isPlayAnim = true
|
2020-05-09 13:31:21 +08:00
|
|
|
allMail={}
|
|
|
|
NetManager.GetAllMailData(function ()
|
2021-02-26 14:52:59 +08:00
|
|
|
this.OnShowMailListData(MailManager.mialDataList, true,true)
|
2020-05-09 13:31:21 +08:00
|
|
|
end)
|
|
|
|
end
|
|
|
|
function this.CallBackOnShow()
|
|
|
|
allMail={}
|
|
|
|
NetManager.GetAllMailData(function ()
|
|
|
|
this.OnShowMailListData(MailManager.mialDataList)
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
local maildataCount=0--数据数量
|
|
|
|
--设置英雄列表数据
|
2021-02-26 14:52:59 +08:00
|
|
|
function this.OnShowMailListData(_allMail, isTop,isAni)
|
|
|
|
LogRed("isTop "..tostring(isTop).." isAni "..tostring(isAni))
|
2020-05-09 13:31:21 +08:00
|
|
|
allMail= _allMail
|
|
|
|
this:SortAllMail(allMail)
|
|
|
|
maildataCount=#allMail
|
2021-04-09 12:26:35 +08:00
|
|
|
this.mialNum.text=Language[11167]..maildataCount
|
2020-05-09 13:31:21 +08:00
|
|
|
this.ScrollView:SetData(allMail, function (index, go)
|
|
|
|
this.SingleMialDataShow(go, allMail[index])
|
2021-02-26 14:52:59 +08:00
|
|
|
end, not isTop,not isAni)
|
2021-01-15 22:11:38 +08:00
|
|
|
-- if isPlayAnim then
|
|
|
|
-- SecTorPlayAnimByScroll(this.ScrollView)
|
|
|
|
-- isPlayAnim = false
|
|
|
|
-- end
|
2020-05-09 13:31:21 +08:00
|
|
|
end
|
|
|
|
function this.SingleMialDataShow(_go,_mailData)
|
|
|
|
local mailImage = Util.GetGameObject(_go.transform, "mailImage")
|
|
|
|
local openMailImage = Util.GetGameObject(_go.transform, "openMailImage")
|
|
|
|
local getOk = Util.GetGameObject(_go.transform, "goBtn/getOk")
|
|
|
|
local goBtn = Util.GetGameObject(_go.transform, "goBtn")
|
|
|
|
if _mailData.state==nil then
|
|
|
|
_mailData.state=0
|
|
|
|
end
|
|
|
|
if _mailData.mailItem=="" then--无附件
|
|
|
|
goBtn:SetActive(false)
|
|
|
|
else
|
|
|
|
goBtn:SetActive(true)
|
|
|
|
end
|
|
|
|
if _mailData.state==0 then--未读
|
|
|
|
mailImage :SetActive(true)
|
|
|
|
openMailImage :SetActive(false)
|
|
|
|
getOk :SetActive(false)
|
|
|
|
elseif _mailData.state==1 then--已读取
|
|
|
|
mailImage :SetActive(false)
|
|
|
|
openMailImage :SetActive(true)
|
|
|
|
getOk :SetActive(false)
|
|
|
|
elseif _mailData.state==2 then--未领取
|
|
|
|
mailImage :SetActive(false)
|
|
|
|
openMailImage :SetActive(true)
|
|
|
|
getOk :SetActive(false)
|
|
|
|
elseif _mailData.state==3 then--已领取
|
|
|
|
mailImage :SetActive(false)
|
|
|
|
openMailImage :SetActive(true)
|
|
|
|
getOk :SetActive(true)
|
|
|
|
end
|
2021-01-15 22:11:38 +08:00
|
|
|
Util.GetGameObject(_go.transform, "infoText"):GetComponent("Text").text = _mailData.head
|
2021-04-09 12:26:35 +08:00
|
|
|
Util.GetGameObject(_go.transform, "sendText"):GetComponent("Text").text = GetTimeStrBySeconds(_mailData.sendTime)--Language[11168].._mailData.sendName
|
2020-05-09 13:31:21 +08:00
|
|
|
local mialBtn = Util.GetGameObject(_go.transform, "Imagebg")
|
|
|
|
Util.AddOnceClick(mialBtn, function()
|
|
|
|
if _mailData.state==0 then--未读
|
|
|
|
NetManager.ReadSingleMailData(_mailData.mailId,function ()
|
|
|
|
MailManager.UpdataMialIsReadState(_mailData.mailId,1)
|
2021-03-02 15:59:29 +08:00
|
|
|
Log("读取邮件成功 ".._mailData.mailId)
|
2021-04-10 15:37:10 +08:00
|
|
|
UIManager.OpenPanel(UIName.MainSingleInfoPanel,MailManager.GetSingleMail(_mailData.mailId),this)
|
2020-05-09 13:31:21 +08:00
|
|
|
this.UpdateMailData()
|
|
|
|
end)
|
2021-04-10 15:37:10 +08:00
|
|
|
else
|
|
|
|
NetManager.ReadSingleMailData(_mailData.mailId,function ()
|
|
|
|
UIManager.OpenPanel(UIName.MainSingleInfoPanel,MailManager.GetSingleMail(_mailData.mailId),this)
|
|
|
|
end)
|
2020-05-09 13:31:21 +08:00
|
|
|
end
|
|
|
|
end)
|
2021-01-15 22:11:38 +08:00
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
Util.GetGameObject(_go.transform, "mialRedPoint"):SetActive( _mailData.state==0)
|
2021-01-15 22:11:38 +08:00
|
|
|
-- if isPlayAnim then
|
|
|
|
-- _go:SetActive(false)
|
|
|
|
-- else
|
|
|
|
-- _go:SetActive(true)
|
|
|
|
-- end
|
2020-05-09 13:31:21 +08:00
|
|
|
end
|
|
|
|
function this.UpdateMailData()
|
|
|
|
this.OnShowMailListData(MailManager.mialDataList)
|
|
|
|
end
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
|
|
function MailMainPanel:OnClose()
|
|
|
|
|
|
|
|
if openPanel then
|
|
|
|
openPanel.RefreshRedPoint()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
function MailMainPanel:OnDestroy()
|
|
|
|
|
|
|
|
|
|
|
|
this.ScrollView = nil
|
|
|
|
end
|
|
|
|
|
|
|
|
function MailMainPanel:SortAllMail(allMail)
|
|
|
|
table.sort(allMail, function(a,b)
|
|
|
|
--return a.state < b.state
|
|
|
|
if a.state == b.state then
|
|
|
|
return a.sendTime > b.sendTime
|
|
|
|
else
|
|
|
|
return a.state < b.state
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
2020-06-23 18:36:24 +08:00
|
|
|
return MailMainPanel
|