local UIMonthCardRenew = UIViewClass() function UIMonthCardRenew:OnOpened(context) self:RegistSystemEvent(EventID.UI_MonthCard_RewardClaimRefresh, self.RefreshMonthCardRenew) self.monthCardId = context.monthCardId self:RefreshMonthCardRenew(self.monthCardId) end function UIMonthCardRenew:RefreshMonthCardRenew() local monthCardInfo = MDL.MonthCard.GetMonthCardInfoById(self.monthCardId) local leftDays = monthCardInfo and monthCardInfo.leftDays or 0 local data = DataSheetManager.MonthCard:GetDataByMonthCardID(self.monthCardId) self:RefreshMonthCard(data) self:RefreshRewardItems(data.BuyReward_Table, self.group_BuyItems) UIUtils.SetLabel(self.txt_SustainDays, string.FormatByIdsId(Const_IDS.IDS_MonthCard_RenewHint2, data.LastDay)) UIUtils.SetLabel(self.txt_Days, string.FormatByIdsId(Const_IDS.IDS_MonthCard_RenewHint4, leftDays)) self:RefreshRewardItems(data.DailyReward_Table, self.group_DailyItems) self.btn_Continue:SetText(string.FormatByIdsId(Const_IDS.IDS_MonthCard_RenewButton, MDL.Currency.GetFullyIAPPrice(data.IAPID))) end function UIMonthCardRenew:RefreshMonthCard(data) UIUtils.SetLabelText(self.UICommonPayPopUp.txt_Title, Const_IDS[data.CardName]) UIUtils.SetImageByAssetBundle(self.img_MonthCardPicture, data.CardPicture) end function UIMonthCardRenew: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 UIMonthCardRenew:OnBackButtonPressed() self:OnButtonClicked(self.btn_Cancel) end function UIMonthCardRenew:OnButtonClicked(comp) if comp == self.UICommonPayPopUp.btn_Close or comp == self.btn_Cancel then self:CloseView() elseif comp == self.btn_Continue then --购买的逻辑 local data = DataSheetManager.MonthCard:GetDataByMonthCardID(self.monthCardId) local monthCardInfo = MDL.MonthCard.GetMonthCardInfoById(self.monthCardId) local leftDays = monthCardInfo and monthCardInfo.leftDays or 0 if leftDays < data.MaxDay then MDL.Currency.GetOrderIDReq(data.IAPID, MDL.Currency.PayType.MonthCard, self.monthCardId) else CTL.Tips.AddTipsMsg(Const_IDS["IDS_MonthCard_DayMax_Hint"]) end return else for i, v in ipairs(self.group_BuyItems) do if comp == v.event_Click then local rewardData = DataSheetManager.MonthCard:GetDataByMonthCardID(self.monthCardId).BuyReward_Table UTL.ItemTips.ShowCommonTipsById(rewardData[i].ItemID) return end end for i, v in ipairs(self.group_DailyItems) do if comp == v.event_Click then local rewardData = DataSheetManager.MonthCard:GetDataByMonthCardID(self.monthCardId).DailyReward_Table UTL.ItemTips.ShowCommonTipsById(rewardData[i].ItemID) return end end end end return UIMonthCardRenew