2020-08-06 17:52:32 +08:00
|
|
|
|
--[[
|
2020-05-09 13:31:21 +08:00
|
|
|
|
* @ClassName CumulativeSignInPage
|
|
|
|
|
|
* @Description 累计签到
|
|
|
|
|
|
* @Date 2019/8/1 20:07
|
|
|
|
|
|
* @Author MagicianJoker, fengliudianshao@outlook.com
|
|
|
|
|
|
* @Copyright Copyright (c) 2019, MagicianJoker
|
|
|
|
|
|
--]]
|
|
|
|
|
|
---@class CumulativeSignInPage
|
|
|
|
|
|
local CumulativeSignInPage = quick_class("CumulativeSignInPage")
|
|
|
|
|
|
local kMaxDay = 31
|
|
|
|
|
|
--已领取 再领一次
|
|
|
|
|
|
local receiveImage={[1]="s_slbz_yilingqu",[2]="r_meiriqiandao_zailingyici"}
|
|
|
|
|
|
--本地标记可领取次数
|
|
|
|
|
|
local receiveNum=0
|
|
|
|
|
|
--今日是否充值标记 1未充值 2已充值
|
|
|
|
|
|
local rechargeNum=0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function CumulativeSignInPage:ctor(mainPanel, gameObject)
|
|
|
|
|
|
self.mainPanel = mainPanel
|
|
|
|
|
|
self.gameObject = gameObject
|
|
|
|
|
|
|
|
|
|
|
|
self.signInContent = Util.GetGameObject(self.gameObject, "signList/viewPort/content")
|
|
|
|
|
|
self.signInItem = Util.GetGameObject(self.signInContent, "signInItem")
|
|
|
|
|
|
self.signInItem:SetActive(false)
|
|
|
|
|
|
self.signInList = {}
|
|
|
|
|
|
self.signInRewardList = {}
|
|
|
|
|
|
end
|
|
|
|
|
|
local sortingOrder = 0
|
|
|
|
|
|
function CumulativeSignInPage:OnShow(_sortingOrder)
|
|
|
|
|
|
sortingOrder = _sortingOrder
|
|
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.FiveAMRefresh.ServerNotifyRefresh, self.RefreshPanel, self)
|
|
|
|
|
|
self.gameObject:SetActive(true)
|
|
|
|
|
|
self:RefreshPanel()
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function CumulativeSignInPage:OnHide()
|
|
|
|
|
|
self.gameObject:SetActive(false)
|
|
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.FiveAMRefresh.ServerNotifyRefresh, self.RefreshPanel, self)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function CumulativeSignInPage:RefreshPanel()
|
|
|
|
|
|
self.SignData = OperatingManager.GetSignInData()
|
|
|
|
|
|
if table.nums(self.signInList) <= 0 then
|
|
|
|
|
|
self:CreateSignList()
|
|
|
|
|
|
end
|
|
|
|
|
|
self:RefreshSignList()
|
|
|
|
|
|
end
|
|
|
|
|
|
function CumulativeSignInPage:OnSortingOrderChange(cursortingOrder)
|
|
|
|
|
|
if self.signInRewardList then
|
|
|
|
|
|
for i=1, #self.signInRewardList do
|
|
|
|
|
|
self.signInRewardList[i]:SetEffectLayer(cursortingOrder)
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
--创建List
|
|
|
|
|
|
function CumulativeSignInPage:CreateSignList()
|
|
|
|
|
|
for i = 1, kMaxDay do
|
|
|
|
|
|
self.signInList[i] = newObjToParent(self.signInItem, self.signInContent)
|
2020-05-25 19:16:23 +08:00
|
|
|
|
self.signInList[i].gameObject.name = "signInReward_"..i
|
2020-05-09 13:31:21 +08:00
|
|
|
|
self.signInRewardList[i] = SubUIManager.Open(SubUIConfig.ItemView, Util.GetGameObject(self.signInList[i], "rewardPos").transform)
|
|
|
|
|
|
end
|
|
|
|
|
|
table.walk(self.signInList, function(signInItem)
|
|
|
|
|
|
signInItem:SetActive(false)
|
|
|
|
|
|
end)
|
|
|
|
|
|
end
|
|
|
|
|
|
--刷新List
|
|
|
|
|
|
function CumulativeSignInPage:RefreshSignList()
|
|
|
|
|
|
receiveNum=PrivilegeManager.GetPrivilegeRemainValue(PRIVILEGE_TYPE.DAY_SIGN_IN)--可领取次数
|
|
|
|
|
|
rechargeNum=PrivilegeManager.GetPrivilegeNumber(PRIVILEGE_TYPE.DAY_SIGN_IN)--充值标记 1未充值 2已充值
|
|
|
|
|
|
CheckRedPointStatus(RedPointType.CumulativeSignIn)
|
|
|
|
|
|
|
|
|
|
|
|
table.walk(self.signInList, function(signInItem)
|
|
|
|
|
|
signInItem:SetActive(false)
|
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
--控制添加点击事件
|
2020-06-03 19:09:01 +08:00
|
|
|
|
local _month = 1--math.floor(os.date("%m", GetTimeStamp()))
|
|
|
|
|
|
local signInConfigs = ConfigManager.GetConfig(ConfigName.SignInConfig)--, "Month", _month)
|
|
|
|
|
|
local i = 0
|
|
|
|
|
|
for _, signInfo in ConfigPairs(signInConfigs) do
|
|
|
|
|
|
i = i + 1
|
|
|
|
|
|
local day = i
|
2020-05-09 13:31:21 +08:00
|
|
|
|
Util.AddOnceClick(Util.GetGameObject(self.signInList[i], "receiveBtn"), function()
|
2020-06-03 19:09:01 +08:00
|
|
|
|
self:OnSignInClicked(signInfo.Id, day)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end)
|
|
|
|
|
|
self.signInRewardList[i]:OnOpen(false, signInfo.reward,1,false,false,false,sortingOrder)
|
|
|
|
|
|
self.signInList[i]:SetActive(true)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local dayIndexEnd
|
|
|
|
|
|
if self.SignData.state == 0 then
|
|
|
|
|
|
dayIndexEnd = self.SignData.days
|
|
|
|
|
|
else
|
|
|
|
|
|
dayIndexEnd = self.SignData.days + 1
|
|
|
|
|
|
end
|
|
|
|
|
|
dayIndexEnd = dayIndexEnd >= kMaxDay and kMaxDay or dayIndexEnd
|
|
|
|
|
|
|
|
|
|
|
|
for i, signInItem in ipairs(self.signInList) do
|
|
|
|
|
|
if i < dayIndexEnd then
|
|
|
|
|
|
--默认已过去的天数都赋值已领取图片
|
|
|
|
|
|
Util.GetGameObject(signInItem, "received"):GetComponent("Image").sprite=Util.LoadSprite(receiveImage[1])
|
|
|
|
|
|
self:SetIcon(1,Util.GetGameObject(self.signInList[dayIndexEnd-1], "received"))
|
|
|
|
|
|
end
|
|
|
|
|
|
Util.GetGameObject(signInItem, "received"):SetActive(i < dayIndexEnd)--已过天数显示已领取
|
|
|
|
|
|
Util.GetGameObject(signInItem, "receiveBtn"):SetActive(i < dayIndexEnd)--已过天数开启按钮点击事件
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--当已第一次签到 设置图片
|
|
|
|
|
|
if self.SignData.state==1 and ((receiveNum==0 and rechargeNum==1) or (receiveNum==1 and rechargeNum==2)) then
|
|
|
|
|
|
local received=Util.GetGameObject(self.signInList[dayIndexEnd-1], "received")
|
|
|
|
|
|
received:GetComponent("Image").sprite=Util.LoadSprite(receiveImage[2])
|
|
|
|
|
|
self:SetIcon(2,received)
|
|
|
|
|
|
Util.GetGameObject(self.signInList[dayIndexEnd-1], "redPoint"):SetActive(self:CheckRedPoint())--红点显隐
|
|
|
|
|
|
Util.GetGameObject(self.signInList[dayIndexEnd-1], "receiveBtn"):SetActive(self:CheckIsReceive())--该奖励按钮是否可点击
|
|
|
|
|
|
else
|
|
|
|
|
|
Util.GetGameObject(self.signInList[dayIndexEnd], "redPoint"):SetActive(self:CheckRedPoint())--红点显隐
|
|
|
|
|
|
Util.GetGameObject(self.signInList[dayIndexEnd], "receiveBtn"):SetActive(self:CheckIsReceive())--该奖励按钮是否可点击
|
|
|
|
|
|
end
|
2020-06-13 11:47:13 +08:00
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
|
|
if dayIndexEnd >= 25 then
|
|
|
|
|
|
self.signInContent.transform.anchoredPosition3D = Vector3(0, 150, 0)
|
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--点击事件
|
|
|
|
|
|
function CumulativeSignInPage:OnSignInClicked(Id, index)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
Log(index.."||"..self.SignData.days)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
if index < self.SignData.days then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[10350])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif index == self.SignData.days then
|
|
|
|
|
|
if receiveNum>0 then
|
|
|
|
|
|
NetManager.RequestSignIn(Id, function(respond)
|
|
|
|
|
|
PrivilegeManager.RefreshPrivilegeUsedTimes(PRIVILEGE_TYPE.DAY_SIGN_IN,1)--本地刷新下次数
|
|
|
|
|
|
UIManager.OpenPanel(UIName.RewardItemPopup, respond.drop, 1)
|
|
|
|
|
|
OperatingManager.SetSignInData({
|
|
|
|
|
|
days = index,
|
|
|
|
|
|
state = 1
|
|
|
|
|
|
})
|
|
|
|
|
|
self.SignData.state = 1
|
|
|
|
|
|
Util.GetGameObject(self.signInList[index], "redPoint"):SetActive(false)
|
|
|
|
|
|
self:RefreshSignList()
|
|
|
|
|
|
end)
|
|
|
|
|
|
elseif receiveNum==0 and rechargeNum==1 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
MsgPanel.ShowTwo(Language[11446], function()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end, function()
|
|
|
|
|
|
JumpManager.GoJump(27001)
|
2020-06-23 18:36:24 +08:00
|
|
|
|
end, Language[10719], Language[10023],nil, false)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
else
|
2020-06-23 18:36:24 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[10350])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
else
|
2020-06-23 18:36:24 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[11447])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--检查是否可领取 当未第一次签到 或 第一次签到后 (未充值 本地领s取次数为0)或(已充值 今天有领取次数)
|
|
|
|
|
|
function CumulativeSignInPage:CheckIsReceive()
|
|
|
|
|
|
return self.SignData.state==0 or (self.SignData.state==1 and ((receiveNum==0 and rechargeNum==1) or (receiveNum==1 and rechargeNum==2)))
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function CumulativeSignInPage:CheckRedPoint()
|
|
|
|
|
|
return self.SignData.state==0 or receiveNum>0
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--设置图片转换 index 1已领取 2再领一次
|
|
|
|
|
|
function CumulativeSignInPage:SetIcon(index,root)
|
|
|
|
|
|
if index==1 then
|
|
|
|
|
|
root:GetComponent("Image"):SetNativeSize()
|
|
|
|
|
|
root.transform.localEulerAngles = Vector3.New(0, 0, 0)
|
|
|
|
|
|
root.transform.sizeDelta = Vector2.New(190, 116)
|
|
|
|
|
|
elseif index==2 then
|
|
|
|
|
|
root:GetComponent("Image"):SetNativeSize()
|
|
|
|
|
|
root.transform.localEulerAngles = Vector3.New(0, 0, 6.2)
|
|
|
|
|
|
root.transform.sizeDelta = Vector2.New(185.57, 99.26)
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return CumulativeSignInPage
|