hengyang_client/lua_probject/base_project/Game/View/Family/FamilyJoinAndCreate.lua

141 lines
4.1 KiB
Lua
Raw Normal View History

2025-07-22 20:00:07 +08:00
local tipsWindow = import("..Common.tipsWindow")
2025-05-21 14:22:02 +08:00
local FamilyJoinAndCreate = {}
2025-07-22 20:00:07 +08:00
local function SendJoinRoom(self, roomId, remark)
2025-11-06 17:37:53 +08:00
ViewUtil.ShowModalWait2()
2025-07-22 20:00:07 +08:00
local fgCtr = ControllerManager.GetController(NewGroupController)
fgCtr:FG_JoinGroup(tonumber(roomId), function(res)
2025-11-06 17:37:53 +08:00
ViewUtil.CloseModalWait2()
if res.ReturnCode ~= 0 then
ViewUtil.ErrorTip(res.ReturnCode)
end
end,
remark)
2025-07-22 20:00:07 +08:00
end
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
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')
2025-07-04 19:46:28 +08:00
self.input_name.emojies = EmojiDitc.EmojiesDitc
self.input_wxId.emojies = EmojiDitc.EmojiesDitc
2025-07-23 15:40:53 +08:00
self._view:GetChild('btn_create').onClick:Set(function()
2025-07-22 20:00:07 +08:00
if self.style.selectedIndex ~= 1 then
2025-06-17 15:29:16 +08:00
self.style.selectedIndex = 1
return
2025-05-21 14:22:02 +08:00
end
end)
2025-07-23 15:40:53 +08:00
self._view:GetChild('btn_join').onClick:Set(function()
2025-07-22 20:00:07 +08:00
if self.style.selectedIndex ~= 0 then
2025-06-17 15:29:16 +08:00
self.style.selectedIndex = 0
return
2025-05-21 14:22:02 +08:00
end
end)
2025-06-17 15:29:16 +08:00
2025-07-23 15:40:53 +08:00
self._view:GetChild('btn_c').onClick:Set(function()
2025-11-06 17:37:53 +08:00
ViewUtil.ShowModalWait2()
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-11-06 17:37:53 +08:00
ViewUtil.CloseModalWait2()
2025-05-21 14:22:02 +08:00
if res.ReturnCode == 0 then
root.familyType.selectedIndex = 1
2025-11-12 13:53:54 +08:00
Utils.SaveLocalFile("Family_lastID" .. DataManager.SelfUser.account_id, res.Data.info.id)
root:Reflash()
2025-11-12 13:53:54 +08:00
-- root:ConnetFamily(1, DataManager.groups.groupList, true)
2025-05-21 14:22:02 +08:00
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)
2025-07-22 20:00:07 +08:00
for i = 0, self.list_keyBoard.numItems - 1 do
2025-06-17 15:29:16 +08:00
local btn = self.list_keyBoard:GetChildAt(i)
local btnStyle = btn:GetController('cStyle')
local num = i + 1
if num <= 9 then
2025-07-22 20:00:07 +08:00
btn:GetChild('text_num').text = num
2025-06-17 15:29:16 +08:00
btn.onClick:Set(function()
print(num)
self:NumTexInput(num)
end)
2025-07-22 20:00:07 +08:00
elseif num == 10 then
2025-06-17 15:29:16 +08:00
btnStyle.selectedIndex = 1
btn.onClick:Set(function()
print(i)
self:ClearNumTex()
end)
2025-07-22 20:00:07 +08:00
elseif num == 11 then
btn:GetChild('text_num').text = 0
2025-06-17 15:29:16 +08:00
btn.onClick:Set(function()
print(num)
self:NumTexInput(0)
end)
2025-07-22 20:00:07 +08:00
elseif num == 12 then
2025-06-17 15:29:16 +08:00
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)
2025-07-22 20:00:07 +08:00
if #self.tex_num.text >= 6 then
2025-06-17 15:29:16 +08:00
self.tex_num.text = string.sub(self.tex_num.text, 1, 6)
return
end
self.tex_num.text = self.tex_num.text .. num
2025-06-19 14:29:16 +08:00
2025-07-22 20:00:07 +08:00
if #self.tex_num.text == 6 then
2025-06-19 14:29:16 +08:00
self:JoinRoom(self.tex_num.text)
end
2025-06-17 15:29:16 +08:00
end
function FamilyJoinAndCreate:BackNumTex()
2025-07-22 20:00:07 +08:00
if #self.tex_num.text <= 0 then
2025-06-17 15:29:16 +08:00
return
end
local cur = #self.tex_num.text
2025-07-22 20:00:07 +08:00
self.tex_num.text = string.sub(self.tex_num.text, 0, cur - 1)
2025-06-17 15:29:16 +08:00
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
self:ClearNumTex()
2025-07-22 20:00:07 +08:00
local win = tipsWindow.New()
win:Show("提交申请", "请输入申请信息", function(remark)
SendJoinRoom(self, roomId, remark)
2025-05-21 14:22:02 +08:00
end)
end
2025-06-17 15:29:16 +08:00
return FamilyJoinAndCreate