|
- local MJDefine = MJFramework.MJImport("mj.luaScript.MJDefine")
-
- local MJMyInfoView = class("MJMyInfoView", cc.UIView)
-
-
- function MJMyInfoView:ctor(nUserId)
- MJMyInfoView.super.ctor(self);
-
- self.nUserId=nUserId
-
- local ui = loadUI("mj/res/ui/ui_fangjian/mj_ui_my_info.ui")
- self.ui = ui
- self:addChild(ui)
- end
-
- function MJMyInfoView:onEnter()
- MJMyInfoView.super.onEnter(self)
-
- self.ui.Items.Layout_Player_Info:setTouchEnabled(true)
-
- --更新头像
- local userInfo = app.room:getUserInfo(self.nUserId)
- local nickname = ""
- if userInfo and userInfo.nickname then
- nickname = getSubStringNickname(userInfo.nickname)
- -- self:updateUserHead(self.ui,v.nUserId, userInfo.sex, userInfo.headimgurl);
- setPlayerHeadImage(self.nUserId,userInfo.headimgurl,self.ui.Items.ImageView_Head)
-
- -- self.ui.Items.Text_Ip:setText("IP:"..userInfo.ip)
- end
-
- self.ui.Items.Text_Name:setText(nickname)
- self.ui.Items.Text_Id:setText("ID:"..self.nUserId)
-
-
-
-
- self:initProps()
- end
-
- function MJMyInfoView:initProps()
- local nSeatShowId=app.room:getViewIdByUserId(self.nUserId)
- self.lastPropTouchTime = tonumber(loadUserInfo("lastPropTouchTime")) or 0
- saveUserInfo("lastPropTouchTime",self.lastPropTouchTime)
-
- --道具实现
- for i = 1 ,5 do
- local name = string.format("Button_Prop_%d",i)
- self.ui.Items[name]:registerClick(function ()
- playBtnEffect()
- if app.room.isOnLooker then
- showTooltip("旁观不允许发送道具")
- return
- end
- if table.nums(app.room.roomInfo.memberList) == 1 then
- showTooltip("桌子上没有其他人可以发哦")
- return
- end
- local curTime = os.time()
- local distance = curTime - self.lastPropTouchTime
- local disbandTime = 12
- if distance <= disbandTime then
- showTooltip(string.format("您操作太快,请%d秒后再试!",disbandTime - distance + 1))
- return
- end
- self.lastPropTouchTime = curTime
- saveUserInfo("lastPropTouchTime",self.lastPropTouchTime)
-
- if nSeatShowId == MJDefine.MyViewId then
- --群发道具
- --根据在线人数发送道具
- local propID = i
- --local targetUid = app.room:getUserIdByViewId(nSeatShowId)
- self:SendPropMessage(app.user.loginInfo.uid,self.nUserId,propID,4,1)
- else
- local propID = i
- --local targetUid = app.room:getUserIdByViewId(nSeatShowId)
- if not self.nUserId then
- showTooltip("道具:目标ID不存在")
- return
- end
- self:SendPropMessage(app.user.loginInfo.uid,self.nUserId,propID,4,0)
- end
- end)
- end
- end
-
-
- function MJMyInfoView:SendPropMessage(uidStarId,uidEndId,propId,mType,isQunFa)
- -- self:onClickBG()
-
- if not app.user:canSendChatMessage(1) then
- showTooltip("您发送聊天信息的间隔时间太短,请稍后再发!")
- return
- end
-
- local sexId = 0
- local memberInfo = app.room.roomInfo.memberList[app.user.loginInfo.uid]
- if memberInfo then
- local userInfo = json.decode(memberInfo.userInfo)
- if not userInfo then
- return
- end
- --男1女2,默认是男生
- sexId = tonumber(userInfo.sex) or 1
- end
- local tt = json.decode(app.user.userInfo)
-
- local data =
- {
- uidStarId = uidStarId,
- uidEndId = uidEndId,
- propId = propId,
- isQunFa = isQunFa,
- areano = tt.areano,
- }
-
- -- 发送消息到服务器
- --1: 表情 2: 语音 3:聊天
- local str = json.encode(data)
- local isSendSuccess = app.user:sendChatMessage(mType, str);
- --[[if isSendSuccess == true then
- if mType == 4 then
- self:showProp(uidStarId, uidEndId,propId,isQunFa)
- end
- end--]]
- end
-
-
-
- return MJMyInfoView;
|