local UIHorseRearReward = UIViewClass() function UIHorseRearReward:OnOpened(context) self.activityId = context.activityId if Localization.IsAllChinese() then UIUtils.SetLocalizationImage(self.img_Title, "sywy_msz_01.png") end self:RefreshTabList() end function UIHorseRearReward:RefreshTabList() if self.loop_FeedRewardTab.Count > 0 then self.loop_FeedRewardTab:ClearCells() end for i, v in MDL.OperationActivity.HorseRearEvent:GetEnumeratorByActivityID(self.activityId) do self.loop_FeedRewardTab:AddData(v, 0) end self.loop_FeedRewardTab:SelectIndex(0) end function UIHorseRearReward:RefreshFeedEventReward(normalRewardId, randomRewardId) local normalRewardCfg = DataSheetManager.RewardClientShow:GetDataByClientShowID(normalRewardId) local normalRewardTable = DataSheetUtil.GetRewardClientShowItemTable(normalRewardCfg) for i, v in ipairs(self.group_FixedItem) do local itemData = normalRewardTable[i] if itemData then UTL.Item.SetItemCell(v, itemData.ItemID, itemData.ItemNum) UIUtils.SetActive(v.gameObject, true) else UIUtils.SetActive(v.gameObject, false) end end if self.loop_RandomReward.Count > 0 then self.loop_RandomReward:ClearCells() end local randomRewardCfg = DataSheetManager.RewardClientShow:GetDataByClientShowID(randomRewardId) local randomRewardTable = DataSheetUtil.GetRewardClientShowItemTable(randomRewardCfg) for i, v in ipairs(randomRewardTable) do self.loop_RandomReward:AddData(v, 0) end end function UIHorseRearReward:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIHorseRearReward:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() else for i, v in ipairs(self.group_FixedItem) do if comp == v.event_Click then local eventData = MDL.OperationActivity.HorseRearEvent:GetDataByActivityID_EventID(self.activityId, self.eventId) local itemID = DataSheetManager.RewardClientShow:GetDataByClientShowID(eventData.NormalRewardShow).ItemID UTL.ItemTips.ShowCommonTipsById(itemID[i]) return end end end end function UIHorseRearReward:OnCellSelect(scrollRect, index, cellTable, data) if scrollRect == self.loop_FeedRewardTab then self.eventId = data.EventID self:RefreshFeedEventReward(data.NormalRewardShow, data.RandomRewardShow) end end function UIHorseRearReward:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_FeedRewardTab then UIUtils.SetLabelText(cellTable.txt_UnSelectTabName, Const_IDS[data.EventName]) UIUtils.SetLabelText(cellTable.txt_SelectedTabName, Const_IDS[data.EventName]) UIUtils.SetImageByAssetBundle(cellTable.img_FeedEventIcon, data.EventIcon) UIUtils.SetImageByAssetBundle(cellTable.img_FeedEventIconSelected, data.EventIcon) elseif scrollRect == self.loop_RandomReward then UTL.Item.SetItemCell(cellTable.item, data.ItemID, data.ItemNum) end end function UIHorseRearReward:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_RandomReward then if target == cellTable.item.event_Click then UTL.ItemTips.ShowCommonTipsById(data.ItemID) end end end return UIHorseRearReward