2025-05-21 14:22:02 +08:00
|
|
|
local FamilyJoinAndCreate = {}
|
|
|
|
|
|
2025-06-17 15:29:16 +08:00
|
|
|
function FamilyJoinAndCreate:init(root)
|
2025-05-21 14:22:02 +08:00
|
|
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
2025-06-17 15:29:16 +08:00
|
|
|
--local createOrJoin = self._view:GetController('createOrJoin')
|
2025-05-21 14:22:02 +08:00
|
|
|
|
2025-06-17 15:29:16 +08:00
|
|
|
self._view = root._view:GetChild('com_createAndJoin')
|
|
|
|
|
self.style = self._view:GetController('cStyle')
|
2025-05-21 14:22:02 +08:00
|
|
|
self._currenIndex = 0
|
|
|
|
|
|
2025-06-17 15:29:16 +08:00
|
|
|
self:KeyBoardInit()
|
2025-05-21 14:22:02 +08:00
|
|
|
|
2025-06-17 15:29:16 +08:00
|
|
|
self.tex_num = self._view:GetChild('text_FamilyId')
|
|
|
|
|
self.input_name = self._view:GetChild('input_name')
|
|
|
|
|
self.input_wxId = self._view:GetChild('input_wxId')
|
|
|
|
|
|
|
|
|
|
self._view:GetChild('btn_create').onClick:Add(function()
|
|
|
|
|
|
|
|
|
|
if self.style.selectedIndex ~= 1 then
|
|
|
|
|
self.style.selectedIndex = 1
|
|
|
|
|
return
|
2025-05-21 14:22:02 +08:00
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
|
2025-06-17 15:29:16 +08:00
|
|
|
self._view:GetChild('btn_join').onClick:Add(function()
|
|
|
|
|
|
|
|
|
|
if self.style.selectedIndex ~= 0 then
|
|
|
|
|
self.style.selectedIndex = 0
|
|
|
|
|
return
|
2025-05-21 14:22:02 +08:00
|
|
|
end
|
2025-06-17 15:29:16 +08:00
|
|
|
|
|
|
|
|
self:JoinRoom(self.tex_num.text)
|
2025-05-21 14:22:02 +08:00
|
|
|
end)
|
2025-06-17 15:29:16 +08:00
|
|
|
|
|
|
|
|
self._view:GetChild('btn_c').onClick:Add(function()
|
2025-05-21 14:22:02 +08:00
|
|
|
fgCtr:FG_GroupList(function(res)
|
2025-06-17 15:29:16 +08:00
|
|
|
fgCtr:FG_CreateGroup(self.input_name.text, 1, 2, function(res)
|
2025-05-21 14:22:02 +08:00
|
|
|
if res.ReturnCode == 0 then
|
2025-06-17 15:29:16 +08:00
|
|
|
--self.familyType.selectedIndex = 1
|
2025-05-21 14:22:02 +08:00
|
|
|
self:ConnetFamily(1, DataManager.groups.groupList, true)
|
|
|
|
|
else
|
|
|
|
|
ViewUtil.ErrorTip(res.ReturnCode, '创建大联盟失败!')
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end)
|
|
|
|
|
end)
|
|
|
|
|
return self
|
|
|
|
|
end
|
|
|
|
|
|
2025-06-17 15:29:16 +08:00
|
|
|
function FamilyJoinAndCreate:KeyBoardInit()
|
|
|
|
|
self.list_keyBoard = self._view:GetChild('list_keyBoard')
|
|
|
|
|
|
|
|
|
|
print("self.list_keyBoard.numItems", self.list_keyBoard.numItems)
|
|
|
|
|
|
|
|
|
|
for i=0, self.list_keyBoard.numItems -1 do
|
|
|
|
|
local btn = self.list_keyBoard:GetChildAt(i)
|
|
|
|
|
local btnStyle = btn:GetController('cStyle')
|
|
|
|
|
local num = i + 1
|
|
|
|
|
|
|
|
|
|
if num <= 9 then
|
|
|
|
|
btn:GetChild('text_num').text = num
|
|
|
|
|
btn.onClick:Set(function()
|
|
|
|
|
print(num)
|
|
|
|
|
self:NumTexInput(num)
|
|
|
|
|
end)
|
|
|
|
|
elseif num == 10 then
|
|
|
|
|
btnStyle.selectedIndex = 1
|
|
|
|
|
btn.onClick:Set(function()
|
|
|
|
|
print(i)
|
|
|
|
|
self:ClearNumTex()
|
|
|
|
|
end)
|
|
|
|
|
elseif num == 11 then
|
|
|
|
|
btn:GetChild('text_num').text = 0
|
|
|
|
|
btn.onClick:Set(function()
|
|
|
|
|
print(num)
|
|
|
|
|
self:NumTexInput(0)
|
|
|
|
|
end)
|
|
|
|
|
elseif num == 12 then
|
|
|
|
|
btnStyle.selectedIndex = 2
|
|
|
|
|
btn.onClick:Set(function()
|
|
|
|
|
print(num)
|
|
|
|
|
self:BackNumTex()
|
|
|
|
|
end)
|
2025-05-21 14:22:02 +08:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2025-06-17 15:29:16 +08:00
|
|
|
function FamilyJoinAndCreate:NumTexInput(num)
|
|
|
|
|
if #self.tex_num.text > 6 then
|
|
|
|
|
self.tex_num.text = string.sub(self.tex_num.text, 1, 6)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if #self.tex_num.text == 6 then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
self.tex_num.text = self.tex_num.text .. num
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function FamilyJoinAndCreate:BackNumTex()
|
|
|
|
|
|
|
|
|
|
if #self.tex_num.text <= 0 then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local cur = #self.tex_num.text
|
|
|
|
|
self.tex_num.text = string.sub(self.tex_num.text, 0, cur -1)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function FamilyJoinAndCreate:ClearNumTex()
|
2025-05-21 14:22:02 +08:00
|
|
|
self.tex_num.text = ""
|
|
|
|
|
self._currenIndex = 0
|
|
|
|
|
end
|
|
|
|
|
|
2025-06-17 15:29:16 +08:00
|
|
|
function FamilyJoinAndCreate:JoinRoom(roomId)
|
2025-05-21 14:22:02 +08:00
|
|
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
|
|
|
|
--后端似乎还未调通
|
|
|
|
|
self:ClearNumTex()
|
|
|
|
|
fgCtr:FG_JoinGroup(tonumber(roomId), function(res)
|
|
|
|
|
if res.ReturnCode ~= 0 then
|
|
|
|
|
ViewUtil.ShowOneChooose("加入失败" .. res.ReturnCode)
|
|
|
|
|
else
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
--先换成邀请玩家
|
|
|
|
|
-- fgCtr:FG_AddMember(self._group.id, tonumber(roomId), function(res)
|
|
|
|
|
-- if (res.ReturnCode == 0) then
|
|
|
|
|
-- ViewUtil.ShowBannerOnScreenCenter('添加成功!', 1)
|
|
|
|
|
-- else
|
|
|
|
|
-- ViewUtil.ErrorTip(res.ReturnCode, '邀请玩家失败!')
|
|
|
|
|
-- end
|
|
|
|
|
|
|
|
|
|
-- self:ChangeNumber(fgCtr, self._group.id, 0, self._group.total_member_num1, false,
|
|
|
|
|
-- 1)
|
|
|
|
|
-- end)
|
|
|
|
|
end
|
|
|
|
|
|
2025-06-17 15:29:16 +08:00
|
|
|
return FamilyJoinAndCreate
|