-- <* -- @Author: Saber -- @Description: 藏宝图系统限时商店界面(收纳商品) -- *> TreasureMapStorageShopView = TreasureMapStorageShopView or BaseClass(BaseView) local TreasureMapStorageShopView = TreasureMapStorageShopView function TreasureMapStorageShopView:__init() self.base_file = "treasureMap" self.layout_file = "TreasureMapShopView" self.layer_name = "UI" self.destroy_imm = true self.use_background = true --全屏界面默认使用这个参数,非全屏界面自行设置 self.hide_maincancas = false --全屏界面需要隐藏主UI self.change_scene_close = true --是否切换场景时关闭(弹出界面使用) self.model = TreasureMapModel:getInstance() self.load_callback = function () self:LoadSuccess() self:AddEvent() end self.open_callback = function ( ) self:UpdateView() end self.destroy_callback = function ( ) self:DestroySuccess() end end function TreasureMapStorageShopView:Open( ) --self.data = data BaseView.Open(self) end function TreasureMapStorageShopView:LoadSuccess() local nodes = { "win_bg:raw", "close_btn:obj", "item_scroll", "item_scroll/Viewport/item_con", } self:GetChildren(nodes) lua_resM:setOutsideRawImage(self, self.win_bg_raw, GameResPath.GetViewBigBg("tm_shop_bg")) -- 使用的是原先的商城界面,改成类名方便搜索 -- self.transform.name = "TreasureMapStorageShopView" end function TreasureMapStorageShopView:AddEvent() local function click_event(target) if target == self.close_btn_obj then self:Close() end end AddClickEvent(self.close_btn_obj, click_event) end function TreasureMapStorageShopView:UpdateView() -- 获取数据之前,剔除掉过期的商品 self.data = self.model:GetTreasureMapStorageShopData(true) self.shop_item_creator = self.shop_item_creator or self:AddUIComponent(UI.ItemListCreator) local info = { data_list = self.data, item_con = self.item_con, scroll_view = self.item_scroll, item_class = TreasureMapStorageShopItem, item_width = 171, item_height = 240, start_x = 6.5, start_y = -4, space_x = 29, space_y = 2, create_frequency = 0.01, alignment = UnityEngine.TextAnchor.UpperLeft, on_update_item = function(item, i, v) item:SetData(v) end, } self.shop_item_creator:UpdateItems(info) end function TreasureMapStorageShopView:DestroySuccess( ) end