CSMainExploitRankTab = CSMainExploitRankTab or BaseClass(BaseItem) local CSMainExploitRankTab = CSMainExploitRankTab function CSMainExploitRankTab:__init() self.base_file = "csMain" self.layout_file = "CSMainExploitRankTab" self.model = CSMainModel:getInstance() self:Load() end function CSMainExploitRankTab:Load_callback() self.nodes = { "bg:obj", "select:obj", "red:obj", "tabName:tmp", "countryFlag:obj", } self:GetChildren(self.nodes) self:AddEvents() if self.need_refreshData then self:UpdateView() end if self.need_reclick then self:OnClick(self.click_index) end end function CSMainExploitRankTab:AddEvents( ) local on_click = function ( click_obj ) if self.gameObject == click_obj then if self.in_select then return end self.model:Fire(CSMainConst.ON_CLICK_CONTRAY_TAB,self.index) end end AddClickEvent(self.gameObject, on_click) --事件绑定:点击自身item处理 local click_func = function(id) self:OnClick(id) end self:BindEvent(self.model, CSMainConst.ON_CLICK_CONTRAY_TAB, click_func) local function update_red_dot(tab_id) if not self.is_loaded then return end if tab_id == CSMainConst.RedType.WorShip then self:RefreshRed() end end self:BindEvent(self.model, CSMainConst.ANS_UPDATE_RED_DOT, update_red_dot) end function CSMainExploitRankTab:RefreshRed( ) local my_country_id = KfWorldModel:GetInstance():GetMyCountryId() if self.data and my_country_id and self.data.contray_id == my_country_id then local red = self.model:GetWorShipRed() self.red_obj:SetActive(red) else self.red_obj:SetActive(false) end end function CSMainExploitRankTab:UpdateView( ) local my_country_id = KfWorldModel:GetInstance():GetMyCountryId() if my_country_id and self.data.contray_id == my_country_id then self.countryFlag_obj:SetActive(true) else self.countryFlag_obj:SetActive(false) end self.tabName_tmp.text = self.data.name self:RefreshRed() end function CSMainExploitRankTab:OnClick(click_index) self.click_index = click_index if self.is_loaded then self.need_reclick = false if self.click_index == self.index then self.in_select = true self.bg_obj:SetActive(false) self.select_obj:SetActive(true) self.tabName_tmp.color = ColorUtil:ConvertHexToRGBColor("ffffff") SetTMPSharedMaterial(self.tabName_tmp, ShaderTools.TMPSharedMaterialType.HKYTW7OutlineBlueTab) if self.call_back then self.call_back(self.index,self.data.contray_id) end else self.in_select = false self.bg_obj:SetActive(true) self.select_obj:SetActive(false) self.tabName_tmp.color = ColorUtil:ConvertHexToRGBColor("7d91ac") SetTMPSharedMaterial(self.tabName_tmp, ShaderTools.TMPSharedMaterialType.HKYTW7FFDefault) end else self.need_reclick = true end end function CSMainExploitRankTab:SetData( data,index,call_back) self.data = data self.index = index self.call_back = call_back if self.is_loaded then self.need_refreshData = false self:UpdateView() else self.need_refreshData = true end end function CSMainExploitRankTab:__delete( ) end