-- <* -- @Author: Saber -- @Description: 社团主界面 -- *> GuildMainView = GuildMainView or BaseClass(BaseView) local GuildMainView = GuildMainView GuildMainView.Tab_List = { {id = Config.ConfigGuild.TabId.Apply, name = "申请", module_id = 400, open_lv = 0, open_task = 0}, {id = Config.ConfigGuild.TabId.MainInfo, name = "主页", module_id = 400, open_lv = 0, open_task = 0}, {id = Config.ConfigGuild.TabId.List, name = "列表", module_id = 400, open_lv = 0, open_task = 0}, {id = Config.ConfigGuild.TabId.Active, name = "活跃", module_id = 400, sub_id = 2}, {id = Config.ConfigGuild.TabId.Order, name = "拼单", module_id = 400, sub_id = 3}, {id = Config.ConfigGuild.TabId.Shop, name = "商城", module_id = 400, sub_id = 4}, {id = Config.ConfigGuild.TabId.Event, name = "活动", module_id = 400, sub_id = 5}, } function GuildMainView:__init() self.base_file = "guild" self.layout_file = "GuildMainView" self.layer_name = "UI" self.destroy_imm = true self.view_list = {} -- 子界面列表 self.change_scene_close = true --是否切换场景时关闭(弹出界面使用) self.append_to_ctl_queue = true --是否要添加进界面堆栈 --self.need_show_money = false --是否要显示顶部的金钱栏 self.tab_index = 1 -- 当前页签id self.hide_maincancas = true self.is_set_zdepth = true self.use_background = G_USING_BG self.blur_activity_bg = true self.use_show_anim = true self.use_hide_anim = true self.is_trigger_guide = false self.model = GuildModel:getInstance() self.load_callback = function () self:LoadSuccess() self:AddEvent() self.model:Fire(GuildModel.REQUEST_CCMD_EVENT,40005) self:UpdateTabRed() end self.open_callback = function ( ) self:OpenSuccess() end self.switch_callback = function(index) self:SwitchTab(index, true) end self.destroy_callback = function ( ) self:DestroySuccess() end end function GuildMainView:Open(tab_index) --self.data = data self.tab_index = tab_index or 1 BaseView.Open(self) end function GuildMainView:LoadSuccess() local nodes = { "container", } self:GetChildren(nodes) local function select_callback(index) self:SwitchTab(index) end local function close_callback() self:Close() end local tab_list = self:GetGuildTabData() self.tabWindowComponent = UITabWindow.New(self.transform, tab_list, select_callback, close_callback, self.background_wnd, nil, UITabWindow.SizeSmallHall, nil, nil, true) self.tabWindowComponent:SetTitleText("社团") self.tabWindowComponent:ChangeShowFlag("Guild") self:AddToStageHandler() end function GuildMainView:AddEvent() local function update_red(view_type) self:UpdateTabRed(view_type) end self:BindEvent(self.model, GuildModel.UPDATE_RED_DOT_BY_TYPE, update_red) local function update_tab_list() self:RefreshGuildTabData(true) -- true代表协议刷新,不要出现手动跳转页签时会出现的飘字 end self:BindEvent(self.model, GuildModel.RefreshGuildInfoEvt, update_tab_list) local function onGuideTrigger() self:AddToStageHandler() end self:BindEvent(GlobalEventSystem, EventName.TRIGGER_GUIDE_TYPE, onGuideTrigger) end function GuildMainView:OpenSuccess() self:SwitchTab(self.tab_index) end function GuildMainView:GetGuildTabData( ) local guild_info = self.model:GetGuildBaseInfo() self.last_cache_guild_id = self.last_cache_guild_id or guild_info.guild_id or nil self.is_joined_guild = guild_info.guild_id and guild_info.guild_id ~= 0 or false self.tab_index = self.is_joined_guild and self.tab_index or Config.ConfigGuild.TabId.Apply -- 未加入社团的只能看第一个页签 local tab_list = {} for k, v in ipairs(GuildMainView.Tab_List) do if v.id == Config.ConfigGuild.TabId.Apply then if not self.is_joined_guild then tab_list[#tab_list+1] = v end elseif v.id == Config.ConfigGuild.TabId.MainInfo then if self.is_joined_guild then tab_list[#tab_list+1] = v end else tab_list[#tab_list+1] = v end end return tab_list end function GuildMainView:RefreshGuildTabData(hide_msg) local guild_info = self.model:GetGuildBaseInfo() local cur_guild_id = guild_info.guild_id or 0 if self.tabWindowComponent and (not self.last_cache_guild_id or self.last_cache_guild_id ~= cur_guild_id) then self.hide_tips_msg = hide_msg local new_tab_list = self:GetGuildTabData() self.tab_index = self.is_joined_guild and Config.ConfigGuild.TabId.MainInfo or Config.ConfigGuild.TabId.Apply -- 强制刷新页签 self.tabWindowComponent:RefeshTabbar(new_tab_list, nil, nil, true) self.last_cache_guild_id = guild_info.guild_id self:UpdateTabRed() end end function GuildMainView:UpdateView() if self.tab_index == Config.ConfigGuild.TabId.Apply then -- 申请界面 if not self.view_list[self.tab_index] then self.view_list[self.tab_index] = GuildApplyView.New(self.container, nil, self.layer_name) end self.tabWindowComponent:SetBackgroundRes("guild_apply_bg") elseif self.tab_index == Config.ConfigGuild.TabId.MainInfo then -- 主信息界面 if not self.view_list[self.tab_index] then self.view_list[self.tab_index] = GuildInfoView.New(self.container, nil, self.layer_name) end self.tabWindowComponent:SetBackgroundRes("guild_info_bg") elseif self.tab_index == Config.ConfigGuild.TabId.List then -- 列表界面 if not self.view_list[self.tab_index] then self.view_list[self.tab_index] = GuildListView.New(self.container, nil, self.layer_name) end self.tabWindowComponent:SetBackgroundRes("guild_list_bg") elseif self.tab_index == Config.ConfigGuild.TabId.Active then -- 社团活跃界面 if not self.view_list[self.tab_index] then self.view_list[self.tab_index] = GuildActiveView.New(self.container, nil, self.layer_name) end self.tabWindowComponent:SetBackgroundRes("guild_active_bg") elseif self.tab_index == Config.ConfigGuild.TabId.Order then -- 社团派单界面 if not self.view_list[self.tab_index] then self.view_list[self.tab_index] = GuildSpellListView.New(self.container, nil, self.layer_name) end self.tabWindowComponent:SetBackgroundRes("default_bg_6") elseif self.tab_index == Config.ConfigGuild.TabId.Shop then -- 社团商城界面 if not self.view_list[self.tab_index] then self.view_list[self.tab_index] = GuildShopView.New(self.container, nil, self.layer_name) end -- 如果存在商城红点,进入页签后销毁红点 if self.model:GetGuildRedDotCache(Config.ConfigGuild.TabId.Shop) then self.model.show_guild_shop_red = false self.model:CheckGuildRedDot(Config.ConfigGuild.TabId.Shop, true) end self.tabWindowComponent:SetBackgroundRes("default_bg_6") elseif self.tab_index == Config.ConfigGuild.TabId.Event then -- 社团活动界面 if not self.view_list[self.tab_index] then self.view_list[self.tab_index] = GuildEventView.New(self.container, nil, self.layer_name) end self.tabWindowComponent:SetBackgroundRes("default_bg_6") end -- 判断是否在社团拼单界面 self.model._is_in_guild_spelllist_view = self.tab_index == Config.ConfigGuild.TabId.Order self:PopUpChild(self.view_list[self.tab_index]) end -- show_msg:提醒加入社团飘字 function GuildMainView:SwitchTab( index ) if self.is_joined_guild then if index == Config.ConfigGuild.TabId.Apply then self.tab_index = Config.ConfigGuild.TabId.MainInfo else self.tab_index = index end else if index ~= Config.ConfigGuild.TabId.Apply then self.tab_index = Config.ConfigGuild.TabId.Apply if not self.hide_tips_msg then Message.show("请先加入社团") else self.hide_tips_msg = false end end end --设置页签索引值切换主页面 if self.tabWindowComponent then self.tabWindowComponent:SetTabBarIndex(self.tab_index) end self:UpdateView() end function GuildMainView:UpdateTabRed( view_type ) local red_cache = self.model:GetGuildRedDotCache(view_type) if view_type then self.tabWindowComponent:ShowRedPoint(view_type, red_cache) else for k, v in pairs(Config.ConfigGuild.TabId) do self.tabWindowComponent:ShowRedPoint(v, red_cache[v] or false) end end end function GuildMainView:DestroySuccess( ) for k, v in pairs(self.view_list) do v:DeleteMe() v = nil end self.view_list = {} if self.tabWindowComponent then self.tabWindowComponent:DeleteMe() self.tabWindowComponent = nil end end function GuildMainView:AddToStageHandler() local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_GUILD,3) if not helpVo then return end local help_type = helpVo.help_type if (help_type == HelpType.TYPE_GUILD) then local step = helpVo.step local button = false if (help_type == HelpType.TYPE_GUILD) and step == 3 then self.is_trigger_guide = true end end end function GuildMainView:Close( ) if self.is_trigger_guide then GlobalEventSystem:Fire(EventName.FORCE_TO_DO_TASK) end BaseView.Close(self) -- 重置变量 self.model._is_in_guild_spelllist_view = false end