local UITestingGiftBase = UIViewClass() local EventSystem = require('Event/EventSystem') local ImageType = { Image = 1,--图片 Lihui = 2,--立绘 } local function SortRule(welfareConfig1,welfareConfig2) return welfareConfig1.Weight > welfareConfig2.Weight end --"测试有礼"入口进来的界面,即原来的"UIActivities" function UITestingGiftBase:OnOpened(context) self.infoList = {} self:RegistSystemEvent(EventID.UI_SDKUser_Unlock_Update, self.UpdateEntry) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.TestingGift_FaceBook, self.UpdateTabRed) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.TestingGift_StoreScore, self.UpdateTabRed) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.TestingGift_BindAccount, self.UpdateTabRed) self.subViewType = nil self:UpdateTabs() end function UITestingGiftBase:UpdateTabs() table.clearArray(self.infoList) for i, v in DataSheetManager.Welfare:GetEnumerator() do if CTL.TestingGift.CheckTabShow(v) then table.insert(self.infoList, v) end end table.sort(self.infoList, SortRule) self.loopScroll_ActivitiesTabs:ReloadAll(self.infoList) self.loopScroll_ActivitiesTabs:SelectIndex(0) end --监听开关 function UITestingGiftBase:UpdateEntry() if CTL.TestingGift.HasEntry() == false then self:CloseView() return end self.loopScroll_ActivitiesTabs:ClearCells() self:UpdateTabs() end function UITestingGiftBase:UpdateTabRed() local count = self.loopScroll_ActivitiesTabs.Count for i = 0, count - 1 do local data = self.infoList[i + 1] self.loopScroll_ActivitiesTabs:UpdateIndex(i, data) end end function UITestingGiftBase:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UITestingGiftBase:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() end end function UITestingGiftBase:OnClosed() self:SetSubTabRed() end function UITestingGiftBase:SetSubTabRed() if self.lastSelectData then local redKey = MDL.TestingGift.RedPointKey[self.lastSelectData.ID] if redKey then MDL.TestingGift.SetSubTabRed(self.lastSelectData, true) end end end function UITestingGiftBase:OnCellSelect(scrollRect, index, cellTable, data) self:SetSubTabRed() self.lastSelectData = data if self.subViewType == data.ImageType then EventSystem.Dispatch(EventID.UI_TestingGift_Refresh, data) else if self.subViewType then self.subView:CloseAll() end if data.ImageType == ImageType.Image then self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UITestingGiftImage), data) else self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UITestingGiftLihui), data) end end self.subViewType = data.ImageType end function UITestingGiftBase:OnCellInit(scrollRect, index, cellTable, data) UIUtils.SetLabelText(cellTable.lab_UnSelected,Const_IDS[data.Title]) UIUtils.SetLabelText(cellTable.lab_Selected,Const_IDS[data.Title]) --设置红点 local redKey = MDL.TestingGift.RedPointKey[data.ID] if redKey then local isRed = CTL.RedPoint.GetRedPointActive(redKey) cellTable.cell:SetRedPoint(isRed) else cellTable.cell:SetRedPoint(false) end end return UITestingGiftBase