--[[@------------------------------------------------------------------ @description:福利大厅 @author:HWR ----------------------------------------------------------------------]] FuliMainView = FuliMainView or BaseClass(BaseView) FuliMainView.TAB_DATA = { {id = FuliConst.TAB_ID.SIGN,name = "每日签到",light_res = "icon_bb1_1",dark_res = "icon_bb1_2", open_lv = Config.Modulesub["160@1"].open_lv, open_day = Config.Modulesub["160@1"].open_day }, {id = FuliConst.TAB_ID.AI,name = "在线奖励",light_res = "icon_ck1_1",dark_res = "icon_ck1_2", open_lv = Config.Modulesub["160@2"].open_lv, open_day = Config.Modulesub["160@2"].open_day}, {id = FuliConst.TAB_ID.LEVEL,name = "冲级大礼",light_res = "icon_ck1_1",dark_res = "icon_ck1_2", open_lv = Config.Modulesub["160@3"].open_lv, open_day = Config.Modulesub["160@3"].open_day}, {id = FuliConst.TAB_ID.NOTICE,name = "游戏公告",light_res = "icon_ck1_1",dark_res = "icon_ck1_2", open_lv = Config.Modulesub["160@1"].open_lv, open_day = Config.Modulesub["160@1"].open_day}, {id = FuliConst.TAB_ID.DOWNLOAD,name = "资源礼包",light_res = "icon_ck1_1",dark_res = "icon_ck1_2", open_lv = Config.Modulesub["160@4"].open_lv, open_day = Config.Modulesub["160@4"].open_day}, {id = FuliConst.TAB_ID.CDK,name = "邀请礼包",light_res = "icon_ck1_1",dark_res = "icon_ck1_2", open_lv = Config.Modulesub["160@5"].open_lv, open_day = Config.Modulesub["160@5"].open_day}, } function FuliMainView:__init() self.base_file = "fuli" self.layout_file = "FuliBaseView" self.layer_name = "UI" self.use_background = true self.hide_maincancas = true self.close_mode = CloseMode.CloseDestroy self.destroy_imm = true self.append_to_ctl_queue = true self.is_set_zdepth = false self.close_fog = true self.model = FuliModel:getInstance() self.model:Fire(FuliConst.REQ_FULI_SCMD, 16001) self.model:Fire(FuliConst.REQ_FULI_SCMD, 16003) self.model:Fire(FuliConst.REQ_FULI_SCMD, 16005) self.mainRoleVo = RoleManager.Instance.mainRoleInfo self.current_index = nil self.sub_view_list = {} self.fire_change_visible_event = true self.show_tab_conf = {} local can_show = true for k,v in ipairs(FuliMainView.TAB_DATA) do table.insert( self.show_tab_conf, v ) end ------------------------- --万物宝典 if GetModuleIsOpen(331,74) then local temp_list = CustomActivityModel:getInstance():getAllActListByBaseType(CustomActivityModel.CustomActBaseType.CONTRACT) for i,v in pairs(temp_list or {}) do local id = 33100000 + CustomActivityModel.CustomActBaseType.CONTRACT * 1000 + v.sub_type ------------------------- local temp_conf = {id = id,name = v.name,light_res = "icon_ck1_1",dark_res = "icon_ck1_2", open_lv = Config.Modulesub["331@74"].open_lv, open_day = Config.Modulesub["331@74"].open_day} table.insert( self.show_tab_conf,1, temp_conf ) end end ------------------------- self.load_callback = function () self:LoadSuccess() self:InitEvent() end self.open_callback = function () self.tabWindowComponent:SetTabBarIndex(self.cur_index or self:GetFirstRedIndex()) self:UpdateRedDot() end self.close_callback = function () self:Remove() end end function FuliMainView:GetFirstRedIndex( ) --获取列表里的第一个红点页签 local red_data = self.model:GetAllFuliRedDot() for k,v in ipairs(self.show_tab_conf) do if red_data[v.id] == true then return v.id end end return self.show_tab_conf[1] and self.show_tab_conf[1].id or 1 end function FuliMainView:Open(index, type_id) self.cur_index = index self.type_id = type_id BaseView.Open(self) end function FuliMainView:Remove() if self.tabWindowComponent then self.tabWindowComponent:DeleteMe() self.tabWindowComponent = nil end for i,v in pairs(self.sub_view_list) do v:DeleteMe() v = nil end self.sub_view_list = {} end function FuliMainView:LoadSuccess() self.container = GetChildTransforms(self.transform, { "container", }) if self.tabWindowComponent == nil then local select_callback = function(index) self:SeletedTabbar(index) end local close_callback = function() self:Close() end self.tabWindowComponent = UITabWindow.New(self.transform, self.show_tab_conf, select_callback, close_callback, self.background_wnd, nil, UITabWindow.SizeSmallHall, false, nil, true) self.tabWindowComponent:SetTitleText("福利") end local function bg_back_func( ... ) if self.background_wnd and self.background_wnd:GetComponent("RawImageExtend") then self:MoveUIToBack(self.background_wnd:GetComponent("RawImageExtend")) end if self.tabWindowComponent and self.tabWindowComponent.win_bg then self:MoveUIToBack(self.tabWindowComponent.win_bg) end end if self.background_wnd then bg_back_func() else self.bg_back_func = bg_back_func end end function FuliMainView:InitEvent() local function on_ans_update_red_dot( tab_id,bool )--设置红点的状态注意此处的协议是从model那边发过来的 self:UpdateRedDot() end self.on_ans_update_red_dot_id = self.model:Bind(FuliConst.ANS_UPDATE_FULI_RED_DOT, on_ans_update_red_dot) local function CLICK_TASK_ITEM( ) self:Close() end self:BindEvent(ContractModel:getInstance(), ContractConst.CLICK_TASK_ITEM, CLICK_TASK_ITEM) local function MOVE_UI_TO_BACK( node_image ) if node_image then self:MoveUIToBack(node_image) end end self:BindEvent(self.model, FuliConst.MOVE_UI_TO_BACK, MOVE_UI_TO_BACK) end function FuliMainView:SeletedTabbar(index) if self.current_index == index then return elseif index == FuliConst.TAB_ID.NOTICE then local data = LoginModel:getInstance():GetNoticeData("fuli_view") if TableSize(data) == 0 then Message.show("暂无公告哦") self.tabWindowComponent:SetTabBarIndex(self.current_index) return end end if self.current_index ~= nil then self.is_changeIndex = true end local current_index = self.tabWindowComponent:GetCurrentSelectIndex() self:SwitchView(index) self.current_index = index end function FuliMainView:SwitchView(index) local is_contract = false--是否是万物宝典 local contract_index_start = 33100000 + CustomActivityModel.CustomActBaseType.CONTRACT * 1000 if index > contract_index_start and index <= (contract_index_start + 999) then is_contract = index - contract_index_start end local bg_res = "default_bg_6" local is_online_ai = index == FuliConst.TAB_ID.AI if is_contract or is_online_ai then LuaViewManager:getInstance():SetBackCameraShow(true) else LuaViewManager:getInstance():SetBackCameraShow(false) end ------------------------- if index == FuliConst.TAB_ID.SIGN then self.model:Fire(FuliConst.REQ_FULI_SCMD, 16001) if self.sub_view_list[index] == nil then self.sub_view_list[index] = FuliSignView.New(self.container) end elseif index == FuliConst.TAB_ID.AI then if self.sub_view_list[index] == nil then self.sub_view_list[index] = FuliAIView.New(self.container) end self.model:Fire(FuliConst.REQ_FULI_SCMD, 16003) bg_res = "fuli_ai_bg" elseif index == FuliConst.TAB_ID.LEVEL then self.model:Fire(FuliConst.REQ_FULI_SCMD, 16005) if self.sub_view_list[index] == nil then self.sub_view_list[index] = FuliLevelView.New(self.container) end bg_res = "fuli_level_bg" elseif index == FuliConst.TAB_ID.NOTICE then if self.sub_view_list[index] == nil then self.sub_view_list[index] = FuliNoticeView.New(self.container) end bg_res = "fuli_notice_bg" elseif index == FuliConst.TAB_ID.DOWNLOAD then self.model:Fire(FuliConst.REQ_FULI_SCMD, 16007) if self.sub_view_list[index] == nil then self.sub_view_list[index] = FuliDownloadView.New(self.container) end bg_res = "fuli_download_bg" elseif index == FuliConst.TAB_ID.CDK then if self.sub_view_list[index] == nil then self.sub_view_list[index] = FuliCDKView.New(self.container) end elseif is_contract then if self.sub_view_list[index] == nil then self.sub_view_list[index] = ContractSubView.New(self.container,nil,self.layer_name,is_contract) self.contract_view = self.contract_view or self.sub_view_list[index] else self.sub_view_list[index]:JumpToDefaultPos() end end self.tabWindowComponent:SetBackgroundRes(bg_res) self:PopUpChild(self.sub_view_list[index]) self.sub_view_list[index]:SetData(index, self.type_id) if self.contract_view then self.contract_view:ShowBg(is_contract) end end function FuliMainView:UpdateRedDot() if self.tabWindowComponent then local red_data = self.model:GetAllFuliRedDot() for k,v in pairs(red_data) do self.tabWindowComponent:ShowRedPoint(k,v) end end end function FuliMainView:ReOpen(index, sub_index, param_list ) self.cur_index = index or 1 self.sub_index = sub_index self.param_list = param_list if self.is_loaded then self:SeletedTabbar(self.cur_index) end end