You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

353 lines
10 KiB

  1. -- 成员列表Layout
  2. local ClubPlayerMatchInfo = class("ClubPlayerMatchInfo" , cc.UIView);
  3. local ClubDefine = require("luaScript.Protocol.Club.ClubDefine")
  4. local MATCH_DAY = {
  5. JIN_RI = 0,
  6. ZUO_RI = 1,
  7. QIAN_RI = 2,
  8. }
  9. local HISTORY_DAY_Txt = {
  10. [ClubDefine.RedFlowRecordType.ALL] = "全部",
  11. [ClubDefine.RedFlowRecordType.SUM_SUB] = "加减记录",
  12. [ClubDefine.RedFlowRecordType.PAI_JU] = "比赛记录",
  13. [ClubDefine.RedFlowRecordType.PRIZE] = "赠送记录",
  14. }
  15. --一页30个
  16. local PAGE_COUNT = 30
  17. function ClubPlayerMatchInfo:ctor(clubId)
  18. ClubPlayerMatchInfo.super.ctor(self)
  19. --单个茶馆数据
  20. self.clubInfo = app.club_php.clubList[clubId]
  21. --只用于是否播放标签页按钮音效
  22. self.touchIdx = 1;
  23. self.touchIdx2 = 1;
  24. self.curPage = 1
  25. self.totolPage = 1
  26. self.mapType = ClubDefine.RedFlowRecordType.ALL
  27. self:loadUI()
  28. end
  29. function ClubPlayerMatchInfo:loadUI()
  30. local ui = loadUI("res/ui/ui_club/ui_club_player_match_info.ui")
  31. self.ui = ui;
  32. self:addChild(ui);
  33. end
  34. function ClubPlayerMatchInfo:onEnter()
  35. ClubPlayerMatchInfo.super.onEnter(self)
  36. self:initButton()
  37. self.ui.Items.Image_SelectBg:setVisible(false)
  38. self.ui.Items.ScrollView:hideAllBar()
  39. self.ui.Items.ScrollView_Select:hideAllBar()
  40. self:initPlayer()
  41. self:initBindEvent()
  42. self:onRecord()
  43. --权限发生改变
  44. self:bindEvent(app.club_php , GAME_EVENT.CLUB_CHANGE_ROLE , handler(self , self.onChangeRole));
  45. self:bindEvent(app.club_php , GAME_EVENT.CLUB_SET , handler(self , self.onSetSuccess));
  46. --
  47. self:bindEvent(app.club_php , GAME_EVENT.CLUB_PLAYER_LIST , handler(self , self.initPlayer));
  48. end
  49. -- 当比赛一关,其他和比赛有关的界面需要关闭
  50. function ClubPlayerMatchInfo:onSetSuccess(data)
  51. if not data or not data.setType then
  52. return
  53. end
  54. if data.setType == GAME_CLUB_SET_STATE.Math_Switch then
  55. self:removeFromParent()
  56. end
  57. end
  58. -- 角色权限修改
  59. function ClubPlayerMatchInfo:onChangeRole()
  60. self:removeFromParent()
  61. end
  62. function ClubPlayerMatchInfo:initPlayer()
  63. local playerInfo = app.club_php:getMatchPlayer(self.clubInfo.clubId,app.user.loginInfo.uid)
  64. if not playerInfo then
  65. local playerJson
  66. playerJson = {
  67. clubId = self.clubInfo.clubId,
  68. viewType = ClubDefine.PlayListType.MATCH_MEMBER,
  69. status = ClubDefine.PlayListType.MATCH_MEMBER,
  70. }
  71. app.club_php:requestPlayerList(playerJson)
  72. return
  73. end
  74. --头像
  75. local nodeHead = self.ui.Items.ImageView_head;
  76. local headSize = nodeHead:getContentSize();
  77. if playerInfo.strHeadUrl and playerInfo.strHeadUrl ~= "" then
  78. setPlayerHeadImage(playerInfo.uid, playerInfo.strHeadUrl, nodeHead);
  79. else
  80. setDefaultHeadImg(playerInfo.sex, playerInfo.strHeadUrl, nodeHead, headSize.width);
  81. end
  82. --昵称
  83. local name = getSubStringNickname(playerInfo.name, self.ui.Items.Text_nickname)
  84. self.ui.Items.Text_nickname:setText(name or "未知昵称")
  85. --id号
  86. local strID = playerInfo.uid
  87. if playerInfo.agent == 1 then
  88. --是代理
  89. strID = "ID: " .. string.format("%d(代理)", playerInfo.uid)
  90. end
  91. self.ui.Items.Text_id:setText(strID);
  92. --职位
  93. if playerInfo.role == 1 then
  94. self.ui.Items.Text_job:setText("成 员")
  95. elseif playerInfo.role == 2 then
  96. self.ui.Items.Text_job:setText("管理员")
  97. elseif playerInfo.role == 3 then
  98. 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)
  99. elseif playerInfo.role == 4 then
  100. self.ui.Items.Text_job:setText("合伙人")
  101. end
  102. if self.clubInfo.memberInfo then
  103. local memberInfo = self.clubInfo.memberInfo
  104. self.ui.Items.Text_userRedFlower:setText("可用红花数:"..tostring(memberInfo.arena_score))
  105. end
  106. end
  107. function ClubPlayerMatchInfo:initButton()
  108. --关闭
  109. self.ui.Items.Button_close:registerClick(handler(self , self.onClose))
  110. --翻页
  111. self.ui.Items.Button_page_up:registerClick(handler(self , self.onClickUpPage))
  112. self.ui.Items.Button_page_next:registerClick(handler(self , self.onClickNextPage))
  113. self.ui.Items.Layout_Select_0:registerClick(function ()
  114. self:onClickDay(ClubDefine.RedFlowRecordType.ALL)
  115. end)
  116. self.ui.Items.Layout_Select_1:registerClick(function ()
  117. self:onClickDay(ClubDefine.RedFlowRecordType.SUM_SUB)
  118. end)
  119. self.ui.Items.Layout_Select_2:registerClick(function ()
  120. self:onClickDay(ClubDefine.RedFlowRecordType.PAI_JU)
  121. end)
  122. self.ui.Items.Layout_Select_3:registerClick(function ()
  123. self:onClickDay(ClubDefine.RedFlowRecordType.PRIZE)
  124. end)
  125. self.ui.Items.Image_Up:registerClick(handler(self,self.onUp))
  126. self.ui.Items.Image_Down:registerClick(handler(self,self.onDown))
  127. self.ui.Items.Image_Down:setVisible(false)
  128. local radioManager = import("luaScript.Tools.RadioManager"):new()
  129. --0今天,1昨天,2前天
  130. radioManager:addItem(self.ui.Items.CheckBox_match_jinri,MATCH_DAY.JIN_RI)
  131. radioManager:addItem(self.ui.Items.CheckBox_match_zuori,MATCH_DAY.ZUO_RI)
  132. radioManager:addItem(self.ui.Items.CheckBox_match_qianri,MATCH_DAY.QIAN_RI)
  133. radioManager:setCallback(handler(self,self.onClickMatchTypeTag))
  134. radioManager:setDefault(MATCH_DAY.JIN_RI)
  135. end
  136. function ClubPlayerMatchInfo:onClickMatchTypeTag(tag)
  137. if self.touchIdx2 > 1 then
  138. --playBtnTagEffect()
  139. end
  140. self.touchIdx2 = self.touchIdx2 + 1
  141. self.dayTag = tag
  142. if self.clubInfo then
  143. self.operatorId = app.user.loginInfo.uid
  144. app.club_php:requestRedFlowerRecord(self.clubInfo.clubId,self.operatorId,self.operatorId,self.mapType,self.dayTag,-1)
  145. end
  146. end
  147. function ClubPlayerMatchInfo:onUp()
  148. playBtnEffect()
  149. self.ui.Items.Image_SelectBg:setVisible(true)
  150. self.ui.Items.Image_Down:setVisible(true)
  151. self.ui.Items.Image_Up:setVisible(false)
  152. end
  153. function ClubPlayerMatchInfo:onDown()
  154. playBtnEffect()
  155. self.ui.Items.Image_SelectBg:setVisible(false)
  156. self.ui.Items.Image_Down:setVisible(false)
  157. self.ui.Items.Image_Up:setVisible(true)
  158. end
  159. function ClubPlayerMatchInfo:onClickDay(tag)
  160. if self.touchIdx > 1 then
  161. playBtnEffect()
  162. end
  163. self.touchIdx = self.touchIdx + 1
  164. self.mapType = tag
  165. self.curPage = 1
  166. self.ui.Items.Image_SelectBg:setVisible(false)
  167. self.ui.Items.Image_Down:setVisible(false)
  168. self.ui.Items.Image_Up:setVisible(true)
  169. self.ui.Items.Text_Info:setText(tostring(HISTORY_DAY_Txt[tag]))
  170. if self.clubInfo then
  171. self.operatorId = app.user.loginInfo.uid
  172. app.club_php:requestRedFlowerRecord(self.clubInfo.clubId,self.operatorId,self.operatorId,self.mapType,self.dayTag,-1)
  173. end
  174. end
  175. function ClubPlayerMatchInfo:initBindEvent()
  176. self:bindEvent(app.club_php , GAME_EVENT.CLUB_RED_FLOWER_RECORD , handler(self , self.onRecord))
  177. end
  178. function ClubPlayerMatchInfo:onClose()
  179. playBtnCloseEffect()
  180. self:removeFromParent()
  181. end
  182. --下一页
  183. function ClubPlayerMatchInfo:onClickNextPage()
  184. playBtnEffect()
  185. self.curPage = self.curPage + 1
  186. if self.curPage>self.totolPage then
  187. self.curPage = self.totolPage
  188. end
  189. self:updatePlayerList()
  190. end
  191. --上一页
  192. function ClubPlayerMatchInfo:onClickUpPage()
  193. playBtnEffect()
  194. self.curPage = self.curPage - 1
  195. if self.curPage<1 then
  196. self.curPage = 1
  197. end
  198. self:updatePlayerList()
  199. end
  200. function ClubPlayerMatchInfo:onRecord(data)
  201. if not data or not data.type then
  202. return
  203. end
  204. local mType = data.type
  205. local mListView = self.ui.Items.ScrollView
  206. mListView:hideAllBar()
  207. mListView:getInnerContainer():setAutoSize(true)
  208. mListView:removeAllChildren()
  209. local list = data.result.list
  210. local count = data.result.count
  211. local page = data.result.page
  212. local userInfo = data.result.userInfo
  213. if #list > 0 then
  214. self.ui.Items.Text_nodata:setVisible(false)
  215. end
  216. self.list = list
  217. if userInfo then
  218. local changeRedFlower = userInfo.arena_score
  219. local changeGreen = userInfo.arena_profit
  220. local play_win_number = userInfo.play_win_number --大赢家(按日期统计)
  221. local play_number = userInfo.play_number --成局数(按日期统计)
  222. local total_score = userInfo.total_score --输赢积分(按日期统计)
  223. if changeRedFlower > 0 then
  224. self.ui.Items.Text_redChange:setText("+"..tostring(changeRedFlower))
  225. self.ui.Items.Text_redChange:setTextColor(cc.c4b(235,72,15,255))
  226. else
  227. self.ui.Items.Text_redChange:setText(tostring(changeRedFlower))
  228. self.ui.Items.Text_redChange:setTextColor(cc.c4b(0,150,3,255))
  229. end
  230. if play_number > 0 then
  231. self.ui.Items.Text_jushu:setText(tostring(play_number))
  232. self.ui.Items.Text_jushu:setTextColor(cc.c4b(235,72,15,255))
  233. else
  234. self.ui.Items.Text_jushu:setText(tostring(play_number))
  235. self.ui.Items.Text_jushu:setTextColor(cc.c4b(0,150,3,255))
  236. end
  237. if total_score > 0 then
  238. self.ui.Items.Text_score:setText("+"..tostring(total_score))
  239. self.ui.Items.Text_score:setTextColor(cc.c4b(235,72,15,255))
  240. else
  241. self.ui.Items.Text_score:setText(tostring(total_score))
  242. self.ui.Items.Text_score:setTextColor(cc.c4b(0,150,3,255))
  243. end
  244. if play_win_number > 0 then
  245. self.ui.Items.Text_dayingjia:setText(tostring(play_win_number))
  246. self.ui.Items.Text_dayingjia:setTextColor(cc.c4b(235,72,15,255))
  247. else
  248. self.ui.Items.Text_dayingjia:setText(tostring(play_win_number))
  249. self.ui.Items.Text_dayingjia:setTextColor(cc.c4b(0,150,3,255))
  250. end
  251. end
  252. self:updatePlayerList(list)
  253. end
  254. function ClubPlayerMatchInfo:updatePlayerList(data)
  255. local mListView = self.ui.Items.ScrollView
  256. mListView:getInnerContainer():setAutoSize(true)
  257. mListView:removeAllChildren()
  258. local list = {}
  259. if data then
  260. list = data
  261. --记录上一次排序后的players数组,点上一页下一页时用
  262. self.lastSortPlayer = list
  263. else
  264. if self.lastSortPlayer and #self.lastSortPlayer >0 then
  265. list = self.lastSortPlayer
  266. else
  267. for k,v in pairs(self.list) do
  268. table.insert(list,v)
  269. end
  270. end
  271. end
  272. self.totolPage = math.ceil(table.nums(list)/PAGE_COUNT)
  273. local startIndex = (self.curPage-1) * PAGE_COUNT + 1
  274. local endIndex = startIndex + PAGE_COUNT - 1
  275. for i=startIndex,endIndex do
  276. local v = list[i]
  277. if v then
  278. item = import("luaScript.Views.Club.ClubPlayerMatchHistoryItem"):new(v,self.clubInfo.clubId,i)
  279. mListView:addChild(item.ui)
  280. end
  281. end
  282. mListView:jumpToTopOnSizeChanged()
  283. self.ui.Items.Text_Cur_page:setString(self.curPage)
  284. self.ui.Items.Text_Total_page:setString("/"..self.totolPage)
  285. if self.totolPage == 0 then
  286. self.ui.Items.Text_Cur_page:setString("0")
  287. end
  288. end
  289. return ClubPlayerMatchInfo