WardrobeMainView = WardrobeMainView or BaseClass(BaseView) local WardrobeMainView = WardrobeMainView WardrobeMainView.TabData = { {id = WardrobeConst.TabId.SHOP, name = "总览", abName = "wardrobe_asset", light_res = "wardrobe_tab_1", dark_res = "wardrobe_tab_1_gray", view = "WardrobeShopView",open_lv = Config.Moduleid[422].open_lv,open_task = Config.Moduleid[422].task_id}, {id = WardrobeConst.TabId.FASHION, name = "时装", abName = "wardrobe_asset", light_res = "wardrobe_tab_2", dark_res = "wardrobe_tab_2_gray", view = "FashionSubView",open_lv = Config.Moduleid[413].open_lv,open_task = Config.Moduleid[413].task_id}, {id = WardrobeConst.TabId.DESIGNATION, name = "称号", abName = "wardrobe_asset", light_res = "wardrobe_tab_3", dark_res = "wardrobe_tab_3_gray", view = "DesignationSubView",open_lv = Config.Moduleid[411].open_lv,open_task = Config.Moduleid[411].task_id}, {id = WardrobeConst.TabId.DRESS, name = "聊天", abName = "wardrobe_asset", light_res = "wardrobe_tab_4", dark_res = "wardrobe_tab_4_gray", view = "ChatDressSubView",open_lv = Config.Moduleid[112].open_lv,open_task = Config.Moduleid[112].task_id }, } function WardrobeMainView:__init() self.base_file = "wardrobe" self.layout_file = "WardrobeMainView" self.layer_name = "UI" self.destroy_imm = true self.use_background = true self.model_activity_bg = true -- 3d背景模式,带镜面反射,一级全屏界面才需要 self.model_activity_bg_pos = Vector2(-308,30) -- 3d背景的偏移坐标,默认是居中的,如果你的模型不是居中的话就要调整坐标 self.model_activity_bg_type = 1 self.append_to_ctl_queue = true self.change_scene_close = true self.hide_maincancas = true self.close_fog = true self.fire_change_visible_event = true self.mainVo = RoleManager.Instance.mainRoleInfo self.model = WardrobeModel:getInstance() DesignationModel:GetInstance():Fire(DesignationModel.REQUEST_DESIGNATION, 41101) --请求称号列表信息 FashionModel:GetInstance():Fire(FashionEvent.REQUEST_FASHION_PROTOCOL, 41300) --请求时装列表信息 FashionModel:GetInstance():Fire(FashionEvent.REQUEST_FASHION_PROTOCOL, 41313) --请求时装套装信息 self.model:Fire(WardrobeConst.REQ_WARDROBE_SCMD, 42202, 1) self.model:Fire(WardrobeConst.REQ_WARDROBE_SCMD, 42200, 1) self.current_index = false self.contaner_list = {} self.tab_name_list = {} self.load_callback = function () self:LoadSuccess() self:AddEvent() end self.open_callback = function ( ) self:OpenSuccess() self:SwitchTab(self.current_index or 1, true) self:ShowTabRedPointState() end self.switch_callback = function(index) self:SwitchTab(index) end self.close_win_callback = function ( ) self:Close() end self.destroy_callback = function ( ) self:DestroySuccess() end end function WardrobeMainView:GetRealIndex( index ) index = index or 1 return index end function WardrobeMainView:Open(index,sub_index,value) self.current_index = self:GetRealIndex(index) self.sub_index = sub_index self.value = value BaseView.Open(self) end function WardrobeMainView:ReOpen(index,sub_index,value) self.current_index = self:GetRealIndex(index) self.sub_index = sub_index self.value = value self:SwitchTab(self.current_index or 1, true) self:ShowTabRedPointState() end function WardrobeMainView:LoadSuccess() local nodes = { "winCon", } self:GetChildren(nodes) self.tabWindowComponent = UITabWindow.New(self.transform,WardrobeMainView.TabData,self.switch_callback, self.close_win_callback,self.background_wnd,self.winCon, UITabWindow.SizeLarge, false,nil,true) self.tabWindowComponent:SetTitleText( "风采" ) self.tabWindowComponent:SetUIBack({target = self, bg1 = GameResPath.GetViewBigBg("default_bg_1")}) end function WardrobeMainView:AddEvent() local function on_ans_update_red_dot() self:ShowTabRedPointState() end self:BindEvent(self.model, WardrobeConst.ANS_UPDATE_RED_DOT, on_ans_update_red_dot) local function on_close_new_main_role_view() self:Close() end self:BindEvent(self.model, WardrobeConst.CLOSE_WARDROBE_MAIN_VIEW, on_close_new_main_role_view) end function WardrobeMainView:OpenSuccess() self:UpdateView() end function WardrobeMainView:UpdateView() end function WardrobeMainView:SwitchTab( index, force ) if self.current_index == index and not force then return end if self.tabWindowComponent ~= nil then self.tabWindowComponent:SetTabBarIndex(index) end local chile_view = self.contaner_list[index] if not chile_view then local viewModule = false for k,v in pairs(WardrobeMainView.TabData) do if v.id == tonumber(index) then viewModule = v break end end if viewModule then chile_view = self:CreateItem(_G[viewModule.view], self.winCon, self.layer_name) end self.contaner_list[index] = chile_view end if chile_view then if chile_view.SetData then chile_view:SetData(index, self.sub_index, self.value) end self:PopUpChild(chile_view) self.sub_index = nil--一般是用来跳转的 用完就置空了 end self.current_index = index if index == WardrobeConst.TabId.SHOP then self.tabWindowComponent:SetBackgroundRes("default_bg_2") elseif index == WardrobeConst.TabId.FASHION then self.tabWindowComponent:SetBackgroundRes("default_bg_2") elseif index == WardrobeConst.TabId.DESIGNATION then self.tabWindowComponent:SetBackgroundRes("default_bg_2") elseif index == WardrobeConst.TabId.DRESS then self.tabWindowComponent:SetBackgroundRes("default_bg_2") end end function WardrobeMainView:DestroySuccess( ) if self.tabWindowComponent then self.tabWindowComponent:DeleteMe() end self.tabWindowComponent = nil -- 复原绿屏 CheatModel:getInstance():DisabledGreenScreenEffect() end function WardrobeMainView:ShowTabRedPointState() if self.tabWindowComponent then local red_data = self.model:GetWardrobeAllRedDot() for k,v in pairs(red_data) do self.tabWindowComponent:ShowRedPoint(k,v) end end end