|
|
- CSMainMilitaryRanksBaseView = CSMainMilitaryRanksBaseView or BaseClass(BaseView)
- local CSMainMilitaryRanksBaseView = CSMainMilitaryRanksBaseView
-
- function CSMainMilitaryRanksBaseView:__init()
- self.base_file = "csMain"
- self.layout_file = "CSMainMilitaryRanksBaseView"
- self.layer_name = "Activity"
- self.destroy_imm = true
- self.use_background = true
- self.change_scene_close = true
- self.hide_maincancas = true --是否隐藏主界面
- self.append_to_ctl_queue = false --是否要添加进界面堆栈
- self.need_show_money = false --是否要显示顶部的金钱栏
- self.is_set_zdepth = true
-
- self.model = CSMainModel:getInstance()
-
- self.tab_item_list = {}
-
- self.current_index = nil
-
- self.load_callback = function ()
- self:LoadSuccess()
- self:AddEvent()
- end
- self.open_callback = function ( )
- self:OpenSuccess()
- 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 CSMainMilitaryRanksBaseView:Open(index)
- self.current_index = index or 1
- BaseView.Open(self)
- end
-
- function CSMainMilitaryRanksBaseView:LoadSuccess()
- local nodes = {
- "closeBtn:obj", "bg:raw", "tabCon", "subCon",
- }
- self:GetChildren(nodes)
-
- end
-
- function CSMainMilitaryRanksBaseView:AddEvent()
- local on_click = function ( click_obj )
- if self.closeBtn_obj == click_obj then
- self:Close()
- end
- end
- AddClickEvent(self.closeBtn_obj, on_click)
-
- local function CLICK_GET_WAY_ITEM( )
- self:Close()
- end
- self:BindEvent(GlobalEventSystem, EventName.CLICK_GET_WAY_ITEM, CLICK_GET_WAY_ITEM)
- end
-
- function CSMainMilitaryRanksBaseView:OpenSuccess()
- -- self:InitTab()
- self:SwitchTab(1)
- end
-
- function CSMainMilitaryRanksBaseView:InitTab( )
- local tab_data = {
- [1] = {name = "军衔详情"},
- [2] = {name = "军衔排行"},
- }
-
- local function call_back(tab_index)
- self:SwitchTab(tab_index)
- end
- for k,v in pairs(self.tab_item_list) do
- v:SetVisible(false)
- end
- for i,v in ipairs(tab_data) do
- local item = self.tab_item_list[i]
- if not item then
- item = CSMainMilitaryRanksTab.New(self.tabCon)
- self.tab_item_list[i] = item
- end
- item:SetVisible(true)
- item:SetData(v,i,call_back)
- item:SetAnchoredPosition(-2, 41-(i-1)*(74-5))
- end
- for k,v in pairs(self.tab_item_list) do
- v:OnClick(self.current_index)
- end
- end
-
- function CSMainMilitaryRanksBaseView:SwitchTab( index )
- self.current_index = index
-
- if index == 1 then
- lua_resM:setOutsideRawImage(self,self.bg_raw,GameResPath.GetViewBigBg("cs_main_military_ranks_bg_1"))
- if self.details_view == nil then
- self.details_view = CSMainMilitaryRanksDetailsView.New(self.subCon)
- end
- self.details_view:SetData()
- self:PopUpChild(self.details_view)
- elseif index == 2 then
- lua_resM:setOutsideRawImage(self,self.bg_raw,GameResPath.GetViewBigBg("cs_main_military_ranks_bg_2"))
- if self.rank_view == nil then
- self.rank_view = CSMainMilitaryRanksRankView.New(self.subCon)
- end
- self.rank_view:SetData()
- self:PopUpChild(self.rank_view)
- end
- end
-
- function CSMainMilitaryRanksBaseView:DestroySuccess( )
- for i, v in ipairs(self.tab_item_list) do
- v:DeleteMe()
- end
- self.tab_item_list = {}
- if self.details_view then
- self.details_view:DeleteMe()
- end
- self.details_view = nil
- if self.rank_view then
- self.rank_view:DeleteMe()
- end
- self.rank_view = nil
- end
|