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.

346 lines
9.0 KiB

  1. -- 成员列表Layout
  2. local TiantiRank = class("TiantiRank" , cc.UIView);
  3. local ClubDefine = require("luaScript.Protocol.Club.ClubDefine")
  4. function TiantiRank:ctor()
  5. TiantiRank.super.ctor(self)
  6. self:loadUI()
  7. self:initView()
  8. end
  9. function TiantiRank:loadUI()
  10. local ui = loadUI("res/ui/ui_tianti/ui_tianti_rank.ui")
  11. self.ui = ui;
  12. self:addChild(ui);
  13. end
  14. function TiantiRank:onEnter()
  15. TiantiRank.super.onEnter(self)
  16. self:registerButton()
  17. self:initBindEvent()
  18. self:initMyVfiew()
  19. end
  20. function TiantiRank:initView()
  21. self.ui.Items.Layout_item_team_rank:setVisible(false)
  22. self.ui.Items.ScrollView_1:hideAllBar()
  23. self.ui.Items.ScrollView_1:getInnerContainer():setAutoSize(true)
  24. self.radioManager = import("luaScript.Tools.RadioManager"):new();
  25. self.radioManager:setColorSwitch(false)
  26. self.selectType = app.serverConfigs:getStickyType()
  27. self.ui.Items.ScrollView:getInnerContainer():setAutoSize(true)
  28. self.ui.Items.ScrollView:removeAllChildren()
  29. local misstions = {}
  30. for i=1,4 do
  31. if i == 1 then
  32. local temp= {}
  33. temp.name = "今日"
  34. temp.type = 1
  35. table.insert(misstions, temp)
  36. elseif i == 2 then
  37. local temp= {}
  38. temp.name = "上周"
  39. temp.type = 2
  40. table.insert(misstions, temp)
  41. elseif i == 3 then
  42. local temp= {}
  43. temp.name = "上月"
  44. temp.type = 3
  45. table.insert(misstions, temp)
  46. elseif i == 4 then
  47. local temp= {}
  48. temp.name = "总榜"
  49. temp.type = 4
  50. table.insert(misstions, temp)
  51. end
  52. end
  53. self.ui.Items.CheckBox_XuanXiang:setVisible(false)
  54. for k,v in pairs(misstions) do
  55. local ui = self.ui.Items.CheckBox_XuanXiang:getCopied()
  56. ui:setVisible(true)
  57. ui.Items = getUIItems(ui)
  58. ui.Items.Text_Nor:setText(v.name)
  59. ui.Items.Text_Sel:setText(v.name)
  60. ui.Items.Text_Sel:setVisible(false)
  61. self.ui.Items.ScrollView:addChild(ui)
  62. self.radioManager:addItem(ui, v)
  63. end
  64. -- self.ui.Items.ScrollView:setTouchEnabled(false)
  65. self.radioManager:setCallback(handler(self, self.onClickItem))
  66. self.radioManager:setDefault(1)
  67. self.type = 1
  68. self.ui.Items.ScrollView:hideAllBar()
  69. self.ui.Items.ScrollView:jumpToTopOnSizeChanged()
  70. app.club_php:requestTiantiRank(handler(self,self.onUpdatePlayerListEvent), self.type)
  71. end
  72. -- 底部初始化个人信息
  73. function TiantiRank:initMyVfiew()
  74. self.ui.Items.Text_mingci_2:setText("")
  75. local userInfo = json.decode(app.user.userInfo);
  76. local nodeHead = self.ui.Items.ImageView_head_2
  77. local headSize = nodeHead:getContentSize()
  78. setPlayerHeadImage(app.user.loginInfo.uid, userInfo.headimgurl, nodeHead)
  79. --昵称
  80. local name = getSubStringNickname(userInfo.nickname)
  81. self.ui.Items.Text_name_2:setText(name or "未知昵称")
  82. end
  83. -- 底部个人信息
  84. function TiantiRank:updateMyView(playerInfo)
  85. if not playerInfo then
  86. return
  87. end
  88. --名词
  89. if playerInfo.rank and playerInfo.rank > 0 and playerInfo.rank <= 3 then
  90. self.ui.Items.Text_mingci_2:setVisible(false)
  91. local file = "res/ui/zy_club/club_room/club_match_main/all_match_rank/all_match_rank_"..tostring(playerInfo.rank)..".png"
  92. self.ui.Items.ImageView_rank_2:loadTexture(file)
  93. self.ui.Items.ImageView_rank_2:setVisible(true)
  94. else
  95. self.ui.Items.ImageView_rank_2:setVisible(false)
  96. self.ui.Items.Text_mingci_2:setText(tostring(playerInfo.rank or ""))
  97. self.ui.Items.Text_mingci_2:setFontSize(32)
  98. self.ui.Items.Text_mingci_2:setVisible(true)
  99. if tostring(playerInfo.rank) == "0" then
  100. self.ui.Items.Text_mingci_2:setFontSize(24)
  101. self.ui.Items.Text_mingci_2:setText("未上榜")
  102. end
  103. end
  104. --头像
  105. -- local nodeHead = self.ui.Items.ImageView_head_2
  106. -- local headSize = nodeHead:getContentSize()
  107. -- if playerInfo.icon and playerInfo.icon ~= "" then
  108. -- setPlayerHeadImage(playerInfo.uid, playerInfo.icon, nodeHead)
  109. -- else
  110. -- setDefaultHeadImg(playerInfo.sex, playerInfo.icon, nodeHead, headSize.width)
  111. -- end
  112. --昵称
  113. -- local name = getSubStringNickname(playerInfo.nickname)
  114. -- self.ui.Items.Text_name_2:setText(name or "未知昵称")
  115. self.ui.Items.Text_rank_level_2:setVisible(false)
  116. self.ui.Items.Layout_online_2:setVisible(false)
  117. self.ui.Items.ImageView_flag_2:setVisible(false)
  118. if playerInfo.istian then
  119. if playerInfo.istian == 1 then
  120. self.ui.Items.Text_wei_baoming:setVisible(false)
  121. else
  122. self.ui.Items.Text_wei_baoming:setVisible(true)
  123. end
  124. end
  125. self.ui.Items.Text_item_saidian_2:setString(tostring(playerInfo.contribute))
  126. self.ui.Items.Text_item_jishufen_2:setString(tostring(playerInfo.total_score))
  127. self.ui.Items.Text_item_shenglv_2:setString(tostring(playerInfo.play_win_number))
  128. self.ui.Items.Text_item_biaozhunfen_2:setString(tostring(playerInfo.tianscore))
  129. self.ui.Items.Text_item_jiangli_2:setString(tostring(playerInfo.des))
  130. end
  131. function TiantiRank:onClickItem(mission,checkNode)
  132. if self.selectItem and not tolua.isnull(self.selectItem) then
  133. playBtnEffect()
  134. self.selectItem.Items.Text_Nor:setVisible(true)
  135. self.selectItem.Items.Text_Sel:setVisible(false)
  136. self.type = mission.type
  137. app.club_php:requestTiantiRank(handler(self,self.onUpdatePlayerListEvent), self.type)
  138. end
  139. self.selectItem = checkNode
  140. if self.selectItem then
  141. self.selectItem.Items.Text_Nor:setVisible(false)
  142. self.selectItem.Items.Text_Sel:setVisible(true)
  143. end
  144. end
  145. function TiantiRank:onUpdatePlayerListEvent(data)
  146. if not data then
  147. return
  148. end
  149. local pageList = data.list
  150. local players = pageList or self.pageList or {}
  151. self.pageList = players
  152. self:updatePlayerList(players)
  153. self.myselfInfo = data.memberinfo
  154. self:updateMyView(self.myselfInfo)
  155. end
  156. function TiantiRank:updatePlayerList(data)
  157. local mListView = self.ui.Items.ScrollView_1
  158. mListView:removeAllChildren()
  159. local players = {}
  160. if data then
  161. players = data
  162. self.lastSortPlayer = players
  163. else
  164. if self.lastSortPlayer and table.nums(self.lastSortPlayer) > 0 then
  165. players = self.lastSortPlayer
  166. end
  167. end
  168. self.ui.Items.Text_nodata:setVisible(table.nums(players) == 0)
  169. self.curPageCheckBoxItems = {}
  170. self.curPagePlayer = {}
  171. for k,v in ipairs(players) do
  172. if v then
  173. table.insert(self.curPagePlayer,v)
  174. self:createItem(v)
  175. end
  176. end
  177. self.ui.Items.ScrollView_1:requestDoLayout()
  178. self.ui.Items.ScrollView_1:doLayout()
  179. mListView:jumpToTopOnSizeChanged()
  180. end
  181. function TiantiRank:createItem(playerInfo)
  182. local matchUI = self.ui.Items.Layout_item_team_rank:getCopied()
  183. -- autoAdaptWidth(matchUI)
  184. matchUI.Items = getUIItems(matchUI)
  185. --名词
  186. if playerInfo.rank and playerInfo.rank > 0 and playerInfo.rank <= 3 then
  187. matchUI.Items.Text_mingci_1:setVisible(false)
  188. local file = "res/ui/zy_club/club_room/club_match_main/all_match_rank/all_match_rank_"..tostring(playerInfo.rank)..".png"
  189. matchUI.Items.ImageView_rank_1:loadTexture(file)
  190. matchUI.Items.ImageView_rank_1:setVisible(true)
  191. else
  192. matchUI.Items.ImageView_rank_1:setVisible(false)
  193. matchUI.Items.Text_mingci_1:setText(tostring(playerInfo.rank or ""))
  194. matchUI.Items.Text_mingci_1:setFontSize(32)
  195. matchUI.Items.Text_mingci_1:setVisible(true)
  196. end
  197. --头像
  198. local nodeHead = matchUI.Items.ImageView_head_1
  199. local headSize = nodeHead:getContentSize()
  200. if playerInfo.icon and playerInfo.icon ~= "" then
  201. setPlayerHeadImage(playerInfo.uid, playerInfo.icon, nodeHead)
  202. else
  203. setDefaultHeadImg(playerInfo.sex, playerInfo.icon, nodeHead, headSize.width)
  204. end
  205. --离线
  206. matchUI.Items.Layout_online_1:setVisible(playerInfo.online == 0)
  207. matchUI.Items.Layout_online_1:setVisible(false)
  208. --等级
  209. matchUI.Items.Text_rank_level_1:setText("LV."..tostring(playerInfo.level))
  210. matchUI.Items.Text_rank_level_1:setVisible(false)
  211. --角色标签
  212. -- local file = "res/ui/zy_club/club_room/club_cest_main/club_cest_main_flag_role_"..tostring(playerInfo.role)..".png"
  213. -- if playerInfo.role ~= ClubDefine.Job.Member and playerInfo.role and playerInfo.role ~= 0 then
  214. -- matchUI.Items.ImageView_flag_1:loadTexture(file)
  215. -- else
  216. matchUI.Items.ImageView_flag_1:setVisible(false)
  217. -- end
  218. --昵称
  219. -- local name = getSubStringNickname(playerInfo.nickname, matchUI.Items.Text_name_1)
  220. local name = getSubStringNickname(playerInfo.nickname)
  221. matchUI.Items.Text_name_1:setText(name or "未知昵称")
  222. matchUI.Items.Text_item_saidian_1:setText(tostring(playerInfo.contribute))
  223. matchUI.Items.Text_item_jishufen_1:setText(tostring(playerInfo.total_score))
  224. matchUI.Items.Text_item_shenglv_1:setText(tostring(playerInfo.play_win_number))
  225. matchUI.Items.Text_item_biaozhunfen_1:setText(tostring(playerInfo.tianscore))
  226. matchUI.Items.Text_item_jiangli_1:setText(tostring(playerInfo.des))
  227. self.ui.Items.ScrollView_1:addChild(matchUI)
  228. end
  229. function TiantiRank:registerButton()
  230. self.ui.Items.Button_close:registerClick(handler(self,self.onClose))
  231. -- self.ui.Items.Layout_:registerClick(handler(self,self.onClose))
  232. self.ui.Items.Text_wei_baoming:registerClick(handler(self,self.onBaoming))
  233. end
  234. function TiantiRank:onBaoming()
  235. local view = import("luaScript.Views.Tianti.TiantiBaoming"):new()
  236. view:setAnchorPoint(cc.p(0.5, 0.5))
  237. app:showWaitDialog(view)
  238. end
  239. function TiantiRank:onClose()
  240. playBtnCloseEffect()
  241. self:removeFromParent()
  242. end
  243. function TiantiRank:initBindEvent()
  244. -- self:bindEvent(app.club_php , GAME_EVENT.CLUB_ALL_PEOPLE_MATCH , handler(self , self.onUpdatePlayerListEvent))
  245. end
  246. return TiantiRank