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.

1168 lines
47 KiB

  1. local DEEP_COL1 = cc.c3b(0xf8, 0xee, 0xc1)
  2. local WEAK_COL1 = cc.c3b(0x0b, 0x2d, 0x67)
  3. local BG_W = 564
  4. local scheduler = require("luaScript.ModuleEapSdk.SdkSocket.scheduler")
  5. local BaseLayer = require("luaScript.ModuleEapSdk.BaseLayers.BaseLayer")
  6. local LayerMatch = EapClass("LayerMatch", BaseLayer)
  7. function LayerMatch.createWithData(__node, __zorder)
  8. local layer = LayerMatch.new()
  9. layer.m_parent = __node
  10. __node:addChild(layer, __zorder)
  11. return layer
  12. end
  13. function LayerMatch:myShow()
  14. -- self:addListener(true)
  15. self:initData()
  16. self:initUI()
  17. end
  18. function LayerMatch:myClose()
  19. if self.m_schIDCDTime then
  20. scheduler.unscheduleGlobal(self.m_schIDCDTime)
  21. end
  22. end
  23. function LayerMatch:initData()
  24. self.m_itemArr = {}
  25. self.m_redItems = {} --红包记录
  26. self.m_awardState = 0 --报名按钮是否点击
  27. self.m_tips = {
  28. {
  29. pos = cc.p(180, 170),
  30. des = "赛程分数:赛程综合排名积分"
  31. },
  32. {
  33. pos = cc.p(260, 170),
  34. des = "平均成绩:赛事期间的平均局数成绩"
  35. },
  36. {
  37. pos = cc.p(340, 170),
  38. des = "比赛局数:赛事期间的累积比赛局数"
  39. },
  40. {
  41. pos = cc.p(420, 170),
  42. des = "热力局数:在热力时间段内打的对局数 (每天12:30~14:30)"
  43. },
  44. {
  45. pos = cc.p(500, 330),
  46. des = "获得方式:每局结束奖励。用途:可在商城兑换商品。"
  47. },
  48. }
  49. end
  50. function LayerMatch:initUI()
  51. self.imgPath = {
  52. "res/ModuleEapSdk/eapsdk_img_null.png",
  53. "res/ModuleEapSdk/eapsdk_public_back_bg2.png",
  54. "res/ModuleEapSdk/eapsdk_public_back_bg3.png",
  55. "res/ModuleEapSdk/eapsdk_img_icon.png", --奖章
  56. "res/ModuleEapSdk/eapsdk_img_tip.png", --5
  57. "res/ModuleEapSdk/Eap_Score/eapsdk_img_title.png",
  58. "res/ModuleEapSdk/eapsdk_wj_icon_question.png",
  59. "res/ModuleEapSdk/eapsdk_wj_btn_rank.png",
  60. "res/ModuleEapSdk/eapsdk_bg_bj_sp2.png",
  61. "res/ModuleEapSdk/eapsdk_public_back_bg4.png", --10
  62. "res/ModuleEapSdk/Eap_Red/eapsdk_red_btn_signin.png",
  63. "res/ModuleEapSdk/Eap_Score/eapsdk_btn_award.png",
  64. "res/ModuleEapSdk/Eap_Score/eapsdk_btn_dailyGame.png",
  65. "res/ModuleEapSdk/Eap_Score/eapsdk_img_matchlistItemBG.png",
  66. "res/ModuleEapSdk/Eap_Score/eapsdk_btn_myScore_off.png", --15
  67. "res/ModuleEapSdk/Eap_Score/eapsdk_btn_myScore_on.png",
  68. "res/ModuleEapSdk/Eap_Score/eapsdk_btn_FriendScore_off.png",
  69. "res/ModuleEapSdk/Eap_Score/eapsdk_btn_FriendScore_on.png",
  70. "res/ModuleEapSdk/Eap_Score/eapsdk_btn_search_off.png",
  71. "res/ModuleEapSdk/Eap_Score/eapsdk_btn_search_on.png", --20
  72. "res/ModuleEapSdk/Eap_Score/eapsdk_btn_search.png",
  73. "res/ModuleEapSdk/eapsdk_img_search.png",
  74. "res/ModuleEapSdk/Eap_Score/eapsdk_img_searchBG.png",
  75. "res/ModuleEapSdk/Eap_Score/eapsdk_img_follow.png",
  76. "res/ModuleEapSdk/Eap_Score/eapsdk_img_followed.png", --25
  77. "res/ModuleEapSdk/eapsdk_public_back_bg6.png",
  78. "res/ModuleEapSdk/eapsdk_public_back_bg12.png",
  79. "res/ModuleEapSdk/eapsdk_wj_icon_question_off.png", --赛事规则off
  80. "res/ModuleEapSdk/eapsdk_wj_btn_rank_off.png", --排行榜off
  81. "res/ModuleEapSdk/Eap_Score/eapsdk_btn_dailyGame_off.png", --当日详情off --30
  82. "res/ModuleEapSdk/Eap_Score/eapsdk_btn_kefu_on.png", --客服on
  83. "res/ModuleEapSdk/Eap_Score/eapsdk_btn_kefu_off.png", --客服off
  84. "res/ModuleEapSdk/Eap_Score/eapsdk_img_match_title.png",
  85. "res/ModuleEapSdk/Eap_Score/eapsdk_img_mylist_title.png", --我的赛事排行榜
  86. "res/ModuleEapSdk/Eap_Score/eapsdk_img_friendlist_title.png", --好友赛事排行榜 --35
  87. "res/ModuleEapSdk/Eap_Score/eapsdk_img_frilistItemBG_on.png", --好友赛事排行元素底图
  88. "res/ModuleEapSdk/Eap_Score/eapsdk_img_frilistItemBG_off.png", --好友赛事排行元素底图
  89. "res/ModuleEapSdk/Eap_Score/eapsdk_img_searchEditBG.png", --搜索框地图
  90. "res/ModuleEapSdk/eapsdk_public_back_bg11.png",
  91. "res/ModuleEapSdk/eapsdk_img_tipsBG.png", --提示框背景图 --40
  92. "res/ModuleEapSdk/eapsdk_img_timeBG.png",
  93. "res/ModuleEapSdk/Eap_Red/eapsdk_redpack_bj01.png", --红包
  94. "res/ModuleEapSdk/Eap_Red/eapsdk_wj_btn_redpack.png", --红包按钮
  95. "res/ModuleEapSdk/Eap_Red/eapsdk_red_img_title.png",
  96. "res/ModuleEapSdk/Eap_Red/eapsdk_red_img_txt1.png", --45
  97. "res/ModuleEapSdk/Eap_Red/eapsdk_red_img_txt2.png",
  98. "res/ModuleEapSdk/Eap_Red/eapsdk_red_btn_signin1.png", --激活成绩按钮
  99. "res/ModuleEapSdk/Eap_Red/eapsdk_red_img_btnRedDesBG.png",
  100. "res/ModuleEapSdk/Eap_Red/eapsdk_red_btn_open.png",
  101. "res/ModuleEapSdk/Eap_Red/eapsdk_red_btn_rule.png", --50
  102. "res/ModuleEapSdk/Eap_Red/eapsdk_red_img_btnRedTitle.png",
  103. "res/ModuleEapSdk/Eap_Red/eapsdk_red_img_hand.png",
  104. "res/ModuleEapSdk/Eap_Red/eapsdk_red_img_line.png",
  105. "res/ModuleEapSdk/Eap_Red/eapsdk_red_img_rankBG.png",
  106. "res/ModuleEapSdk/Eap_Red/eapsdk_red_img_ruleBG.png", --55
  107. "res/ModuleEapSdk/Eap_Red/eapsdk_red_img_titleBG.png",
  108. "res/ModuleEapSdk/Eap_Red/eapsdk_red_img_ruleDes.png",
  109. }
  110. local fix_x = display.width
  111. local fix_y = display.cy
  112. local imgBack2 = G_EapAbbreviation.createImageView(self.imgPath[1], self, cc.p(fix_x, fix_y+45), true, 2, 2101, cc.p(1, 0.5))
  113. imgBack2:setSize(cc.size(BG_W, 510))
  114. self.imgBack2 = imgBack2
  115. self.imgCover = G_EapAbbreviation.createImageView(self.imgPath[39], self, cc.p(fix_x, fix_y+45-130), true, 5, 2102, cc.p(1, 0.5))
  116. self.imgCover:setSize(cc.size(BG_W, 300))
  117. self.imgCover:setVisible(false)
  118. -- local imgLine = G_EapAbbreviation.createImageView(self.imgPath[10], imgBack2, cc.p(-1, -90), false, 2, 2101, cc.p(0.5, 0))
  119. -- imgLine:setScale(0.5, 300)
  120. self.imgTime = G_EapAbbreviation.createImageView(self.imgPath[41], imgBack2, cc.p(BG_W/2, 340))
  121. self.imgTime:setScale(0.6)
  122. self.lblCDTime1 = G_EapAbbreviation.createSystemLabel(imgBack2, cc.p(BG_W/2-27, 340), "00", 22, DEEP_COL1)
  123. self.lblCDTime2 = G_EapAbbreviation.createSystemLabel(imgBack2, cc.p(BG_W/2+27, 340), "00", 22, DEEP_COL1)
  124. self.lblCDTime3 = G_EapAbbreviation.createSystemLabel(imgBack2, cc.p(BG_W/2+100, 340), "00", 22, WEAK_COL1)
  125. --奖章
  126. local imgJZ = G_EapAbbreviation.createImageView(self.imgPath[4], imgBack2, cc.p(460, 340))
  127. imgJZ:setScale(0.6)
  128. local myItem = G_EapSdkMgr:getItem(ITEM_TYPE.INTEGRAL)
  129. local scoreNum = myItem and myItem.nNum or 0
  130. local score = scoreNum
  131. self.lblScore = G_EapAbbreviation.createSystemLabel(imgBack2, cc.p(475, 340), score, 18, DEEP_COL1, false, display.RIGHT)
  132. self.lblScore:setAnchorPoint(cc.p(0, 0.5))
  133. local imgTip = G_EapAbbreviation.createImageView(self.imgPath[5], imgBack2, cc.p(545, 340))
  134. imgTip:setScale(0.6)
  135. --天梯赛img
  136. local imgMatchTitle = G_EapAbbreviation.createImageView(self.imgPath[33], imgBack2, cc.p(BG_W/2, 290))
  137. imgMatchTitle:setScale(0.6)
  138. --客服
  139. self.btnKefu = ccui.ImageView:create(self.imgPath[32])
  140. self.btnKefu:setPosition(cc.p(62, 450))
  141. self.btnKefu:setScale(0.6)
  142. imgBack2:addChild(self.btnKefu)
  143. addButtonListener(self.btnKefu, function()
  144. print("LayerMatch btnKefu clicked === ")
  145. if G_LayerMain:isSubLayerVis(LAYER_ENUM.LAYER_SUPPORT) then
  146. G_LayerMain:closeSubLayer(LAYER_ENUM.LAYER_SUPPORT)
  147. self.btnKefu:loadTexture(self.imgPath[32])
  148. else
  149. G_LayerMain:showSubLayer(LAYER_ENUM.LAYER_SUPPORT)
  150. self.btnKefu:loadTexture(self.imgPath[31])
  151. self.btnDes:loadTexture(self.imgPath[28])
  152. self.btnRank:loadTexture(self.imgPath[29])
  153. self.btnDailyResult:loadTexture(self.imgPath[30])
  154. end
  155. end)
  156. --赛事规则
  157. self.btnDes = ccui.ImageView:create(self.imgPath[28])
  158. self.btnDes:setPosition(cc.p(62, 410))
  159. self.btnDes:setScale(0.6)
  160. imgBack2:addChild(self.btnDes)
  161. addButtonListener(self.btnDes, function()
  162. print("LayerMatch btnDes clicked === ")
  163. if G_LayerMain:isSubLayerVis(LAYER_ENUM.LAYER_RULE) then
  164. G_LayerMain:closeSubLayer(LAYER_ENUM.LAYER_RULE)
  165. self.btnDes:loadTexture(self.imgPath[28])
  166. else
  167. for k,v in pairs(G_EapSdkMgr.m_matchInfos) do
  168. local matchID = k
  169. if not G_EapSdkMgr.m_matchRule and matchID then
  170. G_EapSocketLogin.request_matchRuleGet(matchID)
  171. end
  172. break
  173. end
  174. G_LayerMain:showSubLayer(LAYER_ENUM.LAYER_RULE)
  175. self.btnDes:loadTexture(self.imgPath[7])
  176. self.btnRank:loadTexture(self.imgPath[29])
  177. self.btnDailyResult:loadTexture(self.imgPath[30])
  178. self.btnKefu:loadTexture(self.imgPath[32])
  179. end
  180. end)
  181. --排行榜
  182. self.btnRank = ccui.ImageView:create(self.imgPath[29])
  183. self.btnRank:setPosition(cc.p(62, 370))
  184. self.btnRank:setScale(0.6)
  185. imgBack2:addChild(self.btnRank)
  186. addButtonListener(self.btnRank, function()
  187. print("LayerMatch btnRank clicked === ")
  188. if G_LayerMain:isSubLayerVis(LAYER_ENUM.LAYER_RANK) then
  189. G_LayerMain:closeSubLayer(LAYER_ENUM.LAYER_RANK)
  190. self.btnRank:loadTexture(self.imgPath[29])
  191. else
  192. G_LayerMain:showSubLayer(LAYER_ENUM.LAYER_RANK)
  193. self.btnRank:loadTexture(self.imgPath[8])
  194. self.btnDailyResult:loadTexture(self.imgPath[30])
  195. self.btnKefu:loadTexture(self.imgPath[32])
  196. self.btnDes:loadTexture(self.imgPath[28])
  197. end
  198. end)
  199. --当日成绩按钮
  200. self.btnDailyResult = ccui.ImageView:create(self.imgPath[30])
  201. self.btnDailyResult:setPosition(cc.p(62, 300))
  202. self.btnDailyResult:setScale(0.6)
  203. imgBack2:addChild(self.btnDailyResult)
  204. addButtonListener(self.btnDailyResult, function()
  205. print("LayerMatch btnDailyResult clicked === ")
  206. if G_LayerMain:isSubLayerVis(LAYER_ENUM.LAYER_DAILY_GAME) then
  207. G_LayerMain:closeSubLayer(LAYER_ENUM.LAYER_DAILY_GAME)
  208. self.btnDailyResult:loadTexture(self.imgPath[30])
  209. else
  210. G_LayerMain:showSubLayer(LAYER_ENUM.LAYER_DAILY_GAME)
  211. self.btnDailyResult:loadTexture(self.imgPath[13])
  212. self.btnKefu:loadTexture(self.imgPath[32])
  213. self.btnDes:loadTexture(self.imgPath[28])
  214. self.btnRank:loadTexture(self.imgPath[29])
  215. end
  216. end)
  217. --切换
  218. local rankMenus = cc.Node:create()
  219. rankMenus:setPosition(cc.p(BG_W/2, 240))
  220. imgBack2:addChild(rankMenus)
  221. self.btnMyScore = ccui.ImageView:create(self.imgPath[16])
  222. self.btnMyScore:setPosition(cc.p(-80, 0))
  223. rankMenus:addChild(self.btnMyScore)
  224. addButtonListener(self.btnMyScore, function()
  225. print("self.btnMyScore clicked ========= ")
  226. self.btnMyScore:setTouchEnabled(false)
  227. self.btnFriend:setTouchEnabled(true)
  228. self.btnMyScore:loadTexture(self.imgPath[16])
  229. self.btnFriend:loadTexture(self.imgPath[17])
  230. self.node_myScore:setVisible(true)
  231. self.node_Friend:setVisible(false)
  232. self.btnRed:setVisible(true)
  233. end)
  234. self.btnFriend = ccui.ImageView:create(self.imgPath[17])
  235. self.btnFriend:setPosition(cc.p(80, 0))
  236. rankMenus:addChild(self.btnFriend)
  237. addButtonListener(self.btnFriend, function()
  238. print("self.btnFriend clicked ========= ")
  239. G_EapSocketLogin.request_markLog(MARK_LOG11012)
  240. if G_LayerMain.m_needRefreshFriend then
  241. G_LayerMain.m_needRefreshFriend = false
  242. G_EapSocketLogin.request_FriendListGet()
  243. end
  244. self.btnMyScore:setTouchEnabled(true)
  245. self.btnFriend:setTouchEnabled(false)
  246. self.btnMyScore:loadTexture(self.imgPath[15])
  247. self.btnFriend:loadTexture(self.imgPath[18])
  248. self.node_myScore:setVisible(false)
  249. self.node_Friend:setVisible(true)
  250. self.node_friList:setVisible(true)
  251. self.node_search:setVisible(false)
  252. self.btnRed:setVisible(false)
  253. end)
  254. self.btnMyScore:setScale(0.6)
  255. self.btnFriend:setScale(0.6)
  256. self.btnMyScore:setTouchEnabled(false)
  257. self.btnFriend:setTouchEnabled(true)
  258. --我的成绩
  259. self.node_myScore = cc.Node:create()
  260. imgBack2:addChild(self.node_myScore)
  261. --好友成绩
  262. self.node_Friend = cc.Node:create()
  263. imgBack2:addChild(self.node_Friend)
  264. --好友成绩列表
  265. self.node_friList = cc.Node:create()
  266. self.node_friList:setPosition(cc.p(0, -5))
  267. self.node_Friend:addChild(self.node_friList)
  268. --搜索好友
  269. self.node_search = cc.Node:create()
  270. self.node_search:setPosition(cc.p(0, -5))
  271. self.node_Friend:addChild(self.node_search)
  272. self.node_myScore:setVisible(true)
  273. self.node_Friend:setVisible(false)
  274. -------------------------------------------- 我的成绩 -------------------------------------------
  275. local imgMyScoreTitle = G_EapAbbreviation.createImageView(self.imgPath[34], self.node_myScore, cc.p(BG_W/2, 210), false, 1, 3103, cc.p(0.5, 1))
  276. imgMyScoreTitle:setScale(0.6)
  277. self.scrollView = ccui.ScrollView:create()
  278. self.inner_h = 110
  279. self.scrlContent = self.scrollView:getInnerContainer()
  280. self.scrollView:setAnchorPoint(cc.p(0.5, 1))
  281. self.scrollView:setTouchEnabled(true)
  282. self.scrollView:setBounceEnabled(false)
  283. if self.scrollView.hideAllBar then
  284. self.scrollView:hideAllBar()
  285. end
  286. if self.scrollView.setScrollBarEnabled and type(self.scrollView.setScrollBarEnabled) == "function" then
  287. self.scrollView:setScrollBarEnabled(false)
  288. end
  289. self.scrollView:setSize(cc.size(414, self.inner_h))
  290. self.scrollView:setPosition(cc.p(BG_W/2, 150))
  291. self.scrollView:setInnerContainerSize(cc.size(414, self.inner_h))
  292. self.node_myScore:addChild(self.scrollView)
  293. -- 报名领奖
  294. -- self.btnAward = ccui.Button:create(self.imgPath[11])
  295. -- self.btnAward:setPosition(cc.p(BG_W/2, 55))
  296. -- self.btnAward:setScale(0.6)
  297. -- self.imgCover:addChild(self.btnAward, 3)
  298. -- addButtonListener(self.btnAward, function()
  299. -- print("LayerMatch btnAward clicked === ")
  300. -- G_EapSocketLogin.request_markLog(MARK_LOG10014)
  301. -- G_LayerMain:showLayer(LAYER_ENUM.LAYER_BINDPHONE)
  302. -- end)
  303. -------------------------------------------- 好友成绩 -------------------------------------------
  304. local imgFriListTitle = G_EapAbbreviation.createImageView(self.imgPath[35], self.node_Friend, cc.p(BG_W/2-30, 155), false, 0, 3103, cc.p(0.5, 1))
  305. imgFriListTitle:setScale(0.6)
  306. local imgSearchBG = G_EapAbbreviation.createImageView(self.imgPath[38], self.node_Friend, cc.p(10, 210), false, 0, 2101, cc.p(0, 1))
  307. imgSearchBG:setScale(0.6)
  308. local imgSearch = G_EapAbbreviation.createImageView(self.imgPath[22], self.node_Friend, cc.p(30, 185))
  309. imgSearch:setScale(0.6)
  310. local showStr = "输入好友赛事ID可关注好友成绩排行"
  311. self.editPhone = G_EapLabelTool.getEditBox(self.imgPath[1], cc.size(340, 48), showStr, nil, nil, 20)
  312. self.editPhone:setAnchorPoint(cc.p(0, 0.5))
  313. self.editPhone:setPosition(cc.p(50, 185))
  314. self.node_Friend:addChild(self.editPhone)
  315. --搜索按钮
  316. self.btnSearchGo = ccui.Button:create(self.imgPath[21])
  317. self.btnSearchGo:setPosition(cc.p(485, 185))
  318. self.btnSearchGo:setScale(0.6)
  319. self.node_Friend:addChild(self.btnSearchGo)
  320. addButtonListener(self.btnSearchGo, function()
  321. G_EapSocketLogin.request_markLog(MARK_LOG10010)
  322. print("LayerMatch btnSearchGo clicked === ")
  323. self.btnSearchGo:setTouchEnabled(false)
  324. scheduler.performWithDelayGlobal(function()
  325. self.btnSearchGo:setTouchEnabled(true)
  326. end, 1)
  327. local matchIDs = table.keys(G_EapSdkMgr.m_matchInfos)
  328. if matchIDs[1] then
  329. local pid = tonumber(self.editPhone:getText()) or 0
  330. G_EapSocketLogin.request_userMatchInfoGet(matchIDs[1], pid)
  331. if not G_EapSdkMgr.m_userBaseInfos[pid] then
  332. local idArr = {
  333. pid
  334. }
  335. G_EapSocketLogin.request_GetMultiUserInfoReq(idArr)
  336. end
  337. end
  338. self.node_search:setVisible(true)
  339. self.node_friList:setVisible(false)
  340. end)
  341. -------------------------------------------- 搜索结果 -------------------------------------------
  342. local imgSearchRes = G_EapAbbreviation.createImageView(self.imgPath[37], self.node_search, cc.p(10, 100), false, 0, 2101, cc.p(0, 1))
  343. imgSearchRes:setScale(0.6)
  344. local node_searcRes = cc.Node:create()
  345. node_searcRes:setPosition(cc.p(10, 100-33))
  346. self.node_search:addChild(node_searcRes)
  347. local title = "-"
  348. self.lblSrchMatchName = G_EapAbbreviation.createSystemLabel(node_searcRes, cc.p(45, 16), title, 18, DEEP_COL1)
  349. self.lblSrchName = G_EapAbbreviation.createSystemLabel(node_searcRes, cc.p(40+80, 16), title, 16, DEEP_COL1)
  350. self.lblSrchScore = G_EapAbbreviation.createSystemLabel(node_searcRes, cc.p(40+80*2, 16), title, 16, DEEP_COL1)
  351. self.lblSrchBlScore = G_EapAbbreviation.createSystemLabel(node_searcRes, cc.p(40+80*3, 16), title, 16, DEEP_COL1)
  352. self.lblSrchAllNum = G_EapAbbreviation.createSystemLabel(node_searcRes, cc.p(40+80*4, 16), title, 16, DEEP_COL1)
  353. self.lblSrchReNum = G_EapAbbreviation.createSystemLabel(node_searcRes, cc.p(40+80*5, 16), title, 16, DEEP_COL1)
  354. self.lblSrchErr = G_EapAbbreviation.createSystemLabel(self.node_search, cc.p(BG_W/2, 45), "", 22, cc.c3b(220, 0, 0))
  355. self.btnFollow = ccui.ImageView:create(self.imgPath[24])
  356. self.btnFollow:setScale(0.6)
  357. self.btnFollow:setPosition(cc.p(515, 80))
  358. self.node_search:addChild(self.btnFollow)
  359. self.btnFollow:setVisible(false)
  360. addButtonListener(self.btnFollow, function()
  361. self.btnFollow:setTouchEnabled(false)
  362. scheduler.performWithDelayGlobal(function()
  363. self.btnFollow:setTouchEnabled(true)
  364. end, 1)
  365. local srchPID = tonumber(self.editPhone:getText()) or 0
  366. if G_EapSdkMgr:isFriend(srchPID) then
  367. G_EapSocketLogin.request_markLog(MARK_LOG10012)
  368. G_EapSocketLogin.request_FriendFollowReq(srchPID, 2)
  369. else
  370. G_EapSocketLogin.request_markLog(MARK_LOG10011)
  371. G_EapSocketLogin.request_FriendFollowReq(srchPID, 1)
  372. end
  373. end)
  374. self:initRedPack()
  375. self:initCDTime()
  376. self:setInfoItem()
  377. self:initTips()
  378. self:refreshBattleScore()
  379. end
  380. function LayerMatch:initRedPack()
  381. local redCol = cc.c3b(0xd5, 0x31, 0x2f)
  382. local fix_x = display.width
  383. local fix_y = display.cy
  384. self.imgRedBG = G_EapAbbreviation.createImageView(self.imgPath[27], self, cc.p(fix_x, fix_y+45), true, 6, 2102, cc.p(1, 0.5))
  385. self.imgRedBG:setSize(cc.size(BG_W, 510))
  386. self.imgRedBG:setVisible(false)
  387. addButtonListener(self.imgRedBG, function()
  388. if G_EapSdkMgr.EapPhone then
  389. self.imgRedBG:setVisible(false)
  390. end
  391. end)
  392. local act1 = cc.ScaleTo:create(2, 1.2)
  393. local act2 = cc.DelayTime:create(0.5)
  394. local act3 = cc.ScaleTo:create(1, 0.9)
  395. local seq1 = cc.Sequence:create(act1, act2, act3)
  396. local rep1 = cc.RepeatForever:create(seq1)
  397. -- 红包按钮
  398. self.btnRed = ccui.Button:create(self.imgPath[43])
  399. self.btnRed:setPosition(cc.p(BG_W/2, 55))
  400. self.btnRed:setScale(0.6)
  401. self.imgBack2:addChild(self.btnRed)
  402. addButtonListener(self.btnRed, function()
  403. print("LayerMatch btnRed clicked === ")
  404. G_EapSocketLogin.request_markLog(MARK_LOG11003)
  405. self.imgRedBG:setVisible(true)
  406. local matchIDs = table.keys(G_EapSdkMgr.m_matchInfos)
  407. if matchIDs[1] then
  408. G_EapSocketLogin.request_UserRedChangeGet(matchIDs[1], 1)
  409. G_EapSocketLogin.request_UserRedChangeGet(matchIDs[1], 2)
  410. end
  411. end)
  412. self.lblBtnRedNum = G_EapAbbreviation.createSystemLabel(self.btnRed, cc.p(79, 120), "0", 40, redCol, true)
  413. self.imgRedBtnBG = G_EapAbbreviation.createImageView(self.imgPath[48], self.btnRed, cc.p(162, 90))
  414. self.imgRedBtnBG:setAnchorPoint(cc.p(0, 0))
  415. self.imgRedBtnBG:setScale(1.5)
  416. local gameName = ""
  417. local matchIDs = table.keys(G_EapSdkMgr.m_matchInfos)
  418. local matchInfo = G_EapSdkMgr.m_matchInfos[matchIDs[1]]
  419. if matchInfo then
  420. local gameInfo = G_EapSdkMgr:getGameInfo(matchInfo.GameID)
  421. gameName = gameInfo and gameInfo.name or "麻将"
  422. end
  423. local redDesStr = "参与"..gameName.."对局(4人)可增加红包金额"
  424. -- self.lblRedBtnDes = G_EapAbbreviation.createSystemLabel(self.imgRedBtnBG, cc.p(15, 15), redDesStr, 16, display.COLOR_WHITE, true)
  425. -- self.lblRedBtnDes:setWidth(160)
  426. -- self.lblRedBtnDes:setAnchorPoint(cc.p(0, 0))
  427. self.lblRedBtnDes = cc.Text:createNode();
  428. self.lblRedBtnDes:setDefaults();
  429. local config = self.lblRedBtnDes:getFontConfig();
  430. config.fontSize = 16;
  431. self.lblRedBtnDes:setFontConfig(config);
  432. self.lblRedBtnDes:setColor(display.COLOR_WHITE)
  433. self.lblRedBtnDes:setTextAreaSize(cc.size(165, 0))
  434. self.lblRedBtnDes:setLinePadding(2)
  435. self.lblRedBtnDes:setAnchorPoint(cc.p(0, 0))
  436. self.lblRedBtnDes:setPosition(cc.p(15, 15))
  437. self.lblRedBtnDes:setText(redDesStr)
  438. self.imgRedBtnBG:addChild(self.lblRedBtnDes)
  439. self.imgRedOpen = G_EapAbbreviation.createImageView(self.imgPath[49], self.btnRed, cc.p(79, 55))
  440. self.imgRedOpen:runAction(rep1:clone())
  441. self.imgRed = G_EapAbbreviation.createImageView(self.imgPath[42], self.imgRedBG, cc.p(BG_W/2, 170))
  442. self.imgRed:setScale(0.6)
  443. self.imgRed:setTouchEnabled(true)
  444. self.node_redNoSign = cc.Node:create() --未报名
  445. self.imgRed:addChild(self.node_redNoSign)
  446. self.node_redSign = cc.Node:create() --已报名
  447. self.imgRed:addChild(self.node_redSign)
  448. self.imgRedRule = G_EapAbbreviation.createImageView(self.imgPath[55], self.imgRedBG, cc.p(BG_W/2, 230))
  449. self.imgRedRule:setScale(0.6)
  450. self.imgRedRule:setVisible(false)
  451. addButtonListener(self.imgRedRule, function()
  452. self.imgRedRule:setVisible(false)
  453. end)
  454. self:initRedRule()
  455. -- 报名领奖
  456. self.btnAward = ccui.ImageView:create(self.imgPath[11])
  457. self.btnAward:setPosition(cc.p(177, 55))
  458. self.node_redNoSign:addChild(self.btnAward, 3)
  459. addButtonListener(self.btnAward, function()
  460. print("LayerMatch btnAward clicked === ")
  461. G_EapSocketLogin.request_markLog(MARK_LOG10014)
  462. G_LayerMain:showLayer(LAYER_ENUM.LAYER_BINDPHONE)
  463. end)
  464. self.btnAward:runAction(rep1)
  465. self.lblNoSignRedNum = G_EapAbbreviation.createSystemLabel(self.node_redNoSign, cc.p(137, 330), "0", 75, redCol, true)
  466. self.imgRedTitle = G_EapAbbreviation.createImageView(self.imgPath[44], self.node_redNoSign, cc.p(177, 455))
  467. self.imgRedTitle2 = G_EapAbbreviation.createImageView(self.imgPath[45], self.node_redNoSign, cc.p(177, 160))
  468. self.imgRedTitle3 = G_EapAbbreviation.createImageView(self.imgPath[56], self.node_redNoSign, cc.p(177, 530))
  469. self.imgRedTitle3:setVisible(false)
  470. --已报名
  471. local title1 = "当前红包"
  472. self.lblRedTitle1 = G_EapAbbreviation.createSystemLabel(self.node_redSign, cc.p(177-85, 395), title1, 32, cc.c3b(0xd6, 0x8d, 0x52), true)
  473. local title2 = "满300元可领"
  474. self.lblRedTitle2 = G_EapAbbreviation.createSystemLabel(self.node_redSign, cc.p(177, 260), title2, 22, cc.c3b(0xe4, 0x55, 0x53))
  475. local title3 = "0"
  476. self.lblRedNum = G_EapAbbreviation.createSystemLabel(self.node_redSign, cc.p(137, 325), title3, 68, redCol, true)
  477. -- 红包规则
  478. self.btnRedRule = ccui.ImageView:create(self.imgPath[50])
  479. self.btnRedRule:setPosition(cc.p(310, 25))
  480. self.node_redSign:addChild(self.btnRedRule, 3)
  481. addButtonListener(self.btnRedRule, function()
  482. print("LayerMatch btnRedRule clicked === ")
  483. self.imgRedRule:setVisible(true)
  484. end)
  485. local imgTimeBG = G_EapAbbreviation.createImageView(self.imgPath[2], self.node_redSign, cc.p(245, 395), true)
  486. imgTimeBG:setSize(cc.size(165, 36))
  487. self.lblRedTime = G_EapAbbreviation.createSystemLabel(imgTimeBG, cc.p(82, 18), "", 18, redCol)
  488. local imgRedLine = G_EapAbbreviation.createImageView(self.imgPath[53], self.node_redSign, cc.p(177, 153))
  489. local imgRedRankBG = G_EapAbbreviation.createImageView(self.imgPath[54], self.node_redSign, cc.p(177, 150), false, 0, 2101, cc.p(0.5, 1))
  490. self:initRedList()
  491. end
  492. --红包规则界面
  493. function LayerMatch:initRedRule()
  494. self.scrlRedRule = ccui.ScrollView:create()
  495. local inner_h = 630
  496. self.scrlRedRule:setTouchEnabled(true)
  497. self.scrlRedRule:setBounceEnabled(false)
  498. if self.scrlRedRule.setScrollBarEnabled and type(self.scrlRedRule.setScrollBarEnabled) == "function" then
  499. self.scrlRedRule:setScrollBarEnabled(false)
  500. end
  501. self.scrlRedRule:setSize(cc.size(588, inner_h))
  502. self.scrlRedRule:setPosition(cc.p(0, 10))
  503. self.scrlRedRule:setInnerContainerSize(cc.size(588, 1408))
  504. self.imgRedRule:addChild(self.scrlRedRule)
  505. local imgRedRuleDes = G_EapAbbreviation.createImageView(self.imgPath[57], self.scrlRedRule, cc.p(30, 0))
  506. imgRedRuleDes:setAnchorPoint(cc.p(0, 0))
  507. end
  508. --红包奖励记录
  509. function LayerMatch:initRedList()
  510. self.scrlRed = ccui.ScrollView:create()
  511. local inner_h = 110
  512. self.scrlContent = self.scrlRed:getInnerContainer()
  513. self.scrlRed:setAnchorPoint(cc.p(0.5, 1))
  514. self.scrlRed:setBounceEnabled(false)
  515. if self.scrlRed.setScrollBarEnabled and type(self.scrlRed.setScrollBarEnabled) == "function" then
  516. self.scrlRed:setScrollBarEnabled(false)
  517. end
  518. self.scrlRed:setSize(cc.size(354, inner_h))
  519. self.scrlRed:setPosition(cc.p(177, 150))
  520. self.scrlRed:setInnerContainerSize(cc.size(354, inner_h))
  521. self.node_redSign:addChild(self.scrlRed)
  522. end
  523. --红包奖励记录
  524. function LayerMatch:refreshRedList()
  525. local __datas = {}
  526. local index = 1
  527. for k,v in pairs(G_EapSdkMgr.m_redRecords) do
  528. for i=1, #v do
  529. __datas[index] = v[i]
  530. index = index + 1
  531. end
  532. end
  533. if #__datas <= 0 then
  534. return
  535. end
  536. local gameName = ""
  537. local matchIDs = table.keys(G_EapSdkMgr.m_matchInfos)
  538. local matchInfo = G_EapSdkMgr.m_matchInfos[matchIDs[1]]
  539. if matchInfo then
  540. local gameInfo = G_EapSdkMgr:getGameInfo(matchInfo.GameID)
  541. gameName = gameInfo and gameInfo.name or tostring(matchInfo.GameID)
  542. end
  543. local item_h = 55
  544. local dataLen = table.nums(__datas)
  545. local data_h = item_h*dataLen
  546. local inner_h = 110
  547. inner_h = data_h > inner_h and data_h or inner_h
  548. self.scrlRed:setInnerContainerSize(cc.size(354, inner_h))
  549. for i=1, dataLen do
  550. local recordInfo = __datas[i]
  551. if recordInfo then
  552. local recTime = EapFormatTime(recordInfo.ChangeTime, 9)
  553. local redNum = recordInfo.ChangeMoney or 0
  554. local redNumStr = string.format("%.2f", redNum)
  555. redNumStr = redNumStr.."红包"
  556. if redNum > 0 then
  557. redNumStr = "+"..redNumStr
  558. end
  559. local type = recordInfo.Type or 0
  560. local typeStr = ""
  561. if type == 1 then
  562. typeStr = gameName.."对局奖励"
  563. elseif type == 2 then
  564. typeStr = gameName.."排名奖励"
  565. end
  566. local itemNode = self.m_redItems[i]
  567. if itemNode then
  568. itemNode:setPosition(cc.p(177, inner_h-(i-1)*item_h))
  569. itemNode.lblTime:setString(recTime)
  570. itemNode.lblRedNum:setString(redNumStr)
  571. itemNode.lblType:setString(typeStr)
  572. else
  573. local itemNode = ccui.Layout:create()
  574. itemNode:setAnchorPoint(cc.p(0.5, 1))
  575. itemNode:setSize(cc.size(354, item_h))
  576. itemNode:setPosition(cc.p(177, inner_h-(i-1)*item_h))
  577. self.scrlRed:addChild(itemNode)
  578. itemNode.lblTime = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(88-10, 40), recTime, 20, cc.c3b(0xff, 0xf6, 0xaa))
  579. itemNode.lblRedNum = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(88-10, 15), redNumStr, 30, cc.c3b(0xe6, 0x65, 0x60))
  580. itemNode.lblType = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(88+157, 13), typeStr, 24, cc.c3b(0xff, 0xf6, 0xaa))
  581. self.m_redItems[#self.m_redItems + 1] = itemNode
  582. end
  583. end
  584. end
  585. end
  586. --刷新红包数据
  587. function LayerMatch:refreshRedInfo()
  588. local redInfo = G_EapSdkMgr.m_redInfo or {}
  589. if redInfo then
  590. local money = redInfo.Money or 0
  591. if money ~= 0 then
  592. if G_EapSdkMgr.EapPhone then
  593. money = string.format("%.2f", money)
  594. else
  595. money = string.format("%.2f", money-100)
  596. end
  597. else
  598. if G_EapSdkMgr.EapPhone then
  599. money = 188
  600. else
  601. money = 88
  602. end
  603. end
  604. local moneyStr = money
  605. self.lblBtnRedNum:setString(moneyStr)
  606. self.lblRedNum:setString(moneyStr)
  607. self.lblNoSignRedNum:setString(moneyStr)
  608. local matchIDs = table.keys(G_EapSdkMgr.m_matchInfos)
  609. if matchIDs[1] then
  610. local gameName = ""
  611. local matchInfo = G_EapSdkMgr.m_matchInfos[matchIDs[1]]
  612. if matchInfo then
  613. local gameInfo = G_EapSdkMgr:getGameInfo(matchInfo.GameID)
  614. gameName = gameInfo and gameInfo.name or "麻将"
  615. end
  616. local redDesStr = "参与"..gameName.."对局(4人)可增加红包金额"
  617. self.lblRedBtnDes:setString(redDesStr)
  618. local selfRank = G_EapSdkMgr:getSelfRankByID(matchIDs[1])
  619. if selfRank then
  620. selfRank.Rank = selfRank.Rank or 0
  621. if selfRank.Rank >=1 and selfRank.Rank < 33 then --32强
  622. self.btnAward:loadTexture(self.imgPath[47])
  623. self.imgRedTitle2:loadTexture(self.imgPath[46])
  624. self.imgRedTitle3:setVisible(true)
  625. elseif selfRank.Rank >= 33 then
  626. self.btnAward:loadTexture(self.imgPath[11])
  627. self.imgRedTitle2:loadTexture(self.imgPath[45])
  628. self.imgRedTitle3:setVisible(false)
  629. end
  630. end
  631. end
  632. end
  633. end
  634. function LayerMatch:initTips()
  635. --提示框所在层
  636. self.imgTipsBG = G_EapAbbreviation.createImageView(self.imgPath[1], self.imgBack2, cc.p(0, 0), true, 10, 2102, cc.p(0, 0))
  637. self.imgTipsBG:setSize(cc.size(BG_W, 510))
  638. self.imgTipsBG:setVisible(false)
  639. addButtonListener(self.imgTipsBG, function()
  640. self.imgTipsBG:setVisible(false)
  641. end)
  642. self.imgTips = G_EapAbbreviation.createImageView(self.imgPath[40], self.imgTipsBG, cc.p(BG_W/2, 0), false, 1, 2102, cc.p(1, 0))
  643. -- self.lblTips = G_EapAbbreviation.createSystemLabel(self.imgTips, cc.p(5, 40), "", 12, WEAK_COL1)
  644. -- self.lblTips:setWidth(192)
  645. -- self.lblTips:setLineBreakWithoutSpace(true) --自动换行
  646. self.lblTips = cc.Text:createNode();
  647. self.lblTips:setDefaults();
  648. local config = self.lblTips:getFontConfig();
  649. config.fontSize = 20;
  650. self.lblTips:setFontConfig(config);
  651. self.lblTips:setColor(WEAK_COL1)
  652. self.lblTips:setTextAreaSize(cc.size(290, 0))
  653. self.lblTips:setLinePadding(2)
  654. self.lblTips:setAnchorPoint(cc.p(0, 0.5))
  655. self.lblTips:setPosition(cc.p(5, 55))
  656. self.imgTips:addChild(self.lblTips)
  657. self.node_tips = cc.Node:create()
  658. self.imgBack2:addChild(self.node_tips)
  659. for i=1, #self.m_tips do
  660. local node_parent = self.node_myScore
  661. if i == #self.m_tips then
  662. node_parent = self.imgBack2
  663. end
  664. local tipInfo = self.m_tips[i]
  665. local btnTip = G_EapAbbreviation.createImageView(self.imgPath[1], node_parent, tipInfo.pos, true, 1, 2102, cc.p(0, 0))
  666. btnTip:setSize(cc.size(60, 30))
  667. addButtonListener(btnTip, function()
  668. self.imgTips:setPosition(cc.p(tipInfo.pos.x+50, tipInfo.pos.y+35))
  669. local des = tipInfo.des
  670. -- if i == 4 then
  671. -- local matchIDs = table.keys(G_EapSdkMgr.m_matchInfos)
  672. -- local matchInfo = G_EapSdkMgr.m_matchInfos[matchIDs[1]]
  673. -- local timeStr = ""
  674. -- if matchInfo then
  675. -- if matchInfo.VecReLi then
  676. -- local reLen = #matchInfo.VecReLi
  677. -- for i=1, reLen do
  678. -- local time1 = matchInfo.VecReLi[i]
  679. -- timeStr = timeStr..EapFormatTime(time1.TimeStart, 4).."~"..EapFormatTime(time1.TimeEnd, 4)
  680. -- if i ~= reLen then
  681. -- timeStr = timeStr.." "
  682. -- end
  683. -- end
  684. -- end
  685. -- end
  686. -- if timeStr ~= "" then
  687. -- timeStr = "(每天"..timeStr..")"
  688. -- end
  689. -- des = tipInfo.des.." "..timeStr
  690. -- end
  691. self.lblTips:setText(des)
  692. self.imgTipsBG:setVisible(true)
  693. end)
  694. end
  695. end
  696. function LayerMatch:initCDTime()
  697. local endTime = 0
  698. local startTime = 0
  699. for k,v in pairs(G_EapSdkMgr.m_allMatchs) do
  700. local matchtime = v.MatchTime
  701. endTime = matchtime.TimeEnd
  702. startTime = matchtime.TimeStart
  703. break
  704. end
  705. local cdStr = ""
  706. local curTime = os.time()
  707. if curTime < startTime then
  708. cdStr = cdStr..GetCountDownTime(startTime)
  709. else
  710. cdStr = cdStr..GetCountDownTime(endTime)
  711. end
  712. local timeArr = string.split(cdStr, ":")
  713. for i=1, 3 do
  714. self["lblCDTime"..i]:setString(timeArr[i])
  715. end
  716. local hour = tonumber(timeArr[1])*24 + tonumber(timeArr[2])
  717. local redTimeStr = hour.."小时"..timeArr[3].."分后清零"
  718. self.lblRedTime:setString(redTimeStr)
  719. self.m_schIDCDTime = scheduler.scheduleGlobal(function()
  720. local curTime = os.time()
  721. if curTime >= endTime and self.m_schIDCDTime then
  722. scheduler.unscheduleGlobal(self.m_schIDCDTime)
  723. return
  724. end
  725. local cdStr = ""
  726. local curTime = os.time()
  727. if curTime < startTime then
  728. cdStr = cdStr..GetCountDownTime(startTime)
  729. else
  730. cdStr = cdStr..GetCountDownTime(endTime)
  731. end
  732. local timeArr = string.split(cdStr, ":")
  733. for i=1, 3 do
  734. self["lblCDTime"..i]:setString(timeArr[i])
  735. end
  736. local hour = tonumber(timeArr[1])*24 + tonumber(timeArr[2])
  737. local redTimeStr = hour.."小时"..timeArr[3].."分后清零"
  738. self.lblRedTime:setString(redTimeStr)
  739. end, 60)
  740. end
  741. function LayerMatch:setInfoItem()
  742. local item_h = 42
  743. local dataLen = table.nums(G_EapSdkMgr.m_matchInfos)
  744. local data_h = item_h*dataLen
  745. self.inner_h = data_h > self.inner_h and data_h or self.inner_h
  746. self.scrollView:setInnerContainerSize(cc.size(414, self.inner_h))
  747. local index = 1
  748. for k,v in pairs(G_EapSdkMgr.m_matchInfos) do
  749. local gameInfo = G_EapSdkMgr:getGameInfo(v.GameID)
  750. local gameName = gameInfo and gameInfo.name or tostring(v.GameID)
  751. if G_EapLabelTool.GetUTF8StrNums( gameName ) > 9 then
  752. gameName = G_EapLabelTool.GetUTF8StrByIdxNumEx(gameName, 9)
  753. gameName = gameName..".."
  754. end
  755. local selfData = G_EapSdkMgr:getSelfRankByID(k)
  756. local tmpData = selfData or {
  757. Calcu = "0",
  758. BlScore = "0",
  759. AllNum = "0",
  760. ReNum = "0",
  761. }
  762. if not G_EapSdkMgr.m_pointSelGameID then
  763. local maxMatch = G_EapSdkMgr:getMaxNumMatch()
  764. if maxMatch and maxMatch.GameNum > 0 then
  765. else
  766. tmpData = {
  767. Calcu = "0",
  768. BlScore = "0",
  769. AllNum = "0",
  770. ReNum = "0",
  771. }
  772. gameName = "--"
  773. end
  774. end
  775. curScore = tmpData.Calcu or 0
  776. blScore = tmpData.BlScore or 0
  777. tmpData.AllNum = tmpData.AllNum or 0
  778. tmpData.ReNum = tmpData.ReNum or 0
  779. if curScore ~= 0 then
  780. curScore = string.format("%.2f", curScore)
  781. end
  782. if blScore ~= 0 then
  783. blScore = string.format("%.2f", blScore)
  784. end
  785. local itemNode = self.m_itemArr[index]
  786. if itemNode then
  787. itemNode.lblCoreName:setString(gameName)
  788. itemNode.lblRank:setString(curScore)
  789. itemNode.lblBlRank:setString(blScore)
  790. itemNode.lblAcRank:setString(tmpData.AllNum)
  791. itemNode.lblReRank:setString(tmpData.ReNum)
  792. else
  793. local itemNode = ccui.Layout:create()
  794. itemNode:setAnchorPoint(cc.p(0.5, 1))
  795. itemNode:setSize(cc.size(414, item_h))
  796. itemNode:setPosition(cc.p(414/2, self.inner_h-(index-1)*item_h))
  797. self.scrollView:addChild(itemNode)
  798. local imgBack3 = G_EapAbbreviation.createImageView(self.imgPath[14], itemNode, cc.p(414/2, item_h), false, 0, 2102, cc.p(0.5, 1))
  799. imgBack3:setScale(0.6)
  800. itemNode.lblCoreName = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(41.5, 25), gameName, 18, DEEP_COL1, true)
  801. --热力时间
  802. -- local timeStr = ""
  803. -- if v.VecReLi then
  804. -- local reLen = #v.VecReLi
  805. -- for i=1, reLen do
  806. -- local time1 = v.VecReLi[i]
  807. -- timeStr = timeStr..EapFormatTime(time1.TimeStart, 4).."~"..EapFormatTime(time1.TimeEnd, 4)
  808. -- if i ~= reLen then
  809. -- timeStr = timeStr.."\r\n"
  810. -- end
  811. -- end
  812. -- end
  813. -- local hotStr = timeStr
  814. -- itemNode.lblHotDur = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(10, item_h-50), hotStr, 18, WEAK_COL1)
  815. -- itemNode.lblHotDur:setAnchorPoint(cc.p(0, 1))
  816. local rankStr = curScore
  817. itemNode.lblRank = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(41.5+83, 25), rankStr, 18, DEEP_COL1)
  818. local blRankStr = blScore
  819. itemNode.lblBlRank = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(41.5+83*2, 25), blRankStr, 18, DEEP_COL1)
  820. local acRankStr = tmpData.AllNum
  821. itemNode.lblAcRank = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(41.5+83*3, 25), acRankStr, 18, DEEP_COL1)
  822. local reRankStr = tmpData.ReNum
  823. itemNode.lblReRank = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(41.5+83*4, 25), reRankStr, 18, DEEP_COL1)
  824. self.m_itemArr[#self.m_itemArr + 1] = itemNode
  825. end
  826. index = index + 1
  827. end
  828. self.scrollView:jumpToTop()
  829. if not G_EapSdkMgr.EapPhone then --是否绑定手机号
  830. self:checkBindPhone(false)
  831. else
  832. self:checkBindPhone(true)
  833. end
  834. end
  835. function LayerMatch:refreshFollowState()
  836. local srchPID = tonumber(self.editPhone:getText()) or 0
  837. print("LayerMatch:refreshFollowState( ", srchPID)
  838. if G_EapSdkMgr:isFriend(srchPID) then
  839. self.btnFollow:loadTexture(self.imgPath[25])
  840. else
  841. self.btnFollow:loadTexture(self.imgPath[24])
  842. end
  843. end
  844. function LayerMatch:refreshSearchRes()
  845. --搜索昵称
  846. local srchPID = tonumber(self.editPhone:getText()) or 0
  847. local userInfo = G_EapSdkMgr.m_userBaseInfos[srchPID]
  848. if userInfo then
  849. local nickname = userInfo and userInfo.strNickname
  850. local title1 = nickname or tostring(srchPID)
  851. if G_EapLabelTool.GetUTF8StrNums( title1 ) > 6 then
  852. title1 = G_EapLabelTool.GetUTF8StrByIdxNumEx(title1, 6)
  853. title1 = title1..".."
  854. end
  855. self.lblSrchName:setString(title1)
  856. else
  857. self.lblSrchName:setString("-")
  858. end
  859. self:refreshFollowState()
  860. local matchInfo = G_EapSdkMgr.m_otherMatchInfos[srchPID]
  861. if G_EapSdkMgr:isFriend(srchPID) then
  862. local matchIDs = table.keys(G_EapSdkMgr.m_matchInfos)
  863. matchInfo = G_EapSdkMgr:getFriendMatchInfo(matchIDs[1], srchPID)
  864. end
  865. if matchInfo then
  866. local curScore = matchInfo.Calcu or 0
  867. local blScore = matchInfo.BlScore or 0
  868. local allNum = matchInfo.AllNum or 0
  869. local gameCount = matchInfo.ReNum or 0
  870. if curScore ~= 0 then
  871. curScore = string.format("%.2f", curScore)
  872. end
  873. if blScore ~= 0 then
  874. blScore = string.format("%.2f", blScore)
  875. end
  876. local tmpMatch = G_EapSdkMgr.m_matchInfos[matchInfo.MatchID]
  877. if tmpMatch then
  878. local gameInfo = G_EapSdkMgr:getGameInfo(tmpMatch.GameID)
  879. local gameName = gameInfo and gameInfo.name or tostring(tmpMatch.GameID)
  880. if G_EapLabelTool.GetUTF8StrNums( gameName ) > 9 then
  881. gameName = G_EapLabelTool.GetUTF8StrByIdxNumEx(gameName, 9)
  882. gameName = gameName..".."
  883. end
  884. self.lblSrchMatchName:setString(gameName)
  885. end
  886. self.lblSrchScore:setString(curScore)
  887. self.lblSrchBlScore:setString(blScore)
  888. self.lblSrchAllNum:setString(allNum)
  889. self.lblSrchReNum:setString(gameCount)
  890. else
  891. self.lblSrchMatchName:setString("-")
  892. self.lblSrchScore:setString("-")
  893. self.lblSrchBlScore:setString("-")
  894. self.lblSrchAllNum:setString("-")
  895. self.lblSrchReNum:setString("-")
  896. end
  897. if userInfo or matchInfo then
  898. self.btnFollow:setVisible(true)
  899. else
  900. self.btnFollow:setVisible(false)
  901. end
  902. --不可关注自己
  903. if srchPID == G_EapSdkMgr.UserId then
  904. self.btnFollow:setVisible(false)
  905. end
  906. end
  907. function LayerMatch:refreshFriendList(__matchID)
  908. local __datas = G_EapSdkMgr.m_friendMatchInfos[__matchID]
  909. if self.scrlViewFriends then
  910. self.scrlViewFriends:destroySelf()
  911. self.scrlViewFriends = nil
  912. end
  913. if not __datas then
  914. return
  915. end
  916. local EapListView = require("luaScript.ModuleEapSdk.GameTools.EapListView")
  917. self.scrlViewFriends = EapListView.createWithData(self.node_friList, self)
  918. local params = {
  919. scrl_h = 105, -- 外框高度
  920. scrl_w = 480, -- 外框宽度
  921. inner_h = 105, -- 内容器高度
  922. item_h = 50, -- 元素高度
  923. }
  924. self.scrlViewFriends:setScrlParam(params)
  925. self.scrlViewFriends:setPosition(cc.p(12, 0))
  926. self.scrlViewFriends:refreshRankList(__datas)
  927. end
  928. function LayerMatch:initItemInfo(itemNode, info)
  929. info = info or {}
  930. local init_x = 40
  931. info = info or {}
  932. itemNode.m_id = info.PID
  933. itemNode.imgBG = G_EapAbbreviation.createImageView(self.imgPath[36], itemNode, cc.p(240, 25))
  934. itemNode.imgBG:setScale(0.6)
  935. local curScore = info.Calcu or 0
  936. local blScore = info.BlScore or 0
  937. local allNum = info.AllNum or 0
  938. local gameCount = info.ReNum or 0
  939. if curScore ~= 0 then
  940. curScore = string.format("%.2f", curScore)
  941. end
  942. if blScore ~= 0 then
  943. blScore = string.format("%.2f", blScore)
  944. end
  945. --赛事名称
  946. itemNode.lblMatchName = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(43, 25), "", 18, WEAK_COL1)
  947. local matchIDs = table.keys(G_EapSdkMgr.m_matchInfos)
  948. local matchInfo = G_EapSdkMgr.m_matchInfos[matchIDs[1]]
  949. if matchInfo then
  950. local gameInfo = G_EapSdkMgr:getGameInfo(matchInfo.GameID)
  951. local gameName = gameInfo and gameInfo.name or tostring(matchInfo.GameID)
  952. if G_EapLabelTool.GetUTF8StrNums( gameName ) > 9 then
  953. gameName = G_EapLabelTool.GetUTF8StrByIdxNumEx(gameName, 9)
  954. gameName = gameName..".."
  955. end
  956. itemNode.lblMatchName:setString(gameName)
  957. end
  958. --昵称
  959. local userInfo = G_EapSdkMgr.m_userBaseInfos[itemNode.m_id]
  960. local nickname = userInfo and userInfo.strNickname
  961. local title1 = nickname or tostring(itemNode.m_id)
  962. if G_EapLabelTool.GetUTF8StrNums( title1 ) > 6 then
  963. title1 = G_EapLabelTool.GetUTF8StrByIdxNumEx(title1, 6)
  964. title1 = title1..".."
  965. end
  966. itemNode.lblName = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(init_x+init_x*2, 25), title1, 16, WEAK_COL1)
  967. --赛程分
  968. local title3 = curScore
  969. itemNode.lblScore = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(init_x+init_x*2*2, 25), title3, 16, WEAK_COL1)
  970. --平均局数
  971. local title4 = blScore
  972. itemNode.lblCount = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(init_x+init_x*2*3, 25), title4, 16, WEAK_COL1)
  973. --比赛局数
  974. local title5 = allNum
  975. itemNode.lblAllNum = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(init_x+init_x*2*4, 25), title5, 16, WEAK_COL1)
  976. --热力局数
  977. local title6 = gameCount
  978. itemNode.lblReNum = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(init_x+init_x*2*5, 25), title6, 16, WEAK_COL1)
  979. end
  980. function LayerMatch:refreshItemInfo(itemNode, info, index)
  981. if not itemNode or not index or not info then
  982. return
  983. end
  984. itemNode.m_id = info.PID
  985. itemNode.infoIndex = index --数据索引
  986. itemNode.m_info = info
  987. local curScore = info.Calcu or 0
  988. local blScore = info.BlScore or 0
  989. local allNum = info.AllNum or 0
  990. local gameCount = info.ReNum or 0
  991. if curScore ~= 0 then
  992. curScore = string.format("%.2f", curScore)
  993. end
  994. if blScore ~= 0 then
  995. blScore = string.format("%.2f", blScore)
  996. end
  997. --赛事名称
  998. local matchIDs = table.keys(G_EapSdkMgr.m_matchInfos)
  999. local matchInfo = G_EapSdkMgr.m_matchInfos[matchIDs[1]]
  1000. if matchInfo then
  1001. local gameInfo = G_EapSdkMgr:getGameInfo(matchInfo.GameID)
  1002. local gameName = gameInfo and gameInfo.name or tostring(matchInfo.GameID)
  1003. if G_EapLabelTool.GetUTF8StrNums( gameName ) > 9 then
  1004. gameName = G_EapLabelTool.GetUTF8StrByIdxNumEx(gameName, 9)
  1005. gameName = gameName..".."
  1006. end
  1007. itemNode.lblMatchName:setString(gameName)
  1008. end
  1009. --昵称
  1010. local userInfo = G_EapSdkMgr.m_userBaseInfos[itemNode.m_id]
  1011. local nickname = userInfo and userInfo.strNickname
  1012. local title1 = nickname or tostring(itemNode.m_id)
  1013. if G_EapLabelTool.GetUTF8StrNums( title1 ) > 6 then
  1014. title1 = G_EapLabelTool.GetUTF8StrByIdxNumEx(title1, 6)
  1015. title1 = title1..".."
  1016. end
  1017. itemNode.lblName:setString(title1)
  1018. --赛程分
  1019. local title3 = curScore
  1020. itemNode.lblScore:setString(title3)
  1021. --平均局数
  1022. local title4 = blScore
  1023. itemNode.lblCount:setString(title4)
  1024. --比赛局数
  1025. local title5 = allNum
  1026. itemNode.lblAllNum:setString(title5)
  1027. --热力局数
  1028. local title6 = gameCount
  1029. itemNode.lblReNum:setString(title6)
  1030. end
  1031. function LayerMatch:refreshFriendListItems(__id)
  1032. if self.scrlViewFriends then
  1033. self.scrlViewFriends:refreshAllItems(__id)
  1034. end
  1035. end
  1036. function LayerMatch:checkBindPhone(__state)
  1037. self.imgCover:setVisible(not __state)
  1038. self.imgRedBG:setVisible(not __state)
  1039. self.node_redNoSign:setVisible(not __state)
  1040. self.node_redSign:setVisible(__state)
  1041. end
  1042. function LayerMatch:refreshBattleScore()
  1043. local myItem = G_EapSdkMgr:getItem(ITEM_TYPE.INTEGRAL)
  1044. local scoreNum = myItem and myItem.nNum or 0
  1045. local score = scoreNum
  1046. self.lblScore:setString(score)
  1047. end
  1048. return LayerMatch