|
|
- StrengthView = StrengthView or BaseClass(BaseView)
- function StrengthView:__init()
- self.base_file = "strength"
- self.layout_file = "StrengthView"
- self.layer_name = "Activity"
- self.destroy_imm = false
- self.delay_delete_time = 1
- self.use_background = false
- self.hide_maincancas = false
- self.use_show_anim = true
- self.use_hide_anim = true
- self.item_list = {}
- self.open_guide_close = true
- self.model = StrengthModel:getInstance()
- self.change_scene_close = true
- self:AddPreLoadList("strength",{"StrengthItem"})
- self.load_callback = function()
- self:LoadSuccess()
- self:InitEvent()
- end
-
- self.open_callback = function()
- self:UpdateView()
- self:AutoCheckViewNotData()
- end
-
- self.close_callback = function()
-
- end
-
- self.destroy_callback = function()
- self:Remove()
- end
- end
-
- function StrengthView:Remove()
- for k,v in pairs(self.item_list) do
- v:DeleteMe()
- end
- self.item_list = {}
- self:ClearTimer()
- end
-
- function StrengthView:LoadSuccess()
- local nodes = {
- "close_btn:obj",
- }
- self:GetChildren(nodes)
-
- self.ScrollView,
- self.ScrollViewViewport,
- self.ScrollViewCon,
- self.InfoCon
- = GetChildTransforms(self.transform,
- {
-
- "InfoCon/ScrollView",
- "InfoCon/ScrollView/Viewport",
- "InfoCon/ScrollView/Viewport/Content",
- "InfoCon",
- })
- self.firstChargeBtn = self:GetChild("InfoCon/firstChargeBtn").gameObject
- self.img_sp_img = self:GetChild("InfoCon/firstChargeBtn/img_sp"):GetComponent("Image")
- SetAnchoredPosition(self.transform,(ScreenWidth / 2 - 460 - ClientConfig.iphone_x_offset_right), 230-ScreenHeight / 2 )
- SetAnchoredPosition(self.close_btn, - (ScreenWidth / 2 - 460 - ClientConfig.iphone_x_offset_right), -(230-ScreenHeight / 2 ))
- SetSizeDelta(self.close_btn, ScreenWidth * 1.5, ScreenHeight*1.5)
- end
-
- function StrengthView:InitEvent()
-
-
- local function onBtnClickHandler(target)
- if target == self.firstChargeBtn then
- local b,res,module_id,module_sub,module_name,sub_tab_id = self.model:GetOtherOption()
- if b then
- OpenFun.Open(module_id, module_sub, nil,sub_tab_id)
- end
- self:Close()
- elseif target == self.close_btn_obj then
- self:Close()
- end
- end
- AddClickEvent(self.close_btn_obj,onBtnClickHandler)
- AddClickEvent(self.firstChargeBtn,onBtnClickHandler)
-
- local function onGuideTrigger()
- self:AddToStageHandler()
- end
- self:BindEvent(GlobalEventSystem, EventName.TRIGGER_GUIDE_TYPE, onGuideTrigger)
- end
-
- function StrengthView:UpdateView( )
- local call_back = function( vo )
- self:ClickOperation(vo)
- end
- local list = self.model:GetStrengthList()
- local b,res,module_id,module_sub,module_name = self.model:GetOtherOption()
- if b then
- if #list <= 2 then
- self.firstChargeBtn.gameObject:SetActive(false)
- SetSizeDeltaY(self.ScrollView, 173)
- else
- lua_resM:setImageSprite(self,self.img_sp_img,"strength_asset",res)
- self.firstChargeBtn.gameObject:SetActive(true)
- SetSizeDeltaY(self.ScrollView, 110)
- end
- else
- self.firstChargeBtn.gameObject:SetActive(false)
- SetSizeDeltaY(self.ScrollView, 162)
- end
-
- --如果小于2条的时候,这首充跟着item滑动
- if #list > 0 and #list <= 2 then
- local b,res,module_id,module_sub,module_name,sub_tab_id = self.model:GetOtherOption()
- if b then
- table.insert(list, {name = module_name, winId = module_id, subId = module_sub, tabId = nil, sort_id=80, res_name = res, sub_tab_id = sub_tab_id})
- end
- end
- local h = 0
- for i,v in ipairs(list) do
- local item = self.item_list[i]
- if not item then
- item = StrengthItem.New(self.ScrollViewCon)
- self.item_list[i] = item
- end
- item:SetVisible(true)
- item:SetData(v, call_back)
-
- if v.winId == 159 and v.subId == 1 then
- item:SetAnchoredPosition(0, -h - 7)
- h = h + 55
- else
- item:SetAnchoredPosition(0, -(i - 1) * 54 )
- h = h + 54
- end
- end
- SetSizeDeltaY(self.ScrollViewCon, h)
- for i=#list+1, #self.item_list do
- self.item_list[i]:SetVisible(false)
- end
-
- self:AddToStageHandler()
- end
-
- function StrengthView:ClickOperation( vo )
- if vo.winId == 610 and vo.subId == 0 and vo.tabId == 1 then
- ExpDunModel:getInstance():Fire(ExpDunModel.CHECK_OPEN_HANGUP_RECEIVE_VIEW)
- elseif vo.winId == 610 and vo.subId == 0 and vo.tabId == 2 then
- ExpDunModel:getInstance():Fire(ExpDunModel.OPEN_QUICK_HANGUP_VIEW, true)
- elseif vo.winId == 210 then
- GlobalEventSystem:Fire(EventName.OPEN_SKILL_VIEW, vo.tabId, true)
- else
- OpenFun.Open(vo.winId, vo.subId, vo.tabId, vo.sub_tab_id)
- end
- self:Close()
- end
-
- -- 有时候界面会出现空白的情况 所以加一个判断机制 在打开界面的情况下 倒计时几秒后检查数据还有没有
- function StrengthView:AutoCheckViewNotData()
- self:ClearTimer()
- if self._use_delete_Method then return end
- local function DelayFunc()
- local bool = self.model:CanStrength()
- if not bool then
- self:Close()
- end
- end
- self.timer = setTimeout(DelayFunc, 5)
- end
-
- function StrengthView:ClearTimer()
- if self.timer then
- GlobalTimerQuest:CancelQuest(self.timer)
- self.timer = nil
- end
- end
-
- function StrengthView:AddToStageHandler()
- local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_SHOW_FIGHT_UP_TIPS,1)
- if not helpVo then return end
- local help_type = helpVo.help_type
- if help_type == HelpType.TYPE_SHOW_FIGHT_UP_TIPS then
- local step = helpVo.step
- local button = false
- if (help_type == HelpType.TYPE_SHOW_FIGHT_UP_TIPS and step == 1) then
- button = self.firstChargeBtn
- end
- if button then
- local function call_back()
-
- end
- GlobalEventSystem:Fire(EventName.OPEN_GUIDE_PROMPT_VIEW, button.transform, button.transform.parent.transform, call_back, helpVo, self.layout_file)
- end
- end
- end
-
-
- function StrengthView:Close()
- --完成引导
- local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_SHOW_FIGHT_UP_TIPS,1)
- if helpVo then
- GlobalEventSystem:Fire(EventName.FINISH_CURRENT_HELP_STEP,helpVo)
- end
- BaseView.Close(self)
- end
|