local UIOfficialPositionProfitPreview = UIViewClass() function UIOfficialPositionProfitPreview:OnCreated() UIUtils.SetActive(self.rect_CloseTips, false) end function UIOfficialPositionProfitPreview:OnOpened(context) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_OfficialPrivilege_Preview) self.profitInfoDic = {} local titleInfo = MDL.OfficialPosition.GetOfficialInfo() self.curTitle = titleInfo.CurTitle self.highestTitle = titleInfo.HighestTitle local moveIndex = 1 for i, v in DataSheetManager.OfficialPosition:GetEnumerator() do if v.ID == self.curTitle then moveIndex = i end self.loop_OfficialPositionProfit:AddData(v, 0) end self.loop_OfficialPositionProfit:MoveIndex(moveIndex - 1) end function UIOfficialPositionProfitPreview:OnCellInit(scrollRect, index, cellTable, data) UIUtils.SetImageByAssetBundle(cellTable.img_Icon, data.OfficialHat) UIUtils.SetActive(cellTable.group_Now, data.ID == self.curTitle) cellTable.txt_Position.text = CTL.OfficialPosition.GetColorTitleFullTxt(data.ID) --道具奖励 local rewardConfig = DataSheetManager.OfficialRankingReward:GetDataByID(data.Reward) local itemDatas = rewardConfig.Item_Table for i, itemData in ipairs(itemDatas) do local contentItem = cellTable.group_Item[i] if not contentItem then contentItem = self:InstantiateCellCollection(cellTable.cell.gameObject, cellTable.group_Item, self.templateItem.gameObject) if GameAppInfo.IsVersionGreaterThan16000() then self:InitCellUITemplate(cellTable.cell.gameObject, contentItem.baseItem, contentItem.gameObject) end end UIUtils.SetActive(contentItem.gameObject, true) UIUtils.SetActive(contentItem.group_Get, self.highestTitle >= data.ID) UTL.Item.SetItemCell(contentItem.baseItem, itemData.ItemID, itemData.ItemNum) end for i = #itemDatas + 1, #cellTable.group_Item do UIUtils.SetActive(cellTable.group_Item[i].gameObject, false) end --属性 local attrData = DataSheetManager.OfficialPositionAttr:GetDataByAttrRepeatID(data.OfficialPositionAttr).Attr_Table for i, v in ipairs(cellTable.group_Attr) do if i <= #attrData then UIUtils.SetActive(v.gameObject, true) UTL.Attr.SetAttrItemByCompName(v, attrData[i].AttrType, attrData[i].AttrNum, false, true) else UIUtils.SetActive(v.gameObject, false) end end --收益图标 UIUtils.SetActive(cellTable.group_Tip, false) local infoList = self.profitInfoDic[data.GradeID] if infoList == nil then infoList = {} self.profitInfoDic[data.GradeID] = infoList end CTL.OfficialPosition.UpdateProfitList(data.GradeID, infoList) for i, info in ipairs(infoList) do local contentItem = cellTable.group_btn[i] if not contentItem then contentItem = self:InstantiateCellCollection(cellTable.cell.gameObject, cellTable.group_btn, self.templateBtnProfit.gameObject) end UIUtils.SetActive(contentItem.gameObject, true) UIUtils.SetImageByAssetBundle(contentItem.img_Icon, info.Icon) UTL.Color.SetQualityImageByType(contentItem.img_qua, data.QualityColor, UTL.Color.QualityType.OfficialProfitQuality) end for i = #infoList + 1, #cellTable.group_btn do UIUtils.SetActive(cellTable.group_btn[i].gameObject, false) end end function UIOfficialPositionProfitPreview:OnCellClicked(scrollRect, index, cellTable, target, data) local clickIndex = 0 for i, v in ipairs(cellTable.group_btn) do if target == v.rect_btn then clickIndex = i break end end if clickIndex > 0 then self.clickIndex = index UIUtils.SetActive(self.rect_CloseTips, true) UIUtils.SetActive(cellTable.group_Tip, true) local infoList = self.profitInfoDic[data.GradeID] local info = infoList and infoList[clickIndex] if info then cellTable.txt_Tip.text = string.FormatByIdsId(Const_IDS[info.IDS], info.Parm) end else for i, v in ipairs(cellTable.group_Item) do if target == v.baseItem.event_Click then local rewardConfig = DataSheetManager.OfficialRankingReward:GetDataByID(data.Reward) local itemDatas = rewardConfig.Item_Table UTL.ItemTips.ShowCommonTipsById(itemDatas[i].ItemID) break end end end end function UIOfficialPositionProfitPreview:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIOfficialPositionProfitPreview:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() elseif comp == self.rect_CloseTips then UIUtils.SetActive(self.rect_CloseTips, false) self.loop_OfficialPositionProfit:UpdateIndex(self.clickIndex) end end return UIOfficialPositionProfitPreview