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.

137 lines
4.1 KiB

  1. -- 战绩单元Layout
  2. local MJWanFa=MJFramework.ImportWanFa("MaJiang.MJWanFa")
  3. local MJRoomListItemView = class("MJRoomListItemView", cc.UIView)
  4. function MJRoomListItemView:ctor(data)
  5. self.ui = loadUI("mj/res/ui/ui_dating/mj_room_list_Item.ui")
  6. self.listInfo = data
  7. self:init()
  8. end
  9. function MJRoomListItemView:init()
  10. -- 监听事件
  11. self:bindEvent(app.hall , "onJoinRoomResponse", handler(self , self.onJoinRoomResponse));
  12. self.ui.Items.Button_Invite:registerClick(handler(self,self.onClickInvite))
  13. self.ui.Items.Text_RoomNum:setText(tostring(self.listInfo.nShowTableId))
  14. if isReviewVersion() then
  15. self.ui.Items.Button_Invite:setVisible(false);
  16. end
  17. local crateRoomInfo = json.decode(self.listInfo.strGameInfo)
  18. self.ui.Items.Text_Rule:setText(MJWanFa.getWanFaName("playmode",crateRoomInfo.playmode))--tostring(LHQ_CreateRoom_scoreRule[crateRoomInfo.scoreRule]))
  19. self.ui.Items.Text_JuShu:setText(tostring(self.listInfo.nTotalGameNum))
  20. self.ui.Items.Text_People:setText(tostring(self.listInfo.nUserCount.."/"..self.listInfo.nMaxUserCount))
  21. self.ui.Items.ImageView_Line:setTouchEnabled(true)
  22. self.ui.Items.ImageView_Line:registerClick(handler(self,self.onJoinRoom))
  23. self.ui.Items.ImageView_Full:setVisible(false)
  24. if self.listInfo.nUserCount == self.listInfo.nMaxUserCount then
  25. self.ui.Items.ImageView_Full:setVisible(true)
  26. self.ui.Items.Button_Invite:setVisible(false)
  27. end
  28. end
  29. function MJRoomListItemView:getRoot()
  30. return self.ui
  31. end
  32. -- 邀请按钮按钮
  33. function MJRoomListItemView:onClickInvite()
  34. playBtnEffect()
  35. -- local crateRoomInfo = json.decode(self.listInfo.strGameInfo)
  36. local tt =
  37. {
  38. [0] = "零缺三",
  39. [1] = "一缺二",
  40. [2] = "二缺一",
  41. [3] = "满座",
  42. }
  43. local num = self.listInfo.nUserCount
  44. local strNum = tt[num]
  45. --根据游戏类型分享
  46. local title = string.format("%s 房号[%s] %s", "红中麻将",self.listInfo.nShowTableId,strNum)
  47. local strGameNum = string.format("%s局", self.listInfo.nTotalGameNum)
  48. local ruleStr = MJWanFa.getWanFaInfo(self.listInfo.strGameInfo)--""
  49. -- ruleStr = ruleStr..(LHQ_GAME_CONST_WANFA[crateRoomInfo.gamerule] or "").." "
  50. -- ruleStr = ruleStr..(LHQ_CreateRoom_scoreRule[crateRoomInfo.scoreRule] or "").." "
  51. -- ruleStr = ruleStr..(LHQ_CreateRoom_HuType[crateRoomInfo.huShu] or "").." "
  52. -- --玩法
  53. -- local spec = crateRoomInfo.specRule
  54. -- if spec > 0 then
  55. -- local strSpec = ""
  56. -- local ret = getNumBand(spec,LHQ_CreateRoomWanFa.DI_FEN_TWO)
  57. -- if ret > 0 then
  58. -- strSpec = strSpec..LHQ_CreateRoom_specialRule[LHQ_CreateRoomWanFa.DI_FEN_TWO].." "
  59. -- end
  60. -- local ret = getNumBand(spec,LHQ_CreateRoomWanFa.SUPPORT_ONE_FIVE_TEN)
  61. -- if ret > 0 then
  62. -- strSpec = strSpec..LHQ_CreateRoom_specialRule[LHQ_CreateRoomWanFa.SUPPORT_ONE_FIVE_TEN].." "
  63. -- end
  64. -- local ret = getNumBand(spec,LHQ_CreateRoomWanFa.SHAO_SHOW_CARD)
  65. -- if ret > 0 then
  66. -- strSpec = strSpec..LHQ_CreateRoom_specialRule[LHQ_CreateRoomWanFa.SHAO_SHOW_CARD].." "
  67. -- end
  68. -- ruleStr = ruleStr..strSpec..""
  69. -- end
  70. -- ruleStr = ruleStr..(LHQ_CreateRoom_MingTang[crateRoomInfo.multiRule] or "").." "
  71. -- ruleStr = ruleStr..(LHQ_CreateRoom_XingType[crateRoomInfo.xingType] or "")
  72. local desc = string.format("%s,%s", strGameNum, ruleStr)
  73. print(desc)
  74. local imagePath = cc.FileUtils:getInstance():getWritablePath().."icon.png"
  75. local info = {}
  76. info.scene = "talk"
  77. info.contentType = "url"
  78. info.url = app.config.Setting.appDownloadUrl
  79. info.title = title
  80. info.description = desc
  81. info.image = imagePath
  82. info.imageWidth = 100
  83. app.plugin:shareGame(info)
  84. end
  85. -- 加入按钮
  86. function MJRoomListItemView:onJoinRoom()
  87. playBtnEffect()
  88. local request = JoinRoomRequest:new()
  89. request.gameId = app.gameId;
  90. request.inputTid = self.listInfo.nShowTableId;
  91. app.hall:requestJoinRoom(app.gameId, self.listInfo.nShowTableId)
  92. end
  93. function MJRoomListItemView:onJoinRoomResponse(event)
  94. if not event then
  95. return
  96. end
  97. local errCode = event.errCode
  98. if errCode ~= 0 then
  99. local errString = ENTER_ROOM_RET_STR[errCode] or "房间不存在"
  100. showTooltip(errString);
  101. app.hall:dispatchEvent({name = "requestRoomList"});
  102. end
  103. end
  104. return MJRoomListItemView