You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

276 lines
10 KiB

  1. local DEEP_COL1 = cc.c3b(0xff, 0xff, 0xff)
  2. local WEAK_COL1 = cc.c3b(0xeb, 0xda, 0xa9)
  3. local RED_COL1 = cc.c3b(0xd5, 0x31, 0x2f)
  4. local BG_W = 564
  5. local BaseLayer = require("luaScript.ModuleEapSdk.BaseLayers.BaseLayer")
  6. local LayerEnd = EapClass("LayerEnd", BaseLayer)
  7. function LayerEnd.createWithData(__node, __zorder)
  8. local layer = LayerEnd.new()
  9. layer.m_parent = __node
  10. __node:addChild(layer, __zorder)
  11. return layer
  12. end
  13. function LayerEnd:myShow()
  14. -- self:addListener(true)
  15. self:initData()
  16. self:initUI()
  17. end
  18. function LayerEnd:myClose()
  19. end
  20. function LayerEnd:initData()
  21. self.m_sel = true
  22. end
  23. function LayerEnd:initUI()
  24. self.imgPath = {
  25. "res/ModuleEapSdk/eapsdk_img_null.png",
  26. "res/ModuleEapSdk/eapsdk_public_back_bg2.png",
  27. "res/ModuleEapSdk/eapsdk_public_back_bg3.png",
  28. "res/ModuleEapSdk/eapsdk_bg_bj_sp1.png",
  29. "res/ModuleEapSdk/eapsdk_bt_xb_sp.png", --5
  30. "res/ModuleEapSdk/Eap_Score/eapsdk_img_title.png",
  31. "res/ModuleEapSdk/eapsdk_wj_icon_question.png",
  32. "res/ModuleEapSdk/eapsdk_wj_btn_lingjiang.png",
  33. "res/ModuleEapSdk/eapsdk_wj_icon_question_off.png", --赛事规则off
  34. "res/ModuleEapSdk/Eap_Red/eapsdk_redpack_bj02.png", --10
  35. "res/ModuleEapSdk/eapsdk_store_btnDeal_off.png",
  36. "res/ModuleEapSdk/eapsdk_store_btnDeal_on.png",
  37. "res/ModuleEapSdk/eapsdk_img_icon.png",
  38. "res/ModuleEapSdk/Eap_Red/eapsdk_red_img_arrow.png",
  39. }
  40. local fix_x = display.width
  41. local fix_y = display.cy
  42. local imgBack2 = G_EapAbbreviation.createImageView(self.imgPath[1], self, cc.p(fix_x, fix_y+45), true, 2, 2101, cc.p(1, 0.5))
  43. imgBack2:setSize(cc.size(BG_W, 510))
  44. self.imgBack2 = imgBack2
  45. self.lblCDTime = G_EapAbbreviation.createSystemLabel(imgBack2, cc.p(BG_W/2, 350), "", 22, DEEP_COL1)
  46. self.btnDes = ccui.ImageView:create(self.imgPath[9])
  47. self.btnDes:setPosition(cc.p(62, 410))
  48. self.btnDes:setScale(0.6)
  49. imgBack2:addChild(self.btnDes)
  50. addButtonListener(self.btnDes, function()
  51. print("LayerMatch btnDes clicked === ")
  52. if G_LayerMain:isSubLayerVis(LAYER_ENUM.LAYER_RULE) then
  53. G_LayerMain:closeSubLayer(LAYER_ENUM.LAYER_RULE)
  54. self.btnDes:loadTexture(self.imgPath[9])
  55. else
  56. for k,v in pairs(G_EapSdkMgr.m_matchInfos) do
  57. local matchID = k
  58. if not G_EapSdkMgr.m_matchRule and matchID then
  59. G_EapSocketLogin.request_matchRuleGet(matchID)
  60. end
  61. break
  62. end
  63. G_LayerMain:showSubLayer(LAYER_ENUM.LAYER_RULE)
  64. self.btnDes:loadTexture(self.imgPath[7])
  65. end
  66. end)
  67. local title = "赛事结束,线下赛即将开启"
  68. G_EapAbbreviation.createSystemLabel(imgBack2, cc.p(BG_W/2, 300+30), title, 26, DEEP_COL1, true)
  69. self.btnGo = ccui.Button:create(self.imgPath[8])
  70. self.btnGo:setPosition(cc.p(BG_W/2, 45))
  71. self.btnGo:setScale(0.6)
  72. self.btnGo:setVisible(false)
  73. imgBack2:addChild(self.btnGo)
  74. addButtonListener(self.btnGo, function()
  75. local saveMatchID = G_EapSdkMgr:getSelMatchID()
  76. local maxMatch = G_EapSdkMgr:getSelfRankByID(saveMatchID)
  77. local rank = maxMatch and maxMatch.Rank or 1200
  78. if rank > 32 then
  79. G_EapSocketLogin.request_markLog(MARK_LOG11014)
  80. G_EapSocketLogin.request_ItemExChangeGet(saveMatchID)
  81. elseif rank >= 1 then
  82. G_EapSocketLogin.request_markLog(MARK_LOG11013, tostring(self.m_sel))
  83. local redNum = self.lblRedNumIn32:getString()
  84. G_EapSdkMgr:setRedAward(redNum)
  85. self:refreshRedInfo()
  86. end
  87. end)
  88. self:initSignNode()
  89. end
  90. --已报名排名处理
  91. function LayerEnd:initSignNode()
  92. local redInfo = G_EapSdkMgr.m_redInfo
  93. local saveMatchID = G_EapSdkMgr:getSelMatchID()
  94. local maxMatch = G_EapSdkMgr:getSelfRankByID(saveMatchID)
  95. local rank = maxMatch and maxMatch.Rank or 1200
  96. self.node_in32 = cc.Node:create()
  97. self.imgBack2:addChild(self.node_in32) --32强
  98. self.node_out32 = cc.Node:create()
  99. self.imgBack2:addChild(self.node_out32)
  100. -----------------------------------------------------------------------------------------
  101. self.imgRedIn32 = G_EapAbbreviation.createImageView(self.imgPath[10], self.node_in32, cc.p(BG_W/2, 115+90))
  102. self.imgRedIn32:setScale(0.6)
  103. local title11 = self:getAwardByRank(rank)
  104. if self.m_sel then
  105. title11 = title11 + 300
  106. end
  107. self.lblRedNumIn32 = G_EapAbbreviation.createSystemLabel(self.imgRedIn32, cc.p(60, 130), title11, 25, RED_COL1, true)
  108. self.btnSel = ccui.ImageView:create(self.imgPath[12])
  109. self.btnSel:setPosition(cc.p(BG_W/2 - 160, 75+20))
  110. self.btnSel:setScale(0.6)
  111. self.node_in32:addChild(self.btnSel)
  112. addButtonListener(self.btnSel, function()
  113. local money = self:getAwardByRank(rank)
  114. if self.m_sel then
  115. self.btnSel:loadTexture(self.imgPath[11])
  116. else
  117. money = money + 300
  118. self.btnSel:loadTexture(self.imgPath[12])
  119. end
  120. self.lblRedNumIn32:setString(money)
  121. self.m_sel = not self.m_sel
  122. end)
  123. -----------------------------------------------------------------------------------------
  124. self.imgRedOut32 = G_EapAbbreviation.createImageView(self.imgPath[10], self.node_out32, cc.p(BG_W/2-150, 115+50))
  125. self.imgRedOut32:setScale(0.6)
  126. local money1 = redInfo and redInfo.Money or 0
  127. local title21 = string.format("%.2f", money1)
  128. self.lblRedNumOut32 = G_EapAbbreviation.createSystemLabel(self.imgRedOut32, cc.p(60, 130), title21, 25, RED_COL1, true)
  129. self.imgArrow = G_EapAbbreviation.createImageView(self.imgPath[14], self.node_out32, cc.p(BG_W/2, 115+50))
  130. self.imgArrow:setScale(0.6)
  131. self.imgJZ = G_EapAbbreviation.createImageView(self.imgPath[13], self.node_out32, cc.p(BG_W/2+100, 115+50))
  132. local jzNum = math.floor(money1) * 10
  133. self.lblJZNum = G_EapAbbreviation.createSystemLabel(self.node_out32, cc.p(BG_W/2+130, 115+50), jzNum, 30, RED_COL1, true, display.LEFT)
  134. self.lblJZNum:setAnchorPoint(cc.p(0, 0.5))
  135. -----------------------------------------------------------------------------------------
  136. local title1 = "最终排名第"..rank.."名"
  137. self.lblRank = G_EapAbbreviation.createSystemLabel(self.imgBack2, cc.p(BG_W/2, 215+70), title1, 30, WEAK_COL1, true)
  138. local title2 = "您将获得 赛事奖金"
  139. self.lblAward1 = G_EapAbbreviation.createSystemLabel(self.imgBack2, cc.p(BG_W/2, 115+90), title2, 30, WEAK_COL1, true)
  140. local title3 = "同意参加,其中300元为线下参赛补贴"
  141. self.lblAward2 = G_EapAbbreviation.createSystemLabel(self.imgBack2, cc.p(BG_W/2, 75+20), title3, 16, DEEP_COL1)
  142. local title4 = "未获得线下赛资格,关注后续赛事取得好成绩!"
  143. self.lblAward3 = G_EapAbbreviation.createSystemLabel(self.imgBack2, cc.p(BG_W/2, 115+130), title4, 18, WEAK_COL1)
  144. self:refreshRedInfo()
  145. end
  146. function LayerEnd:refreshRedInfo()
  147. local redInfo = G_EapSdkMgr.m_redInfo
  148. local saveMatchID = G_EapSdkMgr:getSelMatchID()
  149. local maxMatch = G_EapSdkMgr:getSelfRankByID(saveMatchID)
  150. local rank = maxMatch and maxMatch.Rank or 1200
  151. local title1 = "最终排名第"..rank.."名"
  152. self.lblRank:setString(title1)
  153. local title11 = self:getAwardByRank(rank)
  154. if self.m_sel then
  155. title11 = title11 + 300
  156. end
  157. self.lblRedNumIn32:setString(title11)
  158. local money1 = redInfo and redInfo.Money or 0
  159. local title21 = string.format("%.2f", money1)
  160. self.lblRedNumOut32:setString(title21)
  161. local jzNum = math.floor(money1) * 10
  162. self.lblJZNum:setString(jzNum)
  163. local title3 = "同意参加,其中300元为线下参赛补贴"
  164. local title5 = "将会有工作人员电话联系您沟通奖金发放事宜,请确保电话畅通!"
  165. local title6 = "赛事红包转换为奖章可在商城中兑换商品"
  166. if not G_EapSdkMgr.m_pointSelGameID then
  167. self.node_in32:setVisible(false)
  168. self.node_out32:setVisible(false)
  169. self.btnGo:setVisible(false)
  170. self.lblRank:setVisible(false)
  171. self.lblAward2:setVisible(false)
  172. self.lblAward1:setVisible(false)
  173. self.lblAward3:setVisible(true)
  174. else
  175. self.lblRank:setVisible(true)
  176. self.lblAward2:setVisible(true)
  177. self.btnGo:setVisible(true)
  178. if rank > 32 then
  179. self.node_in32:setVisible(false)
  180. self.node_out32:setVisible(true)
  181. self.lblAward1:setVisible(false)
  182. self.lblAward3:setVisible(true)
  183. self.lblAward2:setString(title6)
  184. if not redInfo or (redInfo and redInfo.ExchangeTime) then --已领取
  185. self.node_out32:setVisible(false)
  186. self.btnGo:setVisible(false)
  187. self.lblAward2:setVisible(false)
  188. end
  189. elseif rank >=1 then
  190. self.node_in32:setVisible(true)
  191. self.node_out32:setVisible(false)
  192. self.lblAward1:setVisible(true)
  193. self.lblAward3:setVisible(false)
  194. local redAward = G_EapSdkMgr:getRedAward()
  195. if redAward ~= "" then
  196. self.btnSel:setVisible(false)
  197. self.lblAward2:setString(title5)
  198. self.btnGo:setVisible(false)
  199. end
  200. end
  201. end
  202. end
  203. function LayerEnd:refreshRank()
  204. local saveMatchID = G_EapSdkMgr:getSelMatchID()
  205. local maxMatch = G_EapSdkMgr:getSelfRankByID(saveMatchID)
  206. local rank = maxMatch and maxMatch.Rank or 1200
  207. local title1 = ""
  208. if rank > 32 then
  209. title1 = "您尚未获得线下赛资格,可关注后续更多赛事取得好成绩!"
  210. elseif rank >=1 then
  211. title1 = "最终排名第"..rank.."名,您已获得线下赛资格,我们将通过电话联系您!"
  212. end
  213. if not G_EapSdkMgr.m_pointSelGameID then
  214. title1 = "您尚未获得线下赛资格,可关注后续更多赛事取得好成绩!"
  215. end
  216. self.lblRank:setString(title1)
  217. end
  218. function LayerEnd:getAwardByRank(__rank)
  219. local resNum = 0
  220. if __rank == 1 then
  221. resNum = 1000
  222. elseif __rank == 2 then
  223. resNum = 700
  224. elseif __rank == 3 then
  225. resNum = 600
  226. elseif __rank == 4 then
  227. resNum = 500
  228. elseif __rank == 5 then
  229. resNum = 400
  230. elseif __rank == 6 then
  231. resNum = 300
  232. elseif __rank >= 7 and __rank <= 32 then
  233. resNum = 200
  234. end
  235. return resNum
  236. end
  237. return LayerEnd