|
- -- 战绩单元Layout
- local MJWanFa=MJFramework.ImportWanFa("MaJiang.MJWanFa")
-
- local MJRoomListItemView = class("MJRoomListItemView", cc.UIView)
-
- function MJRoomListItemView:ctor(data)
- self.ui = loadUI("mj/res/ui/ui_dating/mj_room_list_Item.ui")
-
- self.listInfo = data
- self:init()
- end
-
-
- function MJRoomListItemView:init()
- -- 监听事件
- self:bindEvent(app.hall , "onJoinRoomResponse", handler(self , self.onJoinRoomResponse));
-
- self.ui.Items.Button_Invite:registerClick(handler(self,self.onClickInvite))
-
-
- self.ui.Items.Text_RoomNum:setText(tostring(self.listInfo.nShowTableId))
-
- if isReviewVersion() then
- self.ui.Items.Button_Invite:setVisible(false);
- end
-
- local crateRoomInfo = json.decode(self.listInfo.strGameInfo)
-
- self.ui.Items.Text_Rule:setText(MJWanFa.getWanFaName("playmode",crateRoomInfo.playmode))--tostring(LHQ_CreateRoom_scoreRule[crateRoomInfo.scoreRule]))
-
- self.ui.Items.Text_JuShu:setText(tostring(self.listInfo.nTotalGameNum))
-
- self.ui.Items.Text_People:setText(tostring(self.listInfo.nUserCount.."/"..self.listInfo.nMaxUserCount))
-
- self.ui.Items.ImageView_Line:setTouchEnabled(true)
- self.ui.Items.ImageView_Line:registerClick(handler(self,self.onJoinRoom))
-
- self.ui.Items.ImageView_Full:setVisible(false)
- if self.listInfo.nUserCount == self.listInfo.nMaxUserCount then
- self.ui.Items.ImageView_Full:setVisible(true)
- self.ui.Items.Button_Invite:setVisible(false)
- end
- end
-
-
- function MJRoomListItemView:getRoot()
- return self.ui
- end
-
-
- -- 邀请按钮按钮
- function MJRoomListItemView:onClickInvite()
- playBtnEffect()
- -- local crateRoomInfo = json.decode(self.listInfo.strGameInfo)
- local tt =
- {
- [0] = "零缺三",
- [1] = "一缺二",
- [2] = "二缺一",
- [3] = "满座",
- }
- local num = self.listInfo.nUserCount
- local strNum = tt[num]
- --根据游戏类型分享
- local title = string.format("%s 房号[%s] %s", "红中麻将",self.listInfo.nShowTableId,strNum)
-
- local strGameNum = string.format("%s局", self.listInfo.nTotalGameNum)
-
- local ruleStr = MJWanFa.getWanFaInfo(self.listInfo.strGameInfo)--""
- -- ruleStr = ruleStr..(LHQ_GAME_CONST_WANFA[crateRoomInfo.gamerule] or "").." "
- -- ruleStr = ruleStr..(LHQ_CreateRoom_scoreRule[crateRoomInfo.scoreRule] or "").." "
- -- ruleStr = ruleStr..(LHQ_CreateRoom_HuType[crateRoomInfo.huShu] or "").." "
- -- --玩法
- -- local spec = crateRoomInfo.specRule
- -- if spec > 0 then
- -- local strSpec = ""
- -- local ret = getNumBand(spec,LHQ_CreateRoomWanFa.DI_FEN_TWO)
- -- if ret > 0 then
- -- strSpec = strSpec..LHQ_CreateRoom_specialRule[LHQ_CreateRoomWanFa.DI_FEN_TWO].." "
- -- end
- -- local ret = getNumBand(spec,LHQ_CreateRoomWanFa.SUPPORT_ONE_FIVE_TEN)
- -- if ret > 0 then
- -- strSpec = strSpec..LHQ_CreateRoom_specialRule[LHQ_CreateRoomWanFa.SUPPORT_ONE_FIVE_TEN].." "
- -- end
- -- local ret = getNumBand(spec,LHQ_CreateRoomWanFa.SHAO_SHOW_CARD)
- -- if ret > 0 then
- -- strSpec = strSpec..LHQ_CreateRoom_specialRule[LHQ_CreateRoomWanFa.SHAO_SHOW_CARD].." "
- -- end
- -- ruleStr = ruleStr..strSpec..""
- -- end
- -- ruleStr = ruleStr..(LHQ_CreateRoom_MingTang[crateRoomInfo.multiRule] or "").." "
- -- ruleStr = ruleStr..(LHQ_CreateRoom_XingType[crateRoomInfo.xingType] or "")
-
- local desc = string.format("%s,%s", strGameNum, ruleStr)
- print(desc)
-
- local imagePath = cc.FileUtils:getInstance():getWritablePath().."icon.png"
-
- local info = {}
- info.scene = "talk"
- info.contentType = "url"
- info.url = app.config.Setting.appDownloadUrl
- info.title = title
- info.description = desc
- info.image = imagePath
- info.imageWidth = 100
-
- app.plugin:shareGame(info)
- end
-
- -- 加入按钮
- function MJRoomListItemView:onJoinRoom()
- playBtnEffect()
-
- local request = JoinRoomRequest:new()
- request.gameId = app.gameId;
- request.inputTid = self.listInfo.nShowTableId;
-
- app.hall:requestJoinRoom(app.gameId, self.listInfo.nShowTableId)
- end
-
- function MJRoomListItemView:onJoinRoomResponse(event)
- if not event then
- return
- end
- local errCode = event.errCode
- if errCode ~= 0 then
- local errString = ENTER_ROOM_RET_STR[errCode] or "房间不存在"
- showTooltip(errString);
- app.hall:dispatchEvent({name = "requestRoomList"});
- end
- end
-
-
-
-
- return MJRoomListItemView
|