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.

282 lines
8.0 KiB

  1. -- 战绩单元Layout
  2. local ClubDaYingJia = class("ClubDaYingJia",cc.UIView)
  3. --- ClubDaYingJia:ctor
  4. -- @param showType 1: 大赢家明细 2:局数明细
  5. -- @param data = {
  6. -- gid 俱乐部id
  7. -- suid 被查询人uid
  8. -- lastday 查询时间,大赢家明细使用
  9. -- searchDate 查询时间,局数明细使用
  10. -- }
  11. function ClubDaYingJia:ctor(showType, data)
  12. ClubDaYingJia.super.ctor(self)
  13. local ui = loadUI("res/ui/ui_club/ui_club_dayingjia_detail.ui")
  14. self.ui = ui;
  15. self.dayingjialist = nil
  16. self.showType = showType
  17. self.suid = data.suid
  18. self.lastday = data.lastday
  19. self.searchDate = data.searchDate
  20. self.gid = data.gid
  21. self:addChild(ui)
  22. end
  23. --初始化界面
  24. function ClubDaYingJia:onEnter()
  25. ClubDaYingJia.super.onEnter(self)
  26. self.ui.Items.Layout_0:setVisible(false)
  27. self.ui.Items.ScrollView:hideAllBar()
  28. self:initTitle()
  29. self.ui.Items.Button_Close:registerClick(handler(self,self.onClickClose))
  30. if self.showType == 1 then
  31. app.club_zhanji:requestDaYingJiaZhanJi(self.gid, self.suid, self.lastday) --填数据
  32. self:bindEvent(app, "onDaYingJiaZhanJiresponse", handler(self, self.initDaYingJiaView))
  33. self.ui.Items.Layout_player_count:setContentSize(cc.size(780, 105))
  34. else
  35. app.club_zhanji:getIdxlistByPlayerUid(self.gid, 3, self.searchDate, nil, self.suid) --填数据
  36. self:bindEvent(app.club_zhanji, "getZhanjiBriefResponse", handler(self, self.initJuShuDetailView))
  37. self.ui.Items.Layout_player_count:setContentSize(cc.size(880, 105))
  38. end
  39. --权限发生改变
  40. self:bindEvent(app.club_php , GAME_EVENT.CLUB_CHANGE_ROLE , handler(self , self.onChangeRole));
  41. end
  42. function ClubDaYingJia:initTitle()
  43. if self.showType == 1 then
  44. -- 大赢家
  45. self.ui.Items.ImageView_title:loadTexture("res/ui/zy_club/club_dayingjia_detail/zy_club_dayingjia_title.png")
  46. else
  47. -- 局数明细
  48. self.ui.Items.ImageView_title:loadTexture("res/ui/zy_club/club_dayingjia_detail/zy_club_jushu_title.png")
  49. end
  50. end
  51. -- 角色权限修改
  52. function ClubDaYingJia:onChangeRole()
  53. self:removeFromParent()
  54. end
  55. --- ClubDaYingJia:initDaYingJiaView 初始化大赢家详情
  56. function ClubDaYingJia:initDaYingJiaView()
  57. logD("ClubDaYingJia:initDaYingJiaView")
  58. local dayingjialist = app.club_zhanji.dayijingjiadetail.list
  59. if not dayingjialist or table.nums(dayingjialist) <= 0 then
  60. return
  61. end
  62. self:initZhanJiList(dayingjialist)
  63. end
  64. --- ClubDaYingJia:initJuShuDetailView 初始化局数明细
  65. function ClubDaYingJia:initJuShuDetailView()
  66. logD("ClubDaYingJia:initJuShuDetailView")
  67. local zhanjiList = app.club_zhanji:getZhanJiList(self.gid, 3, 1)
  68. if not zhanjiList or table.nums(zhanjiList) <= 0 then
  69. return
  70. end
  71. local function formatData( zhanjiList )
  72. local list = {}
  73. for k, zj in pairs(zhanjiList) do
  74. local tmp = {}
  75. local scoreList = {}
  76. for uid, v in pairs(zj.tscore or {}) do
  77. local nickname = "";
  78. local playerInfo = app.playerInfoManager:getPlayerInfo(uid);
  79. if playerInfo then
  80. local len = string.len(playerInfo.name)
  81. if len == 0 then
  82. nickname = "未知昵称"
  83. end
  84. nickname = getSubStringNickname(playerInfo.name)
  85. end
  86. local obj = {}
  87. obj.score = v
  88. obj.nickname = nickname
  89. obj.uid = uid
  90. table.insert(scoreList, obj)
  91. end
  92. tmp.roomid = zj.roomid
  93. tmp.ext = scoreList
  94. tmp.game_id = zj.gameid
  95. tmp.gamerule = zj.gext.gamerule
  96. tmp.time = zj.endtime
  97. tmp.gambid = 1
  98. table.insert(list, tmp)
  99. end
  100. table.sort( list, function (a, b)
  101. return a.time > b.time
  102. end)
  103. return list
  104. end
  105. local list = formatData(zhanjiList)
  106. self:initZhanJiList(list)
  107. end
  108. function ClubDaYingJia:initZhanJiList(zhanjiList)
  109. logD("ClubDaYingJia:initZhanJiList")
  110. self.ui.Items.Layout_0:setVisible(true)
  111. local uiScrollView = self.ui.Items.ScrollView;
  112. uiScrollView:hideAllBar();
  113. uiScrollView:removeAllChildren()
  114. uiScrollView:getInnerContainer():setAutoSize(true)
  115. for k, zhanji in pairs(zhanjiList) do
  116. local item = self:createZhanjiItem(zhanji)
  117. uiScrollView:addChild(item);
  118. end
  119. uiScrollView:jumpToTopOnSizeChanged()
  120. end
  121. function ClubDaYingJia:createZhanjiItem(itemData)
  122. local uiTemplateLayout = self.ui.Items.Layout_0
  123. local uiItemLayout = uiTemplateLayout:getCopied()
  124. uiItemLayout.Items = getUIItems(uiItemLayout)
  125. local scoreList = itemData.ext
  126. --游戏icon
  127. local gameID = tonumber(itemData.game_id)
  128. local gameRule = toNumber(itemData.gamerule)
  129. local gameConfig = getSubGameConfig(gameID)
  130. local gameName = getSubGameRuleName(gameID,gameRule)
  131. uiItemLayout.Items.ImageView_flag:setVisible(true)
  132. uiItemLayout.Items.ImageView_flag:loadTexture("res/ui/zy_dating/zhanji/zhanji_win_icon.png")
  133. uiItemLayout.Items.Layout_game_title_me:setVisible(true)
  134. uiItemLayout.Items.Text_game_me:setString(gameName)
  135. uiItemLayout.Items.Text_game_me_1:setString(gameName)
  136. local club = app.club_php.clubList[self.gid]
  137. if club.role == 3 or club.role == 2 then
  138. if itemData.gambid == 1 then
  139. uiItemLayout.Items.Layout_3:setVisible(false)
  140. else
  141. uiItemLayout.Items.Layout_3:setVisible(true)
  142. end
  143. else
  144. uiItemLayout.Items.Layout_3:setVisible(false)
  145. end
  146. if club and club.role~=1 and 3 ~= ClUB_ZHANJI_TYPE.Mine then
  147. if app.club_zhanji.zhanJiIdxStatus[itemData.gambid]==2 then --确认过
  148. uiItemLayout.Items.Button_Sure:setVisible(false)
  149. end
  150. else
  151. uiItemLayout.Items.Button_Sure:getParent():setVisible(false)
  152. end
  153. local function onClickSure()
  154. playBtnEffect()
  155. local club = app.club_php.clubList[self.gid]
  156. if club then
  157. if app.club_zhanji.zhanJiIdxStatus[itemData.gambid]==2 then --确认过
  158. uiItemLayout.Items.Button_Sure:setVisible(false)
  159. return
  160. end
  161. end
  162. app.club_zhanji:requestZhanjiSure(self.gid,itemData.gambid,function()
  163. if not tolua.isnull(uiItemLayout) then
  164. uiItemLayout.Items.Button_Sure:setVisible(false)
  165. end
  166. end)
  167. end
  168. uiItemLayout.Items.Button_Sure:registerClick(onClickSure)
  169. --时间
  170. local time = os.date("%Y-%m-%d %H:%M",itemData.time)
  171. uiItemLayout.Items.Text_time:setText(time)
  172. -- local club = app.club_php.clubList[self.gid]
  173. -- if club and club.role~=1 and self.zhanjiType ~= ClUB_ZHANJI_TYPE.Mine then
  174. -- if app.club_zhanji.zhanJiIdxStatus[self.roomInfo.pid]==2 then --确认过
  175. -- self.ui.Items.Button_Sure:setVisible(false)
  176. -- end
  177. -- else
  178. -- self.ui.Items.Button_Sure:getParent():setVisible(false)
  179. -- end
  180. --大赢家
  181. --[[local maxScore = nil;
  182. for uid, score in pairs(scoreList) do
  183. if not maxScore or maxScore < score then
  184. maxScore = score;```
  185. end
  186. end--]]
  187. --房号
  188. local roomInfo = itemData.roomid;
  189. uiItemLayout.Items.Text_roomid:setText("房号:"..roomInfo);
  190. --最终分数
  191. local scorUI = uiItemLayout.Items.Layout_player_count;
  192. --scorUI:getInnerContainer():setAutoSize(true);
  193. scorUI:removeAllChildren();
  194. local uiTemplate = self.ui.Items.Layout_player;
  195. local contentSize = scorUI:getContentSize();
  196. local scoreSize = table.nums(scoreList)
  197. for k,v in pairsByKeys(scoreList) do
  198. local uiItem = uiTemplate:getCopied()
  199. uiItem:setSize(cc.size(contentSize.width / scoreSize, contentSize.height))
  200. uiItem.Items = getUIItems(uiItem)
  201. --名字
  202. local name = getSubStringNickname(v.nickname)
  203. uiItem.Items.Text_player_name:setText(name)
  204. -- 大赢家明细,全都不除以10
  205. if gameConfig.isUseDivision10 and self.showType ~= 1 then
  206. v.score = v.score /10
  207. end
  208. --分数
  209. if v.score > 0 then
  210. v.score = "+"..tostring(v.score)
  211. uiItem.Items.Text_score:setFntFile("res/fonts/zhanji_win.fnt")
  212. else
  213. --绿色
  214. uiItem.Items.Text_score:setFntFile("res/fonts/zhanji_lose.fnt")
  215. end
  216. uiItem.Items.Text_score:setText(v.score)
  217. scorUI:addChild(uiItem);
  218. if k == table.nums(scoreList) then
  219. uiItem.Items.ImageView_1:setVisible(false)
  220. end
  221. if v.uid == tostring(self.suid) then
  222. local isWin = tonumber(v.score) > 0
  223. local path = isWin and "res/ui/zy_dating/zhanji/zhanji_win_icon.png" or "res/ui/zy_dating/zhanji/zhanji_lose_icon.png"
  224. uiItemLayout.Items.ImageView_flag:loadTexture(path)
  225. end
  226. end
  227. scorUI:requestDoLayout()
  228. scorUI:doLayout()
  229. return uiItemLayout
  230. end
  231. function ClubDaYingJia:onClickClose()
  232. playBtnCloseEffect()
  233. self:removeFromParent()
  234. end
  235. return ClubDaYingJia