require("Base/BasePanel") local TrialRewardBackPopup = Inherit(BasePanel) local this = TrialRewardBackPopup local ItemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig) --初始化组件(用于子类重写) function TrialRewardBackPopup:InitComponent() this.spLoader = SpriteLoader.New() this.btnBack = Util.GetGameObject(self.transform, "mask") this.itemRoot = Util.GetGameObject(self.transform, "showMopUp/scroller/grid") this.item = Util.GetGameObject(self.transform, "showMopUp/scroller/grid/reward") this.itemList = {} end --绑定事件(用于子类重写) function TrialRewardBackPopup:BindEvent() Util.AddClick(this.btnBack, function() PlaySoundWithoutClick(SoundConfig.Sound_UICancel) this:ClosePanel() end) end --添加事件监听(用于子类重写) function TrialRewardBackPopup:AddListener() end --移除事件监听(用于子类重写) function TrialRewardBackPopup:RemoveListener() end --界面打开时调用(用于子类重写) function TrialRewardBackPopup:OnOpen(drop,func) this.drop = drop if func then this.func = func end end function this:OnSortingOrderChange() end --界面打开或者重新打开后,界面刷新时调用(用于子类重写) function TrialRewardBackPopup:OnShow() local data = BagManager.GetTableByBackDropDataNew(this.drop) for i = 1,math.max(#data,#this.itemList) do if not data[i] then this.itemList[i].go.gameObject:SetActive(false) else if not this.itemList[i] then this.itemList[i] = {} this.itemList[i].go = newObjToParent(this.item,this.itemRoot) this.itemList[i].icon = Util.GetGameObject(this.itemList[i].go, "icon") this.itemList[i].name = Util.GetGameObject(this.itemList[i].go, "name"):GetComponent("Text") this.itemList[i].num = Util.GetGameObject(this.itemList[i].go, "num"):GetComponent("Text") this.itemList[i].itemView = SubUIManager.Open(SubUIConfig.ItemView,this.itemList[i].icon.transform) end self:ItemAdapter(this.itemList[i], data[i]) end end end -- 物体数据匹配 function TrialRewardBackPopup:ItemAdapter(node, data) node.itemView:OnOpen(false, { data.sId, 0 }, 0.74,false,false,false,self.sortingOrder) node.name.text = data.name node.num.text = data.num end --界面关闭时调用(用于子类重写) function TrialRewardBackPopup:OnClose() if this.func then this.func() end end --界面销毁时调用(用于子类重写) function TrialRewardBackPopup:OnDestroy() this.spLoader:Destroy() this.itemList = {} end return TrialRewardBackPopup