2021-04-21 13:12:04 +08:00
|
|
|
|
|
2021-03-30 20:17:26 +08:00
|
|
|
|
local UpperMonthCard = {}
|
|
|
|
|
local sortingOrder = 0
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local chargeConfig = ConfigManager.GetConfig(ConfigName.RechargeCommodityConfig)
|
|
|
|
|
--- 本地枚举
|
|
|
|
|
local ImgType = {
|
2021-03-30 20:17:26 +08:00
|
|
|
|
[10002] = {
|
2020-05-09 13:31:21 +08:00
|
|
|
|
bg = "y_yjj_128beijdi",
|
|
|
|
|
mask = "y_yjj_128dikuang001",
|
|
|
|
|
rewardBg = "y_yjj_128kuang",
|
2021-03-30 20:44:24 +08:00
|
|
|
|
moneyTag = "y_yjj_128",
|
2020-05-09 13:31:21 +08:00
|
|
|
|
downBg = "y_yjj_128kuang001",
|
2021-03-30 20:32:05 +08:00
|
|
|
|
rewardPreview = "y_yjj_128kuang002_zh",
|
2020-05-09 13:31:21 +08:00
|
|
|
|
valueMask = "y_yjj_128jjz002",
|
2021-03-30 20:17:26 +08:00
|
|
|
|
chargerBaseType = GoodsTypeDef.MONTHCARD_128,
|
2020-05-09 13:31:21 +08:00
|
|
|
|
},
|
2021-03-30 20:17:26 +08:00
|
|
|
|
[10003] = {
|
2020-05-09 13:31:21 +08:00
|
|
|
|
bg = "y_yjj_328beijdi",
|
|
|
|
|
mask = "y_yjj_328dikuang001",
|
|
|
|
|
rewardBg = "y_yjj_328kuang",
|
2021-03-30 20:44:24 +08:00
|
|
|
|
moneyTag = "y_yjj_328",
|
2020-05-09 13:31:21 +08:00
|
|
|
|
downBg = "y_yjj_328kuang001",
|
2021-03-30 20:32:05 +08:00
|
|
|
|
rewardPreview = "y_yjj_328kuang002_zh",
|
2020-05-09 13:31:21 +08:00
|
|
|
|
valueMask = "y_yjj_328jjz002",
|
2021-03-30 20:17:26 +08:00
|
|
|
|
chargerBaseType = GoodsTypeDef.MONTHCARD_328,
|
2020-05-09 13:31:21 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
2021-03-30 20:17:26 +08:00
|
|
|
|
function UpperMonthCard:New(gameObject)
|
|
|
|
|
local b = {}
|
|
|
|
|
b.gameObject = gameObject
|
|
|
|
|
b.transform = gameObject.transform
|
|
|
|
|
setmetatable(b, { __index = UpperMonthCard })
|
|
|
|
|
return b
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
2021-03-30 20:17:26 +08:00
|
|
|
|
--初始化组件(用于子类重写)
|
|
|
|
|
function UpperMonthCard:InitComponent()
|
2021-04-21 13:12:04 +08:00
|
|
|
|
self.spLoader = SpriteLoader.New()
|
2021-03-30 20:17:26 +08:00
|
|
|
|
self.Bg = Util.GetGameObject(self.gameObject, "bg"):GetComponent("Image")
|
|
|
|
|
self.mask = Util.GetGameObject(self.gameObject, "Bg/mask"):GetComponent("Image")
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
2021-03-30 20:17:26 +08:00
|
|
|
|
self.chargeType = Util.GetGameObject(self.gameObject, "Bg/payBack/type"):GetComponent("Image")
|
|
|
|
|
self.btnPreview = Util.GetGameObject(self.gameObject, "Bg/previewRoot/btnPreview")
|
|
|
|
|
self.valueIcon = Util.GetGameObject(self.gameObject, "Bg/previewRoot/Image/icon"):GetComponent("Image")
|
|
|
|
|
self.totalValue = Util.GetGameObject(self.gameObject, "Bg/previewRoot/Image/value"):GetComponent("Text")
|
|
|
|
|
self.valueMask = Util.GetGameObject(self.gameObject, "Bg/previewRoot/Image"):GetComponent("Image")
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
|
|
|
|
--- 不同的充值行为显示部分
|
2021-03-30 20:17:26 +08:00
|
|
|
|
self.middlePart = Util.GetGameObject(self.gameObject, "Bg/partDown/Bg")
|
2020-05-09 13:31:21 +08:00
|
|
|
|
self.titleImg = Util.GetGameObject(self.middlePart, "title"):GetComponent("Image")
|
|
|
|
|
self.infoBg = Util.GetGameObject(self.middlePart, "middle"):GetComponent("Image")
|
|
|
|
|
self.grid = Util.GetGameObject( self.middlePart, "middle/grid")
|
|
|
|
|
self.itemPre = Util.GetGameObject(self.middlePart, "middle/itemPre")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--- 未购买
|
|
|
|
|
self.buyPanel = Util.GetGameObject(self.middlePart, "buyPart")
|
|
|
|
|
self.tipIcon = Util.GetGameObject(self.buyPanel, "tip/icon/Image"):GetComponent("Image") -- 那啥图标
|
|
|
|
|
self.charmyNum = Util.GetGameObject(self.buyPanel, "tip/value"):GetComponent("Text") -- 返利
|
|
|
|
|
self.actLeftTime = Util.GetGameObject(self.buyPanel, "leftTime"):GetComponent("Text") -- 活动剩余天数
|
|
|
|
|
self.btnBuy = Util.GetGameObject(self.buyPanel, "btnBuy")
|
|
|
|
|
self.textBuy = Util.GetGameObject(self.btnBuy, "Text"):GetComponent("Text")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 已经购买,你先可以享受这你觉得还可以的服务了
|
|
|
|
|
self.boughtPanel = Util.GetGameObject(self.middlePart, "rewardPart")
|
|
|
|
|
self.totalLoginday = Util.GetGameObject(self.boughtPanel, "totalDay"):GetComponent("Text")
|
|
|
|
|
self.boughtLeftTime = Util.GetGameObject(self.boughtPanel, "time"):GetComponent("Text")
|
|
|
|
|
|
|
|
|
|
---- 奖励列表
|
|
|
|
|
self.rewardList = {}
|
2021-03-30 20:17:26 +08:00
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
2021-03-30 20:17:26 +08:00
|
|
|
|
--绑定事件(用于子类重写)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
function UpperMonthCard:BindEvent()
|
2021-04-27 17:53:15 +08:00
|
|
|
|
Util.AddOnceClick(self.btnPreview, function()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.MonthRewardPreviewPopup, self.baseType, self.chargerBaseType)
|
|
|
|
|
end)
|
|
|
|
|
|
2021-04-27 17:53:15 +08:00
|
|
|
|
Util.AddOnceClick(self.btnBuy, function()
|
2021-10-31 02:06:49 +08:00
|
|
|
|
-- local isActive = VipManager.GetMonthCardOpenState()
|
|
|
|
|
-- if not isActive then
|
|
|
|
|
-- MsgPanel.ShowTwo(Language[11387], function()
|
|
|
|
|
-- end, function(isShow)
|
|
|
|
|
-- JumpManager.GoJump(36004)
|
|
|
|
|
-- end, Language[10731], Language[10019],nil, false)
|
|
|
|
|
-- else
|
2020-09-09 18:47:17 +08:00
|
|
|
|
PayManager.Pay(self.baseType, function(id)
|
|
|
|
|
self:RechargeSuccessFunc(id)
|
|
|
|
|
end)
|
2021-10-31 02:06:49 +08:00
|
|
|
|
-- end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end)
|
2021-03-30 20:17:26 +08:00
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
2021-03-30 20:17:26 +08:00
|
|
|
|
-- --添加事件监听(用于子类重写)
|
|
|
|
|
-- function UpperMonthCard:AddListener()
|
|
|
|
|
|
|
|
|
|
-- end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
2021-03-30 20:17:26 +08:00
|
|
|
|
-- --移除事件监听(用于子类重写)
|
|
|
|
|
-- function UpperMonthCard:RemoveListener()
|
|
|
|
|
|
|
|
|
|
-- end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
2021-03-30 20:17:26 +08:00
|
|
|
|
--界面打开时调用(用于子类重写)
|
2021-03-30 20:32:05 +08:00
|
|
|
|
function UpperMonthCard:OnOpen(_activityConfig,_index,parent)
|
2021-03-30 20:17:26 +08:00
|
|
|
|
self.actConfig = _activityConfig
|
|
|
|
|
self.pageIndex = _index
|
|
|
|
|
self.parent = parent
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-03-30 20:17:26 +08:00
|
|
|
|
-- 打开,重新打开时回调
|
|
|
|
|
function UpperMonthCard:OnShow(_sortingOrder)
|
|
|
|
|
self.gameObject:SetActive(true)
|
|
|
|
|
sortingOrder = _sortingOrder
|
|
|
|
|
self.actType = self.actConfig.ActId
|
2020-05-09 13:31:21 +08:00
|
|
|
|
--- 鸡精类型
|
2021-03-30 20:17:26 +08:00
|
|
|
|
self.chargerBaseType = ImgType[self.actType].chargerBaseType
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
|
|
|
|
--- 鸡精的商品ID
|
|
|
|
|
-- 判断我是否购买过该商品
|
|
|
|
|
local goodsId = OperatingManager.GetActiveGoodsIDByType(self.chargerBaseType)
|
|
|
|
|
if not goodsId then
|
|
|
|
|
-- 没有购买过判断是否在活动期间
|
|
|
|
|
local gift = OperatingManager.GetGiftGoodsInfo(self.chargerBaseType)
|
|
|
|
|
if not gift then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
goodsId = gift.goodsId
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
self.baseType = goodsId
|
|
|
|
|
self.gameObject:SetActive(true)
|
|
|
|
|
OperatingManager.SetSerData(self.chargerBaseType)
|
2021-03-30 20:17:26 +08:00
|
|
|
|
self:SetPanelType(self.actType)
|
|
|
|
|
self:SetRewardInfo(self.actType)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
self:SetBuyState()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- 设置不同的显示界面
|
|
|
|
|
function UpperMonthCard:SetPanelType(type)
|
2021-04-21 13:12:04 +08:00
|
|
|
|
self.chargeType.sprite = self.spLoader:LoadSprite(ImgType[type].moneyTag)
|
|
|
|
|
self.valueIcon.sprite = SetIcon(self.spLoader, 16)
|
|
|
|
|
self.valueMask = self.spLoader:LoadSprite(ImgType[type].valueMask)
|
|
|
|
|
self.Bg.sprite = self.spLoader:LoadSprite(ImgType[type].bg)
|
|
|
|
|
self.mask.sprite = self.spLoader:LoadSprite(ImgType[type].mask)
|
|
|
|
|
self.titleImg.sprite = self.spLoader:LoadSprite(ImgType[type].rewardPreview)
|
|
|
|
|
self.middlePart:GetComponent("Image").sprite = self.spLoader:LoadSprite(ImgType[type].rewardBg)
|
|
|
|
|
self.infoBg.sprite = self.spLoader:LoadSprite(ImgType[type].downBg)
|
|
|
|
|
self.valueIcon.sprite = SetIcon(self.spLoader, chargeConfig[self.baseType].BaseReward[1][1])
|
|
|
|
|
self.tipIcon.sprite = SetIcon(self.spLoader, chargeConfig[self.baseType].RewardShow[1][1])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
self.totalValue.text = chargeConfig[self.baseType].RewardShow[1][2]
|
|
|
|
|
self.charmyNum.text = " " .. chargeConfig[self.baseType].BaseReward[1][2]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- 设置不同界面的奖励信息
|
|
|
|
|
function UpperMonthCard:SetRewardInfo(type)
|
2020-05-25 19:16:23 +08:00
|
|
|
|
local data = OperatingManager.GetPanelShowReward(self.baseType, false,true)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
for i = 1, #data do
|
|
|
|
|
if not self.rewardList[i] then
|
|
|
|
|
self.rewardList[i] = {}
|
|
|
|
|
self.rewardList[i].go = newObjToParent(self.itemPre, self.grid)
|
|
|
|
|
self.rewardList[i].item = SubUIManager.Open(SubUIConfig.ItemView, self.rewardList[i].go.transform)
|
|
|
|
|
end
|
|
|
|
|
|
2020-05-25 19:16:23 +08:00
|
|
|
|
local rewardData = data[i]
|
2021-03-30 20:17:26 +08:00
|
|
|
|
self.rewardList[i].item:OnOpen(false, {rewardData[1],rewardData[2]}, 1.12,true)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- 根据是否购买了显示信息
|
|
|
|
|
function UpperMonthCard:SetBuyState()
|
2021-10-31 02:06:49 +08:00
|
|
|
|
-- local isActive = VipManager.GetMonthCardOpenState()
|
2021-04-26 20:08:32 +08:00
|
|
|
|
-- local isBought = OperatingManager.IsBaseBuy(self.chargerBaseType)
|
|
|
|
|
local canBuyNum = OperatingManager.GetLeftBuyTime(self.chargerBaseType, self.baseType)
|
|
|
|
|
local isBought = canBuyNum and canBuyNum <= 0
|
2020-05-09 13:31:21 +08:00
|
|
|
|
self.boughtPanel:SetActive(isBought)
|
|
|
|
|
self.buyPanel:SetActive(not isBought)
|
2021-10-31 02:06:49 +08:00
|
|
|
|
-- Util.SetGray(self.btnBuy, not isActive)
|
|
|
|
|
--isActive and
|
|
|
|
|
self.textBuy.text = (string.format(MoneyUtil.GetMoneyUnitName(),MoneyUtil.GetMoney(chargeConfig[self.baseType].Price))) or (string.format(MoneyUtil.GetMoneyUnitName(),MoneyUtil.GetMoney(chargeConfig[self.baseType].Price)))-- .. MoneyUtil.GetMoneyUnitName())
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
2021-04-28 00:58:11 +08:00
|
|
|
|
self.actLeftTime.gameObject:SetActive(false)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
if not isBought then
|
2021-04-28 00:58:11 +08:00
|
|
|
|
-- self:SetBuyPanelInfo()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
else
|
|
|
|
|
self:SetBoughtPanelInfo()
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function UpperMonthCard:SetBuyPanelInfo()
|
|
|
|
|
--- 未激活,在活动时间内
|
|
|
|
|
local isOpen = OperatingManager.IsBaseOpen(self.chargerBaseType, self.baseType)
|
|
|
|
|
self.buyTimer = nil
|
|
|
|
|
if isOpen then
|
|
|
|
|
--- 获取剩余时间,结束时间为0表示不限时
|
|
|
|
|
local data = OperatingManager.GetGiftGoodsInfo(self.chargerBaseType, self.baseType)
|
|
|
|
|
local endTime = data.endTime
|
|
|
|
|
if endTime <= 0 then
|
|
|
|
|
self.actLeftTime.gameObject:SetActive(false)
|
|
|
|
|
else
|
|
|
|
|
self.actLeftTime.gameObject:SetActive(true)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.buyTimer = Timer.New(function ()
|
|
|
|
|
if endTime - GetTimeStamp() <= 0 then
|
2021-01-09 14:20:06 +08:00
|
|
|
|
Log("时间到,活动关闭")
|
2020-05-09 13:31:21 +08:00
|
|
|
|
self.buyTimer:Stop()
|
2021-03-30 20:35:53 +08:00
|
|
|
|
self:ClosePanel()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end, 1, -1, true)
|
|
|
|
|
self.buyTimer:Start()
|
2021-04-01 18:36:34 +08:00
|
|
|
|
self.actLeftTime.text = Language[10573] .. self:TimeFormat(endTime - PlayerManager.serverTime)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
self.actLeftTime.gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function UpperMonthCard:SetBoughtPanelInfo()
|
|
|
|
|
local endTime = OperatingManager.GetGoodsEndTime(self.chargerBaseType)
|
2021-04-01 18:36:34 +08:00
|
|
|
|
self.totalLoginday.text = Language[11388] .. OperatingManager.GetRewardDay(self.chargerBaseType) .. Language[10017]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local startStr, endStr = OperatingManager.GetShowTime(endTime)
|
2021-04-01 18:36:34 +08:00
|
|
|
|
self.boughtLeftTime.text = Language[11389] ..startStr .. " — ".. endStr
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
|
|
|
|
--- 购买后倒计时显示
|
|
|
|
|
self.timer = nil
|
|
|
|
|
self.timer = Timer.New(function()
|
|
|
|
|
if GetTimeStamp() > endTime then
|
|
|
|
|
--- 注销鸡精
|
|
|
|
|
OperatingManager.RemoveEndTime(self.baseType)
|
|
|
|
|
self:SetBuyState()
|
|
|
|
|
self.timer:Stop()
|
|
|
|
|
else
|
|
|
|
|
OperatingManager.SetSerData(self.chargerBaseType)
|
2021-04-01 18:36:34 +08:00
|
|
|
|
self.totalLoginday.text = Language[11388] .. OperatingManager.GetRewardDay(self.chargerBaseType) .. Language[10017]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end, 1, -1, true)
|
|
|
|
|
self.timer:Start()
|
2021-03-30 20:17:26 +08:00
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
2021-03-30 20:17:26 +08:00
|
|
|
|
-- 充值成功回调
|
|
|
|
|
function UpperMonthCard:RechargeSuccessFunc(id)
|
|
|
|
|
FirstRechargeManager.RefreshAccumRechargeValue(id)
|
|
|
|
|
OperatingManager.RefreshGiftGoodsBuyTimes(GoodsTypeDef.DemonCrystal, id)
|
|
|
|
|
--- 设置购买成功数据
|
|
|
|
|
OperatingManager.SetSignRewarDay(self.chargerBaseType, 438)
|
|
|
|
|
local startTime = Today_N_OClockTimeStamp(0)
|
|
|
|
|
OperatingManager.SetGoodsEndTime(self.baseType, startTime + 30 * 24 * 60 * 60 - 1)
|
|
|
|
|
-- Today_N_OClockTimeStamp
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
2021-03-30 20:17:26 +08:00
|
|
|
|
--- 刷新本地显示
|
|
|
|
|
self:FreshBoughtShow()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-03-30 20:17:26 +08:00
|
|
|
|
--- 购买成功刷新
|
|
|
|
|
function UpperMonthCard:FreshBoughtShow()
|
|
|
|
|
self.boughtPanel:SetActive(true)
|
|
|
|
|
self.buyPanel:SetActive(false)
|
2021-04-01 18:36:34 +08:00
|
|
|
|
self.totalLoginday.text = Language[11388] .. OperatingManager.GetRewardDay(self.chargerBaseType) .. Language[10017]
|
2021-03-30 20:17:26 +08:00
|
|
|
|
local startStr, endStr = OperatingManager.GetShowTime(OperatingManager.GetGoodsEndTime(self.chargerBaseType))
|
2021-04-01 18:36:34 +08:00
|
|
|
|
self.boughtLeftTime.text = Language[11389] ..startStr .. " — ".. endStr
|
2021-03-30 20:17:26 +08:00
|
|
|
|
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
2021-03-30 20:17:26 +08:00
|
|
|
|
function UpperMonthCard:TimeFormat(second)
|
|
|
|
|
local day = math.floor(second / (24 * 3600))
|
|
|
|
|
local minute = math.floor(second / 60) % 60
|
|
|
|
|
local sec = second % 60
|
|
|
|
|
local hour = math.floor(math.floor(second - day * 24 * 3600 - sec - minute * 60) / 3600)
|
2021-04-01 18:36:34 +08:00
|
|
|
|
return string.format(Language[11390], day, hour, minute)
|
2021-03-30 20:17:26 +08:00
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
2021-03-30 20:17:26 +08:00
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
|
|
|
function UpperMonthCard:OnClose()
|
|
|
|
|
self.gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
|
function UpperMonthCard:OnDestroy()
|
2021-04-21 13:12:04 +08:00
|
|
|
|
self.spLoader:Destroy()
|
2021-03-30 20:17:26 +08:00
|
|
|
|
for k,v in pairs(self.rewardList) do
|
|
|
|
|
SubUIManager.Close(v.item)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
2021-03-30 20:17:26 +08:00
|
|
|
|
Util.ClearChild(self.grid.transform)
|
|
|
|
|
self.rewardList = {}
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
2021-04-21 13:12:04 +08:00
|
|
|
|
return UpperMonthCard
|
|
|
|
|
|