2020-08-25 15:46:38 +08:00
|
|
|
|
--- 什么又饿吧的鸡精
|
2020-05-09 13:31:21 +08:00
|
|
|
|
UpperMonthCard = {}
|
|
|
|
|
local chargeConfig = ConfigManager.GetConfig(ConfigName.RechargeCommodityConfig)
|
|
|
|
|
|
|
|
|
|
--- 本地枚举
|
|
|
|
|
local ImgType = {
|
|
|
|
|
[128] = {
|
|
|
|
|
bg = "y_yjj_128beijdi",
|
|
|
|
|
mask = "y_yjj_128dikuang001",
|
|
|
|
|
rewardBg = "y_yjj_128kuang",
|
|
|
|
|
moneyTag = "y_yjj_128",
|
|
|
|
|
downBg = "y_yjj_128kuang001",
|
|
|
|
|
rewardPreview = "y_yjj_128kuang002",
|
|
|
|
|
valueMask = "y_yjj_128jjz002",
|
|
|
|
|
},
|
|
|
|
|
[328] = {
|
|
|
|
|
bg = "y_yjj_328beijdi",
|
|
|
|
|
mask = "y_yjj_328dikuang001",
|
|
|
|
|
rewardBg = "y_yjj_328kuang",
|
|
|
|
|
moneyTag = "y_yjj_328",
|
|
|
|
|
downBg = "y_yjj_328kuang001",
|
|
|
|
|
rewardPreview = "y_yjj_328kuang002",
|
|
|
|
|
valueMask = "y_yjj_328jjz002",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function UpperMonthCard:New(parent, gameObject)
|
|
|
|
|
local _o
|
|
|
|
|
_o = _o or {}
|
|
|
|
|
setmetatable(_o, self)
|
|
|
|
|
self.__index = self
|
|
|
|
|
_o:InitComponent(gameObject)
|
|
|
|
|
_o:BindEvent()
|
|
|
|
|
_o.gameObject = gameObject
|
|
|
|
|
_o.parent = parent
|
|
|
|
|
return _o
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- 初始化组件
|
|
|
|
|
function UpperMonthCard:InitComponent(gameObject)
|
|
|
|
|
--- Common Part
|
|
|
|
|
self.Bg = Util.GetGameObject(gameObject, "Bg"):GetComponent("Image")
|
|
|
|
|
self.mask = Util.GetGameObject(gameObject, "Bg/mask"):GetComponent("Image")
|
|
|
|
|
|
|
|
|
|
self.chargeType = Util.GetGameObject(gameObject, "Bg/payBack/type"):GetComponent("Image")
|
|
|
|
|
self.btnPreview = Util.GetGameObject(gameObject, "Bg/previewRoot/btnPreview")
|
|
|
|
|
self.valueIcon = Util.GetGameObject(gameObject, "Bg/previewRoot/Image/icon"):GetComponent("Image")
|
|
|
|
|
self.totalValue = Util.GetGameObject(gameObject, "Bg/previewRoot/Image/value"):GetComponent("Text")
|
|
|
|
|
self.valueMask = Util.GetGameObject(gameObject, "Bg/previewRoot/Image"):GetComponent("Image")
|
|
|
|
|
|
|
|
|
|
--- 不同的充值行为显示部分
|
|
|
|
|
self.middlePart = Util.GetGameObject(gameObject, "Bg/partDown/Bg")
|
|
|
|
|
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 = {}
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function UpperMonthCard:BindEvent()
|
|
|
|
|
Util.AddClick(self.btnPreview, function()
|
|
|
|
|
UIManager.OpenPanel(UIName.MonthRewardPreviewPopup, self.baseType, self.chargerBaseType)
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
Util.AddClick(self.btnBuy, function()
|
|
|
|
|
|
|
|
|
|
local isActive = VipManager.GetMonthCardOpenState()
|
|
|
|
|
if not isActive then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
MsgPanel.ShowTwo(Language[11488], function()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end, function(isShow)
|
|
|
|
|
JumpManager.GoJump(36004)
|
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-07-13 16:48:50 +08:00
|
|
|
|
if AppConst.isSDKLogin then
|
2020-05-09 13:31:21 +08:00
|
|
|
|
PayManager.Pay({ Id = self.baseType })
|
|
|
|
|
else
|
2020-06-23 18:36:24 +08:00
|
|
|
|
Log(Language[11489] .. self.baseType)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
NetManager.RequestBuyGiftGoods(self.baseType, function()
|
|
|
|
|
self:RechargeSuccessFunc(self.baseType)
|
2020-06-23 18:36:24 +08:00
|
|
|
|
Log(Language[10545])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function UpperMonthCard:AddEvent()
|
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.MoneyPay.OnPayResultSuccess, self.RechargeSuccessFunc, self)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function UpperMonthCard:RemoveEvent()
|
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.MoneyPay.OnPayResultSuccess, self.RechargeSuccessFunc, self)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function UpperMonthCard:OnShow(parentSorting, arg, pageIndex)
|
|
|
|
|
self:AddEvent()
|
|
|
|
|
self.panelType = pageIndex == 7 and 128 or 328
|
|
|
|
|
--- 鸡精类型
|
|
|
|
|
self.chargerBaseType = pageIndex == 7 and GoodsTypeDef.MONTHCARD_128 or GoodsTypeDef.MONTHCARD_328
|
|
|
|
|
|
|
|
|
|
--- 鸡精的商品ID
|
|
|
|
|
-- 判断我是否购买过该商品
|
|
|
|
|
local goodsId = OperatingManager.GetActiveGoodsIDByType(self.chargerBaseType)
|
|
|
|
|
if not goodsId then
|
|
|
|
|
-- 没有购买过判断是否在活动期间
|
|
|
|
|
local gift = OperatingManager.GetGiftGoodsInfo(self.chargerBaseType)
|
|
|
|
|
if not gift then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
Log(Language[11490])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
goodsId = gift.goodsId
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
self.baseType = goodsId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.gameObject:SetActive(true)
|
|
|
|
|
OperatingManager.SetSerData(self.chargerBaseType)
|
|
|
|
|
self:SetPanelType(self.panelType)
|
|
|
|
|
self:SetRewardInfo(self.panelType)
|
|
|
|
|
self:SetBuyState()
|
|
|
|
|
-- Log("鸡精类型 --- " .. self.panelType)
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 充值成功回调
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
--- 刷新本地显示
|
|
|
|
|
self:FreshBoughtShow()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--- 设置不同的显示界面
|
|
|
|
|
function UpperMonthCard:SetPanelType(type)
|
|
|
|
|
self.chargeType.sprite = Util.LoadSprite(ImgType[type].moneyTag)
|
|
|
|
|
self.valueIcon.sprite = SetIcon(16)
|
|
|
|
|
self.valueMask = Util.LoadSprite(ImgType[type].valueMask)
|
|
|
|
|
self.Bg.sprite = Util.LoadSprite(ImgType[type].bg)
|
|
|
|
|
self.mask.sprite = Util.LoadSprite(ImgType[type].mask)
|
|
|
|
|
self.titleImg.sprite = Util.LoadSprite(ImgType[type].rewardPreview)
|
|
|
|
|
self.middlePart:GetComponent("Image").sprite = Util.LoadSprite(ImgType[type].rewardBg)
|
|
|
|
|
self.infoBg.sprite = Util.LoadSprite(ImgType[type].downBg)
|
|
|
|
|
self.valueIcon.sprite = SetIcon(chargeConfig[self.baseType].BaseReward[1][1])
|
|
|
|
|
self.tipIcon.sprite = SetIcon(chargeConfig[self.baseType].RewardShow[1][1])
|
|
|
|
|
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)
|
2020-05-25 19:16:23 +08:00
|
|
|
|
--self.rewardList[i].name = Util.GetGameObject(self.rewardList[i].go, "name"):GetComponent("Text")
|
|
|
|
|
Util.GetGameObject(self.rewardList[i].go, "name"):SetActive(false)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
2020-05-25 19:16:23 +08:00
|
|
|
|
local rewardData = data[i]
|
|
|
|
|
self.rewardList[i].item:OnOpen(false, {rewardData[1],rewardData[2]}, 1.12,true)
|
|
|
|
|
--self.rewardList[i].name.text = "第" .. data[i].Day .. "天"
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- 购买成功刷新
|
|
|
|
|
function UpperMonthCard:FreshBoughtShow()
|
|
|
|
|
self.boughtPanel:SetActive(true)
|
|
|
|
|
self.buyPanel:SetActive(false)
|
2020-06-23 18:36:24 +08:00
|
|
|
|
self.totalLoginday.text = Language[11491] .. OperatingManager.GetRewardDay(self.chargerBaseType) .. Language[10021]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local startStr, endStr = OperatingManager.GetShowTime(OperatingManager.GetGoodsEndTime(self.chargerBaseType))
|
2020-06-23 18:36:24 +08:00
|
|
|
|
self.boughtLeftTime.text = Language[11492] ..startStr .. " — ".. endStr
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- 根据是否购买了显示信息
|
|
|
|
|
function UpperMonthCard:SetBuyState()
|
|
|
|
|
local isActive = VipManager.GetMonthCardOpenState()
|
2020-06-23 18:36:24 +08:00
|
|
|
|
Log(Language[11493] .. tostring(isActive))
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local isBought = OperatingManager.IsBaseBuy(self.chargerBaseType)
|
2020-06-23 18:36:24 +08:00
|
|
|
|
Log(self.panelType .. Language[11494] .. tostring(isBought))
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.boughtPanel:SetActive(isBought)
|
|
|
|
|
self.buyPanel:SetActive(not isBought)
|
|
|
|
|
Util.SetGray(self.btnBuy, not isActive)
|
2020-08-25 13:57:21 +08:00
|
|
|
|
-- self.textBuy.text = isActive and (self.panelType .. MoneyUtil.GetMoneyUnitName()) or (self.panelType .. MoneyUtil.GetMoneyUnitName())
|
2020-08-26 12:26:19 +08:00
|
|
|
|
self.textBuy.text = isActive and (string.format(MoneyUtil.GetMoneyUnitName(),MoneyUtil.GetMoney(self.panelType))) or (string.format(MoneyUtil.GetMoneyUnitName(),MoneyUtil.GetMoney(self.panelType)))-- .. MoneyUtil.GetMoneyUnitName())
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
|
|
|
|
if not isBought then
|
|
|
|
|
self:SetBuyPanelInfo()
|
|
|
|
|
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
|
2020-06-23 18:36:24 +08:00
|
|
|
|
Log(Language[11495])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
self.buyTimer:Stop()
|
|
|
|
|
UIManager.OpenPanel(UIName.OperatingPanel)
|
|
|
|
|
end
|
|
|
|
|
end, 1, -1, true)
|
|
|
|
|
self.buyTimer:Start()
|
2020-06-23 18:36:24 +08:00
|
|
|
|
self.actLeftTime.text = Language[11496] .. self:TimeFormat(endTime - PlayerManager.serverTime)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
self.actLeftTime.gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
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)
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return string.format(Language[11497], day, hour, minute)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function UpperMonthCard:SetBoughtPanelInfo()
|
|
|
|
|
local endTime = OperatingManager.GetGoodsEndTime(self.chargerBaseType)
|
2020-06-23 18:36:24 +08:00
|
|
|
|
self.totalLoginday.text = Language[11491] .. OperatingManager.GetRewardDay(self.chargerBaseType) .. Language[10021]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local startStr, endStr = OperatingManager.GetShowTime(endTime)
|
2020-06-23 18:36:24 +08:00
|
|
|
|
self.boughtLeftTime.text = Language[11492] ..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)
|
2020-06-23 18:36:24 +08:00
|
|
|
|
self.totalLoginday.text = Language[11491] .. OperatingManager.GetRewardDay(self.chargerBaseType) .. Language[10021]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end, 1, -1, true)
|
|
|
|
|
self.timer:Start()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function UpperMonthCard:OnHide()
|
|
|
|
|
-- Log(" UpperMonthCard:OnHide()")
|
|
|
|
|
self.gameObject:SetActive(false)
|
|
|
|
|
self:RemoveEvent()
|
|
|
|
|
if self.timer then
|
|
|
|
|
self.timer:Stop()
|
|
|
|
|
self.timer = nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if self.buyTimer then
|
|
|
|
|
self.buyTimer:Stop()
|
|
|
|
|
self.buyTimer = nil
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return UpperMonthCard
|