-- 大厅总战绩 local BTN_TAG_IMG_SELECT = { [0] = "club_zhanji_me_btn_sel.png", --我的战绩 [1] = "zhanji_other_title_sel.png", --茶馆战绩 -- [2] = "club_zhanji_tongji_btn_sel.png", --战绩统计 } local BTN_TAG_IMG_NORMAL = { [0] = "club_zhanji_me_btn.png", --我的战绩 [1] = "zhanji_other_title_nor.png", --茶馆战绩 -- [2] = "club_zhanji_tongji_btn.png", --战绩统计 } local ZhanJiViewBase = class("ZhanJiViewBase", cc.UIView) -- local app.allZhanji = require("luaScript.Protocol.ProtocolZhanJiGame"):new(-1, "zhanji_AllGame"); function ZhanJiViewBase:ctor(gameId, listItemClass,code) ZhanJiViewBase.super.ctor(self); self.gameId = gameId; self.listItemClass = listItemClass; self.code = code self.ui = loadUI("res/ui/ui_zhanji/zhanji_view.ui") self:addChild(self.ui) self.protocolZhanJi = app:getProtocolZhanJi(self.gameId) end function ZhanJiViewBase:onEnter() ZhanJiViewBase.super.onEnter(self) self.ui.Items.Button:registerClick(handler(self , self.onClickClose)) self.ui.Items.Button_search:registerClick(handler(self , self.onClickSearch)) self.ui.Items.Layout_allgame_item:setVisible(false) self.ui.Items.Layout_player_score:setVisible(false) self.ui.Items.Layout_no_data:setVisible(false) self:bindEvent(app.allZhanji, "getZhanjiBriefResponse", handler(self, self.showAllGameZhanji)) if self.gameId == -1 then --当前显示为大厅总战绩 app.allZhanji:init() elseif self.gameId ~= nil then self:showOneGameZhanji() end self.curShowType = 1 if self.code then --有回放码 默认查看他人战绩 self.curShowType = 2 app.allZhanji:requestOtherZhanji(self.code) end local radioManager = import("luaScript.Tools.RadioManager"):new() radioManager:addItem(self.ui.Items.CheckBox_my,1) radioManager:addItem(self.ui.Items.CheckBox_other,2) radioManager:setCallback(handler(self , self.onClickZhanji)) radioManager:setDefault(self.curShowType) if isReviewVersion() then self.ui.Items.Layout_manager:setVisible(false) end end function ZhanJiViewBase:onClickSearch() local str = self.ui.Items.TextField_search:getString() if not str or str=="" then return end app.allZhanji:requestOtherZhanji(str) end function ZhanJiViewBase:onClickZhanji(index) --playBtnTagEffect() self.curShowType = index if index==2 then app.allZhanji:requestOtherZhanji() self.ui.Items.Layout_search:setVisible(true) else self.ui.Items.Layout_search:setVisible(false) end self:showAllGameZhanji() end --显示单个游戏战绩 function ZhanJiViewBase:showOneGameZhanji() local fangjianInfo = self.protocolZhanJi.zhanjiInfoList if fangjianInfo == nil then self.ui.Items.Layout_no_data:setVisible(true) return end self.ui.Items.Layout_no_data:setVisible(false) logD("ZhanJiViewBase:showOneGameZhanji() fangjianInfo"..table.tostring(fangjianInfo)) local mScrollView = self.ui.Items.ScrollView mScrollView:getInnerContainer():setAutoSize(true) mScrollView:removeAllChildren(); mScrollView:hideAllBar() local ttZhanJiList = {} for _,info in pairs(fangjianInfo) do ttZhanJiList[info.endtime] = info; end local totalSize = table.nums(fangjianInfo); if totalSize > 0 then for _,info in pairsByKeysEx(ttZhanJiList) do local item = import(self.listItemClass):new(info) mScrollView:addChild(item:getRoot()) end end mScrollView:jumpToTopOnSizeChanged() end -- 显示所有游戏 function ZhanJiViewBase:showAllGameZhanji(event) local mListView = self.ui.Items.ScrollView mListView:removeAllChildren() mListView:getInnerContainer():setAutoSize(true) if self.curShowType==2 and event and event.result and table.nums(event.result.gamb)==0 then showTooltip("回放码错误或者已经失效!") end local uiTemplate = self.ui.Items.Layout_allgame_item; local zhanjiList = self.curShowType==1 and app.allZhanji:getZhanJiList() or app.allZhanji:getZhanJiListOther() if zhanjiList and table.nums(zhanjiList) <= 0 then self.ui.Items.Layout_no_data:setVisible(true) return end self.ui.Items.Layout_no_data:setVisible(false) local index = table.nums(zhanjiList) for logid, zhanjiInfo in pairsByKeys(zhanjiList) do local endtime = tonumber(zhanjiInfo.endtime) local uiContent = import("luaScript.Views.ZhanJi.ZhanJiItem"):new(self.curShowType, zhanjiInfo ,index) if uiContent and uiContent.ui then mListView:addChild(uiContent.ui) index = index-1 end end mListView:jumpToTopOnSizeChanged() end -- 关闭 function ZhanJiViewBase:onClickClose() playBtnCloseEffect() self:removeFromParent() end return ZhanJiViewBase;