GuildPositionApplyItem = GuildPositionApplyItem or BaseClass(BaseItem)
|
|
local GuildPositionApplyItem = GuildPositionApplyItem
|
|
|
|
function GuildPositionApplyItem:__init(parent_wnd,prefab_asset,layer_name)
|
|
self.base_file = "guild"
|
|
self.layout_file = "GuildPositionApplyItem"
|
|
self.parent_wnd = parent_wnd
|
|
self.layer_name = layer_name
|
|
self.model = GuildModel:getInstance()
|
|
self.bg_pos_x = {
|
|
[2] = 0,
|
|
[4] = -6,
|
|
[3] = -4,
|
|
}
|
|
|
|
self:Load()
|
|
end
|
|
|
|
function GuildPositionApplyItem:Load_callback()
|
|
local nodes = {
|
|
"bg:img",
|
|
"pos_icon:img",
|
|
"apply_scroll:obj", "apply_scroll/Viewport/apply_con",
|
|
"auth_scroll", "auth_scroll/Viewport/auth_con", "auth_scroll/Viewport/auth_con/pos_auth:tmp",
|
|
"cur_num:tmp", "pos_tips:tmp", "line:obj",
|
|
"apply_btn:obj:imgex",
|
|
}
|
|
self:GetChildren(nodes)
|
|
|
|
self:AddEvents()
|
|
if self.need_refreshData then
|
|
self:UpdateView()
|
|
end
|
|
end
|
|
|
|
function GuildPositionApplyItem:AddEvents( )
|
|
local function click_event(target)
|
|
if target == self.apply_btn_obj then
|
|
self:OnClickApplyBtn()
|
|
end
|
|
end
|
|
AddClickEvent(self.apply_btn_obj, click_event, LuaSoundManager.SOUND_UI.SWITCH)
|
|
end
|
|
|
|
function GuildPositionApplyItem:SetData( data, show_line )
|
|
self.data = data
|
|
self.show_line = show_line
|
|
if self.is_loaded then
|
|
self.need_refreshData = false
|
|
self:UpdateView()
|
|
else
|
|
self.need_refreshData = true
|
|
end
|
|
end
|
|
|
|
function GuildPositionApplyItem:UpdateView( )
|
|
local position = self.data.pos
|
|
SetAnchoredPositionX(self.bg, self.bg_pos_x[position] or 0)
|
|
local cur_mem_num = self.model:GetMemberNum(position)
|
|
local mem_max_num = self.model:GetPositionNum(position)
|
|
self.cur_num_tmp.text = string.format("人数 <size=22>%s/%s</size>", cur_mem_num, mem_max_num)
|
|
lua_resM:setImageSprite(self, self.bg_img, "guildPosApply_asset", "guild_apply_pos".. position)
|
|
lua_resM:setImageSprite(self, self.pos_icon_img, "guild_asset", "guild_apply_pos_icon".. position .. "_pointfilter", true)
|
|
if cur_mem_num == mem_max_num then
|
|
self.pos_tips_tmp.text = "职位已满,无法申请,可以联系团长或副团长进行职位分配操作"
|
|
if self.apply_scroll_obj.activeSelf then
|
|
self.apply_scroll_obj:SetActive(false)
|
|
end
|
|
else
|
|
self:UpdateApplyList()
|
|
end
|
|
self:UpdatePosAuthData()
|
|
self.line_obj:SetActive(self.show_line)
|
|
end
|
|
|
|
-- 加载职位权限
|
|
function GuildPositionApplyItem:UpdatePosAuthData( )
|
|
local auth_data = GuildModel.PosApplyDesc[self.data.pos]
|
|
self.auth_item_creator = self.auth_item_creator or self:AddUIComponent(UI.ItemListCreator)
|
|
local info = {
|
|
data_list = auth_data,
|
|
item_con = self.auth_con,
|
|
scroll_view = self.auth_scroll,
|
|
prefab_ab_name = "guild",
|
|
prefab_res_name = "GuildPositionApplyMemItem", -- 改了tmp之后小点不能直接打了,得换成这个节点创建内容了
|
|
item_height = 24,
|
|
create_frequency = 0.01,
|
|
alignment = UnityEngine.TextAnchor.UpperLeft,
|
|
child_names = {"apply_time:tmp", "name:tmp", },
|
|
on_update_item = function(item, i, v)
|
|
item.name_tmp.text = v
|
|
item.apply_time_tmp.text = ""
|
|
end,
|
|
}
|
|
self.auth_item_creator:UpdateItems(info)
|
|
end
|
|
|
|
-- 创建更新当前职位的申请人信息
|
|
function GuildPositionApplyItem:UpdateApplyList( )
|
|
local apply_list = self.model:GetPositionApplyList(self.data.pos)
|
|
local empty = IsTableEmpty(apply_list)
|
|
if empty then -- 空列表
|
|
if self.apply_scroll_obj.activeSelf then
|
|
self.apply_scroll_obj:SetActive(false)
|
|
end
|
|
self.pos_tips_tmp.text = "当前职位空缺,快申请成为社团干部吧"
|
|
else
|
|
if not self.apply_scroll_obj.activeSelf then
|
|
self.apply_scroll_obj:SetActive(true)
|
|
end
|
|
self.apply_item_creator = self.apply_item_creator or self:AddUIComponent(UI.ItemListCreator)
|
|
local info = {
|
|
data_list = apply_list,
|
|
item_con = self.apply_con,
|
|
scroll_view = self.apply_scroll,
|
|
prefab_ab_name = "guild",
|
|
prefab_res_name = "GuildPositionApplyMemItem",
|
|
item_height = 24,
|
|
create_frequency = 0.01,
|
|
alignment = UnityEngine.TextAnchor.UpperLeft,
|
|
child_names = {"apply_time:tmp", "name:tmp", },
|
|
on_update_item = function(item, i, v)
|
|
item.name_tmp.text = v.name
|
|
item.apply_time_tmp.text = TimeUtil:GetTimeStrByServerTime( v.time )
|
|
end,
|
|
}
|
|
self.apply_item_creator:UpdateItems(info)
|
|
end
|
|
-- 更新申请按钮
|
|
local position_num = self.model:GetMemberNum(self.data.pos)
|
|
local position_total_num = self.model:GetPositionNum(self.data.pos)
|
|
self.apply_btn_imgex.gray = position_num >= position_total_num
|
|
end
|
|
|
|
-- 申请职位
|
|
function GuildPositionApplyItem:OnClickApplyBtn()
|
|
if self.apply_btn_imgex.gray then
|
|
Message.show("职位人数已满")
|
|
else
|
|
-- 发送职位申请协议
|
|
self.model:Fire(GuildModel.REQUEST_CCMD_EVENT, 40018, self.data.pos)
|
|
end
|
|
end
|
|
|
|
function GuildPositionApplyItem:__delete( )
|
|
|
|
end
|