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.

139 lines
4.5 KiB

  1. local BG_W = 564
  2. local BaseLayer = require("luaScript.ModuleEapSdk.BaseLayers.BaseLayer")
  3. local LayerBoard = EapClass("LayerBoard", BaseLayer)
  4. function LayerBoard.createWithData(__node, __zorder)
  5. local layer = LayerBoard.new()
  6. layer.m_parent = __node
  7. __node:addChild(layer, __zorder)
  8. return layer
  9. end
  10. function LayerBoard:myShow()
  11. self:addListener(true)
  12. self:initData()
  13. self:initUI()
  14. end
  15. function LayerBoard:myClose()
  16. end
  17. function LayerBoard:initData()
  18. self.m_logos = {}
  19. end
  20. function LayerBoard:initUI()
  21. self.imgPath = {
  22. "res/ModuleEapSdk/eapsdk_img_bg.png",
  23. "res/ModuleEapSdk/Eap_Score/eapsdk_wj_banner_score.png",
  24. "res/ModuleEapSdk/Eap_Score/eapsdk_wj_img_matchSchl.png",
  25. "res/ModuleEapSdk/Eap_Score/eapsdk_img_title.png",
  26. "res/ModuleEapSdk/Eap_Score/eapsdk_wj_img_matchLogo.png",
  27. "res/ModuleEapSdk/eapsdk_wj_btn_close.png",
  28. }
  29. G_EapAbbreviation.addBackLayer(self, 150)
  30. local fix_x = display.width
  31. local fix_y = display.cy
  32. local imgBack = G_EapAbbreviation.createImageView(self.imgPath[1], self, cc.p(fix_x, fix_y), false, 0, 1101, cc.p(1, 0.5))
  33. imgBack:setScale(0.6)
  34. self.btnBack = ccui.Button:create(self.imgPath[6])
  35. self.btnBack:setPosition(cc.p(fix_x-915, fix_y+280))
  36. self:addChild(self.btnBack, 1000)
  37. addButtonListener(self.btnBack, function()
  38. G_LayerMain:showBoard(false)
  39. G_EapSocketLogin.request_markLog(MARK_LOG11002)
  40. end)
  41. local bannerName = self.imgPath[2]
  42. self.imgBanner = G_EapAbbreviation.createImageView(bannerName, self, cc.p(fix_x-BG_W, fix_y), false, 0, 1101, cc.p(1, 0.5))
  43. self.imgSchl = G_EapAbbreviation.createImageView(self.imgPath[3], self, cc.p(fix_x-BG_W-45, fix_y-150), false, 0, 1101, cc.p(1, 0.5))
  44. self.imgBanner:setScale(0.6)
  45. self.imgSchl:setScale(0.6)
  46. self.node_top = cc.Node:create()
  47. self.node_top:setPosition(cc.p(fix_x-BG_W/2, fix_y+230))
  48. self:addChild(self.node_top, 1)
  49. self.imgTitle = G_EapAbbreviation.createImageView(self.imgPath[4], self.node_top, cc.p(0, 0))
  50. self.imgTitle:setScale(0.6)
  51. for i=1, 4 do
  52. local imgLogo = G_EapAbbreviation.createImageView(self.imgPath[5], self.node_top, cc.p(0, 0))
  53. imgLogo:setScale(0.6)
  54. imgLogo:setVisible(false)
  55. if i==1 then
  56. imgLogo:setPosition(cc.p(180, -20))
  57. end
  58. if i==2 then
  59. imgLogo:setPosition(cc.p(240, -20))
  60. end
  61. if i==3 then
  62. imgLogo:setPosition(cc.p(180, -60))
  63. end
  64. if i==4 then
  65. imgLogo:setPosition(cc.p(240, -60))
  66. end
  67. self.m_logos[i] = imgLogo
  68. end
  69. self:refreshIcon()
  70. end
  71. function LayerBoard:showBack(__state)
  72. self.imgBanner:setVisible(__state)
  73. end
  74. function LayerBoard:showTop(__state)
  75. self.node_top:setVisible(__state)
  76. end
  77. function LayerBoard:onTouchEnd(__touch)
  78. local touchPos = __touch:getLocation()
  79. if touchPos.x < 250+FIX_WIDTH-G_LayerMain.fix_w/2 then
  80. if self:isVisible() then
  81. G_EapSocketLogin.request_markLog(MARK_LOG11002)
  82. end
  83. G_LayerMain:showBoard(false)
  84. end
  85. end
  86. function LayerBoard:refreshIcon()
  87. local iconInfo1001 = G_EapSdkMgr:getIconInfo(CONFIG_IMG_1001)
  88. local iconInfo1002 = G_EapSdkMgr:getIconInfo(CONFIG_IMG_1002)
  89. local iconInfo1003 = G_EapSdkMgr:getIconInfo(CONFIG_IMG_1003)
  90. local iconInfo1004 = G_EapSdkMgr:getIconInfo(CONFIG_IMG_1004)
  91. if iconInfo1001 then
  92. local url = iconInfo1001.paths[1]
  93. local saveName = iconInfo1001.categoryId..tostring(iconInfo1001.updateTime)
  94. getUserImage(url, saveName, self.imgBanner, cc.size(332, 600))
  95. end
  96. if iconInfo1002 then
  97. local url = iconInfo1002.paths[1]
  98. local saveName = iconInfo1002.categoryId..tostring(iconInfo1002.updateTime)
  99. getUserImage(url, saveName, self.imgSchl, cc.size(241, 231))
  100. end
  101. if iconInfo1003 then
  102. local url = iconInfo1003.paths[1]
  103. local saveName = iconInfo1003.categoryId..tostring(iconInfo1003.updateTime)
  104. getUserImage(url, saveName, self.imgTitle, cc.size(493, 144))
  105. end
  106. if iconInfo1004 then
  107. for i=1, 4 do
  108. local url = iconInfo1004.paths[i]
  109. if url then
  110. local saveName = tostring(iconInfo1004.categoryId).."_"..i..tostring(iconInfo1004.updateTime)
  111. getUserImage(url, saveName, self.m_logos[i], cc.size(50, 25))
  112. else
  113. self.m_logos[i]:setVisible(false)
  114. end
  115. end
  116. end
  117. end
  118. return LayerBoard