local UIWelfareMonthCard = UIViewClass() local EventSystem = require('Event/EventSystem') function UIWelfareMonthCard:OnOpened(context) self:RegistSystemEvent(EventID.UI_MonthCard_RewardClaimRefresh, self.RefreshMonthCardPanel) self:RefreshMonthCardPanel() CTL.MonthCard.SetDailyRedPointRecord() end function UIWelfareMonthCard:RefreshMonthCardPanel() for i, v in ipairs(self.group_MonthCard) do local data = DataSheetManager.MonthCard:GetDataByMonthCardID(i) self:RefreshSingleMonthCard(data, v) end UIUtils.SetActive(self.img_New, MDL.PayMall.GetMonthCardNewGoodsRedPoint()) end function UIWelfareMonthCard:RefreshSingleMonthCard(data, cell) local monthCardInfo = MDL.MonthCard.GetMonthCardInfoById(data.MonthCardID) local leftDays = monthCardInfo and monthCardInfo.leftDays or 0 local isCanClaim = monthCardInfo and monthCardInfo.todayReward or false self:RefreshMonthCardShow(data, cell) --续费和剩余天数显示 if leftDays > 0 or (leftDays == 0 and isCanClaim) then UIUtils.SetActive(cell.btn_Continue, true) UIUtils.SetActive(cell.group_TimeCountDown.gameObject, true) UIUtils.SetLabel(cell.txt_TimeCountDown, string.FormatByIdsId(Const_IDS.IDS_MonthCard_CardHint1, leftDays == 0 and UTL.Color.FormatRedColor(leftDays) or leftDays)) UIUtils.SetActive(cell.img_SustainDays, false) UIUtils.SetLabelText(cell.txt_RewardTip, Const_IDS.IDS_MonthCard_RenewHint1) else UIUtils.SetActive(cell.group_TimeCountDown.gameObject, false) UIUtils.SetActive(cell.btn_Continue, false) UIUtils.SetActive(cell.img_SustainDays, true) UIUtils.SetLabelText(cell.txt_RewardTip, Const_IDS.IDS_MonthCard_CardHint3) end --激活奖励 self:RefreshRewardItems(data.BuyReward_Table, cell.group_BuyItems) --持续时间 UIUtils.SetLabel(cell.txt_SustainDays, string.FormatByIdsId(Const_IDS.IDS_MonthCard_CardHint2, data.LastDay)) --每日奖励 self:RefreshRewardItems(data.DailyReward_Table, cell.group_EveryDayItems) if leftDays > 0 and not isCanClaim then cell.state_Button:SetState(0) else if leftDays >= 0 and isCanClaim then cell.state_Button:SetState(1) cell.btn_Claim:SetRedPoint(true) else cell.btn_Buy:SetText(string.FormatByIdsId(Const_IDS.IDS_MonthCard_PayButton, MDL.Currency.GetFullyIAPPrice(data.IAPID))) cell.state_Button:SetState(2) cell.btn_Claim:SetRedPoint(false) end end if MDL.Currency.IsNotShowRechargeButton() then UIUtils.SetActive(cell.btn_Buy, false) end end function UIWelfareMonthCard:RefreshMonthCardShow(data, cell) UIUtils.SetLabelText(cell.txt_MonthCardTitle, Const_IDS[data.CardName]) UIUtils.SetLabelText(cell.txt_MonthCardDesc, Const_IDS[data.CardDes]) UIUtils.SetImageByAssetBundle(cell.img_MonthCardPicture, data.CardPicture) end function UIWelfareMonthCard:RefreshRewardItems(rewardTable, cellGroup) for i, v in ipairs(cellGroup) do local reward = rewardTable[i] if reward then UIUtils.SetActive(v.gameObject.transform.parent.gameObject, true) UTL.Item.SetItemCell(v, reward.ItemID, reward.ItemNum) else UIUtils.SetActive(v.gameObject.transform.parent.gameObject, false) end end end function UIWelfareMonthCard:OnButtonClicked(comp) if comp == self.btn_Shop then elseif comp == self.btn_MonthCardMall then local HideMallTabsPoint = DataSheetManager.ConstData:GetDataByID("HideMallTabsPoint").IntValue local HideMallTabsSeverOpenday = DataSheetManager.ConstData:GetDataByID("HideMallTabsSeverOpenday").IntValue if not MDL.MonthCard.HadAllMonthCardActive() and MDL.Player.GetServerDayCount() < HideMallTabsSeverOpenday and MDL.Currency.GetTotalRechargeCredit() < HideMallTabsPoint then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Store_MonthlyCard_LimitTips"]) return end EventSystem.Dispatch(EventID.UI_PayMall_OpenSpecificView, {tabId = CTL.PayMall.ShopTabType.Shop, childTabId = CTL.PayMall.ShopChildTabType.DoubleMonthCardShop}) elseif comp == self.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.MonthCard}) else for i, v in ipairs(self.group_MonthCard) do if comp == v.btn_Claim then --领取的逻辑 local data = DataSheetManager.MonthCard:GetDataByMonthCardID(i) MDL.MonthCard.GetMonthCardRewardReq(data.MonthCardID) return elseif comp == v.btn_Buy then --购买的逻辑 local data = DataSheetManager.MonthCard:GetDataByMonthCardID(i) local monthCardId = data.MonthCardID local monthCardInfo = MDL.MonthCard.GetMonthCardInfoById(monthCardId) local leftDays = monthCardInfo and monthCardInfo.leftDays or 0 if leftDays < data.MaxDay then MDL.Currency.GetOrderIDReq(data.IAPID, MDL.Currency.PayType.MonthCard, monthCardId) else CTL.Tips.AddTipsMsg(Const_IDS["IDS_MonthCard_DayMax_Hint"]) end return elseif comp == v.btn_Continue then --续费的逻辑 local data = DataSheetManager.MonthCard:GetDataByMonthCardID(i) UIManager.OpenView(Const_UI_Lua.UIEnum.UIMonthCardRenew, {monthCardId = data.MonthCardID}) return else for index, value in ipairs(v.group_BuyItems) do if comp == value.event_Click then local rewardData = DataSheetManager.MonthCard:GetDataByMonthCardID(i).BuyReward_Table UTL.ItemTips.ShowCommonTipsById(rewardData[index].ItemID) return end end for index, value in ipairs(v.group_EveryDayItems) do if comp == value.event_Click then local rewardData = DataSheetManager.MonthCard:GetDataByMonthCardID(i).DailyReward_Table UTL.ItemTips.ShowCommonTipsById(rewardData[index].ItemID) return end end end end end end return UIWelfareMonthCard