135 lines
3.8 KiB
Lua
135 lines
3.8 KiB
Lua
local tipsWindow = import("..Common.tipsWindow")
|
|
|
|
local FamilyJoinAndCreate = {}
|
|
|
|
local function SendJoinRoom(self, roomId, remark)
|
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
|
fgCtr:FG_JoinGroup(tonumber(roomId), function(res)
|
|
if res.ReturnCode ~= 0 then
|
|
ViewUtil.ErrorTip(res.ReturnCode)
|
|
end
|
|
end,
|
|
remark)
|
|
end
|
|
|
|
function FamilyJoinAndCreate:init(root)
|
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
|
|
|
self._view = root._view:GetChild('com_createAndJoin')
|
|
self.style = self._view:GetController('cStyle')
|
|
self._currenIndex = 0
|
|
|
|
self:KeyBoardInit()
|
|
|
|
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.input_name.emojies = EmojiDitc.EmojiesDitc
|
|
self.input_wxId.emojies = EmojiDitc.EmojiesDitc
|
|
|
|
self._view:GetChild('btn_create').onClick:Set(function()
|
|
if self.style.selectedIndex ~= 1 then
|
|
self.style.selectedIndex = 1
|
|
return
|
|
end
|
|
end)
|
|
|
|
self._view:GetChild('btn_join').onClick:Set(function()
|
|
if self.style.selectedIndex ~= 0 then
|
|
self.style.selectedIndex = 0
|
|
return
|
|
end
|
|
end)
|
|
|
|
self._view:GetChild('btn_c').onClick:Set(function()
|
|
fgCtr:FG_GroupList(function(res)
|
|
fgCtr:FG_CreateGroup(self.input_name.text, 1, 2, function(res)
|
|
if res.ReturnCode == 0 then
|
|
root.familyType.selectedIndex = 1
|
|
root:ConnetFamily(1, DataManager.groups.groupList, true)
|
|
else
|
|
ViewUtil.ErrorTip(res.ReturnCode, '创建大联盟失败!')
|
|
end
|
|
end)
|
|
end)
|
|
end)
|
|
return self
|
|
end
|
|
|
|
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)
|
|
end
|
|
end
|
|
end
|
|
|
|
function FamilyJoinAndCreate:NumTexInput(num)
|
|
if #self.tex_num.text >= 6 then
|
|
self.tex_num.text = string.sub(self.tex_num.text, 1, 6)
|
|
return
|
|
end
|
|
|
|
self.tex_num.text = self.tex_num.text .. num
|
|
|
|
if #self.tex_num.text == 6 then
|
|
self:JoinRoom(self.tex_num.text)
|
|
end
|
|
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()
|
|
self.tex_num.text = ""
|
|
self._currenIndex = 0
|
|
end
|
|
|
|
function FamilyJoinAndCreate:JoinRoom(roomId)
|
|
self:ClearNumTex()
|
|
|
|
local win = tipsWindow.New()
|
|
win:Show("提交申请", "请输入申请信息", function(remark)
|
|
SendJoinRoom(self, roomId, remark)
|
|
end)
|
|
end
|
|
|
|
return FamilyJoinAndCreate
|