From fb671ca1af22847cff9aad2ff74ca5eb0cf54901 Mon Sep 17 00:00:00 2001 From: chenxi Date: Fri, 16 Jun 2023 15:11:37 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=B4=E6=8A=A4=E5=85=AC=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/common/sdk_manager.lua | 1 + lua/app/module/login/login_manager.lua | 33 ++++++++----------- .../module/login/maintenance_notice_ui.lua | 22 ++++++++++++- 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/lua/app/common/sdk_manager.lua b/lua/app/common/sdk_manager.lua index 93dc038e..14485299 100644 --- a/lua/app/common/sdk_manager.lua +++ b/lua/app/common/sdk_manager.lua @@ -381,6 +381,7 @@ function SDKManager:getServerList(callback) bundle_id = Platform:getIdentifier(), version = Platform:getClientVersion(), device_id = DeviceHelper:getDeviceId(), + language = I18N:getLanguageAndArea(), env = "release",-- 暂时写死 } local loginCenterUrl = CS.BF.BFPlatform.GetLoginCenterURL() diff --git a/lua/app/module/login/login_manager.lua b/lua/app/module/login/login_manager.lua index e0b95ab1..79fc1280 100644 --- a/lua/app/module/login/login_manager.lua +++ b/lua/app/module/login/login_manager.lua @@ -16,8 +16,12 @@ function LoginManager:showTestLoginUI() UIManager:showUI("app/module/login/test_login_ui") end -function LoginManager:showMaintenanceNoticeUI() - UIManager:showUI("app/module/login/maintenance_notice_ui") +function LoginManager:showMaintenanceNoticeUI(content, openTime) + local params = { + content = content, + openTime = openTime, + } + UIManager:showUI("app/module/login/maintenance_notice_ui", params) end ---- 登录界面资源加载完毕后调用 @@ -232,18 +236,6 @@ function LoginManager:removeAllLoginData() self.retryTimes = 0 end -function LoginManager:showServerNotOpenMessage() - local params = { - content = I18N:getGlobalText(I18N.GlobalConst.SERVER_MAINTAINED), - boxType = GConst.MESSAGE_BOX_TYPE.MB_OK, - okText = I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_OK), - okFunc = function() - self:checkServerOpen() - end, - } - GFunc.showMessageBox(params) -end - function LoginManager:getIsNeedHotUpdate() local serverVersion = self.versionInfo.version local clientVersion = CS.BF.BFMain.Instance.GameLaunchMgr:GetCurrentVersion() @@ -286,10 +278,10 @@ function LoginManager:getIsclientLessThanMinVersion() end function LoginManager:checkServerOpen() - local serverOpenTime = tonumber(self.versionInfo.open_time or 0) - local clientTime = os.time()*1000 + local serverOpenTime = tonumber(self.versionInfo.open_at or 0) + local clientTime = Time:getServerTime()*1000 if clientTime < serverOpenTime then -- 未开服 - self:showServerNotOpenMessage() + self:showMaintenanceNoticeUI(self.versionInfo.notice, serverOpenTime) return end @@ -314,7 +306,7 @@ function LoginManager:checkServerOpen() end end -function LoginManager:getServerList(callback) +function LoginManager:getServerList() if self.accountLoginSuccess then if self.authSid then self:unscheduleGlobal(self.authSid) @@ -359,8 +351,11 @@ function LoginManager:getServerList(callback) self.authSid = nil end + local serverTime = (jsonData.now or 0) + if serverTime > 0 then + Time:updateServerTime(serverTime) + end self.versionInfo = jsonData - Logger.printTable(jsonData) self:checkServerOpen() else -- BIReport:postRequestVersionFailed(self.loginCenterUrl, (os.clock() - self.connectStartTimes)*1000, self.retryTimes - 1) diff --git a/lua/app/module/login/maintenance_notice_ui.lua b/lua/app/module/login/maintenance_notice_ui.lua index 85790efe..07597791 100644 --- a/lua/app/module/login/maintenance_notice_ui.lua +++ b/lua/app/module/login/maintenance_notice_ui.lua @@ -1,6 +1,8 @@ local MaintenanceNoticeUI = class("MaintenanceNoticeUI", BaseUI) -function MaintenanceNoticeUI:ctor() +function MaintenanceNoticeUI:ctor(params) + self.content = params and params.content + self.openTime = params and params.openTime or 0 end function MaintenanceNoticeUI:getPrefabPath() @@ -9,6 +11,24 @@ end function MaintenanceNoticeUI:onLoadRootComplete() local uiMap = self.root:genAllChildren() + uiMap["maintenance_notice_ui.bg.title_bg.title_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.NOTICE_TITLE)) + if self.content == nil or self.content == "" then + uiMap["maintenance_notice_ui.bg.img_2.content_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.MAINTENANCE_NOTICE_DEFAULT)) + else + uiMap["maintenance_notice_ui.bg.img_2.content_tx"]:setText(self.content) + end + uiMap["maintenance_notice_ui.bg.ok_btn"]:addClickListener(function() + local clientTime = Time:getServerTime()*1000 + if clientTime >= self.openTime then + self:closeUI() + self:getServerList() + end + end) + uiMap["maintenance_notice_ui.bg.ok_btn.text"]:setText(I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_OK)) +end + +function MaintenanceNoticeUI:getServerList() + ModuleManager.LoginManager:getServerList() end return MaintenanceNoticeUI \ No newline at end of file