Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

335 рядки
9.7 KiB

  1. -- 总结算界面
  2. local PKDef = PKFramework.PKImport("pk_base.luaScript.PKDef")
  3. local PKFuc = PKFramework.PKImport("pk_base.luaScript.PKFunctions")
  4. local PKWanFa = PKFramework.ImportWanFa("luaScript.SubGameDefine.PuKe.PKWanFa")
  5. local PKRoomDaJuView = class("PKRoomDaJuView", cc.UIView)
  6. function PKRoomDaJuView:ctor(response)
  7. PKRoomDaJuView.super.ctor(self);
  8. self.response = response
  9. self.zhanjiUrl = app.serverConfigs.clientConfig.webgamb or app.config.Setting.httpZhanJiUrl
  10. end
  11. function PKRoomDaJuView:onEnter()
  12. PKRoomDaJuView.super.onEnter(self)
  13. setShowCountAll(true);
  14. local ui = loadUI("pk_base/res/ui/ui_fangjian/pk_ui_daju.ui");
  15. self.ui = ui;
  16. self:addChild(ui);
  17. -- 关闭
  18. self.ui.Items.Button_Exit:registerClick(handler(self , self.onClickClose))
  19. -- 防封群分享
  20. self.ui.Items.Button_ShareUrl:registerClick(handler(self , self.onClickSafeShare))
  21. --
  22. self.ui.Items.Button_Share:registerClick(handler(self , self.onClickShare))
  23. --再玩一局
  24. self.ui.Items.Button_Again:registerClick(handler(self , self.onClickPlayAgain))
  25. if isReviewVersion() then
  26. if self.ui.Items.Layout_6 then
  27. self.ui.Items.Layout_6:setVisible(false)
  28. end
  29. if self.ui.Items.Layout_8 then
  30. self.ui.Items.Layout_8:setVisible(false)
  31. end
  32. end
  33. local isClosePlayAgain = false
  34. local config = getSubGameConfig(PKDef.GameID)
  35. if config then
  36. if config.gameDataConfig and config.gameDataConfig.isClosePlayAgain then
  37. isClosePlayAgain = config.gameDataConfig.isClosePlayAgain
  38. end
  39. end
  40. if app.club_php.clubID and app.club_php.clubID ~= 0 and not isClosePlayAgain then
  41. self.ui.Items.Layout_9:setVisible(true)
  42. self.clubInfo = app.club_php.clubList[app.club_php.clubID]
  43. local againid = getAgainGameBaoJianId()
  44. if self.clubInfo then
  45. if againid ~= -1 and self.clubInfo.settings and tonumber(self.clubInfo.settings.baoJianId) ~= tonumber(againid) and self.clubInfo.mode ~= 1 then
  46. app.club_php:requestRuleSet(app.club_php.clubID, againid, 1, 1)
  47. end
  48. end
  49. else
  50. self.ui.Items.Layout_9:setVisible(false)
  51. end
  52. --绑定消息通知回调
  53. self:bindEvent(app.club_php , GAME_EVENT.CLUB_INVITE , handler(self , self.onClubIniteEvent))
  54. --初始化人物信息
  55. self:initOtherData()
  56. self:updatePlayerInfo()
  57. if not app.config.ModuleConfig.IsSupportZhanJiUrl then
  58. self.ui.Items.Layout_8:setVisible(false)
  59. self.ui.Items.Layout_Bottom:requestDoLayout()
  60. self.ui.Items.Layout_Bottom:doLayout()
  61. else
  62. -- 获取分享网页战绩用的连接
  63. self:initShareUrl();
  64. end
  65. end
  66. -- 再玩一局
  67. function PKRoomDaJuView:onClickPlayAgain()
  68. local roomRule = ""
  69. if PKWanFa.getInviteInfo then
  70. roomRule = PKWanFa.getInviteInfo()
  71. end
  72. local uidList = {}
  73. for k,v in pairsByKeys(self.response.allData) do
  74. if tonumber(v.nUserId) ~= app.user.loginInfo.uid then
  75. table.insert(uidList,v.nUserId)
  76. end
  77. end
  78. setIsAgainGamebol(true,roomRule,uidList)
  79. self:removeFromParent()
  80. gotoMainView()
  81. end
  82. function PKRoomDaJuView:onClubIniteEvent(event)
  83. --房间邀请通知
  84. local content = event.content
  85. local clubId = event.clubId
  86. local viewType = type(self.inviteView)
  87. if self.inviteView and viewType == "userdata" then
  88. --提示框已存在
  89. return
  90. end
  91. local function closeCallback()
  92. --关闭提示框时清空数据,用于下次弹出
  93. self.inviteView = nil
  94. end
  95. local function agreeCallback()
  96. self:removeFromParent()
  97. gotoMainView()
  98. end
  99. self.inviteView = import("luaScript.Views.Club.ClubInviteRoomNew"):new(clubId, content, closeCallback,agreeCallback)
  100. self.inviteView:setAnchorPoint(cc.p(0.5, 0.5))
  101. app:showWaitDialog(self.inviteView,0)
  102. end
  103. function PKRoomDaJuView:initOtherData()
  104. local roomInfo = app.room.roomInfo
  105. --规则
  106. self.ui.Items.Text_Rule:setText(PKWanFa.getRuleInfo())
  107. --时间
  108. self.ui.Items.Text_Time:setText(os.date("%Y-%m-%d %X",roomInfo.endtime))
  109. --房号
  110. self.ui.Items.Text_RoomNum:setText("房间号:"..tostring(app.room.roomInfo.nShowTableId))
  111. --局数
  112. self.ui.Items.TextJuShu:setText("局数:"..tostring(app.room.roomInfo.nGameStartCount).."/"..tostring(app.room.roomInfo.nTotalGameNum))
  113. end
  114. function PKRoomDaJuView:initShareUrl()
  115. app.php:initShareZhanJiToUrl(function(url)
  116. self.zhanjiUrl = url
  117. end)
  118. end
  119. function PKRoomDaJuView:updatePlayerInfo()
  120. self.ui.Items.Layout_Player:setVisible(false)
  121. --判断大赢家和土豪
  122. local tuhaoScore = -999999
  123. local winerScore = -999999
  124. local tt = {}
  125. --排除都为0的情况
  126. local zeorNum = 0
  127. for k,v in pairs(self.response.allData) do
  128. if v.nTotalScore == 0 then
  129. zeorNum = zeorNum + 1
  130. end
  131. end
  132. local maxPeople = table.nums(self.response.allData)
  133. if zeorNum ~= maxPeople then
  134. for k,v in pairs(self.response.allData) do
  135. table.insert(tt,v.nTotalScore)
  136. end
  137. local function sortFunc(a,b)
  138. return a < b
  139. end
  140. table.sort(tt,sortFunc)
  141. tuhaoScore = tt[1]
  142. winerScore = tt[maxPeople]
  143. end
  144. local roomInfo = app.room.roomInfo
  145. for k,v in pairsByKeys(self.response.allData) do
  146. v.nTotalScore = tonumber(v.nTotalScore)
  147. local player = self.ui.Items.Layout_Player:getCopied()
  148. player.Items = getUIItems(player)
  149. local userInfo = json.decode(v.userInfo);
  150. local totalInfo = v.totalInfo;
  151. local name = getShortName(userInfo.nickname)
  152. setPlayerHeadImage(v.nUserId,userInfo.headimgurl,player.Items.ImageView_head,false)
  153. player.Items.ImageView_roomer:setVisible(roomInfo.nRoomOwnedUid == v.nUserId)
  154. player.Items.Text_name:setText(name)
  155. player.Items.Text_ID:setText(v.nUserId)
  156. --显示隐藏游戏内选手id(主办人和管理员不限制,只针对海选赛) -- todo lwq
  157. -- begin
  158. local ClubDefine = require("luaScript.Protocol.Club.ClubDefine")
  159. if app.club_php.clubID and app.club_php.clubID ~= 0 then
  160. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  161. --隐私数据
  162. local clubInfo = app.club_php.clubList[app.club_php.clubID]
  163. self.cliext = clubInfo.groupext and clubInfo.groupext.cliext
  164. if not self.cliext or not self.cliext.is_hideUid or (self.cliext and self.cliext.is_hideUid == 1) then
  165. if clubInfo.role == ClubDefine.Job.Creator or clubInfo.role == ClubDefine.Job.Manager then
  166. player.Items.Text_ID:setVisible(true)
  167. else
  168. player.Items.Text_ID:setVisible(false)
  169. end
  170. end
  171. end
  172. end
  173. if v.nUserId == tonumber(app.user.loginInfo.uid) then
  174. player.Items.Text_ID:setVisible(true)
  175. end
  176. -- end
  177. player.Items.ImageView_win:setVisible(v.nTotalScore == winerScore)
  178. if v.nTotalScore > 0 then
  179. player.Items.Text_Score:setText("+"..v.nTotalScore)
  180. else
  181. player.Items.Text_Score:setText(v.nTotalScore)
  182. player.Items.ImageView_bg:loadTexture("pk_base/res/ui/zy_fangjian/jiesuanView/pk_jiesuan_lose2.png")
  183. end
  184. self.ui.Items.Layout_items:addChild(player)
  185. end
  186. self.ui.Items.Layout_items:requestDoLayout()
  187. self.ui.Items.Layout_items:doLayout()
  188. self.ui.Items.Layout_All:requestDoLayout()
  189. self.ui.Items.Layout_All:doLayout()
  190. end
  191. function PKRoomDaJuView:onExit()
  192. PKRoomDaJuView.super.onExit(self);
  193. setShowCountAll(false);
  194. end
  195. -- 关闭
  196. function PKRoomDaJuView:onClickClose()
  197. self:removeFromParent()
  198. gotoMainView()
  199. end
  200. -- 防封群分享
  201. function PKRoomDaJuView:onClickSafeShare()
  202. local imagePath = cc.FileUtils:getInstance():getWritablePath().."icon.png"
  203. local gameName = getSubGameRuleName(PKDef.GameID,app.room.roomInfo.nGameRule) or "悠闲麻将"
  204. local uid = app.user.loginInfo.uid;
  205. local appId = getAppId();
  206. local gameId = PKDef.GameID;
  207. local roomId = app.room.roomInfo.nShowTableId;
  208. local endtime = app.room.roomInfo.endtime;
  209. local info = {}
  210. info.image = fileName
  211. info.title = gameName.."战绩"
  212. info.menuIdxs = {1, 4, 5, 6}
  213. info.FFQFlag = true
  214. info.copyData={
  215. type = 1,
  216. tableId = roomId,
  217. userInfos = {},
  218. }
  219. local content = nil;
  220. for k,v in pairs(self.response.allData) do
  221. local userInfo = json.decode(v.userInfo);
  222. local name = userInfo.nickname
  223. --昵称
  224. local nickname = name or ""
  225. local totalScore = v.nTotalScore
  226. local userInfo = ""
  227. if totalScore > 0 then
  228. userInfo = string.format("%s(+%s)", getShortName(nickname), totalScore)
  229. else
  230. userInfo = string.format("%s(%s)", getShortName(nickname), totalScore)
  231. end
  232. table.insert(info.copyData.userInfos,{nickname = nickname,totalScore = totalScore,nUserId = k})
  233. if content then
  234. content = content .. "," .. userInfo
  235. else
  236. content = userInfo
  237. end
  238. end
  239. -- http://gamb.bashangtour.com/game/gamb?uid=1002757&gameid=2&app=203000&roomid=634116&endtime=1540452491
  240. local url = string.format("%s?uid=%s&gameid=%s&app=%s&roomid=%s&endtime=%s",
  241. self.zhanjiUrl,
  242. uid,
  243. gameId,
  244. appId,
  245. roomId,
  246. endtime);
  247. logD("RoomCountAllView:onClickSafeShare():",url)
  248. info.url = url
  249. info.description = content
  250. dump(info)
  251. local view = import("luaScript.Views.Main.ShareView"):new(info)
  252. view:setAnchorPoint(cc.p(0.5, 0.5))
  253. app:showWaitDialog(view)
  254. end
  255. function PKRoomDaJuView:onClickShare()
  256. local fileName = cc.FileUtils:getInstance():getWritablePath()..tostring(app.room.roomInfo.nShowTableId).."_screen.jpg"
  257. cc.FileUtils:getInstance():screenToFile(fileName, function(ret)
  258. if 1 == tonumber(ret) then
  259. local info = {}
  260. info.scene = "talk"
  261. info.contentType = "image"
  262. info.image = fileName
  263. info.imageWidth = 1000
  264. info.menuIdxs = {1,2,4,5,6}
  265. info.copyData={
  266. type = 1,
  267. tableId = app.room.roomInfo.nShowTableId,
  268. userInfos = {},
  269. gameId = PKDef.GameID,
  270. }
  271. for nUserId,v in pairsByKeys(self.response.allData) do
  272. local userInfo = json.decode(v.userInfo);
  273. local name = userInfo.nickname
  274. --昵称
  275. local nickname = name or ""
  276. local totalScore = v.nTotalScore
  277. table.insert(info.copyData.userInfos,{nickname = nickname,totalScore = totalScore,nUserId = nUserId})
  278. end
  279. local view = import("luaScript.Views.Main.ShareView"):new(info)
  280. view:setAnchorPoint(cc.p(0.5, 0.5))
  281. app:showWaitDialog(view)
  282. else
  283. showTooltip("截图保存失败");
  284. end
  285. end);
  286. end
  287. return PKRoomDaJuView;