local DEEP_COL1 = cc.c3b(0xff, 0xff, 0xff) local BG_W = 564 local scheduler = require("luaScript.ModuleEapSdk.SdkSocket.scheduler") local BaseLayer = require("luaScript.ModuleEapSdk.BaseLayers.BaseLayer") local LayerFree = EapClass("LayerFree", BaseLayer) function LayerFree.createWithData(__node, __zorder) local layer = LayerFree.new() layer.m_parent = __node __node:addChild(layer, __zorder) return layer end function LayerFree:myShow() -- self:addListener(true) self:initUI() end function LayerFree:myClose() if self.m_schIDCDTime then scheduler.unscheduleGlobal(self.m_schIDCDTime) end end function LayerFree:initUI() self.imgPath = { "res/ModuleEapSdk/eapsdk_img_null.png", "res/ModuleEapSdk/eapsdk_public_back_bg2.png", "res/ModuleEapSdk/eapsdk_public_back_bg3.png", "res/ModuleEapSdk/eapsdk_bg_bj_sp1.png", "res/ModuleEapSdk/eapsdk_bt_xb_sp.png", --5 "res/ModuleEapSdk/Eap_Score/eapsdk_img_title.png", "res/ModuleEapSdk/eapsdk_wj_icon_question.png", "res/ModuleEapSdk/Eap_Score/eapsdk_btn_actScore.png", "res/ModuleEapSdk/eapsdk_wj_img_adv.png", "res/ModuleEapSdk/eapsdk_wj_icon_question_off.png", --赛事规则off --10 "res/ModuleEapSdk/eapsdk_img_timeBG.png", "res/ModuleEapSdk/eapsdk_public_img_dots.png", } local fix_x = display.width local fix_y = display.cy local imgBack2 = G_EapAbbreviation.createImageView(self.imgPath[1], self, cc.p(fix_x, fix_y+45), true, 2, 2101, cc.p(1, 0.5)) imgBack2:setSize(cc.size(BG_W, 510)) self.imgBack2 = imgBack2 -- --赛事宣传图 -- self.imgBanner = G_EapAbbreviation.createImageView(self.imgPath[9], imgBack2, cc.p(BG_W/2, 200)) -- self.imgBanner:setScale(0.6) self.imgDots = G_EapAbbreviation.createImageView(self.imgPath[12], imgBack2, cc.p(BG_W/2+200, 70), false, 2) self.imgDots:setScale(0.6) self.imgTime = G_EapAbbreviation.createImageView(self.imgPath[11], imgBack2, cc.p(BG_W/2, 355)) self.imgTime:setScale(0.6) self.lblCDTime1 = G_EapAbbreviation.createSystemLabel(imgBack2, cc.p(BG_W/2-27, 355), "00", 22, DEEP_COL1) self.lblCDTime2 = G_EapAbbreviation.createSystemLabel(imgBack2, cc.p(BG_W/2+27, 355), "00", 22, DEEP_COL1) self.lblCDTime3 = G_EapAbbreviation.createSystemLabel(imgBack2, cc.p(BG_W/2+100, 355), "00", 22, cc.c3b(0x0b, 0x2d, 0x67)) self.btnDes = ccui.ImageView:create(self.imgPath[10]) self.btnDes:setPosition(cc.p(62, 410)) self.btnDes:setScale(0.6) imgBack2:addChild(self.btnDes) addButtonListener(self.btnDes, function() print("LayerMatch btnDes clicked === ") if G_LayerMain:isSubLayerVis(LAYER_ENUM.LAYER_RULE) then G_LayerMain:closeSubLayer(LAYER_ENUM.LAYER_RULE) self.btnDes:loadTexture(self.imgPath[10]) else for k,v in pairs(G_EapSdkMgr.m_matchInfos) do local matchID = k if not G_EapSdkMgr.m_matchRule and matchID then G_EapSocketLogin.request_matchRuleGet(matchID) end break end G_LayerMain:showSubLayer(LAYER_ENUM.LAYER_RULE) self.btnDes:loadTexture(self.imgPath[7]) end end) --报名参赛 self.btnJion = ccui.Button:create(self.imgPath[8]) self.btnJion:setPosition(cc.p(BG_W/2, 30)) self.btnJion:setScale(0.6) imgBack2:addChild(self.btnJion) addButtonListener(self.btnJion, function() G_EapSdkMgr.m_firstLogin = false G_EapSocketLogin.request_markLog(MARK_LOG10013) G_EapSdkMgr:setClickEnter(1) G_LayerMain:showLayer(LAYER_ENUM.LAYER_MATCH) end) self:refreshIcon() self:initCDTime() end function LayerFree:initCDTime() local endTime = 0 local startTime = 0 for k,v in pairs(G_EapSdkMgr.m_allMatchs) do local matchtime = v.MatchTime endTime = matchtime.TimeEnd startTime = matchtime.TimeStart break end local cdStr = "" local curTime = os.time() if curTime < startTime then cdStr = GetCountDownTime(startTime) else cdStr = GetCountDownTime(endTime) end local timeArr = string.split(cdStr, ":") for i=1, 3 do self["lblCDTime"..i]:setString(timeArr[i]) end self.m_schIDCDTime = scheduler.scheduleGlobal(function() local curTime = os.time() if curTime >= endTime and self.m_schIDCDTime then scheduler.unscheduleGlobal(self.m_schIDCDTime) return end local cdStr = "" local curTime = os.time() if curTime < startTime then cdStr = GetCountDownTime(startTime) else cdStr = GetCountDownTime(endTime) end local timeArr = string.split(cdStr, ":") for i=1, 3 do self["lblCDTime"..i]:setString(timeArr[i]) end end, 60) end function LayerFree:refreshIcon() local iconInfo1005 = G_EapSdkMgr:getIconInfo(CONFIG_IMG_1005) --赛事宣传图 if iconInfo1005 then -- local url = iconInfo1005.paths[1] -- local saveName = iconInfo1005.categoryId..tostring(iconInfo1005.updateTime) -- getUserImage(url, saveName, self.imgBanner, cc.size(478, 304)) local imgBannerArr = {} local imgLen = #iconInfo1005.paths for i=1, imgLen do local url = iconInfo1005.paths[i] local imgBanner = G_EapAbbreviation.createImageView(self.imgPath[9], self.imgBack2, cc.p(BG_W/2, 200)) imgBanner:setScale(0.6) if i == 1 then imgBanner:setVisible(true) else imgBanner:setVisible(false) end imgBannerArr[#imgBannerArr + 1] = imgBanner local saveName = tostring(iconInfo1005.categoryId).."_"..i..tostring(iconInfo1005.updateTime) getUserImage(url, saveName, imgBanner, cc.size(478, 304)) addButtonListener(imgBanner, function() imgBanner:setVisible(false) local next = i+1 if next > imgLen then next = 1 end imgBannerArr[next]:setVisible(true) end) end end end return LayerFree