|
- -- 战绩单元Layout
-
- local MJZhanJiItem = class("MJZhanJiItem")
-
- function MJZhanJiItem:ctor(zhanjiInfo, showBtnShare)
- self.zhanjiInfo = zhanjiInfo
-
- logI(table.tostring(self.roomInfo))
-
- self.showBtnShare = showBtnShare;
- self.gameRule = tonumber(zhanjiInfo.gext.gamerule) or 0
-
- self.ui = loadUI("mj/res/ui/ui_zhanji/mj_dt_zhanji_tiao.ui")
- self:initView()
- end
-
- function MJZhanJiItem:initView()
-
- -- 详情按钮
- self.ui.Items.Button_xiangqing:registerClick(handler(self, self.onClickDetails))
-
- -- 分享按钮
- -- self.ui.Items.Button_Share:registerClick(handler(self, self.onClickShare))
- -- self.ui.Items.Button_Share:setVisible(self.showBtnShare == true)
-
- --ui展示
- --房号
- local roomid = self.zhanjiInfo.roomid.."("..self.zhanjiInfo.fbound.."/"..self.zhanjiInfo.nbound..")";
- self.ui.Items.Text_RoomNum:setText(roomid);
-
- --时间
- local time = os.date("%Y-%m-%d %H:%M",self.zhanjiInfo.endtime)
- self.ui.Items.Text_time:setText(time)
-
-
- -- 所有的玩家
- local index=1
- -- local uiPlayers = self.ui.Items.Layout_Players
- for uid, score in pairs(self.zhanjiInfo.tscore) do
- local playerInfo = app.playerInfoManager:getPlayerInfo(uid)
- if playerInfo then
- -- 名称
- local name=playerInfo.name and getSubStringNickname(playerInfo.name) or ""
- self.ui.Items["name_"..index]:setText(name)
-
- end
-
- --分数
- self.ui.Items["score_"..index]:setText(score)
-
- index=index+1
- end
-
- for i=1,4 do
- if index-1<i then
- self.ui.Items["Layout_"..i]:setVisible(false)
- end
- end
- end
-
-
- -- 分享
- function MJZhanJiItem:onClickShare()
- playBtnEffect()
- local fileName = cc.FileUtils:getInstance():getWritablePath().."zhanji_"..tostring(self.zhanjiInfo.roomid).."_screen.jpg"
-
- cc.FileUtils:getInstance():screenToFile(fileName, function(ret)
- if 1 == tonumber(ret) then
- local info = {}
- info.scene = "talk"
- info.contentType = "image"
- info.image = fileName
- info.imageWidth = 1000
- info.thumbWidth = 100
- app.plugin:shareGame(info)
-
- else
- showTooltip("截图保存失败");
- end
- end );
- end
-
- -- 详情按钮
- function MJZhanJiItem:onClickDetails()
- playBtnEffect()
- local protocolZhanJi = app:getProtocolZhanJi(app.gameId)
- if protocolZhanJi then
- local function showDanJuView()
- local view = import("mj.luaScript.Views.Zhanji.MJZhanJiDanJuView"):new(self.zhanjiInfo)
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view)
- end
- protocolZhanJi:getZhanJiDetail(self.zhanjiInfo.pid, 0, showDanJuView)
- end
- end
-
- return MJZhanJiItem
|