|
|
- -- <*
- -- @Author: msh
- -- @Description: 二级邀请提示界面view
- -- *>
- CommonAlertInviteTipView = CommonAlertInviteTipView or BaseClass(BaseView)
- local CommonAlertInviteTipView = CommonAlertInviteTipView
-
- function CommonAlertInviteTipView:__init()
- self.base_file = "common"
- self.layout_file = "CommonAlertInviteTipView"
- self.layer_name = "Top"
- self.destroy_imm = true
- self.use_background = G_USING_BG --全屏界面默认使用这个参数
- --self.hide_maincancas = true --全屏界面需要放开隐藏主UI
- self.change_scene_close = true
- self.append_to_ctl_queue = false --是否要添加进界面堆栈
- self.need_show_money = false --是否要显示顶部的金钱栏
-
- self.load_callback = function ()
- self:LoadSuccess()
- self:AddEvent()
- end
- self.open_callback = function ( )
- self:UpdateView()
- end
- self.switch_callback = function(index)
- self:SwitchTab(index)
- end
- self.destroy_callback = function ( )
- self:DestroySuccess()
- end
- end
-
- function CommonAlertInviteTipView:Open(invite_data)
- self.invite_data = invite_data
- -- 定制层级
- self.layer_name = invite_data.layer_name or self.layer_name
- self:InitNodesAndData()
- BaseView.Open(self)
- end
-
- function CommonAlertInviteTipView:ReOpen(invite_data)
- self.invite_data = invite_data
- if self.is_loaded then
- self:InitNodesAndData()
- self:UpdateView()
- end
- end
-
- function CommonAlertInviteTipView:InitNodesAndData( )
- if self.is_loaded then
- if self.vip_item then
- self.vip_item:SetData(0)
- end
- self.lb_name_tmp.text = ""
- self.lb_content_tmp.text = ""
- end
- self.auto_close_time = self.invite_data.auto_close_time or 10
- -- self.waiting = false
- -- self:ClearAutoCloseTimer()
- -- self:ClearViewAnimId()
- -- self:ClearDestroyTimer()
- end
-
- function CommonAlertInviteTipView:LoadSuccess()
- local nodes = {
- "Window:raw",
- "Window/windowCloseBtn:obj",
- "Window/windowTitleText:tmp",
- "confirmBtn:obj","confirmBtn/lb_confirmBtn:tmp",
- "refuseBtn:obj", "refuseBtn/lb_refuseBtn:tmp",
- "con_vip:obj", "lb_name:tmp", "lb_content:tmp",
- "lb_tip:tmp",
- }
- self:GetChildren(nodes)
- self:UpdateBaseView( )
- end
-
- function CommonAlertInviteTipView:UpdateBaseView( )
- lua_resM:setOutsideRawImage(self, self.Window_raw, GameResPath.GetViewBigBg("tips_comm_bg6"))
- self.vip_item = RoleVipItem.New(self.con_vip)
- self.vip_item:SetAnchoredPosition(0, 0)
- self.vip_item:SetScale(0.84, 0.84)
- self.windowCloseBtn_obj:SetActive(false)
- SetAnchoredPositionX(self.lb_content, 0)
- end
-
- function CommonAlertInviteTipView:AddEvent()
- local on_click = function ( click_obj )
- if self.windowCloseBtn_obj == click_obj then
- if self.invite_data and self.invite_data.reject_callback then
- self.invite_data.reject_callback(self.invite_data)
- end
- self:CloseCallBack()
- elseif self.confirmBtn_obj == click_obj then
- if self.invite_data and self.invite_data.accept_callback then
- self.invite_data.accept_callback(self.invite_data)
- end
- self:CloseCallBack()
- elseif self.refuseBtn_obj == click_obj then
- if self.invite_data and self.invite_data.reject_callback then
- self.invite_data.reject_callback(self.invite_data)
- end
- self:CloseCallBack()
- end
- end
- AddClickEvent(self.windowCloseBtn_obj, on_click)
- AddClickEvent(self.confirmBtn_obj, on_click)
- AddClickEvent(self.refuseBtn_obj, on_click)
- end
-
- -- 关闭界面并回调
- function CommonAlertInviteTipView:CloseCallBack( )
- self:Close()
- CommonController.Instance:Fire(EventName.SHOW_COMMON_INVITE_TIPS)
- end
-
- function CommonAlertInviteTipView:UpdateView()
- if self.invite_data.invite_type == CommonModel.InviteTipsType.Team then -- 组队邀请
- local data = self.invite_data.param_data
- local str = string.format('Lv.%s %s', data.level, HtmlColorTxt( data.name, ColorUtil.BLUE_DARK) )
- self.lb_name_tmp.text = str
- self.lb_content_tmp.text = "邀请与您组队,是否同意请求?"
-
- -- -- 副本目标
- -- local main_type = data.activity_id or ""
- -- local sub_type = data.subtype or ""
- -- local cfg = Config.Teamui[main_type.."@"..sub_type]
- -- if cfg then
- -- local txt = cfg.subtype_name
- -- self.invite_content_tmp.text = "副本:" .. HtmlColorTxt( Trim(txt), "#fdffc2")
- -- else
- -- self.invite_content_tmp.text = "暂无目标"
- -- end
- end
- -- 设置vip 并调整名字的位置
- self.vip_item:SetData(self.invite_data.vip, self.invite_data.svip)
- local pos_x = self.invite_data.vip > 0 and 10 or 0
- SetAnchoredPositionX(self.lb_name, pos_x)
- SetAnchoredPositionX(self.con_vip, pos_x - self.lb_name_tmp.preferredWidth / 2 - 20)
- self:StartAutoCloseTimer()
- end
-
- -- 自动关闭倒计时
- function CommonAlertInviteTipView:StartAutoCloseTimer( )
- local end_time = self.auto_close_time + TimeUtil:getServerTime()
- self:ClearAutoCloseTimer()
- local function auto_close_func()
- local left_time = end_time - TimeUtil:getServerTime()
-
- if left_time > 0 then
- if self.invite_data.invite_type == CommonModel.InviteTipsType.Team and
- SceneManager:getInstance():IsBossMoneyScene() then
- self.lb_tip_tmp.text = string.format('(%s)秒后自动同意', HtmlColorTxt( left_time, ColorUtil.GREEN_DARK) )
- else
- self.lb_tip_tmp.text = string.format('(%s)秒后自动拒绝', HtmlColorTxt( left_time, ColorUtil.GREEN_DARK))
- end
- elseif left_time <= 0 then
- if self.invite_data.invite_type == CommonModel.InviteTipsType.Team and
- SceneManager:getInstance():IsBossMoneyScene() then
- if self.invite_data and self.invite_data.accept_callback then
- self.invite_data.accept_callback(self.invite_data)
- end
- else
- if self.invite_data and self.invite_data.reject_callback then
- self.invite_data.reject_callback(self.invite_data)
- end
- end
- self:ClearAutoCloseTimer()
- self:CloseCallBack()
- end
- end
- self.auto_close_func_id = GlobalTimerQuest:AddPeriodQuest(auto_close_func, 0.3, -1)
- end
-
- function CommonAlertInviteTipView:ClearAutoCloseTimer( )
- if self.auto_close_func_id then
- GlobalTimerQuest:CancelQuest(self.auto_close_func_id)
- self.auto_close_func_id = nil
- end
- end
-
- function CommonAlertInviteTipView:SwitchTab( index )
-
- end
-
- function CommonAlertInviteTipView:DestroySuccess( )
- if self.vip_item then
- self.vip_item:DeleteMe()
- self.vip_item = nil
- end
- self:ClearAutoCloseTimer( )
- end
|