local FamilyMenberManagerDisDetailView = {} local M = FamilyMenberManagerDisDetailView function FamilyMenberManagerDisDetailView.new(data, callback) setmetatable(M, { __index = BaseWindow }) local self = setmetatable({}, { __index = M }) self.class = "FamilyMenberManagerDisDetailView" self._data = data or {} self._callback = callback self._close_destroy = true self._new_hide = false self:init("ui://Family/FamilyMenberManagerDisDetail") return self end function M:init(url) getmetatable(M).__index.init(self, url) self._data.type = self._data.type or 0 local view = self._view self._viewList_player = view:GetChild('list_player') self._viewList_player:SetVirtual() self._viewList_player.itemRenderer = handler(self, self.PlayerRenderer) self._viewText_search = self._view:GetChild('input_search') view:GetChild('btn_search').onClick:Set(handler(self, self.ClickSearch)) view:GetChild('btn_return').onClick:Set(handler(self, self.ShowAllMenber)) self:FillData() end function M:ClickSearch() local text = self._viewText_search.text local tmpTable = self._fillData local searchData = {} for i, v in ipairs(tmpTable) do if v.uid == tonumber(text) or string.find(v.nick, text) then table.insert(searchData, v) end end self._fillData = searchData self._viewList_player.numItems = #self._fillData self._view:GetController('search').selectedIndex = 1 end function M:PlayerRenderer(index, obj) local info = self._fillData[index + 1] ImageLoad.Load(info.portrait, obj:GetChild('btn_head')._iconObject) obj:GetChild('text_name').text = info.nick obj:GetChild('text_id').text = string.format("标识:%s", info.uid) --根据不同type决定控制器的显示和添加按钮的功能 if self._data.type == 2 then local uidData = self._data.uidData or {} obj:GetController('added').selectedIndex = info._flag_add or 0 obj:GetChild('btn_add').onClick:Set(function() table.insert(uidData, info.uid) self._callback(uidData) obj:GetController('added').selectedIndex = 1 if #uidData == 1 then self:Destroy() end end) end end function M:ShowAllMenber() self._viewText_search.text = "" self._fillData = self._data.menberTable or DataManager.CurrenGroup.members self._viewList_player.numItems = #self._fillData end function M:FillData() self:ShowAllMenber() self:Show() end -- 打开窗口 function M:Show() getmetatable(M).__index.Show(self) end -- 关闭窗口 function M:Close() getmetatable(M).__index.Close(self) end -- 销毁窗口 function M:Destroy() getmetatable(M).__index.Destroy(self) end return M