|
- -- 战绩单元Layout
-
- local ZPZhanJiItem = class("ZPZhanJiItem")
-
- --[[
- 显示某个战绩的结算信息。
- 主要是显示房间内每个玩家的基本信息和输赢情况,以及大赢家、土豪等标签
- --]]
-
- function ZPZhanJiItem:ctor(zhanjiInfo)
- logD("sortZhanji zhanjiInfo = ", table.tostring(zhanjiInfo))
- self.zhanjiInfo = zhanjiInfo;
- self.gameRule = tonumber(zhanjiInfo.gext.gamerule) or 0
-
- self.ui = loadUI("zp_base/res/ui/ui_zhanji/zipai_dt_zhanji_tiao.ui")
-
- self:initView()
- end
-
- --初始化界面
- function ZPZhanJiItem:initView()
-
- -- 清空数据
- self.ui.Items.Layout_Players:removeAllChildren();
-
- -- 校验数据
- if not self.zhanjiInfo or not self.zhanjiInfo.tscore or table.nums(self.zhanjiInfo.tscore) <= 0 then
- return
- end
-
- -- 房号
- -- 局数
- local juShu = string.format("%d/%d",tostring(self.zhanjiInfo.fbound), tostring(self.zhanjiInfo.nbound))
- local str1 = tostring(self.zhanjiInfo.roomid).."("..juShu.."局)"
- self.ui.Items.Text_RoomNum:setText(str1)
- -- 时间
- local timeString = os.date("%Y-%m-%d %H:%M",self.zhanjiInfo.endtime)
- self.ui.Items.Text_time:setText(timeString)
-
- -- 详情按钮
- self.ui.Items.Button_xiangqing:registerClick(handler(self, self.onClickDetail))
-
- -- 所有的玩家
- local uiPlayers = self.ui.Items.Layout_Players
- for uid, score in pairs(self.zhanjiInfo.tscore) do
- local item = import("zp_base.luaScript.Views.ZhanJi.ZPZhanJiPlayer"):new(self.gameRule, uid, score)
- if item and item.ui then
- uiPlayers:addChild(item.ui)
- end
- end
- end
-
- -- 分享
- function ZPZhanJiItem: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 ZPZhanJiItem:onClickDetail()
- local protocolZhanJi = app:getProtocolZhanJi(app.gameId)
- if protocolZhanJi then
- local view = import("zp_base.luaScript.Views.ZhanJi.ZPDanJuView"):new(self.zhanjiInfo)
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view)
- end
- end
-
- return ZPZhanJiItem
|