hengyang_client/lua_probject/base_project/Game/View/NewGroup/JoinGroupView.lua

84 lines
2.4 KiB
Lua
Raw Permalink Normal View History

2025-04-01 10:48:36 +08:00
--进入牌友圈View对象
--author--
local JoinGroupView = {}
local M = JoinGroupView
local KEY_DEL = "del"
local KEY_CLEAR = "c"
function JoinGroupView.new(blur_view)
2025-11-06 17:37:53 +08:00
setmetatable(M, { __index = BaseWindow })
local self = setmetatable({}, { __index = M })
2025-04-01 10:48:36 +08:00
self.class = "JoinGroupView"
self._currenIndex = 0
self._close_destroy = true
self._blur_view = blur_view
self:init("ui://NewGroup/Win_FGJoin")
return self
end
function M:init(url)
2025-11-06 17:37:53 +08:00
BaseWindow.init(self, url)
2025-04-01 10:48:36 +08:00
self.tex_num = self._view:GetChild("tex_num")
self:ClearNumTex()
2025-11-06 17:37:53 +08:00
2025-04-01 10:48:36 +08:00
local cnt = self._view.numChildren - 1
2025-11-06 17:37:53 +08:00
for i = 0, 9 do
local obj = self._view:GetChild("btn_" .. i)
obj.onClick:Add(handler(self, self.OnNumButtonAction))
2025-04-01 10:48:36 +08:00
i = i + 1
end
local btn_ok = self._view:GetChild("btn_ok")
btn_ok.onClick:Set(function()
2025-11-06 17:37:53 +08:00
if self._currenIndex < 6 then
ViewUtil.ErrorTip(-12, "您输入的大联盟ID少于六位")
2025-04-01 10:48:36 +08:00
return
end
2025-11-06 17:37:53 +08:00
ViewUtil.ShowModalWait2(self._root_view)
2025-04-01 10:48:36 +08:00
local fgCtr = ControllerManager.GetController(NewGroupController)
2025-11-06 17:37:53 +08:00
fgCtr:FG_JoinGroup(tonumber(self._texnum_str), function(response)
ViewUtil.CloseModalWait2()
2025-04-01 10:48:36 +08:00
if self._is_destroy then
return
end
if (response.ReturnCode == 0) then
ViewUtil.ErrorTip("请等待盟主审核")
self:Destroy()
else
2025-11-06 17:37:53 +08:00
ViewUtil.ErrorTip(response.ReturnCode, "加入大联盟失败!")
2025-04-01 10:48:36 +08:00
end
end)
end)
local btn_del = self._view:GetChild("btn_del")
2025-11-06 17:37:53 +08:00
btn_del.onClick:Add(handler(self, self.OnNumButtonAction))
2025-04-01 10:48:36 +08:00
end
function M:OnNumButtonAction(context)
2025-11-06 17:37:53 +08:00
local typer = string.sub(context.sender.name, 5)
2025-04-01 10:48:36 +08:00
if typer == KEY_DEL then
2025-11-06 17:37:53 +08:00
if (self._currenIndex > 0) then
2025-04-01 10:48:36 +08:00
self._currenIndex = self._currenIndex - 1
2025-11-06 17:37:53 +08:00
self._texnum_str = string.sub(self._texnum_str, 0, self._currenIndex)
2025-04-01 10:48:36 +08:00
self.tex_num.text = self._texnum_str
end
else
if (self._currenIndex < 6) then
self._currenIndex = self._currenIndex + 1
self._texnum_str = self._texnum_str .. typer
self.tex_num.text = self._texnum_str
end
end
end
function M:ClearNumTex()
self._texnum_str = ""
self._currenIndex = 0
self.tex_num.text = self._texnum_str
end
2025-11-06 17:37:53 +08:00
return M