|
- local MJDefine = MJFramework.MJImport("mj.luaScript.MJDefine")
-
- local MJOtherPlayerInfoView = class("MJOtherPlayerInfoView", cc.UIView)
-
-
- function MJOtherPlayerInfoView:ctor(nUserId)
- MJOtherPlayerInfoView.super.ctor(self);
-
- self.nUserId=nUserId
-
- local ui = loadUI("mj/res/ui/ui_fangjian/mj_ui_other_player_info.ui")
- self.ui = ui
- self:addChild(ui)
- end
-
- function MJOtherPlayerInfoView:onEnter()
- MJOtherPlayerInfoView.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.ui.Items.Text_Ip:setText("")
-
-
- self.ui.Items.Button_Voice:registerClick(function ()
- playBtnEffect()
- app.room:dispatchEvent({name = MJDefine.MJEvent.ReplayPlayerVoice, nUserId = self.nUserId})
- end)
-
- self:initProps()
- end
-
- function MJOtherPlayerInfoView:initProps()
- -- local nSeatShowId=app.room:getViewIdByUserId(self.nUserId)
- self.lastPropTouchTime = tonumber(loadUserInfo("lastPropTouchTime")) or 0
- saveUserInfo("lastPropTouchTime",self.lastPropTouchTime)
-
-
- if self.nUserId~=app.user.loginInfo.uid then
- self.ui.Items.ImageView_All_Send:setVisible(false)
- end
-
-
- self.ui.Items.ListView:setItemModel(self.ui.Items.Layout_Prop_Item)
- self.ui.Items.ListView:removeAllItems()
-
- --道具实现
- local tabProp={10,9,4,2,3,5,1,7,6,8}
- for i = 1 ,10 do
- self.ui.Items.ListView:pushBackDefaultItem()
- local item=self.ui.Items.ListView:getItem(i-1)
- local btnProp = item:getChildByName("Button_Prop") --string.format("Button_Prop_%d",i)
- btnProp:loadTextureNormal("mj_prop"..tabProp[i]..".png", cc.TextureResType.plistType)
- btnProp: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 self.nUserId == app.user.loginInfo.uid then
- --群发道具
- --根据在线人数发送道具
- local propID = tabProp[i]
- --local targetUid = app.room:getUserIdByViewId(nSeatShowId)
- self:SendPropMessage(app.user.loginInfo.uid,self.nUserId,propID,4,1)
- else
- local propID = tabProp[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 MJOtherPlayerInfoView: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 MJOtherPlayerInfoView;
|