超过0.8秒的请求才会显示转圈圈

master
罗家炜 2025-07-11 19:45:09 +08:00
parent c21a1d2935
commit 4624ad7a49
2 changed files with 15 additions and 5 deletions

View File

@ -41,7 +41,7 @@ function M:init()
local _btn_login = view:GetChild("btn_wx") local _btn_login = view:GetChild("btn_wx")
_btn_login.onClick:Add(function() _btn_login.onClick:Add(function()
ViewUtil.ShowModalWait(self._root_view, "正在登录游戏...") ViewUtil.ShowModalWait(true, "正在登录游戏...")
coroutine.start(function() coroutine.start(function()
coroutine.wait(8) coroutine.wait(8)
if self.isWXCallBackMark then if self.isWXCallBackMark then
@ -149,7 +149,7 @@ local function __login_response(self, response)
local roomid = user.room_id local roomid = user.room_id
if (string.len(roomid) > 1) then if (string.len(roomid) > 1) then
if user.group_id == 0 then if user.group_id == 0 then
ViewUtil.ShowModalWait(self._root_view, "正在加入房间...") ViewUtil.ShowModalWait(true, "正在加入房间...")
__join_room(roomid, response) __join_room(roomid, response)
return return
end end
@ -198,7 +198,7 @@ function M:QuickLogin()
local session_id = PlayerPrefs.GetString("session_id") local session_id = PlayerPrefs.GetString("session_id")
print("session_id:" .. session_id) print("session_id:" .. session_id)
if session_id and string.len(session_id) > 3 then if session_id and string.len(session_id) > 3 then
ViewUtil.ShowModalWait(self._root_view, "正在登录游戏...") ViewUtil.ShowModalWait(true, "正在登录游戏...")
local loginCtr = ControllerManager.GetController(LoginController) local loginCtr = ControllerManager.GetController(LoginController)
loginCtr:QuickLogin(session_id, function(response) loginCtr:QuickLogin(session_id, function(response)
__login_response(self, response) __login_response(self, response)
@ -214,7 +214,7 @@ function M:LoginCallBack(result, data)
--pt(data) --pt(data)
if (not result) or result ~= 0 then if (not result) or result ~= 0 then
if result == 10 then if result == 10 then
ViewUtil.ShowModalWait(self._root_view) ViewUtil.ShowModalWait(true)
return return
end end
ViewUtil.CloseModalWait() ViewUtil.CloseModalWait()

View File

@ -43,11 +43,21 @@ end
local modal_wait_win = nil local modal_wait_win = nil
-- local modal_wait_win_url = "ui://Common/GlobalModalWaiting" -- local modal_wait_win_url = "ui://Common/GlobalModalWaiting"
function ViewUtil.ShowModalWait(blur_view, title) function ViewUtil.ShowModalWait(blur_view, title)
local flag = type(blur_view) == "boolean"
ViewUtil.CloseModalWait() ViewUtil.CloseModalWait()
ViewUtil.continue = coroutine.start(
function()
coroutine.wait(flag and 0.01 or 0.8)
ModalWaitingWindow.ShowModal(title) ModalWaitingWindow.ShowModal(title)
end
)
end end
function ViewUtil.CloseModalWait() function ViewUtil.CloseModalWait()
if ViewUtil.continue then
coroutine.stop(ViewUtil.continue)
ViewUtil.continue = nil
end
ModalWaitingWindow.CloseModal() ModalWaitingWindow.CloseModal()
end end