|
- -- 成员列表Layout
- local ClubPlayerMatchInfo = class("ClubPlayerMatchInfo" , cc.UIView);
- local ClubDefine = require("luaScript.Protocol.Club.ClubDefine")
-
- local MATCH_DAY = {
- JIN_RI = 0,
- ZUO_RI = 1,
- QIAN_RI = 2,
- }
-
- local HISTORY_DAY_Txt = {
- [ClubDefine.RedFlowRecordType.ALL] = "全部",
- [ClubDefine.RedFlowRecordType.SUM_SUB] = "加减记录",
- [ClubDefine.RedFlowRecordType.PAI_JU] = "比赛记录",
- [ClubDefine.RedFlowRecordType.PRIZE] = "赠送记录",
- }
-
- --一页30个
- local PAGE_COUNT = 30
-
- function ClubPlayerMatchInfo:ctor(clubId)
- ClubPlayerMatchInfo.super.ctor(self)
-
- --单个茶馆数据
- self.clubInfo = app.club_php.clubList[clubId]
-
- --只用于是否播放标签页按钮音效
- self.touchIdx = 1;
- self.touchIdx2 = 1;
-
- self.curPage = 1
-
- self.totolPage = 1
-
- self.mapType = ClubDefine.RedFlowRecordType.ALL
-
- self:loadUI()
- end
-
- function ClubPlayerMatchInfo:loadUI()
- local ui = loadUI("res/ui/ui_club/ui_club_player_match_info.ui")
- self.ui = ui;
- self:addChild(ui);
- end
-
- function ClubPlayerMatchInfo:onEnter()
- ClubPlayerMatchInfo.super.onEnter(self)
-
- self:initButton()
-
- self.ui.Items.Image_SelectBg:setVisible(false)
-
- self.ui.Items.ScrollView:hideAllBar()
- self.ui.Items.ScrollView_Select:hideAllBar()
-
- self:initPlayer()
-
- self:initBindEvent()
-
- self:onRecord()
-
- --权限发生改变
- self:bindEvent(app.club_php , GAME_EVENT.CLUB_CHANGE_ROLE , handler(self , self.onChangeRole));
- self:bindEvent(app.club_php , GAME_EVENT.CLUB_SET , handler(self , self.onSetSuccess));
- --
- self:bindEvent(app.club_php , GAME_EVENT.CLUB_PLAYER_LIST , handler(self , self.initPlayer));
- end
-
- -- 当比赛一关,其他和比赛有关的界面需要关闭
- function ClubPlayerMatchInfo:onSetSuccess(data)
- if not data or not data.setType then
- return
- end
- if data.setType == GAME_CLUB_SET_STATE.Math_Switch then
- self:removeFromParent()
- end
- end
-
- -- 角色权限修改
- function ClubPlayerMatchInfo:onChangeRole()
- self:removeFromParent()
- end
-
- function ClubPlayerMatchInfo:initPlayer()
- local playerInfo = app.club_php:getMatchPlayer(self.clubInfo.clubId,app.user.loginInfo.uid)
- if not playerInfo then
- local playerJson
- playerJson = {
- clubId = self.clubInfo.clubId,
- viewType = ClubDefine.PlayListType.MATCH_MEMBER,
- status = ClubDefine.PlayListType.MATCH_MEMBER,
- }
- app.club_php:requestPlayerList(playerJson)
- return
- end
- --头像
- local nodeHead = self.ui.Items.ImageView_head;
- local headSize = nodeHead:getContentSize();
- if playerInfo.strHeadUrl and playerInfo.strHeadUrl ~= "" then
- setPlayerHeadImage(playerInfo.uid, playerInfo.strHeadUrl, nodeHead);
- else
- setDefaultHeadImg(playerInfo.sex, playerInfo.strHeadUrl, nodeHead, headSize.width);
- end
-
- --昵称
- local name = getSubStringNickname(playerInfo.name, self.ui.Items.Text_nickname)
- self.ui.Items.Text_nickname:setText(name or "未知昵称")
-
- --id号
- local strID = playerInfo.uid
- if playerInfo.agent == 1 then
- --是代理
- strID = "ID: " .. string.format("%d(代理)", playerInfo.uid)
- end
-
- self.ui.Items.Text_id:setText(strID);
-
- --职位
- if playerInfo.role == 1 then
- self.ui.Items.Text_job:setText("成 员")
- elseif playerInfo.role == 2 then
- self.ui.Items.Text_job:setText("管理员")
- elseif playerInfo.role == 3 then
- self.ui.Items.Text_job:setText(app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_CREATOR_DESC2 or PLN.CLUB_CREATOR_DESC2)
- elseif playerInfo.role == 4 then
- self.ui.Items.Text_job:setText("合伙人")
- end
-
- if self.clubInfo.memberInfo then
- local memberInfo = self.clubInfo.memberInfo
- self.ui.Items.Text_userRedFlower:setText("可用红花数:"..tostring(memberInfo.arena_score))
- end
- end
-
- function ClubPlayerMatchInfo:initButton()
- --关闭
- self.ui.Items.Button_close:registerClick(handler(self , self.onClose))
-
- --翻页
- self.ui.Items.Button_page_up:registerClick(handler(self , self.onClickUpPage))
- self.ui.Items.Button_page_next:registerClick(handler(self , self.onClickNextPage))
-
- self.ui.Items.Layout_Select_0:registerClick(function ()
- self:onClickDay(ClubDefine.RedFlowRecordType.ALL)
- end)
- self.ui.Items.Layout_Select_1:registerClick(function ()
- self:onClickDay(ClubDefine.RedFlowRecordType.SUM_SUB)
- end)
- self.ui.Items.Layout_Select_2:registerClick(function ()
- self:onClickDay(ClubDefine.RedFlowRecordType.PAI_JU)
- end)
- self.ui.Items.Layout_Select_3:registerClick(function ()
- self:onClickDay(ClubDefine.RedFlowRecordType.PRIZE)
- end)
-
- self.ui.Items.Image_Up:registerClick(handler(self,self.onUp))
- self.ui.Items.Image_Down:registerClick(handler(self,self.onDown))
- self.ui.Items.Image_Down:setVisible(false)
-
- local radioManager = import("luaScript.Tools.RadioManager"):new()
- --0今天,1昨天,2前天
- radioManager:addItem(self.ui.Items.CheckBox_match_jinri,MATCH_DAY.JIN_RI)
- radioManager:addItem(self.ui.Items.CheckBox_match_zuori,MATCH_DAY.ZUO_RI)
- radioManager:addItem(self.ui.Items.CheckBox_match_qianri,MATCH_DAY.QIAN_RI)
- radioManager:setCallback(handler(self,self.onClickMatchTypeTag))
- radioManager:setDefault(MATCH_DAY.JIN_RI)
- end
-
- function ClubPlayerMatchInfo:onClickMatchTypeTag(tag)
- if self.touchIdx2 > 1 then
- --playBtnTagEffect()
- end
-
- self.touchIdx2 = self.touchIdx2 + 1
-
- self.dayTag = tag
-
- if self.clubInfo then
- self.operatorId = app.user.loginInfo.uid
- app.club_php:requestRedFlowerRecord(self.clubInfo.clubId,self.operatorId,self.operatorId,self.mapType,self.dayTag,-1)
- end
- end
-
- function ClubPlayerMatchInfo:onUp()
- playBtnEffect()
- self.ui.Items.Image_SelectBg:setVisible(true)
- self.ui.Items.Image_Down:setVisible(true)
- self.ui.Items.Image_Up:setVisible(false)
- end
-
- function ClubPlayerMatchInfo:onDown()
- playBtnEffect()
- self.ui.Items.Image_SelectBg:setVisible(false)
- self.ui.Items.Image_Down:setVisible(false)
- self.ui.Items.Image_Up:setVisible(true)
- end
-
- function ClubPlayerMatchInfo:onClickDay(tag)
- if self.touchIdx > 1 then
- playBtnEffect()
- end
- self.touchIdx = self.touchIdx + 1
-
- self.mapType = tag
- self.curPage = 1
- self.ui.Items.Image_SelectBg:setVisible(false)
- self.ui.Items.Image_Down:setVisible(false)
- self.ui.Items.Image_Up:setVisible(true)
- self.ui.Items.Text_Info:setText(tostring(HISTORY_DAY_Txt[tag]))
- if self.clubInfo then
- self.operatorId = app.user.loginInfo.uid
- app.club_php:requestRedFlowerRecord(self.clubInfo.clubId,self.operatorId,self.operatorId,self.mapType,self.dayTag,-1)
- end
- end
-
- function ClubPlayerMatchInfo:initBindEvent()
- self:bindEvent(app.club_php , GAME_EVENT.CLUB_RED_FLOWER_RECORD , handler(self , self.onRecord))
- end
-
-
- function ClubPlayerMatchInfo:onClose()
- playBtnCloseEffect()
- self:removeFromParent()
- end
-
-
- --下一页
- function ClubPlayerMatchInfo:onClickNextPage()
- playBtnEffect()
- self.curPage = self.curPage + 1
- if self.curPage>self.totolPage then
- self.curPage = self.totolPage
- end
- self:updatePlayerList()
- end
-
- --上一页
- function ClubPlayerMatchInfo:onClickUpPage()
- playBtnEffect()
- self.curPage = self.curPage - 1
- if self.curPage<1 then
- self.curPage = 1
- end
- self:updatePlayerList()
- end
-
- function ClubPlayerMatchInfo:onRecord(data)
- if not data or not data.type then
- return
- end
- local mType = data.type
- local mListView = self.ui.Items.ScrollView
- mListView:hideAllBar()
- mListView:getInnerContainer():setAutoSize(true)
- mListView:removeAllChildren()
-
- local list = data.result.list
- local count = data.result.count
- local page = data.result.page
- local userInfo = data.result.userInfo
-
- if #list > 0 then
- self.ui.Items.Text_nodata:setVisible(false)
- end
-
- self.list = list
-
- if userInfo then
- local changeRedFlower = userInfo.arena_score
- local changeGreen = userInfo.arena_profit
- local play_win_number = userInfo.play_win_number --大赢家(按日期统计)
- local play_number = userInfo.play_number --成局数(按日期统计)
- local total_score = userInfo.total_score --输赢积分(按日期统计)
- if changeRedFlower > 0 then
- self.ui.Items.Text_redChange:setText("+"..tostring(changeRedFlower))
- self.ui.Items.Text_redChange:setTextColor(cc.c4b(235,72,15,255))
- else
- self.ui.Items.Text_redChange:setText(tostring(changeRedFlower))
- self.ui.Items.Text_redChange:setTextColor(cc.c4b(0,150,3,255))
- end
-
- if play_number > 0 then
- self.ui.Items.Text_jushu:setText(tostring(play_number))
- self.ui.Items.Text_jushu:setTextColor(cc.c4b(235,72,15,255))
- else
- self.ui.Items.Text_jushu:setText(tostring(play_number))
- self.ui.Items.Text_jushu:setTextColor(cc.c4b(0,150,3,255))
- end
-
- if total_score > 0 then
- self.ui.Items.Text_score:setText("+"..tostring(total_score))
- self.ui.Items.Text_score:setTextColor(cc.c4b(235,72,15,255))
- else
- self.ui.Items.Text_score:setText(tostring(total_score))
- self.ui.Items.Text_score:setTextColor(cc.c4b(0,150,3,255))
- end
-
- if play_win_number > 0 then
- self.ui.Items.Text_dayingjia:setText(tostring(play_win_number))
- self.ui.Items.Text_dayingjia:setTextColor(cc.c4b(235,72,15,255))
- else
- self.ui.Items.Text_dayingjia:setText(tostring(play_win_number))
- self.ui.Items.Text_dayingjia:setTextColor(cc.c4b(0,150,3,255))
- end
-
- end
-
- self:updatePlayerList(list)
- end
-
- function ClubPlayerMatchInfo:updatePlayerList(data)
- local mListView = self.ui.Items.ScrollView
- mListView:getInnerContainer():setAutoSize(true)
- mListView:removeAllChildren()
- local list = {}
- if data then
- list = data
- --记录上一次排序后的players数组,点上一页下一页时用
- self.lastSortPlayer = list
- else
- if self.lastSortPlayer and #self.lastSortPlayer >0 then
- list = self.lastSortPlayer
- else
- for k,v in pairs(self.list) do
- table.insert(list,v)
- end
- end
- end
-
- self.totolPage = math.ceil(table.nums(list)/PAGE_COUNT)
-
- local startIndex = (self.curPage-1) * PAGE_COUNT + 1
- local endIndex = startIndex + PAGE_COUNT - 1
-
- for i=startIndex,endIndex do
- local v = list[i]
- if v then
- item = import("luaScript.Views.Club.ClubPlayerMatchHistoryItem"):new(v,self.clubInfo.clubId,i)
- mListView:addChild(item.ui)
- end
- end
-
- mListView:jumpToTopOnSizeChanged()
-
- self.ui.Items.Text_Cur_page:setString(self.curPage)
- self.ui.Items.Text_Total_page:setString("/"..self.totolPage)
- if self.totolPage == 0 then
- self.ui.Items.Text_Cur_page:setString("0")
- end
- end
-
-
- return ClubPlayerMatchInfo
|