GodActivityBaseView = GodActivityBaseView or BaseClass(BaseItem) local GodActivityBaseView = GodActivityBaseView function GodActivityBaseView:__init(parent_wnd,prefab_asset,layer_name) self.base_file = "godActivity" self.layout_file = "GodActivityBaseView" self.layer_name = layer_name self.model = GodModel:getInstance() self.activity_type = GodConst.ActivityType.Limit self.type_name = { [GodConst.ActivityType.Common] = "普通召唤", [GodConst.ActivityType.Limit] = "限时召唤", } self.full_screen = true self.ani_left = -200 self:Load() end function GodActivityBaseView:Load_callback() self.nodes = { "left:obj", "left/img_tab_1:obj:img", "left/lb_tab_2:tmp", "container", "left/img_tab_2:obj:img", "left/lb_tab_1:tmp", "left/lb_tab_1_up:tmp", "left/lb_tab_2_up:tmp", "left/red_1:obj", "left/red_2:obj", "left/lb_time:tmp", } self:GetChildren(self.nodes) self.left_obj:SetActive(false) self:AddEvents() if self.need_refreshData then self:UpdateView() end end function GodActivityBaseView:AddEvents( ) local function call_back( target ) if self.model.draw_ing then Message.show("抽奖中,请稍后") return end if target == self.img_tab_1_obj then self.activity_type = GodConst.ActivityType.Limit self:UpdateView() else self.activity_type = GodConst.ActivityType.Common self:UpdateView() end end AddClickEvent(self.img_tab_1_obj,call_back,false) AddClickEvent(self.img_tab_2_obj,call_back,false) local function on_update_red_dot( ) self:RefreshRed() end self:BindEvent(self.model, GodConst.UpdateRedDot, on_update_red_dot) local function ANS_ACTIVITY_LIMIT_INFO( ) self:UpdateTime() end self:BindEvent(self.model, GodConst.ANS_ACTIVITY_LIMIT_INFO, ANS_ACTIVITY_LIMIT_INFO) end function GodActivityBaseView:RefreshRed( ) if self.is_loaded then self.red_1_obj:SetActive(self.model:IsActivityLimitRed()) --宠物生活技能 每日免费抽奖一次 local left_free_draw_times = self.model:GetGodLeftFreeDrawTimes() local free_red = left_free_draw_times > 0 self.red_2_obj:SetActive(self.model:IsActivityCommonRed() or free_red) end end function GodActivityBaseView:UpdateView( ) self:UpdateTabList() if self.activity_type == GodConst.ActivityType.Common then if self.view_limit then self.view_limit:SetVisible( false,true ) end self.view_common = self.view_common or self:CreateItem(GodActivityCommonView, self.container, self.layer_name) self.view_common:SetVisible( true,true ) else if self.view_common then self.view_common:SetVisible( false,true ) end self.view_limit = self.view_limit or self:CreateItem(GodActivityLimitView, self.container, self.layer_name) self.view_limit:SetVisible( true,true ) self.view_limit:RefreshModel(true) end self:RefreshRed() if self.switch_call then self.switch_call(self.activity_type) end self:UpdateTime() end function GodActivityBaseView:SetSwitchCall( call_back ) self.switch_call = call_back if self.activity_type and self.switch_call then self.switch_call(self.activity_type) end end function GodActivityBaseView:UpdateTabList( ) if self.activity_type == GodConst.ActivityType.Limit then lua_resM:setImageSprite(self, self.img_tab_1_img, "godActivity_asset", "godActivity_di_8",true) lua_resM:setImageSprite(self, self.img_tab_2_img, "godActivity_asset", "godActivity_di_9",true) self.lb_tab_1_tmp.text = "" self.lb_tab_1_up_tmp.text = self.type_name[GodConst.ActivityType.Limit] self.lb_tab_2_tmp.text = self.type_name[GodConst.ActivityType.Common] self.lb_tab_2_up_tmp.text = "" else lua_resM:setImageSprite(self, self.img_tab_1_img, "godActivity_asset", "godActivity_di_9",true) lua_resM:setImageSprite(self, self.img_tab_2_img, "godActivity_asset", "godActivity_di_8",true) self.lb_tab_1_tmp.text = self.type_name[GodConst.ActivityType.Limit] self.lb_tab_1_up_tmp.text = "" self.lb_tab_2_tmp.text = "" self.lb_tab_2_up_tmp.text = self.type_name[GodConst.ActivityType.Common] end end function GodActivityBaseView:UpdateTime( ) if not self.is_loaded then return end local base_data = self.model:GetActivityLimitInfo() if not base_data then return end local stime_str = TimeUtil:timeConversion(base_data.begin_time, "mm.dd") local etime_str = TimeUtil:timeConversion(base_data.end_time, "mm.dd") self.lb_time_tmp.text = stime_str .. "~" .. etime_str end function GodActivityBaseView:SetData( activity_type ) self.activity_type = activity_type or self.activity_type if self.is_loaded then self.need_refreshData = false self:UpdateView() else self.need_refreshData = true end end function GodActivityBaseView:NeedChangeMoneyFlag( ) return end function GodActivityBaseView:__delete( ) end