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.

2379 lines
80 KiB

  1. -- 茶馆桌子界面Layout
  2. require("luaScript.SubGameFunctions.SubGameFunc_club")
  3. local ClubTable = class("ClubTable" , cc.UIView);
  4. local ClubDefine = require("luaScript.Protocol.Club.ClubDefine")
  5. function ClubTable:ctor(clubId)
  6. ClubTable.super.ctor(self)
  7. self:loadUI()
  8. self.clubId = clubId;
  9. app.club_php.clubID = clubId
  10. --单个茶馆数据
  11. self.clubInfo = app.club_php.clubList[clubId]
  12. -- 页码
  13. self.curPage = 1
  14. -- 所有桌子的节点
  15. self.allTableItem = {}
  16. self.first = true
  17. self.inView = ClubDefine.View.BAOMING
  18. if self.clubInfo.isArena ~= ClubDefine.MATCH_SWITCH.PEOPLE_CEST_OPEN then
  19. -- 先隐藏CEST相关资源
  20. self.ui.Items.Layout_Cest:setVisible(false);
  21. self.ui.Items.Layout_CestInfo:setVisible(false);
  22. self.ui.Items.Layout_cest_bottom:setVisible(false);
  23. self.ui.Items.Layout_bisai_status:setVisible(false);
  24. end
  25. end
  26. function ClubTable:loadUI()
  27. local ui = loadUI("res/ui/ui_club/ui_club_table.ui")
  28. self.ui = ui
  29. self:addChild(ui)
  30. self.srcTableScrollowSize = self.ui.Items.ScrollView:getContentSize()
  31. end
  32. function ClubTable:onEnter()
  33. ClubTable.super.onEnter(self)
  34. setInClubRoom(true)
  35. --适配
  36. --autoAdaptWidth(self.ui.Items.ScrollView)
  37. autoAdaptWidth(self.ui.Items.ImageView_down_bg)
  38. autoAdaptHeight(self.ui.Items.Layout_LeftGame)
  39. autoAdaptHeight(self.ui.Items.ImageView_LeftGame)
  40. autoAdaptHeight(self.ui.Items.ScrollView_GameList)
  41. --设置默认界面(第一次进入需要请求包间数据,所以类型为新增包间)
  42. self:setDefault()
  43. --设置自己的游戏状态
  44. setMyGameStatus(false)
  45. --按钮注册事件
  46. self:registerButton()
  47. --监听事件
  48. self:tableBindEvent()
  49. --更新桌子
  50. self:updateTableList({clubId = self.clubId})
  51. --更换桌布
  52. if self.clubInfo.club_bgprop and table.nums(self.clubInfo.club_bgprop) > 0 then
  53. self:setTableImg(self.clubInfo.club_bgprop.prop_id)
  54. end
  55. self:requestPlayerList()
  56. --请求茶馆桌子数据
  57. app.club_php:requestClubHome(self.clubInfo.clubId,gameId,ruleId)
  58. self:initBoradcastView()
  59. -- todo lwqcest
  60. -- self:initClubCest()
  61. end
  62. function ClubTable:initPlayerInfo()
  63. --读取配置
  64. self.clubData = self:loadGameInfoFromFile()
  65. local gameId = 0
  66. local ruleId = 0
  67. if self.clubInfo.mode == ClubDefine.BaoJianType.ManyRooms then
  68. if self.clubData and self.clubData[tostring(self.clubId)] then
  69. gameId = self.clubData[tostring(self.clubId)].gameId
  70. ruleId = self.clubData[tostring(self.clubId)].ruleId
  71. else
  72. if self.clubData and not self.clubData[tostring(self.clubId)] then
  73. self.clubData[tostring(self.clubId)] = {}
  74. else
  75. self.clubData = {}
  76. end
  77. end
  78. elseif self.clubInfo.mode == ClubDefine.BaoJianType.Normal then
  79. self.clubData = {}
  80. gameId = self.clubInfo.settings.gameId
  81. ruleId = self.clubInfo.settings.baoJianId
  82. end
  83. --保存到内存
  84. app.club_php:setSelectGameId(gameId)
  85. app.club_php:setSelectBaoJianId(ruleId)
  86. -- 茶馆名
  87. local nickname = getShortNameByLength(self.clubInfo.clubName,5)
  88. self.ui.Items.Text_name:setText(nickname)
  89. --club id
  90. local idStr = string.format("ID:%d",self.clubInfo.clubId)
  91. self.ui.Items.Text_id:setText(idStr)
  92. -- 根据条件隐藏茶馆id
  93. local cliext = self.clubInfo.groupext and self.clubInfo.groupext.cliext
  94. if not cliext or not cliext.is_hideGid or (cliext and cliext.is_hideGid == 1) then
  95. if tonumber(self.clubInfo.role) ~= ClubDefine.Job.Manager and tonumber(self.clubInfo.role) ~= ClubDefine.Job.Creator then
  96. self.ui.Items.Text_id:setVisible(false)
  97. end
  98. end
  99. -- 房卡数量
  100. self.ui.Items.Text_FangKa:bind(app.user.loginInfo, "curCardNum", function()
  101. self.ui.Items.Text_FangKa:setText(tostring(app.user.loginInfo.curCardNum))
  102. end)
  103. end
  104. -- 从本地读取上一次游戏选择的信息(gameId,ruleId)
  105. function ClubTable:loadGameInfoFromFile()
  106. local locString = loadStringFromFile("clubData.json")
  107. if not locString or locString == "" then
  108. return nil
  109. end
  110. local locData = json.decode(locString)
  111. if locData then
  112. return locData
  113. end
  114. return nil
  115. end
  116. -- 将游戏选择(gameId,ruleId)信息写入到本地
  117. function ClubTable:saveGameInfoToFile(gameId,ruleId)
  118. if not self.clubData then
  119. self.clubData = {}
  120. end
  121. self.clubData[tostring(self.clubId)] = {
  122. gameId = gameId,
  123. ruleId = ruleId,
  124. }
  125. if self.clubData then
  126. local locString = json.encode(self.clubData)
  127. saveStringToFile(locString,"clubData.json")
  128. end
  129. end
  130. --按钮注册点击事件
  131. function ClubTable:registerButton()
  132. --关闭
  133. self.ui.Items.Button_close:registerClick(handler(self , self.onClose))
  134. --战绩
  135. self.ui.Items.Button_zhanji:registerClick(handler(self , self.onZhanjiClub))
  136. --申请消息
  137. self.ui.Items.Button_apply_msg:registerClick(handler(self , self.onApplyMsg))
  138. --设置
  139. self.ui.Items.Button_set:registerClick(handler(self , self.onSet))
  140. --比赛场设置
  141. self.ui.Items.Button_match_set:registerClick(handler(self, self.onClickMatchSet))
  142. --成员列表
  143. self.ui.Items.Button_player_list:registerClick(handler(self , self.onPlayerList))
  144. --合伙人
  145. self.ui.Items.Button_hehuoren:registerClick(handler(self , self.onBtnHeHuoRenClicked))
  146. --快速加入
  147. self.ui.Items.Button_quick_start:registerClick(handler(self , self.onQuickStart))
  148. self.ui.Items.Button_quick:registerClick(handler(self , self.onQuickStart)) --cest
  149. --修改玩法
  150. self.ui.Items.Button_change_rule:registerClick(handler(self , self.onChangeRule))
  151. --退出茶馆
  152. self.ui.Items.Button_exit:registerClick(handler(self , self.onExitClub))
  153. --点击层
  154. self.ui.Items.Layout_touch:registerClick(handler(self , self.onTouch))
  155. self.ui.Items.Layout_baojian_touch:registerClick(handler(self , self.onTouch))
  156. --进入房间
  157. self.ui.Items.Button_enter_table:registerClick(handler(self , self.onBackRoom))
  158. self.ui.Items.Button_enter:registerClick(handler(self , self.onBackRoom))
  159. --刷新
  160. self.ui.Items.Button_refresh:registerClick(handler(self , self.onRefresh))
  161. -- 比赛开关
  162. self.ui.Items.Layout_match_set:setEnabled(false)
  163. -- 比赛信息
  164. self.ui.Items.Button_match_info:registerClick(handler(self, self.onClickMatchInfo))
  165. --更多游戏
  166. self.ui.Items.Button_moreGame:registerClick(handler(self, self.onClickMoreGame))
  167. --邀请
  168. self.ui.Items.Button_invite:registerClick(handler(self, self.onBtnInviteClicked))
  169. if isReviewVersion() then
  170. self.ui.Items.Layout_invite:setVisible(false)
  171. end
  172. -- 活动按钮
  173. --self.ui.Items.Button_ActivityNew:registerClick(handler(self, self.onBtnActivityClicked))
  174. --榜分说明
  175. if self.clubInfo.role == ClubDefine.Job.Creator then
  176. --亲友圈等级
  177. self.ui.Items.Button_level:registerClick(handler(self, self.onClickClubLevel))
  178. end
  179. self.ui.Items.Button_wenhao:registerClick(handler(self, self.onClickWenHao))
  180. self.ui.Items.ImageView_chognbangfen:registerClick(handler(self, self.onClickWenHao))
  181. self.ui.Items.Layout_right_menu:setTouchEnabled(true);
  182. self.ui.Items.ScrollView:addEventListener(handler(self,self.onScrollViewEvent))
  183. --合盟
  184. self.ui.Items.Button_Union:registerClick(handler(self,self.onClickUnion))
  185. self.ui.Items.Button_Union:setTouchEnabled(self.clubInfo.role == ClubDefine.Job.Creator)
  186. --查看牌桌
  187. self.ui.Items.Button_LookHide:registerClick(handler(self,self.onLookHide))
  188. end
  189. function ClubTable:onLookHide()
  190. playBtnEffect()
  191. self._bShowAllRoom = true
  192. if self.clubInfo.groupext then
  193. self.clubInfo.groupext.is_playerpri = 0
  194. end
  195. local gameId = app.club_php:getSelectGameId()
  196. self:updateTableView(gameId)
  197. self.ui.Items.Layout_daojishi:setVisible(true)
  198. self.ui.Items.Button_LookHide:setVisible(false)
  199. self.ui.Items.HtmlCtrl_time:stopAllActions()
  200. local limlit = 60
  201. self.ui.Items.HtmlCtrl_time:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.CallFunc:create(function()
  202. limlit = limlit - 1
  203. local str = '<font size="18" color="#fff1cf">剩余时间</font><font size="18" color="#ff9955">'..tostring(limlit)..'</font><font size="18" color="#fff1cf">秒</font>'
  204. self.ui.Items.HtmlCtrl_time:setText(str)
  205. if limlit < 0 then
  206. self.ui.Items.Layout_daojishi:setVisible(false)
  207. self.ui.Items.Button_LookHide:setVisible(true)
  208. self.ui.Items.HtmlCtrl_time:stopAllActions()
  209. if self.clubInfo.groupext then
  210. self.clubInfo.groupext.is_playerpri = 1
  211. end
  212. self._bShowAllRoom = false
  213. local gameId = app.club_php:getSelectGameId()
  214. self:updateTableView(gameId)
  215. else
  216. self.ui.Items.HtmlCtrl_time:setText(str)
  217. end
  218. end),cc.DelayTime:create(1))))
  219. end
  220. function ClubTable:onClickUnion()
  221. playBtnEffect()
  222. if self.clubInfo.groupext.master_union == 2 then
  223. local view = import("luaScript.Views.Club.ClubUnionMode.ClubUnionMaster"):new(self.clubInfo.clubId)
  224. view:setAnchorPoint(cc.p(0.5, 0.5))
  225. app:showWaitDialog(view)
  226. elseif self.clubInfo.groupext.slave_union == 2 then
  227. local view = import("luaScript.Views.Club.ClubUnionMode.ClubUnionSlave"):new(self.clubInfo.clubId)
  228. view:setAnchorPoint(cc.p(0.5, 0.5))
  229. app:showWaitDialog(view,0)
  230. else
  231. showTooltip("盟主标识不存在")
  232. end
  233. --保存引导一次
  234. if self.ui.Items.Layout_union_guide:isVisible() then
  235. --阅读引导
  236. local privateSet = {}
  237. --客户端定义字段
  238. privateSet.readUnionGuide = 1
  239. local parm = {
  240. cliext = json.encode(privateSet),
  241. type = 0,
  242. }
  243. app.club_php:requestSetClubNew(self.clubInfo.clubId,parm)
  244. end
  245. self.ui.Items.Layout_union_guide:setVisible(false)
  246. end
  247. function ClubTable:onClickMoreGame()
  248. playBtnEffect()
  249. local view = import("luaScript.Views.Club.ClubMoreGame"):new(self.clubInfo.clubId)
  250. view:setAnchorPoint(cc.p(0.5, 0.5))
  251. app:showWaitDialog(view,0)
  252. end
  253. function ClubTable:onClickWenHao()
  254. playBtnEffect()
  255. if self.clubInfo.unionType ~= 2 and app.club_php:getIsSlaveUnion(self.clubInfo.clubId) then
  256. showTooltip("请先加入一个联盟!")
  257. return
  258. end
  259. local view = import("luaScript.Views.Club.Match.ClubMatchChongBangFen"):new(self.clubInfo.clubId)
  260. view:setAnchorPoint(cc.p(0.5, 0.5))
  261. app:showWaitDialog(view,150)
  262. end
  263. function ClubTable:onClickClubLevel()
  264. playBtnEffect()
  265. local view = import("luaScript.Views.Club.Match.ClubMatchLevel"):new(self.clubInfo.clubId)
  266. view:setAnchorPoint(cc.p(0.5, 0.5))
  267. app:showWaitDialog(view,150)
  268. end
  269. function ClubTable:onClickMatchSet()
  270. playBtnEffect()
  271. local view = import("luaScript.Views.Club.Match.ClubBiSaiSet"):new(self.clubInfo.clubId)
  272. view:setAnchorPoint(cc.p(0.5, 0.5))
  273. app:showWaitDialog(view)
  274. end
  275. function ClubTable:onClickMatchInfo()
  276. playBtnEffect()
  277. local player = app.club_php:getPlayer(self.clubInfo.clubId,app.user.loginInfo.uid)
  278. local memberInfo = self.clubInfo.memberInfo
  279. if memberInfo and memberInfo.status == 0 then
  280. showTooltip("黑名单无法查看!")
  281. return
  282. end
  283. if self.clubInfo.unionType ~= 2 and app.club_php:getIsSlaveUnion(self.clubInfo.clubId) then
  284. showTooltip("请先加入一个联盟!")
  285. return
  286. end
  287. local className = ""
  288. --从普通模式切换到比赛模式,把内存数据清掉,应该是哪里测试出问题,才这么做的。
  289. if player and player.viewType == ClubDefine.PlayListType.NORMAL_MEMBER then
  290. self.clubInfo.players = {}
  291. end
  292. -- todo lwqcest
  293. -- if self.clubInfo.isArena >= ClubDefine.MATCH_SWITCH.PEOPLE_MATCH_SEVER_CLOSE then
  294. if self.clubInfo.isArena >= ClubDefine.MATCH_SWITCH.PEOPLE_MATCH_SEVER_CLOSE
  295. and self.clubInfo.isArena <= ClubDefine.MATCH_SWITCH.PEOPLE_MATCH_OPEN then
  296. className = "luaScript.Views.Club.Match.ClubMatchMain"
  297. elseif self.clubInfo.isArena <= ClubDefine.MATCH_SWITCH.PEOPLE_CEST_OPEN then
  298. className = "luaScript.Views.Club.Cest.ClubCestMain"
  299. else
  300. if self.clubInfo.role == ClubDefine.Job.Manager or self.clubInfo.role == ClubDefine.Job.Creator
  301. or self.clubInfo.role == ClubDefine.Job.LevelOneCopartner or self.clubInfo.role == ClubDefine.Job.LevelTwoCopartner
  302. or self.clubInfo.role == ClubDefine.Job.LevelThreeCopartner then
  303. className = "luaScript.Views.Club.ClubPlayerMatch"
  304. else
  305. className = "luaScript.Views.Club.ClubPlayerMatchInfo"
  306. end
  307. end
  308. local view = import(className):new(self.clubInfo.clubId)
  309. view:setAnchorPoint(cc.p(0.5, 0.5))
  310. app:showWaitDialog(view)
  311. end
  312. function ClubTable:onClickButtonAddDiamand()
  313. playBtnEffect()
  314. local view = import("luaScript.Views.Main.RechargeView"):new()
  315. view:setAnchorPoint(cc.p(0.5, 0.5))
  316. app:showWaitDialog(view)
  317. end
  318. --监听事件
  319. function ClubTable:tableBindEvent()
  320. --桌子数据获取成功
  321. self:bindEvent(app.club_php , GAME_EVENT.CLUB_TABLE , handler(self , self.updateTableList))
  322. --房间刷新
  323. self:bindEvent(app.club_php , GAME_EVENT.CLUB_ROOM_LIST_UPDATE , handler(self , self.updateTableView))
  324. --解散茶馆
  325. self:bindEvent(app.club_php , GAME_EVENT.CLUB_JIE_SAN , handler(self , self.onClubJieSanEvent))
  326. self:bindEvent(app.club_php, GAME_EVENT.CLUB_LIST, handler(self, self.updateTableList))
  327. --绑定请求成员列表成功回调事件
  328. self:bindEvent(app.club_php , GAME_EVENT.CLUB_PLAYER_LIST , handler(self , self.onUpdatePlayerListEvent))
  329. --茶馆数据变更
  330. self:bindEvent(app.club_php , GAME_EVENT.CLUB_CHANGE_PUSH , handler(self , self.onClubChangeEvent))
  331. self:bindEvent(app.club_php , GAME_EVENT.CLUB_BACK_ROOM , handler(self , self.onBackRoomEvent))
  332. --普通消息获取成功
  333. self:bindEvent(app.club_php , GAME_EVENT.CLUB_MESSAGE , handler(self , self.onClubHintsUpdateEvent))
  334. --获取官方活动
  335. self:bindEvent(app.club_php , GAME_EVENT.CLUB_ACTIVITY_LIST , handler(self , self.onGetClubOfficialActivitySucc));
  336. --收到更换背景消息
  337. self:bindEvent(app.club_php, GAME_EVENT.CLUB_CHANGE_BG , handler(self , self.onClubTableChangeBg))
  338. --绑定回调
  339. self:bindEvent(app.club_php , GAME_EVENT.CLUB_SET , handler(self , self.updateSetting));
  340. --调整红花
  341. self:bindEvent(app.club_php , GAME_EVENT.CLUB_UPDATE_RED_FLOWER , handler(self , self.onUpdateHongHua));
  342. --取消合伙人消息弹窗
  343. self:bindEvent(app.club_php , GAME_EVENT.CLUB_CANCEL_COPARTNER_NOTICE , handler(self , self.popClubWindow));
  344. --取消合伙人消息弹窗提示
  345. self:bindEvent(app.club_php , GAME_EVENT.CLUB_CANCEL_COPARTNER_TIP , handler(self , self.onClubHeHuoRenCancelTip));
  346. --GPS距离进房间监听
  347. self:bindEvent(app.club, GAME_EVENT.CLUB_GPS_DISTANCE , handler(self , self.onClubGpsDistanceCheck));
  348. --切换包间
  349. self:bindEvent(app.club_php , GAME_EVENT.CLUB_CHANGE_BAO_JIAN , handler(self , self.onClubChangeBaoJianEvent))
  350. --请求茶馆玩法回调
  351. self.ui:bindEvent(app.club_php , GAME_EVENT.CLUB_CHANGE_RULE_PUSH , handler(self , self.updateTopBaoJianInfo))
  352. self.ui:bindEvent(app.club_php , GAME_EVENT.CLUB_UPDATE_TABLE , handler(self , self.updateTable))
  353. --监听从后台进入游戏事件
  354. self:bindEvent(app, "applicationWillEnterForeground", handler(self, self.onApplicationWillEnterForeground))
  355. self:bindEvent(app, "applicationDidEnterBackground", handler(self, self.onApplicationDidEnterBackground))
  356. --联盟消息获取成功
  357. self:bindEvent(app.club_php , GAME_EVENT.CLUB_UNION_HITS , handler(self , self.onClubUnionHintsUpdateEvent))
  358. end
  359. function ClubTable:onClubTableChangeBg()
  360. if self.clubInfo.club_bgprop then
  361. if table.nums(self.clubInfo.club_bgprop) > 0 then
  362. self:setTableImg(tonumber(self.clubInfo.club_bgprop.prop_id))
  363. else
  364. self:setTableImg()
  365. end
  366. end
  367. end
  368. function ClubTable:onClubJieSanEvent(event)
  369. if event.clubId == self.clubInfo.clubId then
  370. self:onClose()
  371. end
  372. end
  373. function ClubTable:updateLeftGame(scrollState)
  374. self.ui.Items.ScrollView_GameList:removeAllChildren()
  375. self.radioManager = import("luaScript.Tools.RadioManager"):new()
  376. self.radioManager:setColorSwitch(true)
  377. self.radioManager:setSelectColor(cc.c4b(255,255,255,255))
  378. self.radioManager:setNormalColor(cc.c4b(108,130,196,255))
  379. local function addItem(gameName,key)
  380. local gameItem = self.ui.Items.CheckBox_Item:getCopied()
  381. gameItem:setVisible(true)
  382. gameItem.Items = getUIItems(gameItem)
  383. gameItem.Items.Text_gameName:setText(tostring(gameName))
  384. self.radioManager:addItem(gameItem, key)
  385. self.ui.Items.ScrollView_GameList:addChild(gameItem)
  386. end
  387. addItem("全部牌桌",0)
  388. --无激活游戏
  389. if type(self.clubInfo.activeGames) == "table" then
  390. for k,gameId in ipairs(self.clubInfo.activeGames) do
  391. local gameRule = 0
  392. local id = gameId
  393. local gameConfig = getSubGameConfig(tonumber(id))
  394. if gameConfig and gameConfig.bSingleGame then
  395. log("过滤服务器多余的gameID,如黄十八碰胡等")
  396. else
  397. if gameId > 10000 then
  398. gameRule = math.floor(gameId%10000)
  399. id = math.floor(gameId/10000)
  400. end
  401. local gameConfig = getSubGameConfig(tonumber(id))
  402. if gameConfig then
  403. if gameConfig.bSingleGame then
  404. local gameName = getSubGameRuleName(id,gameRule)
  405. if gameName and gameName~= "" then
  406. addItem(gameName,gameId)
  407. end
  408. else
  409. addItem(gameConfig.gameName,gameId)
  410. end
  411. end
  412. end
  413. end
  414. end
  415. self.radioManager:setCallback(handler(self, self.onClickItem))
  416. local default = app.club_php:getSelectGameId()
  417. self.radioManager:setDefault(default)
  418. self.ui.Items.ScrollView_GameList:requestDoLayout()
  419. self.ui.Items.ScrollView_GameList:doLayout()
  420. if scrollState == 2 then
  421. runDelayWithTime(function ()
  422. if not tolua.isnull(self.ui.Items.ScrollView_GameList) then
  423. self.ui.Items.ScrollView_GameList:jumpToBottom()
  424. end
  425. end,0.05)
  426. elseif scrollState == 0 then
  427. logD("do nothing")
  428. else
  429. runDelayWithTime(function ()
  430. if not tolua.isnull(self.ui.Items.ScrollView_GameList) then
  431. self.ui.Items.ScrollView_GameList:jumpToTop()
  432. end
  433. end,0.05)
  434. end
  435. end
  436. function ClubTable:onClickItem(value,node)
  437. self.curSelectBaoJian = nil
  438. if self.first then
  439. self.first = false
  440. return
  441. end
  442. self.isUpdateAll = true
  443. if app.club_php:getSelectGameId() ~= value then
  444. self.ui.Items.ScrollView_BaoJian:jumpToLeft()
  445. end
  446. app.club_php:setSelectGameId(value)
  447. self.ui.Items.Layout_no_set:setVisible(false)
  448. self.ui.Items.Text_no_table:setVisible(false)
  449. self.ui.Items.ScrollView:removeAllChildren()
  450. self.ui.Items.Layout_BaoJian:setVisible(false)
  451. self.curPage = 1
  452. self.ui.Items.Button_quick_start:setVisible(false)
  453. if value == 0 then
  454. self:saveGameInfoToFile(value,0)
  455. if self.clubInfo.mode == ClubDefine.BaoJianType.ManyRooms then
  456. self.ui.Items.Layout_btn_change_rule:setVisible(false)
  457. end
  458. app.club_php:setChangeTable(true)
  459. app.club_php:setSelectBaoJianId(0)
  460. app.club_php:requestRoomList(self.clubInfo.clubId,0,0,self.curPage,true)
  461. else
  462. self:updateChangeRuleBtn()
  463. self:updateBaoJianList()
  464. local isHaveUse = false
  465. for k,v in pairs(self.clubInfo.baoJians) do
  466. if tonumber(v.gameId) == value then
  467. if tonumber(v.is_use) == 1 then
  468. isHaveUse = true
  469. end
  470. end
  471. end
  472. if not isHaveUse then
  473. self:updateTableView(value)
  474. end
  475. end
  476. end
  477. function ClubTable:updateBaoJianList()
  478. local gameId = self.radioManager:getResult()
  479. self.ui.Items.ScrollView_BaoJian:removeAllChildren()
  480. local baojians = {}
  481. for k,v in pairs(self.clubInfo.baoJians) do
  482. if tonumber(v.gameId) == gameId then
  483. baojians[k] = v
  484. end
  485. end
  486. if baojians then
  487. local radioManager = import("luaScript.Tools.RadioManager"):new()
  488. radioManager:setColorSwitch(false)
  489. local function addItem(state,baojian,index)
  490. local baoJianItem = self.ui.Items.Layout_BaoJian_Item:getCopied()
  491. baoJianItem:setVisible(true)
  492. baoJianItem.Items = getUIItems(baoJianItem)
  493. baoJianItem.Items.Layout_normal:setVisible(false)
  494. baoJianItem.Items.Layout_all:setVisible(false)
  495. baoJianItem.state = state
  496. baoJianItem.baojianId = baojian and toNumber(baojian.baoJianId)
  497. baoJianItem.index = index
  498. if state == 0 then
  499. baoJianItem.Items.Layout_all:setVisible(true)
  500. baoJianItem.Items.Text_baojianinfo:setTextColor(cc.c4b(121,146,180,255))
  501. self.curSelectBaoJian = baoJianItem
  502. radioManager:addItem(baoJianItem.Items.CheckBox_BaoJian_Item,0)
  503. elseif state == 1 then--正常状态normal
  504. local jushu = baojian.gameNum
  505. local name = ""
  506. if string.len(baojian.title) > 0 then
  507. name = baojian.title
  508. else
  509. name = "未设包间名"
  510. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  511. name = "未设赛事名"
  512. end
  513. end
  514. baoJianItem.Items.Layout_normal:setVisible(true)
  515. baoJianItem.Items.HtmlCtrl:setText('<font size="20" color="7992b4">' .. tostring(name) .. '</font><font size="18" color="7992b4">' .. tostring("("..tostring(jushu).."局)") .. '</font>');
  516. baoJianItem.Items.Layout_normal:registerClick(function ()
  517. self.isTouchInfo = true
  518. local gameId = baojian.realGameId
  519. local view = import("luaScript.Views.Club.ClubBaoJianInfo"):new(self.clubInfo.clubId,gameId,baojian.gameNum,
  520. baojian.strGameRule,baojian.arena,baojian.title)
  521. view:setAnchorPoint(cc.p(0.5, 0.5))
  522. app:showWaitDialog(view)
  523. end)
  524. baoJianItem.Items.Layout_normal:setEnabled(false)
  525. radioManager:addItem(baoJianItem.Items.CheckBox_BaoJian_Item,baoJianItem.baojianId)
  526. end
  527. self.ui.Items.ScrollView_BaoJian:addChild(baoJianItem)
  528. end
  529. local index = 1
  530. for ruleid,v in pairsByKeys(baojians) do
  531. if tonumber(v.is_use) == 1 then
  532. local gameRule = json.decode(v.strGameRule)
  533. if index == 1 then
  534. --全部
  535. addItem(0,v,1)
  536. end
  537. addItem(1,v,index)
  538. index = index + 1
  539. end
  540. end
  541. radioManager:setCallback(handler(self, self.onClickBaoJian))
  542. local default = app.club_php:getSelectBaoJianId()
  543. radioManager:setDefault(default)
  544. local gameId = self.radioManager:getResult()
  545. self:saveGameInfoToFile(gameId,value)
  546. end
  547. end
  548. function ClubTable:onClickBaoJian(value,node)
  549. if self.isTouchInfo then
  550. self.isTouchInfo = false
  551. return
  552. end
  553. self.isUpdateAll = true
  554. local gameId = self.radioManager:getResult()
  555. self:saveGameInfoToFile(gameId,value)
  556. app.club_php:setChangeTable(true)
  557. app.club_php:setSelectBaoJianId(value)
  558. self.curPage = 1
  559. app.club_php:requestRoomList(self.clubInfo.clubId,gameId,value,self.curPage,true)
  560. if self.curSelectBaoJian and self.curSelectBaoJian.state ~= 0 then
  561. local baoJian = app.club_php:getBaoJian(self.clubInfo.clubId,self.curSelectBaoJian.baojianId)
  562. local jushu = baoJian.gameNum
  563. local name = baoJian.title
  564. if not baoJian.title or baoJian.title == "" then
  565. name = "未设包间名"
  566. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  567. name = "未设赛事名"
  568. end
  569. end
  570. self.curSelectBaoJian.Items.Layout_normal:setVisible(false)
  571. self.curSelectBaoJian.Items.Layout_all:setVisible(false)
  572. self.curSelectBaoJian.Items.Layout_normal:setVisible(true)
  573. self.curSelectBaoJian.Items.Layout_normal:setEnabled(false)
  574. self.curSelectBaoJian.Items.HtmlCtrl:setText('<font size="20" color="7992b4">' .. tostring(name) .. '</font><font size="18" color="7992b4">' .. tostring("("..tostring(jushu).."局)") .. '</font>');
  575. elseif self.curSelectBaoJian and self.curSelectBaoJian.state == 0 then
  576. self.curSelectBaoJian.Items.Text_baojianinfo:setTextColor(cc.c4b(121,146,180,255))
  577. end
  578. if node:getParent().state ~= 0 then
  579. local baoJian = app.club_php:getBaoJian(self.clubInfo.clubId,node:getParent().baojianId)
  580. local jushu = baoJian.gameNum
  581. local name = ""
  582. if string.len(baoJian.title) > 0 then
  583. name = baoJian.title
  584. else
  585. name = "未设包间名"
  586. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  587. name = "未设赛事名"
  588. end
  589. end
  590. node:getParent().Items.Layout_normal:setVisible(false)
  591. node:getParent().Items.Layout_all:setVisible(false)
  592. node:getParent().Items.Layout_normal:setVisible(true)
  593. node:getParent().Items.HtmlCtrl:setText('<font size="20" color="ffffff">' .. tostring(name) .. '</font><font size="18" color="ffffff">' .. tostring("("..tostring(jushu).."局)") .. '</font>');
  594. node:getParent().Items.Layout_normal:setEnabled(true)
  595. elseif node:getParent().state == 0 then
  596. node:getParent().Items.Text_baojianinfo:setTextColor(cc.c4b(255,255,255,255))
  597. end
  598. self.curSelectBaoJian = node:getParent()
  599. end
  600. --修改玩法
  601. function ClubTable:onChangeRule()
  602. playBtnEffect();
  603. if self.clubInfo.mode ~= ClubDefine.BaoJianType.ManyRooms then
  604. self:onClickBaojianNormal()
  605. else
  606. if self.tableIdx then
  607. --有桌子下标,表示当前在房间内游戏,返回时需要退出房间
  608. showTooltip("正在游戏中,禁止修改玩法")
  609. return
  610. end
  611. local gameId = self.radioManager:getResult()
  612. local gamerule = nil
  613. local index = 1
  614. local baojianId = nil
  615. if toNumber(gameId) > 10000 then
  616. gamerule = toNumber(gameId)%10000
  617. --gameId = math.floor(toNumber(gameId)/10000)
  618. else
  619. if self.curSelectBaoJian and self.curSelectBaoJian.state ~= 0 then
  620. local baojian = app.club_php:getBaoJian(self.clubInfo.clubId,self.curSelectBaoJian.baojianId)
  621. if baojian then
  622. gamerule = json.decode(baojian.strGameRule).gamerule
  623. end
  624. end
  625. end
  626. if self.curSelectBaoJian and self.curSelectBaoJian.index then
  627. if self.curSelectBaoJian.index then
  628. index = self.curSelectBaoJian.index
  629. end
  630. if self.curSelectBaoJian.baojianId then
  631. baojianId = self.curSelectBaoJian.baojianId
  632. end
  633. end
  634. local view = import("luaScript.Views.Club.ClubChangeRule"):new(self.clubInfo.clubId,gameId,gamerule,baojianId,index)
  635. view:setAnchorPoint(cc.p(0.5, 0.5))
  636. app:showWaitDialog(view)
  637. end
  638. end
  639. function ClubTable:onClubHintsUpdateEvent()
  640. self.ui.Items.ImageView_dian:setVisible(self.clubInfo.isHints)
  641. end
  642. --设置默认界面
  643. function ClubTable:setDefault()
  644. --根据平台修改提示:当前茶馆还未设置任何游戏哦!
  645. self.ui.Items.Text_1:setString(app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_NOT_GAME or PLN.CLUB_NOT_GAME)
  646. self.ui.Items.Button_enter_table:setVisible(false)
  647. self.ui.Items.Button_quick_start:setVisible(false)
  648. --右边按钮集
  649. self:setRightMenuVisible(false);
  650. --默认不显示人物及提示
  651. self.ui.Items.Layout_no_set:setVisible(false)
  652. self.ui.Items.Text_no_table:setVisible(false)
  653. --点击层
  654. self.ui.Items.Layout_touch:setVisible(false);
  655. self.ui.Items.Layout_baojian_touch:setVisible(false);
  656. --默认不显示红点提示
  657. self.ui.Items.ImageView_dian:setVisible(false)
  658. --包间
  659. self.ui.Items.Layout_BaoJian:setVisible(false)
  660. self.ui.Items.CheckBox_BaoJian_Item:setVisible(false)
  661. --左边游戏集合
  662. self.ui.Items.CheckBox_Item:setVisible(false)
  663. self.ui.Items.ScrollView_GameList:hideAllBar()
  664. self.ui.Items.ScrollView_GameList:getInnerContainer():setAutoSize(true)
  665. self.ui.Items.ScrollView_BaoJian:hideAllBar()
  666. self.ui.Items.ScrollView_BaoJian:getInnerContainer():setAutoSize(true)
  667. --合盟
  668. self.ui.Items.Layout_union_guide:setVisible(false)
  669. self.ui.Items.ImageView_union_dian:setVisible(false)
  670. --隐藏桌数
  671. self.ui.Items.Layout_look_table:setVisible(false)
  672. -- 隐藏海选赛的快速开始layout 和 返回桌子
  673. self.ui.Items.Layout_btn_quick:setVisible(false)
  674. self.ui.Items.Button_enter:setVisible(false)
  675. end
  676. --设置亲友圈背景
  677. function ClubTable:setTableImg(tableImgIndex)
  678. if tableImgIndex and tonumber(tableImgIndex) >= 0 then
  679. self.ui.Items.ImageView:loadTexture("res/ui/zy_club/club_common/club_common_bg_"..tableImgIndex..".jpg");
  680. else
  681. self.ui.Items.ImageView:loadTexture("res/ui/zy_club/club_common/club_common_bg.jpg");
  682. end
  683. end
  684. function ClubTable:onScrollViewEvent(node,event)
  685. if self.clubInfo and self.clubInfo.mode ~= ClubDefine.BaoJianType.Normal then
  686. if event == cc.ScrollviewEventType.bounceRightEnd and not self.isUpdateing and self.isCanRequest and self.clubInfo
  687. and self.clubInfo.pageNum and table.nums(self.clubInfo.rooms) >= self.clubInfo.pageNum then
  688. local gameId = app.club_php:getSelectGameId()
  689. local maxPlayingRoomCount = gameId == 0 and (self.clubInfo.config.allPlayerPri or 10) or (self.clubInfo.config.playerPri or 8)
  690. --创始人和管理员当且查看隐藏桌数的时候可以无限拉取,查看全部桌数
  691. if self._bShowAllRoom or (table.nums(self.clubInfo.rooms) < maxPlayingRoomCount) then
  692. self.isCanRequest = false
  693. self.curPage = self.curPage + 1
  694. app.club_php:setChangeTable(false)
  695. logD("only do onece!!!")
  696. self.isUpdateing = true
  697. runDelay(0.1,function ()
  698. self.isUpdateing = false
  699. end)
  700. app.club_php:requestRoomList(self.clubInfo.clubId,app.club_php:getSelectGameId(),app.club_php:getSelectBaoJianId(),self.curPage,true)
  701. end
  702. elseif event == cc.ScrollviewEventType.scrolling then
  703. local width1 = self.ui.Items.ScrollView:getContentSize().width
  704. local width2 = self.ui.Items.ScrollView:getInnerContainer():getContentSize().width
  705. local pos = self.ui.Items.ScrollView:getInnerContainer():getPosition()
  706. if math.abs(pos.x + width1 - width2) > 100 then
  707. self.isCanRequest = true
  708. end
  709. end
  710. end
  711. end
  712. function ClubTable:onUpdatePlayerListEvent(event)
  713. end
  714. --刷新桌子
  715. function ClubTable:updateTableList(event)
  716. logD(" ------------------------- ClubTable:updateTableList() ------------------------- ")
  717. local clubId = event.clubId
  718. local scrollState = event.scrollState
  719. -- 非当前俱乐部的数据,则不处理
  720. if clubId ~= self.clubId then
  721. logD("ClubTable:updateTableList() clubId ~= self.clubId ")
  722. return
  723. end
  724. self:changeScrollViewSize()
  725. local clubInfo = app.club_php:getClubInfo(self.clubId)
  726. if not clubInfo then
  727. logD("ClubTable:updateTableList() clubInfo is nil")
  728. return
  729. end
  730. self._allTables = {}
  731. --更新个人配置信息
  732. self:initPlayerInfo()
  733. --再来一局
  734. local againBaoJianId = getAgainGameBaoJianId()
  735. local bPlayAgain,wanfa = getIsAgainGamebol()
  736. if bPlayAgain then
  737. gameId = app.club_php:getGameIdByBaoJianId(self.clubInfo.clubId,againBaoJianId)
  738. ruleId = againBaoJianId
  739. --保存到内存
  740. app.club_php:setSelectGameId(gameId)
  741. app.club_php:setSelectBaoJianId(ruleId)
  742. self:saveGameInfoToFile(gameId,ruleId)
  743. local club = app.club_php.clubList[tonumber(self.clubInfo.clubId)]
  744. club.isplaying = 0
  745. end
  746. self:updateSetting()
  747. self:setMenuButton()
  748. --俱乐部消息红点
  749. self:onClubHintsUpdateEvent()
  750. --主盟消息红点
  751. self:onClubUnionHintsUpdateEvent()
  752. self:popClubWindow()
  753. self:updateLeftGame(scrollState)
  754. end
  755. function ClubTable:updateTableView(data)
  756. local clubInfo = app.club_php:getClubInfo(self.clubId)
  757. if not clubInfo then
  758. logD("ClubTable:updateTableList() clubInfo is nil")
  759. return
  760. end
  761. if self._bShowAllRoom and self.clubInfo.groupext then
  762. self.clubInfo.groupext.is_playerpri = 0
  763. end
  764. --快速加入状态更换
  765. self:showButtonState()
  766. local baoJians = {}
  767. local gameId = data
  768. if type(data) == "table" then
  769. gameId = data.gameId--没包括0
  770. if data.tpage and data.tpage < self.curPage then
  771. self.curPage = data.tpage
  772. end
  773. end
  774. --本地的gameid
  775. local localGameId = app.club_php:getSelectGameId()
  776. --全部情况下过滤包间
  777. if localGameId ~= 0 then
  778. local ruleId = app.club_php:getSelectBaoJianId()
  779. for k,v in pairs(self.clubInfo.baoJians) do
  780. if (tonumber(v.gameId) == gameId or gameId == 0) and (tonumber(v.baoJianId) == ruleId or ruleId == 0) and tonumber(v.is_use) == 1 then
  781. baoJians[k] = v
  782. end
  783. end
  784. elseif self.clubInfo.mode == ClubDefine.BaoJianType.Multiple then
  785. for k,v in pairs(self.clubInfo.baoJians) do
  786. if tonumber(v.is_use) == 1 then
  787. baoJians[k] = v
  788. end
  789. end
  790. end
  791. --localGameId 为0则是选中全部,无须过滤,不同游戏之间过滤刷新。
  792. if gameId ~= localGameId and localGameId ~= 0 then
  793. return
  794. end
  795. local mListView = self.ui.Items.ScrollView
  796. mListView:getInnerContainer():setAutoSize(true)
  797. if self.isUpdateAll then
  798. mListView:removeAllChildren()
  799. mListView:jumpToLeft()
  800. self.allTableItem = {}
  801. self.isUpdateAll = false
  802. end
  803. mListView:hideAllBar()
  804. -- 判断包间是否存在
  805. local function isExistBaoJian(baoJianId)
  806. local isExist = false;
  807. local baojians = clubInfo.baoJians;
  808. for k, v in pairs(baojians or {}) do
  809. if tonumber(k) == tonumber(baoJianId) then
  810. isExist = true;
  811. break;
  812. end
  813. end
  814. return isExist;
  815. end
  816. local baoJianNum = table.nums(baoJians)
  817. if baoJianNum == 0 and (localGameId ~= 0 or self.clubInfo.mode == ClubDefine.BaoJianType.Multiple or (self.clubInfo.mode == ClubDefine.BaoJianType.Normal and table.nums(self.clubInfo.settings) == 0)) then --未设置玩法
  818. self.ui.Items.Layout_no_set:setVisible(true)
  819. mListView:removeAllChildren()
  820. logD(" ------------------------- ClubTable:updateTableList() 删除所有桌子")
  821. else
  822. if localGameId ~= 0 and self.clubInfo.mode == ClubDefine.BaoJianType.ManyRooms then
  823. self.ui.Items.Layout_BaoJian:setVisible(true)
  824. end
  825. mListView:setTouchEnabled(false)
  826. self.ui.Items.Layout_no_set:setVisible(false)
  827. -- 记录所有新的 item 的索引
  828. local newAllTableItem = {}
  829. -- 包间的数量
  830. logD(" ------------------------- ClubTable:updateTableList() baoJianNum = ", baoJianNum)
  831. local function isRoomHided (hideRooms, pos)
  832. local isHided = false
  833. for k, v in ipairs(hideRooms or {}) do
  834. if v.pos == pos then
  835. isHided = true
  836. break
  837. end
  838. end
  839. return isHided
  840. end
  841. local rooms, hideRooms = app.club_php:getShowRooms(self.clubInfo.clubId)
  842. local roomNum = table.nums(rooms)
  843. if roomNum == 0 and localGameId == 0 and self.clubInfo.mode == ClubDefine.BaoJianType.ManyRooms then
  844. self.ui.Items.Text_no_table:setVisible(true)
  845. else
  846. self.ui.Items.Text_no_table:setVisible(false)
  847. end
  848. logD(" ------------------------- ClubTable:updateTableList() roomNum = ", roomNum)
  849. local index = 0
  850. if self.clubInfo.mode == ClubDefine.BaoJianType.Normal then
  851. local idxBegin = (self.clubInfo.settings.orderId - 1) * ClubDefine.TableCountMax + 1
  852. local idxEnd = idxBegin + (ClubDefine.TableCountMax - 1)
  853. --1.优先显示属于这个包间已经越界的posnumber桌子
  854. --2.遵守满足30张的规则,不够30张再从当前包间的区间范围里抽余下空桌来凑30张。
  855. ----1.
  856. local maxCount = 30
  857. for i = 1, #rooms do
  858. local roomInfo = rooms[i]
  859. if idxBegin > roomInfo.pos and roomInfo.pos > idxEnd and (not isRoomHided(hideRooms, roomInfo.pos)) then
  860. index = index + 1
  861. newAllTableItem[roomInfo.pos] = 1
  862. -- 只显示包间存在的桌子,
  863. -- 包间不存在的桌子,可能是管理员删除了包间
  864. if isExistBaoJian(roomInfo.baoJianId) then
  865. local realIndex = roomInfo.pos
  866. local showIndex = index
  867. if self.allTableItem[roomInfo.pos] then
  868. logD(" ------------------------- ClubTable:updateTableList() 更新桌子 ", roomInfo.pos)
  869. local item = self.allTableItem[roomInfo.pos];
  870. item.layout:setLocalZOrder(index)
  871. item:updateData(self.clubId, realIndex, showIndex)
  872. else
  873. logD(" ------------------------- ClubTable:updateTableList() 创建桌子 ", roomInfo.pos)
  874. local item = import("luaScript.Views.Club.ClubTableItem"):new(self.clubId, realIndex, showIndex)
  875. item.ui.Items.Button_enter_table = self.ui.Items.Button_enter_table
  876. -- 保存节点
  877. self.allTableItem[roomInfo.pos] = item
  878. -- 添加到容器
  879. mListView:addChild(item.layout, index)
  880. end
  881. end
  882. end
  883. end
  884. -----2.
  885. for tableIdx = idxBegin, idxEnd do
  886. if index < maxCount and (not isRoomHided(hideRooms, tableIdx)) then
  887. index = index + 1
  888. newAllTableItem[tableIdx] = 1
  889. local realIndex = tableIdx
  890. local showIndex = index
  891. if self.allTableItem[tableIdx] then
  892. logD(" ------------------------- ClubTable:updateTableList() 2更新桌子 ", tableIdx)
  893. local item = self.allTableItem[tableIdx];
  894. item.layout:setLocalZOrder(index)
  895. item:updateData(self.clubId, realIndex, showIndex)
  896. else
  897. logD(" ------------------------- ClubTable:updateTableList() 2创建桌子 ", tableIdx)
  898. local item = import("luaScript.Views.Club.ClubTableItem"):new(self.clubId, realIndex, showIndex)
  899. item.ui.Items.Button_enter_table = self.ui.Items.Button_enter_table
  900. -- 保存节点
  901. self.allTableItem[tableIdx] = item
  902. -- 添加到容器
  903. mListView:addChild(item.layout, index);
  904. end
  905. end
  906. end
  907. else
  908. --包间排序
  909. local newBaoJians = app.club_php:getSortClubBaoJians(self.clubInfo.clubId,baoJians)
  910. -- 第一页需要先创建包间
  911. for k,baojianInfo in ipairs(newBaoJians) do
  912. index = index + 1
  913. local baoJianId = baojianInfo.baoJianId;
  914. newAllTableItem[baoJianId] = 1;
  915. if self.allTableItem[baoJianId] then
  916. logD(" ------------------------- ClubTable:updateTableList() 更新玩法桌子 ", baoJianId)
  917. local item = self.allTableItem[baoJianId]
  918. item.layout:setLocalZOrder(index)
  919. item:updateData(baojianInfo, index)
  920. else
  921. logD(" ------------------------- ClubTable:updateTableList() 创建玩法桌子 ", baoJianId)
  922. local item = import("luaScript.Views.Club.ClubTableBaoJianItem"):new(baojianInfo, clubInfo.clubId)
  923. item.ui.Items.Button_enter_table = self.ui.Items.Button_enter_table
  924. -- 保存节点
  925. self.allTableItem[baoJianId] = item
  926. -- 添加到容器
  927. mListView:addChild(item.layout, index);
  928. end
  929. end
  930. for i = 1, #rooms do
  931. index = index + 1
  932. local roomInfo = rooms[i]
  933. newAllTableItem[roomInfo.pos] = 1;
  934. -- 只显示包间存在的桌子,
  935. -- 包间不存在的桌子,可能是管理员删除了包间
  936. if isExistBaoJian(roomInfo.baoJianId) then
  937. local realIndex = roomInfo.pos
  938. local showIndex = index - baoJianNum
  939. if self.allTableItem[roomInfo.pos] then
  940. logD(" ------------------------- ClubTable:updateTableList() 更新桌子 ", roomInfo.pos)
  941. local item = self.allTableItem[roomInfo.pos];
  942. item.layout:setLocalZOrder(index)
  943. item:updateData(self.clubId, realIndex, showIndex)
  944. else
  945. logD(" ------------------------- ClubTable:updateTableList() 创建桌子 ", roomInfo.pos)
  946. local item = import("luaScript.Views.Club.ClubTableItem"):new(self.clubId, realIndex, showIndex)
  947. if item then
  948. item.ui.Items.Button_enter_table = self.ui.Items.Button_enter_table
  949. -- 保存节点
  950. self.allTableItem[roomInfo.pos] = item
  951. -- 添加到容器
  952. mListView:addChild(item.layout, index);
  953. else
  954. --上传日志,便于查找错误问题
  955. uploadLogs(GAME_ERROR_TYPE.TABLENOFIND)
  956. end
  957. end
  958. end
  959. end
  960. -- 比较新旧IDX,删除过期的桌子
  961. for k,v in pairs(self.allTableItem) do
  962. if not newAllTableItem[k] then
  963. if self.clubInfo.mode ~= ClubDefine.BaoJianType.Normal then
  964. local idx = v:getTableIdx()
  965. logD(" ------------------------- ClubTable:updateTableList() 删除桌子 ", k, idx)
  966. v:removeSelf()
  967. end
  968. self.allTableItem[k] = nil
  969. end
  970. end
  971. end
  972. mListView:setTouchEnabled(true)
  973. mListView:getInnerContainer():requestDoLayout()
  974. end
  975. self:playAgainlogic()
  976. logD("ClubTable:updateTableList2")
  977. end
  978. --再来一局
  979. function ClubTable:playAgainlogic()
  980. --在子游戏总结算,点了邀请的同意后,在这里实现进入房间
  981. local agdata = getAgainGameInvitedata()
  982. if agdata then
  983. --同意后进入房间,赋值当前进入的俱乐部id
  984. app.club_php.clubID = agdata.gid
  985. local function doRequest(gameId, roomId)
  986. if not gameId or tonumber(gameId) <= 0 then
  987. showTooltip("房间号不存在")
  988. return
  989. end
  990. app.hall:requestJoinRoom(gameId, roomId)
  991. end
  992. app.hall:queryRoomId(agdata.roomid,doRequest)
  993. setAgainGameInvitedata(nil)
  994. end
  995. --这部分逻辑的意思:点了再来一局按钮时,包间玩法被人删掉了,做了个校验。
  996. local againBaoJianId = getAgainGameBaoJianId()
  997. local baojianbol = false
  998. if self.clubInfo.baoJians then
  999. for key,var in pairs(self.clubInfo.baoJians) do
  1000. if tonumber(key) == tonumber(againBaoJianId) then
  1001. baojianbol = true
  1002. end
  1003. end
  1004. end
  1005. if not baojianbol then
  1006. if not getMyGameCreateStatus() then
  1007. local againbol,wanfa = getIsAgainGamebol()
  1008. if wanfa ~= "" then
  1009. --showTooltip("房间创建失败,该包间玩法已被删除或修改!")
  1010. showTooltip("该游戏包间玩法已被关闭!")
  1011. end
  1012. setIsAgainGamebol(false,"")
  1013. else
  1014. setIsAgainGamebol(false)
  1015. end
  1016. end
  1017. local clubgamedata = getIsRoomGamedata()
  1018. if clubgamedata then
  1019. setisContinueRoomGamebol(true)
  1020. end
  1021. end
  1022. function ClubTable:onClickEnter(data)
  1023. setisContinueRoomGamebol(true)
  1024. local tableMenuView = import("luaScript.Views.Club.ClubTableOperatMenu"):new(data.clubInfo.clubId, data.roomInfo, data.showIndex, false)
  1025. tableMenuView.ui.Items.Button_enter_table = self.ui.Items.Button_enter_table
  1026. tableMenuView:setAnchorPoint(cc.p(0.5, 0.5))
  1027. local worldPos = self.ui.Items.Layout_touch:getWorldPosition();
  1028. local viewContentSize = cc.size(232, 360);
  1029. local x = worldPos.x;
  1030. local y = worldPos.y - self.ui.Items.Layout_touch:getContentSize().height;
  1031. local newPos = cc.p(x, y);
  1032. tableMenuView:setPosition(newPos);
  1033. app:showWaitDialog(tableMenuView, 0, true)
  1034. end
  1035. function ClubTable:showButtonState()
  1036. local room = app.club_php:getMyInRoom(self.clubInfo.clubId)
  1037. local view = app:getCurrentView()
  1038. local baoJian = app.club_php:getBaoJianByGameId(self.clubInfo.clubId,app.club_php:getSelectGameId())
  1039. local isHaveUser = false
  1040. if baoJian then
  1041. for k,v in pairs(baoJian) do
  1042. if tonumber(v.gameId) == app.club_php:getSelectGameId() then
  1043. if tonumber(v.is_use) == 1 then
  1044. isHaveUser = true
  1045. end
  1046. end
  1047. end
  1048. end
  1049. if not room then --在房间界面的话显示进入桌子按钮
  1050. --进入桌子
  1051. self.ui.Items.Button_enter_table:setVisible(false)
  1052. self.ui.Items.Button_quick_start:setVisible(true)
  1053. --如果所在游戏没有包间且不是全部游戏就隐藏
  1054. if ((not isHaveUser and app.club_php:getSelectGameId() ~= 0)
  1055. or app.club_php:getSelectGameId() == 0 or app.club_php:getSelectBaoJianId() == 0) and self.clubInfo.mode ~= ClubDefine.BaoJianType.Normal then
  1056. self.ui.Items.Button_enter_table:setVisible(false)
  1057. self.ui.Items.Button_quick_start:setVisible(false)
  1058. end
  1059. -- cest
  1060. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  1061. --进入桌子
  1062. self.ui.Items.Button_enter:setVisible(false)
  1063. self.ui.Items.Button_quick:setVisible(true)
  1064. --如果所在游戏没有包间且不是全部游戏就隐藏
  1065. if ((not isHaveUser and app.club_php:getSelectGameId() ~= 0)
  1066. or app.club_php:getSelectGameId() == 0 or app.club_php:getSelectBaoJianId() == 0) and self.clubInfo.mode ~= ClubDefine.BaoJianType.Normal then
  1067. self.ui.Items.Button_enter:setVisible(false)
  1068. self.ui.Items.Button_quick:setVisible(false)
  1069. end
  1070. --刷新layout布局
  1071. self.ui.Items.Layout_under:requestDoLayout()
  1072. self.ui.Items.Layout_under:doLayout()
  1073. end
  1074. else
  1075. --进入桌子
  1076. self.ui.Items.Button_enter_table:setVisible(true)
  1077. self.ui.Items.Button_quick_start:setVisible(false)
  1078. -- cest
  1079. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  1080. self.ui.Items.ImageView_zhanji_line:setVisible(true)
  1081. self.ui.Items.Layout_btn_quick:setVisible(true)
  1082. self.ui.Items.Button_enter:setVisible(true)
  1083. self.ui.Items.Button_quick:setVisible(false)
  1084. --刷新layout布局
  1085. self.ui.Items.Layout_under:requestDoLayout()
  1086. self.ui.Items.Layout_under:doLayout()
  1087. end
  1088. end
  1089. end
  1090. function ClubTable:setMenuButton()
  1091. --自己不是管理员或创始人(1:成员 2:管理员 3:创始人)
  1092. local isAdmin = tonumber(self.clubInfo.role) == ClubDefine.Job.Creator
  1093. --设置
  1094. self.ui.Items.Layout_set:setVisible(true)
  1095. --消息
  1096. if self.clubInfo.isArena == ClubDefine.MATCH_SWITCH.PEOPLE_MATCH_OPEN then
  1097. self.ui.Items.Layout_apply_msg:setVisible(isAdmin
  1098. or self.clubInfo.role == ClubDefine.Job.Manager
  1099. or self.clubInfo.role == ClubDefine.Job.LevelOneCopartner
  1100. or self.clubInfo.role == ClubDefine.Job.LevelTwoCopartner
  1101. or self.clubInfo.role == ClubDefine.Job.LevelThreeCopartner);
  1102. elseif self.clubInfo.isArena == ClubDefine.MATCH_SWITCH.PEOPLE_CEST_OPEN then
  1103. self.ui.Items.Layout_apply_msg:setVisible(isAdmin
  1104. or self.clubInfo.role == ClubDefine.Job.Manager
  1105. or self.clubInfo.role == ClubDefine.Job.LevelOneCopartner
  1106. or self.clubInfo.role == ClubDefine.Job.LevelTwoCopartner
  1107. or self.clubInfo.role == ClubDefine.Job.LevelThreeCopartner);
  1108. else
  1109. self.ui.Items.Layout_apply_msg:setVisible(isAdmin or tonumber(self.clubInfo.role) == ClubDefine.Job.Manager);
  1110. end
  1111. --退出
  1112. self.ui.Items.Layout_exit:setVisible(not isAdmin);
  1113. self.ui.Items.Layout_invite:setVisible(self.clubInfo.role == ClubDefine.Job.Manager or self.clubInfo.role == ClubDefine.Job.Creator)
  1114. --self.ui.Items.Layout_activity:setVisible(self.clubInfo.role == ClubDefine.Job.Manager or self.clubInfo.role == ClubDefine.Job.Creator)
  1115. if isReviewVersion() then
  1116. self.ui.Items.Layout_invite:setVisible(false)
  1117. end
  1118. --刷新右上方layout布局
  1119. self.ui.Items.Layout_up_menu:requestDoLayout()
  1120. self.ui.Items.Layout_up_menu:doLayout()
  1121. --刷新下方layout布局
  1122. self.ui.Items.Layout_under:requestDoLayout()
  1123. self.ui.Items.Layout_under:doLayout()
  1124. end
  1125. function ClubTable:updateChangeRuleBtn()
  1126. --如果是成员则显示包间玩法按钮,如果是管理员或创始人则显示修改玩法按钮
  1127. if self.clubInfo.mode == ClubDefine.BaoJianType.Normal or self.clubInfo.mode == ClubDefine.BaoJianType.Multiple then
  1128. if (self.clubInfo.role == ClubDefine.Job.Manager or self.clubInfo.role == ClubDefine.Job.Creator) and not app.club_php:getIsSlaveUnion(self.clubInfo.clubId) then
  1129. self.ui.Items.Button_change_rule:loadTextureNormal("res/ui/zy_club/club_table/bottom_view/club_room_btn_change_rule.png")
  1130. else
  1131. self.ui.Items.Button_change_rule:loadTextureNormal("res/ui/zy_club/club_table/bottom_view/club_room_btn_baojian_wanfa.png")
  1132. end
  1133. self.ui.Items.Layout_btn_change_rule:setVisible(true);
  1134. elseif self.clubInfo.mode == ClubDefine.BaoJianType.ManyRooms then
  1135. if (self.clubInfo.role == ClubDefine.Job.Manager or self.clubInfo.role == ClubDefine.Job.Creator)
  1136. and app.club_php:getSelectGameId() ~= 0 and not app.club_php:getIsSlaveUnion(self.clubInfo.clubId) then
  1137. self.ui.Items.Layout_btn_change_rule:setVisible(true);
  1138. else
  1139. self.ui.Items.Layout_btn_change_rule:setVisible(false);
  1140. end
  1141. end
  1142. -- todo lwqcest
  1143. -- self.ui.Items.Button_change_rule:loadTextureNormal("res/ui/zy_club/club_table/bottom_view/club_cest_room_btn_bisai_guanli.png")
  1144. -- self.ui.Items.Button_match_info:loadTextureNormal("res/ui/zy_club/club_table/bottom_view/club_cest_room_btn_cest_rank.png")
  1145. -- self.ui.Items.Button_zhanji:loadTextureNormal("res/ui/zy_club/club_table/bottom_view/club_cest_room_btn_zhanji.png")
  1146. --刷新layout布局
  1147. self.ui.Items.Layout_under:requestDoLayout()
  1148. self.ui.Items.Layout_under:doLayout()
  1149. end
  1150. --更新玩法数据
  1151. function ClubTable:updateSetting(event)
  1152. if event and event.setType then
  1153. local setType = event.setType
  1154. if setType == GAME_CLUB_SET_STATE.Change_Mode then
  1155. -- 修改包间模式,需要清除一下桌子,再创建新的桌子
  1156. if self.clubInfo.mode ~= event.value then
  1157. self._allTables = {}
  1158. self.ui.Items.ScrollView:removeAllChildren()
  1159. end
  1160. self.clubInfo.mode = event.value
  1161. self:changeScrollViewSize()
  1162. --
  1163. --请求茶馆桌子数据
  1164. local gameId
  1165. local baoJianId
  1166. if self.clubInfo.mode == ClubDefine.BaoJianType.Normal then
  1167. gameId = self.clubInfo.settings.realGameId
  1168. baoJianId = self.clubInfo.settings.baoJianId
  1169. end
  1170. app.club_php:setSelectGameId(gameId or 0)
  1171. app.club_php:setSelectBaoJianId(baoJianId or 0)
  1172. app.club_php:requestClubHome(self.clubInfo.clubId)
  1173. end
  1174. end
  1175. --顶部包间信息
  1176. self:updateTopBaoJianInfo()
  1177. --更多游戏
  1178. if self.clubInfo.role == ClubDefine.Job.Creator or self.clubInfo.role == ClubDefine.Job.Manager then
  1179. self.ui.Items.Button_moreGame:setVisible(true)
  1180. self.ui.Items.Layout_look_table:setVisible(self.clubInfo.mode ~= ClubDefine.BaoJianType.Normal)
  1181. else
  1182. self.ui.Items.Button_moreGame:setVisible(false)
  1183. self.ui.Items.Layout_look_table:setVisible(false)
  1184. self._bShowAllRoom = false
  1185. end
  1186. --包间设置
  1187. self:updateChangeRuleBtn()
  1188. --比赛场设置
  1189. self.ui.Items.Layout_btn_match_info:setVisible(false)
  1190. self.ui.Items.Layout_Score:setVisible(false)
  1191. self.ui.Items.Button_wenhao:setVisible(false)
  1192. self.ui.Items.Button_level:setVisible(false)
  1193. --0后台是否开启这个按钮,1,关闭,2开启
  1194. if self.clubInfo.isArena == ClubDefine.MATCH_SWITCH.SERVER_CLOSE then
  1195. self.ui.Items.Layout_btn_hehuoren:setVisible(true)
  1196. local isShowHeHuoRen = app.config.ModuleConfig.IsSupportHeHuoRen and (self.clubInfo.role == 2 or self.clubInfo.role == 3 or self.clubInfo.role == 4)
  1197. self.ui.Items.Layout_btn_hehuoren:setVisible(isShowHeHuoRen)
  1198. self.ui.Items.Layout_FangKa:setVisible(self.clubInfo.role == 3)
  1199. self.ui.Items.Button_match_set:loadTextureNormal("res/ui/zy_club/club_table/bottom_view/club_room_bottom_normal_mode.png")
  1200. elseif self.clubInfo.isArena == ClubDefine.MATCH_SWITCH.PEOPLE_MATCH_SEVER_CLOSE then
  1201. local isShowHeHuoRen = app.config.ModuleConfig.IsSupportHeHuoRen and (self.clubInfo.role == 2 or self.clubInfo.role == 3 or self.clubInfo.role == 4)
  1202. self.ui.Items.Layout_btn_hehuoren:setVisible(isShowHeHuoRen)
  1203. self.ui.Items.Layout_FangKa:setVisible(self.clubInfo.role == 3)
  1204. self.ui.Items.Button_match_set:loadTextureNormal("res/ui/zy_club/club_table/bottom_view/club_room_bottom_normal_mode.png")
  1205. elseif self.clubInfo.isArena == ClubDefine.MATCH_SWITCH.CLIENT_OPEN then
  1206. self.ui.Items.Layout_btn_hehuoren:setVisible(false)
  1207. if self.clubInfo.role ~= ClubDefine.Job.Member then
  1208. self.ui.Items.Layout_btn_match_info:setVisible(true)
  1209. end
  1210. self.ui.Items.Layout_btn_player_list:setVisible(false)
  1211. self.ui.Items.Button_match_set:loadTextureNormal("res/ui/zy_club/club_table/bottom_view/club_room_bottom_match_mode.png")
  1212. self.ui.Items.Button_wenhao:setVisible(true)
  1213. self.ui.Items.Button_level:setVisible(true)
  1214. self.ui.Items.Layout_FangKa:setVisible(self.clubInfo.role == 3)
  1215. elseif self.clubInfo.isArena == ClubDefine.MATCH_SWITCH.CLIENT_CLOSE then
  1216. local isShowHeHuoRen = app.config.ModuleConfig.IsSupportHeHuoRen and (self.clubInfo.role == 2 or self.clubInfo.role == 3 or self.clubInfo.role == 4)
  1217. self.ui.Items.Layout_btn_hehuoren:setVisible(isShowHeHuoRen)
  1218. self.ui.Items.Layout_btn_player_list:setVisible(true)
  1219. self.ui.Items.Layout_btn_match_info:setVisible(false)
  1220. self.ui.Items.Button_match_set:loadTextureNormal("res/ui/zy_club/club_table/bottom_view/club_room_bottom_normal_mode.png")
  1221. self.ui.Items.Button_wenhao:setVisible(true)
  1222. self.ui.Items.Button_level:setVisible(true)
  1223. self.ui.Items.Layout_FangKa:setVisible(self.clubInfo.role == 3)
  1224. elseif self.clubInfo.isArena == ClubDefine.MATCH_SWITCH.PEOPLE_MATCH_OPEN then
  1225. self.ui.Items.Layout_btn_hehuoren:setVisible(false)
  1226. self.ui.Items.Layout_btn_match_info:setVisible(true)
  1227. self.ui.Items.Layout_btn_player_list:setVisible(false)
  1228. self.ui.Items.Button_match_set:loadTextureNormal("res/ui/zy_club/club_table/bottom_view/club_room_btn_quanminsai.png")
  1229. self.ui.Items.Button_match_info:loadTextureNormal("res/ui/zy_club/club_table/bottom_view/club_room_btn_match_quanminsai.png")
  1230. self.ui.Items.Button_level:setTouchEnabled(self.clubInfo.role == ClubDefine.Job.Creator)
  1231. self.ui.Items.Button_wenhao:setTouchEnabled(true)
  1232. self.ui.Items.Layout_Score:setTouchEnabled(true)
  1233. self.ui.Items.Button_wenhao:setVisible(true)
  1234. self.ui.Items.Button_level:setVisible(true)
  1235. self.ui.Items.Layout_Score:setVisible(true)
  1236. self.ui.Items.Layout_FangKa:setVisible(self.clubInfo.role == 3)
  1237. elseif self.clubInfo.isArena == ClubDefine.MATCH_SWITCH.PEOPLE_MATCH_CLOSE then
  1238. local isShowHeHuoRen = app.config.ModuleConfig.IsSupportHeHuoRen and (self.clubInfo.role == 2 or self.clubInfo.role == 3 or self.clubInfo.role == 4)
  1239. self.ui.Items.Layout_btn_hehuoren:setVisible(isShowHeHuoRen)
  1240. self.ui.Items.Layout_btn_player_list:setVisible(true)
  1241. self.ui.Items.Layout_btn_match_info:setVisible(false)
  1242. self.ui.Items.Button_match_set:loadTextureNormal("res/ui/zy_club/club_table/bottom_view/club_room_bottom_normal_mode.png")
  1243. self.ui.Items.Layout_FangKa:setVisible(self.clubInfo.role == 3)
  1244. end
  1245. -- -- todo lwqcest
  1246. -- self.ui.Items.Button_match_set:loadTextureNormal("res/ui/zy_club/club_table/bottom_view/club_room_bottom_cest.png")
  1247. -- self.ui.Items.Button_match_info:loadTextureNormal("res/ui/zy_club/club_table/bottom_view/club_cest_room_btn_cest_rank.png")
  1248. --合盟显示
  1249. self:onUpdateMaster()
  1250. self:onUpdateHongHua()
  1251. if self.clubInfo.mode == ClubDefine.BaoJianType.Normal or self.clubInfo.mode == ClubDefine.BaoJianType.Multiple then
  1252. --屏蔽左侧游戏列表
  1253. self.ui.Items.Layout_LeftGame:setVisible(false)
  1254. --屏蔽子游戏多包间的包间列表
  1255. self.ui.Items.Layout_BaoJian:setVisible(false)
  1256. else
  1257. self.ui.Items.Layout_LeftGame:setVisible(true)
  1258. end
  1259. --刷新layout布局
  1260. self.ui.Items.Layout_under:requestDoLayout()
  1261. self.ui.Items.Layout_under:doLayout()
  1262. --刷新layout布局
  1263. self.ui.Items.Layout_ChongBangFen:requestDoLayout()
  1264. self.ui.Items.Layout_ChongBangFen:doLayout()
  1265. end
  1266. function ClubTable:onUpdateHongHua()
  1267. if self.clubInfo.memberInfo then
  1268. local memberInfo = self.clubInfo.memberInfo
  1269. self.ui.Items.Text_chongbangfen:setText(tostring(memberInfo.warnum))
  1270. self.ui.Items.TextBMFont:setText(tostring(self.clubInfo.groupLevel))
  1271. end
  1272. end
  1273. --合盟
  1274. function ClubTable:onUpdateMaster()
  1275. local groupext = self.clubInfo.groupext
  1276. --隐私数据
  1277. local cliext = self.clubInfo.groupext and self.clubInfo.groupext.cliext
  1278. if groupext then
  1279. local action = cc.Sequence:create(cc.ScaleTo:create(0.4,0.95),cc.ScaleTo:create(0.4,1.2))
  1280. self.ui.Items.ImageView_hand:runAction(cc.RepeatForever:create(action))
  1281. if groupext and groupext.master_union == 2 then
  1282. self.ui.Items.Button_Union:loadTextureNormal("res/ui/zy_club/club_table/top_view/club_room_master.png")
  1283. self.ui.Items.Button_Union:setVisible(true)
  1284. if cliext and cliext.readUnionGuide ~= 1 and self.clubInfo.role == ClubDefine.Job.Creator then
  1285. self.ui.Items.Layout_union_guide:setVisible(true)
  1286. end
  1287. self.ui.Items.Text_union:setText(PLN.CLUB_UNION_MASTER_INTRO)
  1288. elseif groupext and groupext.slave_union == 2 then
  1289. self.ui.Items.Button_Union:setVisible(true)
  1290. self.ui.Items.Button_Union:loadTextureNormal("res/ui/zy_club/club_table/top_view/club_room_slave.png")
  1291. if cliext and cliext.readUnionGuide ~= 1 and self.clubInfo.role == ClubDefine.Job.Creator then
  1292. self.ui.Items.Layout_union_guide:setVisible(true)
  1293. end
  1294. self.ui.Items.Text_union:setText(PLN.CLUB_UNION_SLAVE_INTRO)
  1295. else
  1296. self.ui.Items.Button_Union:setVisible(false)
  1297. end
  1298. end
  1299. --不管哪个模式,如果自己是副盟,房卡不显示
  1300. if app.club_php:getIsSlaveUnion(self.clubInfo.clubId) then
  1301. self.ui.Items.Layout_FangKa:setVisible(false)
  1302. self.ui.Items.Button_moreGame:setVisible(false)
  1303. end
  1304. end
  1305. function ClubTable:onClose()
  1306. playBtnCloseEffect();
  1307. local room = app.club_php:getMyInRoom(self.clubInfo.clubId)
  1308. if room then
  1309. --有桌子下标,表示当前在房间内游戏,返回时需要退出房间
  1310. self:onExitRoom(room)
  1311. else
  1312. local view = app:getCurrentView()
  1313. -- logD(view.__cname)
  1314. if view and view.__cname == "MainView" then --在主界面则清除ID 在房间界面则不清除 应该是点击切换包间打开的
  1315. app.club_php.clubID = 0
  1316. app.club_php.tableIdx = 0
  1317. end
  1318. setInClubRoom(false)
  1319. self:removeFromParent()
  1320. end
  1321. end
  1322. -- 战绩
  1323. function ClubTable:onZhanjiClub()
  1324. playBtnEffect()
  1325. if self.clubInfo and self.clubInfo.isGamb and (self.clubInfo.role == ClubDefine.Job.Member or self.clubInfo.role == ClubDefine.Job.Copartner
  1326. or self.clubInfo.role == ClubDefine.Job.LevelOneCopartner or self.clubInfo.role == ClubDefine.Job.LevelTwoCopartner
  1327. or self.clubInfo.role == ClubDefine.Job.LevelThreeCopartner) then
  1328. --开启屏蔽战绩时,不显示战绩数据(只限成员)
  1329. local function onOK()
  1330. end
  1331. local function onCancel()
  1332. end
  1333. showConfirmDialog("当前战绩已被屏蔽,如需开启,请联系"..(app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_CREATOR_DESC or PLN.CLUB_CREATOR_DESC).."重新设置隐私选项",onOK,onCancel)
  1334. return
  1335. end
  1336. local memberInfo = self.clubInfo.memberInfo
  1337. if memberInfo and memberInfo.status == 0 then
  1338. showTooltip("黑名单无法查看!")
  1339. return
  1340. end
  1341. local view = import("luaScript.Views.Club.ClubZhanJiView"):new(self.clubInfo)
  1342. view:setAnchorPoint(cc.p(0.5, 0.5))
  1343. app:showWaitDialog(view)
  1344. end
  1345. --消息
  1346. function ClubTable:onApplyMsg()
  1347. playBtnEffect();
  1348. if self.clubInfo.isArena == ClubDefine.MATCH_SWITCH.PEOPLE_MATCH_OPEN then
  1349. local view = import("luaScript.Views.Club.Match.ClubMatchMessage"):new(self.clubInfo.clubId)
  1350. view:setAnchorPoint(cc.p(0.5, 0.5))
  1351. app:showWaitDialog(view)
  1352. elseif self.clubInfo.isArena == ClubDefine.MATCH_SWITCH.PEOPLE_CEST_OPEN then -- lwqcest
  1353. local view = import("luaScript.Views.Club.Cest.ClubCestMessage"):new(self.clubInfo.clubId)
  1354. view:setAnchorPoint(cc.p(0.5, 0.5))
  1355. app:showWaitDialog(view)
  1356. else
  1357. local view = import("luaScript.Views.Club.ClubMessage"):new(self.clubInfo.clubId)
  1358. view:setAnchorPoint(cc.p(0.5, 0.5))
  1359. app:showWaitDialog(view)
  1360. end
  1361. end
  1362. --设置
  1363. function ClubTable:onSet()
  1364. playBtnEffect();
  1365. local isAdmin = (tonumber(self.clubInfo.role) == 3)
  1366. if isAdmin then
  1367. local view = import("luaScript.Views.Club.ClubSheZhi.ClubShezhi"):new(self.clubInfo.clubId)
  1368. view:setAnchorPoint(cc.p(0.5, 0.5))
  1369. app:showWaitDialog(view)
  1370. else
  1371. local isShow = self.ui.Items.Layout_right_menu:isVisible();
  1372. self.ui.Items.Layout_touch:setVisible(not isShow)
  1373. self:setRightMenuVisible(not isShow)
  1374. end
  1375. end
  1376. function ClubTable:setRightMenuVisible(bVisble)
  1377. self.ui.Items.Layout_right_menu:setVisible(bVisble);
  1378. end
  1379. --成员列表
  1380. function ClubTable:onPlayerList()
  1381. playBtnEffect();
  1382. self:onTouch()
  1383. local function delView()
  1384. self.playerListView = nil
  1385. end
  1386. local player = app.club_php:getPlayer(self.clubInfo.clubId,app.user.loginInfo.uid)
  1387. if player and player.viewType ~= ClubDefine.PlayListType.NORMAL_MEMBER then
  1388. self.clubInfo.players = {}
  1389. end
  1390. local view = import("luaScript.Views.Club.ClubNormalMode.ClubPlayerMain"):new(self.clubInfo.clubId,delView)
  1391. self.playerListView = view
  1392. view:setAnchorPoint(cc.p(0.5, 0.5))
  1393. app:showWaitDialog(view)
  1394. end
  1395. --快速开始
  1396. function ClubTable:onQuickStart()
  1397. playBtnEffect();
  1398. if not isEnableEnterRoom() then
  1399. return
  1400. end
  1401. self:enterRoom();
  1402. end
  1403. function ClubTable:enterRoom()
  1404. local baoJian
  1405. if self.clubInfo.mode ~= ClubDefine.BaoJianType.Normal then
  1406. if not self.curSelectBaoJian then
  1407. return
  1408. end
  1409. baoJian = app.club_php:getBaoJian(self.clubInfo.clubId,self.curSelectBaoJian.baojianId)
  1410. else
  1411. baoJian = self.clubInfo.settings
  1412. end
  1413. local roomFull = {}
  1414. local rooms = self.clubInfo.rooms
  1415. if rooms then
  1416. for pos,room in pairsByKeys(rooms) do
  1417. if baoJian.baoJianId == room.baoJianId then
  1418. if table.nums(room.players) < app.club_php:getPlayerNum(baoJian) then
  1419. if room.status == 1 then --未开局
  1420. self:joinClubRoom(pos,room.roomId, baoJian)
  1421. return
  1422. else
  1423. roomFull[pos] = true
  1424. end
  1425. else
  1426. roomFull[pos] = true
  1427. end
  1428. end
  1429. end
  1430. self:createRoom(baoJian)
  1431. end
  1432. end
  1433. function ClubTable:createRoom(baoJianInfo)
  1434. if self.clubInfo.status == 2 then
  1435. showConfirmDialog(app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_DONG_JIE_TIP or PLN.CLUB_DONG_JIE_TIP);
  1436. return;
  1437. end
  1438. if table.nums(baoJianInfo) <= 0 then
  1439. showConfirmDialog("未设置游戏玩法,请先设置游戏玩法后再来开房!");
  1440. return;
  1441. end
  1442. if not app.subGameManager:isInstaller(tonumber(baoJianInfo.realGameId)) or app.subGameManager:isNeedUpdate(tonumber(baoJianInfo.realGameId)) then
  1443. requestDownloadSubGame(tonumber(baoJianInfo.realGameId), function ()
  1444. showTooltip("下载完成")
  1445. end, true)
  1446. return
  1447. end
  1448. local memberInfo = self.clubInfo.memberInfo
  1449. if memberInfo and memberInfo.status == 0 then
  1450. showTooltip("您已被暂停游戏,请联系管理员!")
  1451. return
  1452. end
  1453. local request = self:getCreateRoomData(nil,baoJianInfo);
  1454. logD("clubCreateRoomRequest() request = ",table.tostring(request));
  1455. --开房时记录茶馆id,用于退出房间时返回界面做判断
  1456. app.club_php.clubID = self.clubInfo.clubId
  1457. app.club:requesetCreateRoomInClub(request)
  1458. end
  1459. function ClubTable:getCreateRoomData(pos,ruleInfo)
  1460. --局数
  1461. local jushu = 0;
  1462. if table.nums(ruleInfo) > 0 then
  1463. jushu = ruleInfo.gameNum;
  1464. end
  1465. local tableIdx = pos;
  1466. if not pos and ruleInfo.orderId then
  1467. local startIndex = (ruleInfo.orderId - 1)* ClubDefine.TableCountMax + 1
  1468. for i=startIndex,startIndex + (ClubDefine.TableCountMax - 1) do
  1469. if not self.clubInfo.posList[i] then
  1470. tableIdx = i
  1471. break
  1472. end
  1473. end
  1474. end
  1475. if not tableIdx then
  1476. showTooltip("当前房间数量已达到上限!")
  1477. return
  1478. end
  1479. --showConfirmDialog(tostring(tableIdx))
  1480. local gameId = tonumber(ruleInfo.realGameId)
  1481. --记录茶馆桌子下标,用于房间切换回茶馆时做判断
  1482. app.club_php.tableIdx = tableIdx
  1483. local request = ClubCreateRoomRequest:new()
  1484. request.gameid = gameId;--游戏id
  1485. request.groupId = tonumber(self.clubInfo.clubId);--茶馆标识
  1486. request.groupIndex = tostring(tableIdx); --茶馆桌子序号
  1487. request.groupUid = tonumber(self.clubInfo.ownerId);--茶馆管理员ID
  1488. request.groupMemNum = tonumber(self.clubInfo.playerNum);--茶馆成员人数
  1489. --游戏局数
  1490. request.gameNum = jushu;
  1491. --游戏信息,同游戏创建参数
  1492. local gameinfo = ruleInfo.strGameRule
  1493. local ttGameInfo = json.decode(gameinfo) or {}
  1494. ttGameInfo.clubId = tonumber(self.clubInfo.clubId)
  1495. ttGameInfo.tableIdx = tonumber(tableIdx)
  1496. ttGameInfo.ruleid = tostring(ruleInfo.baoJianId)
  1497. --柳州字牌增加23人玩法
  1498. if gameId == 20 and not ttGameInfo.startMode then
  1499. ttGameInfo.startMode = 1
  1500. end
  1501. gameinfo = json.encode(ttGameInfo)
  1502. request.gameInfo = gameinfo
  1503. --发起创建的用户信息
  1504. local tt = json.decode(app.user.userInfo)
  1505. tt.openid = app.user.openid
  1506. tt.unionid = app.user.unionid
  1507. tt.sex = tonumber(tt.sex)
  1508. request.usrinfo =json.encode(tt)
  1509. return request;
  1510. end
  1511. function ClubTable:joinClubRoom( pos, roomid, ruleInfo)
  1512. if self.clubInfo.status == 2 then
  1513. showConfirmDialog(app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_DONG_JIE_TIP or PLN.CLUB_DONG_JIE_TIP);
  1514. return;
  1515. end
  1516. local gameId = tonumber(ruleInfo.realGameId)
  1517. if not app.subGameManager:isInstaller(gameId) or app.subGameManager:isNeedUpdate(gameId) then
  1518. requestDownloadSubGame(gameId, function ()
  1519. showTooltip("下载完成")
  1520. end, true)
  1521. return
  1522. end
  1523. --[[if self.clubInfo.players then
  1524. local playerList = self.clubInfo.players
  1525. for k,v in pairs(playerList) do
  1526. if v.uid == tostring(app.user.loginInfo.uid) and v.status == 0 then
  1527. showTooltip("您已被暂停游戏,请联系管理员!")
  1528. return
  1529. end
  1530. end
  1531. end--]]
  1532. local memberInfo = self.clubInfo.memberInfo
  1533. if memberInfo and memberInfo.status == 0 then
  1534. showTooltip("您已被暂停游戏,请联系管理员!")
  1535. return
  1536. end
  1537. local request = ClubJoinRoomRequest:new()
  1538. request.gameid = gameId; --游戏id
  1539. request.tableid = tonumber(roomid); --房间号
  1540. request.grouId = tonumber(self.clubInfo.clubId); --茶馆标识
  1541. request.groupIndex = tonumber(pos); --茶馆桌子序号
  1542. --发起创建的用户信息
  1543. local tt = json.decode(app.user.userInfo)
  1544. tt.unionid = app.user.unionid
  1545. tt.openid = app.user.openid
  1546. tt.sex = tonumber(sex)
  1547. request.usrinfo =json.encode(tt)
  1548. --游戏信息,同游戏创建参数
  1549. local gameinfo = json.decode(ruleInfo.strGameRule)
  1550. if gameinfo then
  1551. request.gamerule = gameinfo.gamerule
  1552. end
  1553. logD("clubJoinRoomRequest() request = ",table.tostring(request));
  1554. --开房时记录茶馆id,用于退出房间时返回界面做判断
  1555. app.club_php.clubID = self.clubInfo.clubId;
  1556. local createRoomRequest = self:getCreateRoomData(pos, ruleInfo);
  1557. app.club:requestJoinRoomInClub(request, createRoomRequest)
  1558. end
  1559. --退出茶馆
  1560. function ClubTable:onExitClub()
  1561. playBtnEffect();
  1562. local room = app.club_php:getMyInRoom(self.clubInfo.clubId)
  1563. if room then
  1564. --有桌子下标,表示当前在房间内游戏
  1565. showTooltip(app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_IN_GAME_EXIT or PLN.CLUB_IN_GAME_EXIT)
  1566. return
  1567. end
  1568. self:onTouch()
  1569. local view = import("luaScript.Views.Club.ClubDongJie"):new(self.clubInfo.clubId,3)
  1570. view:setAnchorPoint(cc.p(0.5, 0.5))
  1571. app:showWaitDialog(view)
  1572. end
  1573. function ClubTable:onTouch()
  1574. self.ui.Items.Layout_touch:setVisible(false)
  1575. self:setRightMenuVisible(false);
  1576. self.ui.Items.Layout_baojian_touch:setVisible(false);
  1577. end
  1578. function ClubTable:onApplicationWillEnterForeground()
  1579. logD("ClubTable:onApplicationWillEnterForeground()")
  1580. if not self.clubInfo then
  1581. logD("ClubTable:onApplicationWillEnterForeground() self.clubInfo is nil")
  1582. return
  1583. end
  1584. logD("ClubTable:onApplicationWillEnterForeground() self.clubInfo = ", table.tostring(self.ClubInfo))
  1585. app.club_php:requestClubHome(self.clubInfo.clubId)
  1586. --不在成员列表界面请求茶馆成员列表,默认今日,在成员列表界面由成员列表自己去刷新对应的日期
  1587. if not self.playerListView then
  1588. self:requestPlayerList()
  1589. end
  1590. end
  1591. function ClubTable:onApplicationDidEnterBackground()
  1592. --[[ local size = self.ui.Items.ScrollView:getContentSize()
  1593. self.lastScrollViewSize = size
  1594. dump(size, "ClubTable:onApplicationDidEnterBackground")--]]
  1595. end
  1596. --返回房间
  1597. function ClubTable:onBackRoom()
  1598. playBtnEffect()
  1599. self:removeFromParent()
  1600. end
  1601. function ClubTable:onBackRoomEvent()
  1602. self:removeFromParent()
  1603. end
  1604. --退出房间
  1605. function ClubTable:onExitRoom()
  1606. playBtnEffect();
  1607. local function onClickOk()
  1608. self.ui:sendMsg(app.room, "callLeaveRequest");
  1609. end
  1610. local function onClickCancel()
  1611. end
  1612. local room = app.club_php:getMyInRoom(self.clubInfo.clubId)
  1613. if room then
  1614. showTooltip("游戏中,无法退出!!!")
  1615. return
  1616. end
  1617. --showConfirmDialog("离开后将会自动退出已落座的桌子?", onClickOk, onClickCancel)
  1618. end
  1619. --刷新
  1620. function ClubTable:onRefresh()
  1621. playBtnEffect()
  1622. --最后点击刷新的时间
  1623. self.lastRefreshTime = tonumber(loadUserInfo("lastRefreshTime")) or 0
  1624. saveUserInfo("lastRefreshTime",self.lastRefreshTime)
  1625. --连续点击次数
  1626. self.touchTimes = tonumber(loadUserInfo("touchTime")) or 0
  1627. self.touchTimes = self.touchTimes + 1;
  1628. saveUserInfo("touchTime", self.touchTimes)
  1629. local curTime = os.time()
  1630. local distance = curTime - self.lastRefreshTime
  1631. local disbandTime = 5
  1632. --点击超过三次,提示
  1633. if self.touchTimes > 3 and distance <= disbandTime then
  1634. showTooltip(string.format("请勿频繁刷新,休息一下下哦!"))
  1635. return
  1636. end
  1637. self.lastRefreshTime = curTime
  1638. saveUserInfo("lastRefreshTime",self.lastRefreshTime)
  1639. --刷新回到第一页
  1640. self.curPage = 1;
  1641. app.club_php:setChangeTable(true)
  1642. local gameId = app.club_php:getSelectGameId()
  1643. local ruleId = app.club_php:getSelectBaoJianId()
  1644. app.club_php:requestClubHome(self.clubInfo.clubId,gameId,ruleId)
  1645. --请求茶馆成员列表
  1646. self:requestPlayerList()
  1647. showTooltip("刷新成功")
  1648. end
  1649. --点击公告
  1650. function ClubTable:onClickGongGao()
  1651. if self.clubInfo.role == 1 then
  1652. -- showTooltip("非管理人员")
  1653. else
  1654. playBtnEffect()
  1655. local view = import("luaScript.Views.Club.ClubSetNotice"):new(self.clubInfo)
  1656. view:setAnchorPoint(cc.p(0.5, 0.5))
  1657. app:showWaitDialog(view)
  1658. end
  1659. end
  1660. function ClubTable:onGetClubOfficialActivitySucc(event)
  1661. local view = import("luaScript.Views.Club.ClubOfficialActivityView"):new(event.activitys)
  1662. view:setAnchorPoint(cc.p(0.5, 0.5))
  1663. app:showWaitDialog(view)
  1664. end
  1665. function ClubTable:popClubWindow(data)
  1666. if data then
  1667. self.clubInfo.cancelCopartner = data.response
  1668. end
  1669. if self.clubInfo and self.clubInfo.cancelCopartner and self.clubInfo.cancelCopartner.uid then
  1670. local view = import("luaScript.Views.Club.ClubNoticeHeHuoRen"):new(self.clubInfo.clubId,self.clubInfo.cancelCopartner)
  1671. view:setAnchorPoint(cc.p(0.5, 0.5))
  1672. app:showWaitDialog(view,0)
  1673. end
  1674. end
  1675. function ClubTable:onClubHeHuoRenCancelTip(data)
  1676. local view = import("luaScript.Views.Club.ClubNoticeHeHuoRenTip"):new()
  1677. view:setAnchorPoint(cc.p(0.5, 0.5))
  1678. app:showWaitDialog(view,0)
  1679. end
  1680. function ClubTable:requestPlayerList()
  1681. local playerJson
  1682. if self.clubInfo.isArena == ClubDefine.MATCH_SWITCH.CLIENT_OPEN then--比赛场(弃用模式)
  1683. playerJson = {
  1684. clubId = self.clubInfo.clubId,
  1685. viewType = ClubDefine.PlayListType.MATCH_MEMBER,
  1686. status = ClubDefine.PlayListType.MATCH_MEMBER,
  1687. }
  1688. app.club_php:requestPlayerList(playerJson)
  1689. elseif self.clubInfo.isArena == ClubDefine.MATCH_SWITCH.PEOPLE_MATCH_OPEN then--排名赛(悠闲没有)
  1690. local localData ={
  1691. clubId = self.clubId,
  1692. viewType = ClubDefine.PlayListType.ALL_PEOPLE_MATCH_MANAGER,
  1693. type = 1,
  1694. muid = 0,
  1695. isMyMem = 0,
  1696. orderby = "role",
  1697. sort = "desc",
  1698. lastDay = 0,
  1699. page = 1,
  1700. suid = 0,
  1701. }
  1702. app.club_php:requestMatchManage(localData)
  1703. elseif self.clubInfo.isArena == ClubDefine.MATCH_SWITCH.PEOPLE_CEST_OPEN then
  1704. -- local localData ={
  1705. -- clubId = self.clubId,
  1706. -- viewType = self.viewType,
  1707. -- type = self.type,
  1708. -- muid = self.muid,
  1709. -- isMyMem = self.suid and PLAYER_TYPE_PHP_DATA[PLAYER_TYPE.ALL_MEMBER] or self.isMyMem,--搜索就在全部里面搜索,某个类别里面搜索,可能找不到人。
  1710. -- orderby = self.orderby,
  1711. -- sort = self.sort,
  1712. -- lastday = self.lastDay,
  1713. -- page = self.curPage,
  1714. -- suid = self.suid,
  1715. -- }
  1716. local localData ={
  1717. clubId = self.clubId,
  1718. viewType = ClubDefine.PlayListType.ALL_PEOPLE_MATCH_MANAGER,
  1719. type = 1,
  1720. muid = 0,
  1721. isMyMem = 0,--搜索就在全部里面搜索,某个类别里面搜索,可能找不到人。
  1722. orderby = "role",
  1723. sort = "desc",
  1724. lastday = 0,
  1725. page = 1,
  1726. suid = 0,
  1727. }
  1728. -- app.club_php:requestMatchManage(localData)
  1729. app.club_php:requestCestManage(localData)
  1730. else
  1731. --普通场
  1732. playerJson = {
  1733. clubId = self.clubInfo.clubId,
  1734. viewType = ClubDefine.PlayListType.NORMAL_MEMBER,
  1735. status = ClubDefine.PlayListType.NORMAL_MEMBER,
  1736. }
  1737. app.club_php:requestPlayerList(playerJson)
  1738. end
  1739. end
  1740. function ClubTable:onClubGpsDistanceCheck(data)
  1741. if not data then
  1742. return
  1743. end
  1744. local uid = data.uid
  1745. local userInfo = json.decode(data.userInfo)
  1746. local nickname = getShortName(userInfo.nickname)
  1747. local gpsDistance = data.gpsLimit
  1748. local content = "当前房间禁止"..tostring(gpsDistance).."米内玩家同桌,经检测,您与"..nickname.."的距离小于"..tostring(gpsDistance).."米,无法加入房间"
  1749. showConfirmDialog(content)
  1750. setIsAgainGamebol(false,"")
  1751. end
  1752. function ClubTable:changeScrollViewSize()
  1753. if self.clubInfo.mode == ClubDefine.BaoJianType.Normal then
  1754. self.ui.Items.ScrollView:setSize(cc.size(1280*g_radio_x, self.srcTableScrollowSize.height))
  1755. elseif self.clubInfo.mode == ClubDefine.BaoJianType.Multiple then
  1756. self.ui.Items.ScrollView:setSize(cc.size(1280*g_radio_x, self.srcTableScrollowSize.height))
  1757. elseif self.clubInfo.mode == ClubDefine.BaoJianType.ManyRooms then
  1758. self.ui.Items.ScrollView:setSize(cc.size(self.srcTableScrollowSize.width * g_radio_x, self.srcTableScrollowSize.height))
  1759. end
  1760. end
  1761. --设置通知
  1762. function ClubTable:onClubChangeEvent()
  1763. -- 茶馆名
  1764. local nickname = getShortNameByLength(self.clubInfo.clubName,5)
  1765. self.ui.Items.Text_name:setText(nickname)
  1766. -- 根据条件隐藏茶馆id
  1767. local cliext = self.clubInfo.groupext and self.clubInfo.groupext.cliext
  1768. if not cliext or not cliext.is_hideGid or (cliext and cliext.is_hideGid == 1) then
  1769. if tonumber(self.clubInfo.role) ~= ClubDefine.Job.Manager and tonumber(self.clubInfo.role) ~= ClubDefine.Job.Creator then
  1770. self.ui.Items.Text_id:setVisible(false)
  1771. if app.club_php:getCestIsOpen(self.clubId) then
  1772. self.ui.Items.Text_cest_id:setVisible(false)
  1773. end
  1774. end
  1775. else
  1776. self.ui.Items.Text_id:setVisible(true)
  1777. if app.club_php:getCestIsOpen(self.clubId) then
  1778. self.ui.Items.Text_cest_id:setVisible(true)
  1779. end
  1780. end
  1781. --刷新菜单按钮
  1782. self:setMenuButton()
  1783. --包间切换
  1784. self:changeScrollViewSize()
  1785. local gameId
  1786. local baoJianId
  1787. if self.clubInfo.mode == ClubDefine.BaoJianType.Normal then
  1788. gameId = self.clubInfo.settings.realGameId
  1789. baoJianId = self.clubInfo.settings.baoJianId
  1790. app.club_php:setSelectGameId(gameId or 0)
  1791. app.club_php:setSelectBaoJianId(baoJianId or 0)
  1792. end
  1793. self.ui.Items.Layout_baojian_touch:setVisible(false);
  1794. end
  1795. --点击包间列表
  1796. function ClubTable:onClickBaojianNormal()
  1797. local bVisble = self.ui.Items.Layout_baojian_touch:isVisible()
  1798. self.ui.Items.Layout_baojian_touch:setVisible(not bVisble)
  1799. if not self.baoJianView then
  1800. self.baoJianView = import("luaScript.Views.Club.ClubBaojian"):new(self.clubInfo.clubId)
  1801. self.ui.Items.Layout_baojian_normal:addChild(self.baoJianView);
  1802. end
  1803. end
  1804. --单包间-自己切换包间事件
  1805. function ClubTable:onClubChangeBaoJianEvent()
  1806. self.ui.Items.Layout_baojian_touch:setVisible(false)
  1807. local gameId = self.clubInfo.settings.gameId
  1808. local baoJianId = self.clubInfo.settings.baoJianId
  1809. app.club_php:setSelectGameId(gameId or 0)
  1810. app.club_php:setSelectBaoJianId(baoJianId or 0)
  1811. app.club_php:requestClubHome(self.clubInfo.clubId)
  1812. -- 每次切包间,都滚到最左边
  1813. self.ui.Items.ScrollView:jumpToLeft()
  1814. end
  1815. function ClubTable:updateTopBaoJianInfo()
  1816. if self.clubInfo.baoJians then
  1817. if self.clubInfo.mode == ClubDefine.BaoJianType.Normal then
  1818. local index = 0
  1819. local newBaoJians = app.club_php:getSortClubBaoJians(self.clubInfo.clubId)
  1820. for k,v in ipairs(newBaoJians) do
  1821. if tonumber(v.is_use) == 1 then
  1822. index = index + 1
  1823. end
  1824. if tonumber(v.baoJianId) == tonumber(self.clubInfo.settings.baoJianId) then
  1825. break
  1826. end
  1827. end
  1828. if self.clubInfo.settings.strGameRule then
  1829. local strGameRule = json.decode(self.clubInfo.settings.strGameRule)
  1830. local gamerule = strGameRule.gamerule or strGameRule.gameRule
  1831. local name = getSubGameRuleName(self.clubInfo.settings.realGameId,tonumber(gamerule))
  1832. self.ui.Items.Text_baojian:setText(tostring(name))
  1833. self.ui.Items.Layout_top_baojian_info:setVisible(true)
  1834. -- cest
  1835. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  1836. -- cest
  1837. self.ui.Items.ImageView_zhanji_line:setVisible(true)
  1838. self.ui.Items.Layout_btn_quick:setVisible(true)
  1839. end
  1840. else
  1841. self.ui.Items.Text_baojian:setText(tostring("未设置包间"))
  1842. end
  1843. if index ~= 0 then
  1844. self.ui.Items.Text_index:setText(tostring(index))
  1845. else
  1846. self.ui.Items.Layout_top_baojian_info:setVisible(false)
  1847. -- cest
  1848. self.ui.Items.ImageView_zhanji_line:setVisible(false)
  1849. self.ui.Items.Layout_btn_quick:setVisible(false)
  1850. end
  1851. elseif self.clubInfo.mode == ClubDefine.BaoJianType.Multiple or self.clubInfo.mode == ClubDefine.BaoJianType.ManyRooms then
  1852. self.ui.Items.Layout_top_baojian_info:setVisible(false)
  1853. -- cest
  1854. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  1855. -- self.ui.Items.ImageView_zhanji_line:setVisible(false)
  1856. -- self.ui.Items.Layout_btn_quick:setVisible(false)
  1857. end
  1858. end
  1859. local size = self.ui.Items.Layout_TextSize:getSize()
  1860. self.ui.Items.Layout_TextSize:setSize(cc.size(self.ui.Items.Text_baojian:getSize().width,size.height))
  1861. self.ui.Items.Layout_top_baojian_info:requestDoLayout()
  1862. self.ui.Items.Layout_top_baojian_info:doLayout()
  1863. end
  1864. end
  1865. -- 合伙人按钮点击事件
  1866. function ClubTable:onBtnHeHuoRenClicked()
  1867. playBtnEffect()
  1868. if self.clubInfo.clubId <= 0 then
  1869. showTooltip("请先选择" .. (app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_NAME or PLN.CLUB_NAME))
  1870. return
  1871. end
  1872. if tonumber(self.clubInfo.role) == ClubDefine.Job.Manager or tonumber(self.clubInfo.role) == ClubDefine.Job.Creator then
  1873. local view = import("luaScript.Views.Club.HeHuoRen.ClubHeHuoRenMain"):new(self.clubInfo.clubId)
  1874. view:setAnchorPoint(cc.p(0.5, 0.5))
  1875. app:showWaitDialog(view)
  1876. else
  1877. local view = import("luaScript.Views.Club.HeHuoRen.ClubHeHuoRenDetailed"):new(self.clubInfo, app.user.loginInfo.uid)
  1878. view:setAnchorPoint(cc.p(0.5, 0.5))
  1879. app:showWaitDialog(view)
  1880. end
  1881. end
  1882. -- 邀请按钮点击事件
  1883. -- @return
  1884. --
  1885. function ClubTable:onBtnInviteClicked()
  1886. playBtnEffect()
  1887. if self.clubInfo.clubId <= 0 then
  1888. showTooltip("请先选择" .. (app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_NAME or PLN.CLUB_NAME))
  1889. return
  1890. end
  1891. -- local gname = self.clubInfo.gname
  1892. -- local clubList = app.club_php.clubList
  1893. -- if clubList then
  1894. -- local clubInfo = clubList[tonumber(self.clubInfo.gid)]
  1895. -- if clubInfo then
  1896. -- gname = clubInfo.gname
  1897. -- end
  1898. -- end
  1899. local title = string.format("%s名称:%s", (app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_NAME or PLN.CLUB_NAME), self.clubInfo.clubName)
  1900. local content = string.format("可视化牌桌,不用自己开房就可以玩牌。");
  1901. local desc = string.format("%sID:%s\n%s", (app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_NAME or PLN.CLUB_NAME), self.clubInfo.clubId, content);
  1902. local info = {}
  1903. info.ClubID = self.clubInfo.clubId
  1904. info.title = title
  1905. info.description = desc
  1906. print("用户开始分享")
  1907. --需要显示的按钮(1:微信 2:复制 3:茶馆 )
  1908. if type(menuIdxs) ~= "table" then
  1909. info.menuIdxs = {1, 4, 5, 6}
  1910. end
  1911. if type(copyData) == "string" then
  1912. info.copyData = copyData
  1913. else
  1914. info.copyData = ""
  1915. end
  1916. dump(info)
  1917. local view = import("luaScript.Views.Main.ShareView"):new(info)
  1918. view:setAnchorPoint(cc.p(0.5, 0.5))
  1919. app:showWaitDialog(view)
  1920. end
  1921. -- 活动按钮点击事件
  1922. --
  1923. function ClubTable:onBtnActivityClicked()
  1924. playBtnEffect()
  1925. if self.clubInfo.clubId <= 0 then
  1926. showTooltip("请先选择" .. (app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_NAME or PLN.CLUB_NAME))
  1927. return
  1928. end
  1929. local clubId = self.clubInfo.clubId
  1930. app.club_php:requestClubOfficialActivity(clubId)
  1931. end
  1932. ---
  1933. -- 初始化广播条
  1934. -- @return
  1935. --
  1936. function ClubTable:initBoradcastView(noticeList)
  1937. if not self._broadcastView then
  1938. local ClubBroadcastView = require("luaScript.Views.Club.ClubBroadcastView")
  1939. self._broadcastView = ClubBroadcastView:new()
  1940. self.ui.Items.Layout_Broadcast:addChild(self._broadcastView)
  1941. end
  1942. self._broadcastView:setBroadcastList(noticeList)
  1943. end
  1944. function ClubTable:updateTable(event)
  1945. local showRooms, hideRooms = app.club_php:getShowRooms(nil, nil)
  1946. for kk, vv in pairs(hideRooms or {}) do
  1947. local pos = vv.pos
  1948. for k,v in pairs(self.allTableItem or {}) do
  1949. local idx = v:getTableIdx()
  1950. if idx == pos then
  1951. logD("ClubTable:updateTable 删除桌子 ", k, idx)
  1952. v:removeSelf()
  1953. self.allTableItem[k] = nil
  1954. end
  1955. end
  1956. end
  1957. end
  1958. function ClubTable:onClubUnionHintsUpdateEvent()
  1959. self.ui.Items.ImageView_union_dian:setVisible(self.clubInfo.isUnionHints)
  1960. end
  1961. -- function ClubTable:initClubCest()
  1962. -- self.ui.Items.Layout_Mid:setVisible(false);
  1963. -- self.ui.Items.Layout_Cest:setVisible(true);
  1964. -- --隐藏桌数
  1965. -- self.ui.Items.Layout_look_table:setVisible(false)
  1966. -- self:initClubCestRule()
  1967. -- self:initClubCestChange()
  1968. -- end
  1969. -- function ClubTable:initClubCestRule()
  1970. -- self.ui.Items.Text_rule:setVisible(false);
  1971. -- self.ui.Items.ScrollView_rule:hideAllBar()
  1972. -- self.ui.Items.ScrollView_rule:getInnerContainer():setAutoSize(true)
  1973. -- local mListView = self.ui.Items.ScrollView_rule
  1974. -- mListView:removeAllChildren()
  1975. -- local content = {
  1976. -- "1、玩家根据自己的竞技能力,可自主报名参与对应的比赛场;\n",
  1977. -- "2、报名成功后,可获得该场的初始积分和参赛券;\n",
  1978. -- "3、每参与一场比赛,消耗一定数量参赛券,比赛积分低于淘汰分或参赛券不足时,需本轮比赛结束,将本轮成绩更新到海选赛排行榜上后,可重新参与新一轮比赛;\n",
  1979. -- "4、海选赛排行榜实时更新,以选手每天上报的最高好绩进行排名,为保证自己的最好成绩,选手可提前申请结束本轮比赛,保存本轮比赛成绩;\n",
  1980. -- "5、海选赛排行榜24:00停止刷新,确定最终排名,取排行榜前50名,分别奖励50-1分的天梯赛分和CEST商城兑换积分;\n",
  1981. -- "6、获得天梯赛排名可参与CEST专业赛事,CEST商城兑换积分,可到商城中兑换礼物\n",
  1982. -- }
  1983. -- for k,v in ipairs(content) do
  1984. -- local item = self.ui.Items.Text_rule:getCopied()
  1985. -- item:setString(v)
  1986. -- mListView:addChild(item,0);
  1987. -- end
  1988. -- mListView:requestDoLayout()
  1989. -- mListView:doLayout()
  1990. -- mListView:jumpToTopOnSizeChanged()
  1991. -- end
  1992. -- function ClubTable:initClubCestChange()
  1993. -- self.ui.Items.Button_baoming_1:registerClick(handler(self , self.onCestRequestBaoming))
  1994. -- self.ui.Items.Button_baoming_2:registerClick(handler(self , self.onCestRequestBaoming))
  1995. -- self.ui.Items.Button_baoming_3:registerClick(handler(self , self.onCestRequestBaoming))
  1996. -- end
  1997. -- -- 报名参加
  1998. -- function ClubTable:onCestRequestBaoming(_change)
  1999. -- -- local localData ={
  2000. -- -- clubId = self.clubId,
  2001. -- -- viewType = self.viewType,
  2002. -- -- type = self.type,
  2003. -- -- muid = self.muid,
  2004. -- -- isMyMem = self.suid and PLAYER_TYPE_PHP_DATA[PLAYER_TYPE.ALL_MEMBER] or self.isMyMem,--搜索就在全部里面搜索,某个类别里面搜索,可能找不到人。
  2005. -- -- orderby = self.orderby,
  2006. -- -- sort = self.sort,
  2007. -- -- lastday = self.lastDay,
  2008. -- -- page = self.curPage,
  2009. -- -- suid = self.suid,
  2010. -- -- }
  2011. -- -- app.club_php:requestMatchManage(localData)
  2012. -- self:onCloseCestApplyLayer()
  2013. -- end
  2014. -- function ClubTable:onCloseCestApplyLayer()
  2015. -- self.ui.Items.Layout_Cest:setVisible(false);
  2016. -- end
  2017. -- function ClubTable:onUpdateCestInfo()
  2018. -- -- if self.clubInfo.memberInfo then
  2019. -- local memberInfo = self.clubInfo.memberInfo
  2020. -- self.ui.Items.Text_chongbangfen:setText(tostring(memberInfo.warnum))
  2021. -- self.ui.Items.TextBMFont:setText(tostring(self.clubInfo.groupLevel))
  2022. -- -- end
  2023. -- end
  2024. return ClubTable