local MonthlyCardComp = class("MonthlyCardComp", LuaComponent) local CELL = "app/ui/privilege/cell/card_cell" function MonthlyCardComp:onClose() if self.cardCell1 then self.cardCell1:onClose() end if self.cardCell2 then self.cardCell2:onClose() end DataManager.MonthlyCardData:markAlertTime() -- mark end function MonthlyCardComp:init() local uiMap = self.baseObject:genAllChildren() self.card1 = uiMap["monthly_card_comp.card_cell_1"] self.card2 = uiMap["monthly_card_comp.card_cell_2"] -- 双月卡奖励 self.doubleCardNode = uiMap["monthly_card_comp.double_card"] self.txDoubleTitle = uiMap["monthly_card_comp.double_card.tx_title"] self.txDoubleTips = uiMap["monthly_card_comp.double_card.tx_tips"] self.doubleRewardCells = {} for i = 1, 2 do table.insert(self.doubleRewardCells, uiMap["monthly_card_comp.double_card.rewards.reward_cell_" .. i]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL)) end self.btnDoubleHelp = uiMap["monthly_card_comp.double_card.btn_help"] self.cardCell1 = self.card1:addLuaComponent(CELL) self.cardCell2 = self.card2:addLuaComponent(CELL) self.btnDoubleHelp:addClickListener(function() ModuleManager.TipsManager:showDescTips(I18N:getGlobalText(I18N.GlobalConst.MONTHLY_CARD_16), self.btnDoubleHelp) end) self:bind(DataManager.MonthlyCardData, "isDirty", function() self:refresh() end) self:bind(DataManager.PaymentData, "isDirty", function() self:refresh() end) end function MonthlyCardComp:updateTime() if self.cardCell1 and self.cardCell1.updateTime then self.cardCell1:updateTime() end if self.cardCell2 and self.cardCell2.updateTime then self.cardCell2:updateTime() end end function MonthlyCardComp:refresh() DataManager.MonthlyCardData:setPoped() DataManager.MonthlyCardData:markAlertTime()-- mark self.cardCell1:refresh(GConst.MonthlyCardConst.CARD_TYPE.CARD_1) self.cardCell2:refresh(GConst.MonthlyCardConst.CARD_TYPE.CARD_2) self:refreshDoubleCard() end function MonthlyCardComp:refreshDoubleCard() self.txDoubleTitle:setText(I18N:getGlobalText(I18N.GlobalConst.MONTHLY_CARD_8)) self.txDoubleTips:setText(I18N:getGlobalText(I18N.GlobalConst.MONTHLY_CARD_9)) local received = DataManager.MonthlyCardData:getIsDoubleCardRewardClaimed() local canGet = DataManager.MonthlyCardData:checkCanGetDoubleCardReward() local rewards = DataManager.MonthlyCardData:getDoubleCardRewards() for i, cell in ipairs(self.doubleRewardCells) do if rewards and rewards[i] then cell:getBaseObject():setActive(true) cell:refreshByConfig(rewards[i], received, received) if canGet then cell:showFrameAnimation() cell:addClickListener(function() ModuleManager.MonthlyCardManager:reqGetDoubleCardReward() end) else cell:hideFrameAnimation() cell:setClickShowTips() end else cell:getBaseObject():setActive(false) end end end return MonthlyCardComp