miduo_client/Assets/ManagedResources/~Lua/Modules/Operating/MonthCardManager.lua

200 lines
7.3 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

MonthCardManager = {}
local this = MonthCardManager
local MonthCardText = {
[MONTH_CARD_TYPE.MONTHCARD] = "普通月卡",
[MONTH_CARD_TYPE.LUXURYMONTHCARD] = "豪华月卡",
[MONTH_CARD_TYPE.GIFT] = "挚礼月卡",
}
--初始化月卡数据
local monthCardData = {}
function this.InitMonthCardData(data)
monthCardData = {}
--LogError("月卡信息初始化 "..#data)
for i = 1, #data do
LogError("月卡信息初始化 "..data[i].id.." "..data[i].endingTime.." "..data[i].state)
local singleMonthCard = {}
singleMonthCard.id = data[i].id
singleMonthCard.endingTime = data[i].endingTime --周卡月卡结束时间
singleMonthCard.state = data[i].state --0 未购买 1 未领取 2 已领取
singleMonthCard.totleAmt = data[i].totleAmt
-- LogError("月卡信息初始化 "..i.." 月卡累计充值 "..data[i].totleAmt)
table.insert(monthCardData,singleMonthCard)
end
CheckRedPointStatus(RedPointType.MonthCard)
end
--推送更新月卡数据
function this.UpdateMonthCardData(msg)
--LogError("月卡信息推送 "..#msg.monthinfos)
--当我数据没有 后端推过来的有数据 此时需要弹窗
-- this.showStr = ""
-- for i = 1, #msg.monthinfos do
-- if monthCardData[i].endingTime <= 0 and msg.monthinfos[i].endingTime > 0 then
-- this.showStr = string.format("恭喜您成功激活%s功能是否立即前往月卡界面领取奖励。", MonthCardText[i])--Language[11384]
-- end
-- end
monthCardData = {}
local _CurActive = {}
for i = 1, #msg.monthinfos do
LogError("999999999999")
--LogError("月卡信息推送 "..msg.monthinfos[i].id.." "..msg.monthinfos[i].endingTime.." "..msg.monthinfos[i].state)
local singleMonthCard = {}
singleMonthCard.id = msg.monthinfos[i].id
singleMonthCard.endingTime = msg.monthinfos[i].endingTime
singleMonthCard.state = msg.monthinfos[i].state--0 未领取 1 已领取
singleMonthCard.totleAmt = msg.monthinfos[i].totleAmt
_CurActive[i] = true
table.insert(monthCardData,singleMonthCard)
end
-- 检测红点
CheckRedPointStatus(RedPointType.MonthCard)
-- 判断是否需要发送埋点数据
if this.showStr ~= "" then
if ActTimeCtrlManager.SingleFuncState(JumpType.Welfare) then
if _CurActive[MONTH_CARD_TYPE.MONTHCARD] then
--发送埋点数据
CustomEventManager.SendCustomEvents(FBSDKCustomEventType.FirstBuyMonthCard,0)
end
if _CurActive[MONTH_CARD_TYPE.LUXURYMONTHCARD] then
--发送埋点数据
CustomEventManager.SendCustomEvents(FBSDKCustomEventType.FirstBuyHeightMonthCard,0)
end
end
end
end
-- 检测月卡激活提示是否需要拍脸
function this.CheckMonthCardPatFace()
if this.showStr and this.showStr ~= "" then
MsgPanel.ShowTwo(this.showStr, function()
JumpManager.GoJump(36004)
end,
function()
UIManager.ClosePanel()
end,Language[10586],Language[11385])
-- 拍过后不再提示
this.showStr = ""
return true
end
end
function this.RefreshMonthCardChargeMoney(msg)
-- LogError("月卡金额信息推送 "..msg.monthSaveAmt.." "..msg.smonthSaveAmt)
monthCardData[MONTH_CARD_TYPE.MONTHCARD].totleAmt = msg.monthSaveAmt--月卡累计总额
monthCardData[MONTH_CARD_TYPE.LUXURYMONTHCARD].totleAmt = msg.smonthSaveAmt--豪华月卡累计总额
monthCardData[MONTH_CARD_TYPE.GIFT].totleAmt = msg.sincereMonth--挚礼月卡累计总额
end
-- 月卡累计总额
function this.GetmonthSaveAmt(index)
if monthCardData[index] and monthCardData[index].totleAmt then
return monthCardData[index].totleAmt
end
return 0
end
-- 豪华月卡累计总额
function this.GetsmonthSaveAmt()
return smonthSaveAmt
end
--前端设置月卡领取状态数据
function this.SetMonthCardGetStateData(type,state)
if monthCardData[type] then
monthCardData[type].state = state--0 未购买 1 未领取 2 已领取
end
CheckRedPointStatus(RedPointType.MonthCard)
end
--后端设置月卡领取状态数据 datas已领取的月卡id 五点刷新
function this.BackSetMonthCardGetStateData(datas)
-- for i = 1, #monthCardData do
-- if monthCardData[i] then--0 未领取 1 已领取
-- if datas[i] then
-- --LogError("datas[i]===="..datas[i])
-- LogError("8888888888888888")
-- monthCardData[i].state = 1
-- else
-- monthCardData[i].state = 0
-- end
-- end
-- end
for i = 1, #monthCardData do
if monthCardData[i] then--0 未领取 1 已领取
if monthCardData[i].state==2 then
monthCardData[i].state=1
end
end
-- if datas[i] then
-- -- monthCardData[i].state=0
-- LogError("66666666666")
-- end
-- if PlayerManager.serverTime>=monthCardData[i].endingTime then
-- monthCardData[i].state=0
-- end
end
--事件
CheckRedPointStatus(RedPointType.MonthCard)
Game.GlobalEvent:DispatchEvent(GameEvent.MonthCard.OnMonthCardUpdate)
end
--获取月卡数据
function this.GetMonthCardData()
if monthCardData then
return monthCardData
else
return nil
end
end
function this.IsMonthCardActive()
local curAllMonthCardData = this.GetMonthCardData()
local curMonthCardOpenState = curAllMonthCardData[MONTH_CARD_TYPE.MONTHCARD] and curAllMonthCardData[MONTH_CARD_TYPE.MONTHCARD].endingTime ~= 0
local curLuxuryMonthCardOpenState = curAllMonthCardData[MONTH_CARD_TYPE.LUXURYMONTHCARD] and curAllMonthCardData[MONTH_CARD_TYPE.LUXURYMONTHCARD].endingTime ~= 0
local isMonthCardActive = curLuxuryMonthCardOpenState
return isMonthCardActive
end
--月卡到期
local addTimeNum = 30 * 24 * 60 * 60
function this.RefreshMonthCardEnd()
for i = 1, #monthCardData do
if monthCardData[i] and monthCardData[i].endingTime > 0 then
local dayLuxuryNum = math.floor((monthCardData[i].endingTime + addTimeNum - GetTimeStamp()) / (24 * 3600))
if dayLuxuryNum < 0 then
monthCardData[i].endingTime = 0
monthCardData[i].state = 0 --0 未购买 1 未领取 2 已领取
monthCardData[i].totleAmt = 0
end
end
end
CheckRedPointStatus(RedPointType.MonthCard)
end
--单种月卡红点检测
function this.RefreshMonthCardRedPoint(type)
if monthCardData[type] then
if monthCardData[type].state == 1 then
return true
end
end
return false
end
--所有月卡红点检测
function this.AllRefreshMonthCardRedPoint()
--PlayerPrefs.SetInt(PlayerManager.uid.."monthCard", 0)
local aaa=PlayerPrefs.GetInt(PlayerManager.uid.."monthCard",0)
if aaa==0 then
return true
end
for i = 1, #monthCardData do
if monthCardData[i].state == 1 then
return true
end
end
return false
end
--所有月卡激活状态
function this.GetMonthCardIsOpen(type)
if monthCardData[type] then
if monthCardData[type].endingTime>GetTimeStamp() then
return true
end
end
return false
end