166 lines
5.0 KiB
Lua
166 lines
5.0 KiB
Lua
-- 牌友圈添加成员
|
|
local MngPermission = import(".MngPermission")
|
|
local GroupMngAddMemberView = {}
|
|
|
|
local M = GroupMngAddMemberView
|
|
|
|
function GroupMngAddMemberView.new(gid)
|
|
local self = M
|
|
self.class = "GroupMngAddMemberView"
|
|
self.group_id = gid
|
|
self:FillView()
|
|
return self
|
|
end
|
|
|
|
-- 初始化数据
|
|
function M:initData()
|
|
local ctr_page = self._view:GetController("page")
|
|
if ctr_page.selectedIndex == 1 then
|
|
self:GetJoinsData()
|
|
end
|
|
end
|
|
|
|
-- 快速访问
|
|
function M:navigation()
|
|
self._view:GetController("page").selectedIndex = 1
|
|
self:initData()
|
|
end
|
|
|
|
local function CheckPermission(lev, permission)
|
|
if lev == 2 and not permission then
|
|
ViewUtil.ErrorTip(nil, "您无权操作!如有需要请联系盟主。", 1)
|
|
return false
|
|
end
|
|
return true
|
|
end
|
|
|
|
function M:FillView()
|
|
local group = DataManager.groups:get(self.group_id)
|
|
local perm_array = MngPermission.getPermData(group.permission)
|
|
|
|
self._view = UIPackage.CreateObjectFromURL("ui://NewGroup/View_GroupAddMember")
|
|
|
|
self.tex_num = self._view:GetChild("tex_num")
|
|
self:ClearNumTex()
|
|
|
|
local cnt = self._view.numChildren - 1
|
|
|
|
for i = 0 ,9 do
|
|
local obj = self._view:GetChild("btn_"..i)
|
|
obj.onClick:Add(handler(self , self.OnNumButtonAction))
|
|
i = i + 1
|
|
end
|
|
local btn_ok = self._view:GetChild("btn_ok")
|
|
btn_ok.onClick:Set(function()
|
|
if not CheckPermission(group.lev, perm_array[2]) then
|
|
return
|
|
end
|
|
if self._texnum_str == "" then return end
|
|
ViewUtil.ShowModalWait()
|
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
|
fgCtr:FG_AddMember(self.group_id, tonumber(self._texnum_str), function(response)
|
|
ViewUtil.CloseModalWait()
|
|
if (response.ReturnCode == 0) then
|
|
ViewUtil.ShowBannerOnScreenCenter("添加成功!", 1)
|
|
else
|
|
ViewUtil.ErrorTip(response.ReturnCode,"邀请玩家失败!")
|
|
end
|
|
end)
|
|
end)
|
|
local btn_del = self._view:GetChild("btn_del")
|
|
btn_del.onClick:Add(handler(self , self.OnNumButtonAction))
|
|
|
|
local ctr_mng = self._view:GetController("mng")
|
|
if group.lev < 3 then
|
|
ctr_mng.selectedIndex = 1
|
|
end
|
|
local ctr_page = self._view:GetController("page")
|
|
ctr_page.onChanged:Set(function()
|
|
if ctr_page.selectedIndex == 1 then
|
|
self:GetJoinsData()
|
|
end
|
|
end)
|
|
end
|
|
|
|
--获取申请列表
|
|
function M:GetJoinsData()
|
|
local group = DataManager.groups:get(self.group_id)
|
|
if group.joins > 0 then
|
|
ViewUtil.ShowModalWait()
|
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
|
fgCtr:FG_GroupJoins(self.group_id, function(res)
|
|
ViewUtil.CloseModalWait()
|
|
if (res.ReturnCode == 0) then
|
|
local joins = res.Data.joins
|
|
group.joins = #joins
|
|
if #joins == 0 then
|
|
group.update_joins = true
|
|
end
|
|
self:FillJoinList(joins)
|
|
else
|
|
ViewUtil.ErrorTip(res.ReturnCode,"获取申请列表失败!")
|
|
self:FillJoinList({})
|
|
end
|
|
end)
|
|
else
|
|
self:FillJoinList({})
|
|
end
|
|
end
|
|
|
|
--填充申请
|
|
function M:FillJoinList(data)
|
|
local lst_joins = self._view:GetChild("lst_joins")
|
|
lst_joins:RemoveChildrenToPool()
|
|
for i = 1, #data do
|
|
local item = lst_joins:AddItemFromPool()
|
|
item:GetChild("tex_name").text = ViewUtil.stringEllipsis(data[i].nick)
|
|
item:GetChild("tex_id").text = data[i].id
|
|
local btn_head = item:GetChild("btn_head")
|
|
ImageLoad.Load(data[i].portrait, btn_head._iconObject)
|
|
item:GetChild("btn_yes").onClick:Set(function()
|
|
self:VerifyPlayerJoin(data[i].id, true)
|
|
end)
|
|
item:GetChild("btn_no").onClick:Set(function()
|
|
self:VerifyPlayerJoin(data[i].id, false)
|
|
end)
|
|
end
|
|
end
|
|
|
|
function M:VerifyPlayerJoin(id, allow)
|
|
ViewUtil.ShowModalWait()
|
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
|
fgCtr:FG_GroupVerifyJoin(self.group_id, id, allow, function(res)
|
|
ViewUtil.CloseModalWait()
|
|
if (res.ReturnCode == 0) then
|
|
self:GetJoinsData()
|
|
else
|
|
ViewUtil.ErrorTip(res.ReturnCode, "操作申请失败")
|
|
end
|
|
end)
|
|
end
|
|
|
|
function M:OnNumButtonAction(context)
|
|
local typer = string.sub(context.sender.name ,5)
|
|
if typer == "del" then
|
|
if (self._currenIndex > 0) then
|
|
self._currenIndex = self._currenIndex - 1
|
|
self._texnum_str = string.sub(self._texnum_str,0,self._currenIndex)
|
|
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
|
|
|
|
return M |