您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

131 行
3.5 KiB

  1. local MJDefine = MJFramework.MJImport("mj.luaScript.MJDefine")
  2. local MJMyInfoView = class("MJMyInfoView", cc.UIView)
  3. function MJMyInfoView:ctor(nUserId)
  4. MJMyInfoView.super.ctor(self);
  5. self.nUserId=nUserId
  6. local ui = loadUI("mj/res/ui/ui_fangjian/mj_ui_my_info.ui")
  7. self.ui = ui
  8. self:addChild(ui)
  9. end
  10. function MJMyInfoView:onEnter()
  11. MJMyInfoView.super.onEnter(self)
  12. self.ui.Items.Layout_Player_Info:setTouchEnabled(true)
  13. --更新头像
  14. local userInfo = app.room:getUserInfo(self.nUserId)
  15. local nickname = ""
  16. if userInfo and userInfo.nickname then
  17. nickname = getSubStringNickname(userInfo.nickname)
  18. -- self:updateUserHead(self.ui,v.nUserId, userInfo.sex, userInfo.headimgurl);
  19. setPlayerHeadImage(self.nUserId,userInfo.headimgurl,self.ui.Items.ImageView_Head)
  20. -- self.ui.Items.Text_Ip:setText("IP:"..userInfo.ip)
  21. end
  22. self.ui.Items.Text_Name:setText(nickname)
  23. self.ui.Items.Text_Id:setText("ID:"..self.nUserId)
  24. self:initProps()
  25. end
  26. function MJMyInfoView:initProps()
  27. local nSeatShowId=app.room:getViewIdByUserId(self.nUserId)
  28. self.lastPropTouchTime = tonumber(loadUserInfo("lastPropTouchTime")) or 0
  29. saveUserInfo("lastPropTouchTime",self.lastPropTouchTime)
  30. --道具实现
  31. for i = 1 ,5 do
  32. local name = string.format("Button_Prop_%d",i)
  33. self.ui.Items[name]:registerClick(function ()
  34. playBtnEffect()
  35. if app.room.isOnLooker then
  36. showTooltip("旁观不允许发送道具")
  37. return
  38. end
  39. if table.nums(app.room.roomInfo.memberList) == 1 then
  40. showTooltip("桌子上没有其他人可以发哦")
  41. return
  42. end
  43. local curTime = os.time()
  44. local distance = curTime - self.lastPropTouchTime
  45. local disbandTime = 12
  46. if distance <= disbandTime then
  47. showTooltip(string.format("您操作太快,请%d秒后再试!",disbandTime - distance + 1))
  48. return
  49. end
  50. self.lastPropTouchTime = curTime
  51. saveUserInfo("lastPropTouchTime",self.lastPropTouchTime)
  52. if nSeatShowId == MJDefine.MyViewId then
  53. --群发道具
  54. --根据在线人数发送道具
  55. local propID = i
  56. --local targetUid = app.room:getUserIdByViewId(nSeatShowId)
  57. self:SendPropMessage(app.user.loginInfo.uid,self.nUserId,propID,4,1)
  58. else
  59. local propID = i
  60. --local targetUid = app.room:getUserIdByViewId(nSeatShowId)
  61. if not self.nUserId then
  62. showTooltip("道具:目标ID不存在")
  63. return
  64. end
  65. self:SendPropMessage(app.user.loginInfo.uid,self.nUserId,propID,4,0)
  66. end
  67. end)
  68. end
  69. end
  70. function MJMyInfoView:SendPropMessage(uidStarId,uidEndId,propId,mType,isQunFa)
  71. -- self:onClickBG()
  72. if not app.user:canSendChatMessage(1) then
  73. showTooltip("您发送聊天信息的间隔时间太短,请稍后再发!")
  74. return
  75. end
  76. local sexId = 0
  77. local memberInfo = app.room.roomInfo.memberList[app.user.loginInfo.uid]
  78. if memberInfo then
  79. local userInfo = json.decode(memberInfo.userInfo)
  80. if not userInfo then
  81. return
  82. end
  83. --男1女2,默认是男生
  84. sexId = tonumber(userInfo.sex) or 1
  85. end
  86. local tt = json.decode(app.user.userInfo)
  87. local data =
  88. {
  89. uidStarId = uidStarId,
  90. uidEndId = uidEndId,
  91. propId = propId,
  92. isQunFa = isQunFa,
  93. areano = tt.areano,
  94. }
  95. -- 发送消息到服务器
  96. --1: 表情 2: 语音 3:聊天
  97. local str = json.encode(data)
  98. local isSendSuccess = app.user:sendChatMessage(mType, str);
  99. --[[if isSendSuccess == true then
  100. if mType == 4 then
  101. self:showProp(uidStarId, uidEndId,propId,isQunFa)
  102. end
  103. end--]]
  104. end
  105. return MJMyInfoView;