-- 成员列表Layout local TiantiRank = class("TiantiRank" , cc.UIView); local ClubDefine = require("luaScript.Protocol.Club.ClubDefine") function TiantiRank:ctor() TiantiRank.super.ctor(self) self:loadUI() self:initView() end function TiantiRank:loadUI() local ui = loadUI("res/ui/ui_tianti/ui_tianti_rank.ui") self.ui = ui; self:addChild(ui); end function TiantiRank:onEnter() TiantiRank.super.onEnter(self) self:registerButton() self:initBindEvent() self:initMyVfiew() end function TiantiRank:initView() self.ui.Items.Layout_item_team_rank:setVisible(false) self.ui.Items.ScrollView_1:hideAllBar() self.ui.Items.ScrollView_1:getInnerContainer():setAutoSize(true) self.radioManager = import("luaScript.Tools.RadioManager"):new(); self.radioManager:setColorSwitch(false) self.selectType = app.serverConfigs:getStickyType() self.ui.Items.ScrollView:getInnerContainer():setAutoSize(true) self.ui.Items.ScrollView:removeAllChildren() local misstions = {} for i=1,4 do if i == 1 then local temp= {} temp.name = "今日" temp.type = 1 table.insert(misstions, temp) elseif i == 2 then local temp= {} temp.name = "上周" temp.type = 2 table.insert(misstions, temp) elseif i == 3 then local temp= {} temp.name = "上月" temp.type = 3 table.insert(misstions, temp) elseif i == 4 then local temp= {} temp.name = "总榜" temp.type = 4 table.insert(misstions, temp) end end self.ui.Items.CheckBox_XuanXiang:setVisible(false) for k,v in pairs(misstions) do local ui = self.ui.Items.CheckBox_XuanXiang:getCopied() ui:setVisible(true) ui.Items = getUIItems(ui) ui.Items.Text_Nor:setText(v.name) ui.Items.Text_Sel:setText(v.name) ui.Items.Text_Sel:setVisible(false) self.ui.Items.ScrollView:addChild(ui) self.radioManager:addItem(ui, v) end -- self.ui.Items.ScrollView:setTouchEnabled(false) self.radioManager:setCallback(handler(self, self.onClickItem)) self.radioManager:setDefault(1) self.type = 1 self.ui.Items.ScrollView:hideAllBar() self.ui.Items.ScrollView:jumpToTopOnSizeChanged() app.club_php:requestTiantiRank(handler(self,self.onUpdatePlayerListEvent), self.type) end -- 底部初始化个人信息 function TiantiRank:initMyVfiew() self.ui.Items.Text_mingci_2:setText("") local userInfo = json.decode(app.user.userInfo); local nodeHead = self.ui.Items.ImageView_head_2 local headSize = nodeHead:getContentSize() setPlayerHeadImage(app.user.loginInfo.uid, userInfo.headimgurl, nodeHead) --昵称 local name = getSubStringNickname(userInfo.nickname) self.ui.Items.Text_name_2:setText(name or "未知昵称") end -- 底部个人信息 function TiantiRank:updateMyView(playerInfo) if not playerInfo then return end --名词 if playerInfo.rank and playerInfo.rank > 0 and playerInfo.rank <= 3 then self.ui.Items.Text_mingci_2:setVisible(false) local file = "res/ui/zy_club/club_room/club_match_main/all_match_rank/all_match_rank_"..tostring(playerInfo.rank)..".png" self.ui.Items.ImageView_rank_2:loadTexture(file) self.ui.Items.ImageView_rank_2:setVisible(true) else self.ui.Items.ImageView_rank_2:setVisible(false) self.ui.Items.Text_mingci_2:setText(tostring(playerInfo.rank or "")) self.ui.Items.Text_mingci_2:setFontSize(32) self.ui.Items.Text_mingci_2:setVisible(true) if tostring(playerInfo.rank) == "0" then self.ui.Items.Text_mingci_2:setFontSize(24) self.ui.Items.Text_mingci_2:setText("未上榜") end end --头像 -- local nodeHead = self.ui.Items.ImageView_head_2 -- local headSize = nodeHead:getContentSize() -- if playerInfo.icon and playerInfo.icon ~= "" then -- setPlayerHeadImage(playerInfo.uid, playerInfo.icon, nodeHead) -- else -- setDefaultHeadImg(playerInfo.sex, playerInfo.icon, nodeHead, headSize.width) -- end --昵称 -- local name = getSubStringNickname(playerInfo.nickname) -- self.ui.Items.Text_name_2:setText(name or "未知昵称") self.ui.Items.Text_rank_level_2:setVisible(false) self.ui.Items.Layout_online_2:setVisible(false) self.ui.Items.ImageView_flag_2:setVisible(false) if playerInfo.istian then if playerInfo.istian == 1 then self.ui.Items.Text_wei_baoming:setVisible(false) else self.ui.Items.Text_wei_baoming:setVisible(true) end end self.ui.Items.Text_item_saidian_2:setString(tostring(playerInfo.contribute)) self.ui.Items.Text_item_jishufen_2:setString(tostring(playerInfo.total_score)) self.ui.Items.Text_item_shenglv_2:setString(tostring(playerInfo.play_win_number)) self.ui.Items.Text_item_biaozhunfen_2:setString(tostring(playerInfo.tianscore)) self.ui.Items.Text_item_jiangli_2:setString(tostring(playerInfo.des)) end function TiantiRank:onClickItem(mission,checkNode) if self.selectItem and not tolua.isnull(self.selectItem) then playBtnEffect() self.selectItem.Items.Text_Nor:setVisible(true) self.selectItem.Items.Text_Sel:setVisible(false) self.type = mission.type app.club_php:requestTiantiRank(handler(self,self.onUpdatePlayerListEvent), self.type) end self.selectItem = checkNode if self.selectItem then self.selectItem.Items.Text_Nor:setVisible(false) self.selectItem.Items.Text_Sel:setVisible(true) end end function TiantiRank:onUpdatePlayerListEvent(data) if not data then return end local pageList = data.list local players = pageList or self.pageList or {} self.pageList = players self:updatePlayerList(players) self.myselfInfo = data.memberinfo self:updateMyView(self.myselfInfo) end function TiantiRank:updatePlayerList(data) local mListView = self.ui.Items.ScrollView_1 mListView:removeAllChildren() local players = {} if data then players = data self.lastSortPlayer = players else if self.lastSortPlayer and table.nums(self.lastSortPlayer) > 0 then players = self.lastSortPlayer end end self.ui.Items.Text_nodata:setVisible(table.nums(players) == 0) self.curPageCheckBoxItems = {} self.curPagePlayer = {} for k,v in ipairs(players) do if v then table.insert(self.curPagePlayer,v) self:createItem(v) end end self.ui.Items.ScrollView_1:requestDoLayout() self.ui.Items.ScrollView_1:doLayout() mListView:jumpToTopOnSizeChanged() end function TiantiRank:createItem(playerInfo) local matchUI = self.ui.Items.Layout_item_team_rank:getCopied() -- autoAdaptWidth(matchUI) matchUI.Items = getUIItems(matchUI) --名词 if playerInfo.rank and playerInfo.rank > 0 and playerInfo.rank <= 3 then matchUI.Items.Text_mingci_1:setVisible(false) local file = "res/ui/zy_club/club_room/club_match_main/all_match_rank/all_match_rank_"..tostring(playerInfo.rank)..".png" matchUI.Items.ImageView_rank_1:loadTexture(file) matchUI.Items.ImageView_rank_1:setVisible(true) else matchUI.Items.ImageView_rank_1:setVisible(false) matchUI.Items.Text_mingci_1:setText(tostring(playerInfo.rank or "")) matchUI.Items.Text_mingci_1:setFontSize(32) matchUI.Items.Text_mingci_1:setVisible(true) end --头像 local nodeHead = matchUI.Items.ImageView_head_1 local headSize = nodeHead:getContentSize() if playerInfo.icon and playerInfo.icon ~= "" then setPlayerHeadImage(playerInfo.uid, playerInfo.icon, nodeHead) else setDefaultHeadImg(playerInfo.sex, playerInfo.icon, nodeHead, headSize.width) end --离线 matchUI.Items.Layout_online_1:setVisible(playerInfo.online == 0) matchUI.Items.Layout_online_1:setVisible(false) --等级 matchUI.Items.Text_rank_level_1:setText("LV."..tostring(playerInfo.level)) matchUI.Items.Text_rank_level_1:setVisible(false) --角色标签 -- local file = "res/ui/zy_club/club_room/club_cest_main/club_cest_main_flag_role_"..tostring(playerInfo.role)..".png" -- if playerInfo.role ~= ClubDefine.Job.Member and playerInfo.role and playerInfo.role ~= 0 then -- matchUI.Items.ImageView_flag_1:loadTexture(file) -- else matchUI.Items.ImageView_flag_1:setVisible(false) -- end --昵称 -- local name = getSubStringNickname(playerInfo.nickname, matchUI.Items.Text_name_1) local name = getSubStringNickname(playerInfo.nickname) matchUI.Items.Text_name_1:setText(name or "未知昵称") matchUI.Items.Text_item_saidian_1:setText(tostring(playerInfo.contribute)) matchUI.Items.Text_item_jishufen_1:setText(tostring(playerInfo.total_score)) matchUI.Items.Text_item_shenglv_1:setText(tostring(playerInfo.play_win_number)) matchUI.Items.Text_item_biaozhunfen_1:setText(tostring(playerInfo.tianscore)) matchUI.Items.Text_item_jiangli_1:setText(tostring(playerInfo.des)) self.ui.Items.ScrollView_1:addChild(matchUI) end function TiantiRank:registerButton() self.ui.Items.Button_close:registerClick(handler(self,self.onClose)) -- self.ui.Items.Layout_:registerClick(handler(self,self.onClose)) self.ui.Items.Text_wei_baoming:registerClick(handler(self,self.onBaoming)) end function TiantiRank:onBaoming() local view = import("luaScript.Views.Tianti.TiantiBaoming"):new() view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) end function TiantiRank:onClose() playBtnCloseEffect() self:removeFromParent() end function TiantiRank:initBindEvent() -- self:bindEvent(app.club_php , GAME_EVENT.CLUB_ALL_PEOPLE_MATCH , handler(self , self.onUpdatePlayerListEvent)) end return TiantiRank