SocialityView = SocialityView or BaseClass(BaseView)
|
|
|
|
function SocialityView:__init()
|
|
self.base_file = "sociality"
|
|
self.layout_file = "SocialityView"
|
|
self.layer_name = "UI"
|
|
self.destroy_imm = true
|
|
self.use_background = true
|
|
self.hide_maincancas = true
|
|
self.change_scene_close = true
|
|
self.open_wnd_anim = 0
|
|
self.append_to_ctl_queue = true
|
|
self.model = SocialityModel:getInstance()
|
|
|
|
self.blur_activity_bg = true
|
|
self.use_show_anim = true
|
|
self.use_hide_anim = true
|
|
|
|
self.sub_view_list = {}
|
|
|
|
--预加载的Item
|
|
self:AddPreLoadList("chat",{"chatItem"})
|
|
|
|
--回调方法
|
|
self.load_callback = function()
|
|
self:LoadSuccess()
|
|
self:AddEvent()
|
|
self:RefreshRed()
|
|
end
|
|
|
|
self.open_callback = function()
|
|
self:SwitchView(self.cur_index)
|
|
self.tabWindowComponent:SetTabBarIndex(self.cur_index)
|
|
self.model.sociality_is_open = true
|
|
end
|
|
|
|
self.close_callback = function()
|
|
GlobalEventSystem:Fire(EventName.MAIN_VOICE_BIND)
|
|
self.model.sociality_is_open = false
|
|
|
|
-- --保存聊天记录
|
|
-- CookieWrapper.Instance:WriteChatHistroy()
|
|
end
|
|
|
|
self.destroy_callback = function()
|
|
self:Clear()
|
|
end
|
|
end
|
|
|
|
function SocialityView:Open( index )
|
|
self.cur_index = index or 1
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function SocialityView:AddEvent( )
|
|
local onRed = function ( )
|
|
self:RefreshRed()
|
|
end
|
|
self.social_event_id = GlobalEventSystem:Bind(EventName.REFRESH_SOCIAL_RED_DOT, onRed)
|
|
end
|
|
|
|
function SocialityView:RefreshRed( )
|
|
for i=1, 3 do
|
|
if i==1 then --好友
|
|
self.tabWindowComponent:ShowRedPoint(i, MainUIModel:getInstance():IsShowFriendRed())
|
|
elseif i==3 then --邮件
|
|
self.tabWindowComponent:ShowRedPoint(i, MainUIModel:getInstance():IsShowMailRed())
|
|
elseif i==2 then --好友申请
|
|
self.tabWindowComponent:ShowRedPoint(i, MainUIModel:getInstance():IsShowApplyRed())
|
|
end
|
|
end
|
|
end
|
|
|
|
function SocialityView:LoadSuccess()
|
|
self.container = self:GetChild("container")
|
|
local select_callback = function(index)
|
|
self:SwitchView(index)
|
|
end
|
|
local close_callback = function()
|
|
self:Close()
|
|
end
|
|
local menu_name_list = self.model:GetTabData()
|
|
self.tabWindowComponent = UITabWindow.New(self.transform, menu_name_list, select_callback, close_callback, self.background_wnd,
|
|
self.container,UITabWindow.SizeSmallHall,nil,nil,true)
|
|
self.tabWindowComponent:SetBackgroundRes("default_bg_6")
|
|
end
|
|
|
|
|
|
function SocialityView:SwitchView( index )
|
|
if index == 1 or index == 2 then
|
|
if not GetModuleIsOpen(140) then
|
|
Message.show(string.format("%d级开放", GetModuleOpenLevel(140)))
|
|
self.tabWindowComponent:SetTabBarIndex(2)
|
|
return
|
|
end
|
|
end
|
|
self.tabWindowComponent:SetTabBarIndex(index)
|
|
self.cur_index = index
|
|
|
|
local sub_view = self.model:GetSocialSubView(index)
|
|
if sub_view and not self.sub_view_list[index] then
|
|
self.sub_view_list[index] = sub_view.New(self.container)
|
|
--更新列表
|
|
if index == 3 then
|
|
self.sub_view_list[index]:ShowPanel()
|
|
end
|
|
end
|
|
|
|
if self.last_index and self.sub_view_list[self.last_index] then
|
|
self.sub_view_list[self.last_index]:SetVisible(false)
|
|
end
|
|
if self.sub_view_list[index] then
|
|
self.sub_view_list[index]:SetVisible(true)
|
|
end
|
|
|
|
self.last_index = index
|
|
local title_res
|
|
if index == 1 then
|
|
title_res ="好友"
|
|
elseif index == 2 then
|
|
title_res ="添加"
|
|
elseif index == 3 then
|
|
title_res ="邮件"
|
|
end
|
|
self.tabWindowComponent:SetTitleText(title_res)
|
|
end
|
|
|
|
function SocialityView:Clear( )
|
|
for k,v in pairs(self.sub_view_list) do
|
|
v:DeleteMe()
|
|
end
|
|
self.sub_view_list = {}
|
|
if self.social_event_id then
|
|
GlobalEventSystem:UnBind(self.social_event_id)
|
|
self.social_event_id = nil
|
|
end
|
|
if self.tabWindowComponent then
|
|
self.tabWindowComponent:DeleteMe()
|
|
self.tabWindowComponent = nil
|
|
end
|
|
end
|