-- 战绩单元Layout local ClubDaYingJia = class("ClubDaYingJia",cc.UIView) --- ClubDaYingJia:ctor -- @param showType 1: 大赢家明细 2:局数明细 -- @param data = { -- gid 俱乐部id -- suid 被查询人uid -- lastday 查询时间,大赢家明细使用 -- searchDate 查询时间,局数明细使用 -- } function ClubDaYingJia:ctor(showType, data) ClubDaYingJia.super.ctor(self) local ui = loadUI("res/ui/ui_club/ui_club_dayingjia_detail.ui") self.ui = ui; self.dayingjialist = nil self.showType = showType self.suid = data.suid self.lastday = data.lastday self.searchDate = data.searchDate self.gid = data.gid self:addChild(ui) end --初始化界面 function ClubDaYingJia:onEnter() ClubDaYingJia.super.onEnter(self) self.ui.Items.Layout_0:setVisible(false) self.ui.Items.ScrollView:hideAllBar() self:initTitle() self.ui.Items.Button_Close:registerClick(handler(self,self.onClickClose)) if self.showType == 1 then app.club_zhanji:requestDaYingJiaZhanJi(self.gid, self.suid, self.lastday) --填数据 self:bindEvent(app, "onDaYingJiaZhanJiresponse", handler(self, self.initDaYingJiaView)) self.ui.Items.Layout_player_count:setContentSize(cc.size(780, 105)) else app.club_zhanji:getIdxlistByPlayerUid(self.gid, 3, self.searchDate, nil, self.suid) --填数据 self:bindEvent(app.club_zhanji, "getZhanjiBriefResponse", handler(self, self.initJuShuDetailView)) self.ui.Items.Layout_player_count:setContentSize(cc.size(880, 105)) end --权限发生改变 self:bindEvent(app.club_php , GAME_EVENT.CLUB_CHANGE_ROLE , handler(self , self.onChangeRole)); end function ClubDaYingJia:initTitle() if self.showType == 1 then -- 大赢家 self.ui.Items.ImageView_title:loadTexture("res/ui/zy_club/club_dayingjia_detail/zy_club_dayingjia_title.png") else -- 局数明细 self.ui.Items.ImageView_title:loadTexture("res/ui/zy_club/club_dayingjia_detail/zy_club_jushu_title.png") end end -- 角色权限修改 function ClubDaYingJia:onChangeRole() self:removeFromParent() end --- ClubDaYingJia:initDaYingJiaView 初始化大赢家详情 function ClubDaYingJia:initDaYingJiaView() logD("ClubDaYingJia:initDaYingJiaView") local dayingjialist = app.club_zhanji.dayijingjiadetail.list if not dayingjialist or table.nums(dayingjialist) <= 0 then return end self:initZhanJiList(dayingjialist) end --- ClubDaYingJia:initJuShuDetailView 初始化局数明细 function ClubDaYingJia:initJuShuDetailView() logD("ClubDaYingJia:initJuShuDetailView") local zhanjiList = app.club_zhanji:getZhanJiList(self.gid, 3, 1) if not zhanjiList or table.nums(zhanjiList) <= 0 then return end local function formatData( zhanjiList ) local list = {} for k, zj in pairs(zhanjiList) do local tmp = {} local scoreList = {} for uid, v in pairs(zj.tscore or {}) do local nickname = ""; local playerInfo = app.playerInfoManager:getPlayerInfo(uid); if playerInfo then local len = string.len(playerInfo.name) if len == 0 then nickname = "未知昵称" end nickname = getSubStringNickname(playerInfo.name) end local obj = {} obj.score = v obj.nickname = nickname obj.uid = uid table.insert(scoreList, obj) end tmp.roomid = zj.roomid tmp.ext = scoreList tmp.game_id = zj.gameid tmp.gamerule = zj.gext.gamerule tmp.time = zj.endtime tmp.gambid = 1 table.insert(list, tmp) end table.sort( list, function (a, b) return a.time > b.time end) return list end local list = formatData(zhanjiList) self:initZhanJiList(list) end function ClubDaYingJia:initZhanJiList(zhanjiList) logD("ClubDaYingJia:initZhanJiList") self.ui.Items.Layout_0:setVisible(true) local uiScrollView = self.ui.Items.ScrollView; uiScrollView:hideAllBar(); uiScrollView:removeAllChildren() uiScrollView:getInnerContainer():setAutoSize(true) for k, zhanji in pairs(zhanjiList) do local item = self:createZhanjiItem(zhanji) uiScrollView:addChild(item); end uiScrollView:jumpToTopOnSizeChanged() end function ClubDaYingJia:createZhanjiItem(itemData) local uiTemplateLayout = self.ui.Items.Layout_0 local uiItemLayout = uiTemplateLayout:getCopied() uiItemLayout.Items = getUIItems(uiItemLayout) local scoreList = itemData.ext --游戏icon local gameID = tonumber(itemData.game_id) local gameRule = toNumber(itemData.gamerule) local gameConfig = getSubGameConfig(gameID) local gameName = getSubGameRuleName(gameID,gameRule) uiItemLayout.Items.ImageView_flag:setVisible(true) uiItemLayout.Items.ImageView_flag:loadTexture("res/ui/zy_dating/zhanji/zhanji_win_icon.png") uiItemLayout.Items.Layout_game_title_me:setVisible(true) uiItemLayout.Items.Text_game_me:setString(gameName) uiItemLayout.Items.Text_game_me_1:setString(gameName) local club = app.club_php.clubList[self.gid] if club.role == 3 or club.role == 2 then if itemData.gambid == 1 then uiItemLayout.Items.Layout_3:setVisible(false) else uiItemLayout.Items.Layout_3:setVisible(true) end else uiItemLayout.Items.Layout_3:setVisible(false) end if club and club.role~=1 and 3 ~= ClUB_ZHANJI_TYPE.Mine then if app.club_zhanji.zhanJiIdxStatus[itemData.gambid]==2 then --确认过 uiItemLayout.Items.Button_Sure:setVisible(false) end else uiItemLayout.Items.Button_Sure:getParent():setVisible(false) end local function onClickSure() playBtnEffect() local club = app.club_php.clubList[self.gid] if club then if app.club_zhanji.zhanJiIdxStatus[itemData.gambid]==2 then --确认过 uiItemLayout.Items.Button_Sure:setVisible(false) return end end app.club_zhanji:requestZhanjiSure(self.gid,itemData.gambid,function() if not tolua.isnull(uiItemLayout) then uiItemLayout.Items.Button_Sure:setVisible(false) end end) end uiItemLayout.Items.Button_Sure:registerClick(onClickSure) --时间 local time = os.date("%Y-%m-%d %H:%M",itemData.time) uiItemLayout.Items.Text_time:setText(time) -- local club = app.club_php.clubList[self.gid] -- if club and club.role~=1 and self.zhanjiType ~= ClUB_ZHANJI_TYPE.Mine then -- if app.club_zhanji.zhanJiIdxStatus[self.roomInfo.pid]==2 then --确认过 -- self.ui.Items.Button_Sure:setVisible(false) -- end -- else -- self.ui.Items.Button_Sure:getParent():setVisible(false) -- end --大赢家 --[[local maxScore = nil; for uid, score in pairs(scoreList) do if not maxScore or maxScore < score then maxScore = score;``` end end--]] --房号 local roomInfo = itemData.roomid; uiItemLayout.Items.Text_roomid:setText("房号:"..roomInfo); --最终分数 local scorUI = uiItemLayout.Items.Layout_player_count; --scorUI:getInnerContainer():setAutoSize(true); scorUI:removeAllChildren(); local uiTemplate = self.ui.Items.Layout_player; local contentSize = scorUI:getContentSize(); local scoreSize = table.nums(scoreList) for k,v in pairsByKeys(scoreList) do local uiItem = uiTemplate:getCopied() uiItem:setSize(cc.size(contentSize.width / scoreSize, contentSize.height)) uiItem.Items = getUIItems(uiItem) --名字 local name = getSubStringNickname(v.nickname) uiItem.Items.Text_player_name:setText(name) -- 大赢家明细,全都不除以10 if gameConfig.isUseDivision10 and self.showType ~= 1 then v.score = v.score /10 end --分数 if v.score > 0 then v.score = "+"..tostring(v.score) uiItem.Items.Text_score:setFntFile("res/fonts/zhanji_win.fnt") else --绿色 uiItem.Items.Text_score:setFntFile("res/fonts/zhanji_lose.fnt") end uiItem.Items.Text_score:setText(v.score) scorUI:addChild(uiItem); if k == table.nums(scoreList) then uiItem.Items.ImageView_1:setVisible(false) end if v.uid == tostring(self.suid) then local isWin = tonumber(v.score) > 0 local path = isWin and "res/ui/zy_dating/zhanji/zhanji_win_icon.png" or "res/ui/zy_dating/zhanji/zhanji_lose_icon.png" uiItemLayout.Items.ImageView_flag:loadTexture(path) end end scorUI:requestDoLayout() scorUI:doLayout() return uiItemLayout end function ClubDaYingJia:onClickClose() playBtnCloseEffect() self:removeFromParent() end return ClubDaYingJia