123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- ---@class KLTradeCrossServerGoodsPanel:UIKmlLuaPanelBase
- ---@field view KLTradeCrossServerGoodsPanel
- local KLTradeCrossServerGoodsPanel = class(UIKmlLuaPanelBase)
- local this = KLTradeCrossServerGoodsPanel
- ---创建时调用一次
- function this:Init()
- GUI:OSAScrollView_Initialized(self.view.osa_scrollview_crossServer_goods, self.UnionGoodsGetFun, self.UnionGoodsUpdateFun, self)
- self.goodsListData = {}
- self.refreshTimer = SL:Schedule(self.refreshTimer, 0, 3, -1, function()
- return self:RequestCurRefreshGoodsList()
- end)
- ---@type KLTradeUnionGoodsItem[]
- self.tradeUnionGoodsItems = {}
- self.tickTimer = SL:Schedule(self.tickTimer, 0, 1, -1, function()
- return self:Tick()
- end)
- self:RequestRefreshGoodsList()
- end
- function this:UnionGoodsGetFun()
- local item = GUI:UIPanel_Open("dev/outui/Trade/Item/KLTradeUnionGoods/KLTradeUnionGoodsItem", nil, self, nil, true)
- table.insert(self.tradeUnionGoodsItems, item)
- return item
- end
- ---@param item KLTradeUnionGoodsItem
- function this:UnionGoodsUpdateFun(item, index)
- local data = self.goodsListData[index + 1]
- item:SetData(data)
- end
- ---注册UI事件和服务器消息
- function this:RegistEvents()
- --SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_WAR_ALLIANCE_AUCTION_GOODS, self.RES_WAR_ALLIANCE_AUCTION_GOODS, self)
- SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_WAR_ALLIANCE_OPT_INFO, self.RequestCurRefreshGoodsList, self)
- end
- ---创建或者刷新界面数据时调用
- function this:Refresh()
-
- end
- function this:Close()
- SL:UnSchedule(self.refreshTimer)
- SL:UnSchedule(self.tickTimer)
- end
- function this:RequestRefreshGoodsList(type, subType, sortType, careerType, filterLevel, filterQuality)
- self.currentType = type or 2
- self.currentSubType = subType or 1
- self.currentSortType = sortType or 0
- self.currentCareerType = careerType or 0
- -- self.currentFilterLevel = filterLevel or 0
- -- self.currentFilterQuality = filterQuality or 0
- -- SL:LogError(self.currentType)
- -- SL:LogError(self.currentSubType)
- -- SL:LogError(self.currentSortType)
- -- SL:LogError(self.currentCareerType)
- self:RequestCurRefreshGoodsList()
- end
- function this:RequestCurRefreshGoodsList()
- table.clear(self.goodsListData)
- local message = InfoManager.kundunInfo:KunDunTrade_GetInfo(self.currentType,self.currentSubType,self.currentSortType,self.currentCareerType)
- if message and next(message) then
- for k, v in ipairs(message) do
- self.goodsListData[k] = v
- end
- end
- --SL:LogError(#self.goodsListData)
- GUI:OSAScrollView_RefreshList(self.view.osa_scrollview_crossServer_goods, #self.goodsListData)
- end
- function this:Tick()
- local refresh
- local items = GUI:OSAScrollView_GetAllItems(self.view.osa_scrollview_crossServer_goods)
- for i = 0, items.Count - 1 do
- local item = items[i]
- local expireData = item:Tick()
- if expireData then
- refresh = true
- table.removeByValue(self.goodsListData, expireData)
- end
- end
- if refresh then
- GUI:OSAScrollView_RefreshList(self.view.osa_scrollview_crossServer_goods, #self.goodsListData)
- end
- end
- return this
|