local UISubjectMonthHonorOrderBuy = UIViewClass() local EventSystem = require('Event/EventSystem') function UISubjectMonthHonorOrderBuy:OnOpened(context) self:RegistSystemEvent(EventID.UI_SubjectMonth_UpdateHonorOrderInfo, self.RefreshPanel) self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) local battlePassId = CTL.MonthHonorOrder.GetBattlePassId() self.activityId = MDL.SubjectMonth.GetActivityId() self.versionsBattlePassData = DataSheetManager.VersionsBattlePassData:GetDataByBattlePassID(battlePassId) UIUtils.SetLabel(self.group_MonthCard[1].lab_Discount, self.versionsBattlePassData.PaidValue1 * 100 .. "%") UIUtils.SetLabel(self.group_MonthCard[2].lab_Discount, self.versionsBattlePassData.PaidValue2 * 100 .. "%") self:RefreshPanel() end function UISubjectMonthHonorOrderBuy:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:CloseView() end end end function UISubjectMonthHonorOrderBuy:RefreshPanel() local honorOrderGrade = MDL.MonthHonorOrder.HonorOrderGrade local collection = self.group_MonthCard[1] if MDL.MonthHonorOrder.IsUnlockGrade(honorOrderGrade.Grade1) then collection.state_Button:SetState(1) else collection.state_Button:SetState(0) UIUtils.SetLabel(collection.lab_buy, string.FormatByIdsId(Const_IDS.IDS_HeroFund_Buy, MDL.Currency.GetFullyIAPPrice(self.versionsBattlePassData.IAPid1))) end local rewardList = CTL.MonthHonorOrder.GetGradeRewardList(honorOrderGrade.Grade1) for i, v in ipairs(rewardList) do collection.loop_Reward:AddData(v, 0) end local rareReward = DataSheetManager.RewardClientShow:GetDataByClientShowID(self.versionsBattlePassData.RewardDisplay1) for i, v in ipairs(rareReward.ItemID) do collection.loop_RareReward:AddData({ItemID = v, ItemNum = rareReward.ItemNum[i]}, 0) end UIUtils.SetLabel(collection.txt_AddScore, string.FormatByIdsId(Const_IDS.IDS_TotalTopUp_Score_Tips_Giftbag, MDL.Currency.GetAmountByIAPIndex(self.versionsBattlePassData.IAPid1))) local collection = self.group_MonthCard[2] if MDL.MonthHonorOrder.IsUnlockGrade(honorOrderGrade.Grade2) then collection.state_Button:SetState(1) else collection.state_Button:SetState(0) UIUtils.SetLabel(collection.lab_buy, string.FormatByIdsId(Const_IDS.IDS_HeroFund_Buy, MDL.Currency.GetFullyIAPPrice(self.versionsBattlePassData.IAPid2))) end local rewardList = CTL.MonthHonorOrder.GetGradeRewardList(honorOrderGrade.Grade2) for i, v in ipairs(rewardList) do collection.loop_Reward:AddData(v, 0) end local rareReward = DataSheetManager.RewardClientShow:GetDataByClientShowID(self.versionsBattlePassData.RewardDisplay2) for i, v in ipairs(rareReward.ItemID) do collection.loop_RareReward:AddData({ItemID = v, ItemNum = rareReward.ItemNum[i]}, 0) end local iapConfig = DataSheetManager.IAP:GetDataByIndex(self.versionsBattlePassData.IAPid2) UIUtils.SetLabel(collection.txt_AddScore, string.FormatByIdsId(Const_IDS.IDS_TotalTopUp_Score_Tips_Giftbag, MDL.Currency.GetAmountByIAPIndex(self.versionsBattlePassData.IAPid2))) end function UISubjectMonthHonorOrderBuy:OnCellInit(scrollRect, index, cellTable, data) UTL.Item.SetItemCell(cellTable.item, data.ItemID, data.ItemNum) end function UISubjectMonthHonorOrderBuy:OnCellClicked(scrollRect, index, cellTable, target, data) UTL.ItemTips.ShowCommonTipsById(data.ItemID) end function UISubjectMonthHonorOrderBuy:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() elseif comp == self.group_MonthCard[1].btn_Buy then MDL.Currency.GetOrderIDReq(self.versionsBattlePassData.IAPid1, MDL.Currency.PayType.SubjectMonthHonorOrder, 1) elseif comp == self.group_MonthCard[2].btn_Buy then MDL.Currency.GetOrderIDReq(self.versionsBattlePassData.IAPid2, MDL.Currency.PayType.SubjectMonthHonorOrder, 2) end end function UISubjectMonthHonorOrderBuy:OnClosed() EventSystem.Dispatch(EventID.UI_SubjectMonth_CloseUISubjectMonthHonorOrderBuy) end return UISubjectMonthHonorOrderBuy