SupremeVipActivateView = SupremeVipActivateView or BaseClass(BaseView) local SupremeVipActivateView = SupremeVipActivateView function SupremeVipActivateView:__init() self.base_file = "supremeVip" self.layout_file = "SupremeVipActivateView" self.layer_name = "Activity" self.destroy_imm = true self.use_background = true self.change_scene_close = true self.hide_maincancas = false --是否隐藏主界面 self.append_to_ctl_queue = false --是否要添加进界面堆栈 self.need_show_money = false --是否要显示顶部的金钱栏 self.is_set_zdepth = true self.choose_index = 1 self.model = SupremeVipModel:getInstance() self.mainVo = RoleManager.Instance.mainRoleInfo if self.model.login_red then self.model.login_red = false self.model:Fire(SupremeVipConst.UPDATE_SUPREME_VIP_MAIN_BUTTON_RED) end self.load_callback = function () self:LoadSuccess() self:AddEvent() end self.open_callback = function ( ) self:UpdateView() end self.destroy_callback = function ( ) self:DestroySuccess() end end function SupremeVipActivateView:Open( index ) --self.data = data self.choose_index = index or self.choose_index BaseView.Open(self) end function SupremeVipActivateView:LoadSuccess() local nodes = { "sloganImg:img", "bg:raw", "closeBtn:obj", "price:tmp", "price2:tmp", "activateBtn:obj", "rightTitle:tmp", "rightdes:tmp", "rightBigIcon:img", "ScrollView", "ScrollView/Viewport/Content", "tabCon/smallTab3:img", "tabCon/smallTab7:img", "tabCon/smallTab6:img", "tabCon/smallTab4:img", "tabCon/smallTab1:img", "tabCon/smallTab2:img", "tabCon/smallTab5:img", "activateBtn/rightBtnEffect", "extraEffect", "iconEffect", } self:GetChildren(nodes) self:AddUIEffect("ui_effect_shouchong05_2", self.rightBtnEffect, self.layer_name, nil, 1, false,nil,nil,nil,nil,nil,nil,nil,UIPartical.RenderingOther_List.UIBackward) -- local function bg_back_func( ... ) -- if self.background_wnd and self.background_wnd:GetComponent("RawImageExtend") then -- self:MoveUIToBack(self.background_wnd:GetComponent("RawImageExtend")) -- end -- self:MoveUIToBack(self.bg_raw) -- end -- if self.background_wnd then -- bg_back_func() -- else -- self.bg_back_func = bg_back_func -- end -- self.icon_canvas = self.rightBigIcon:GetComponent(typeof(UnityEngine.Canvas)) -- self.icon_canvas.sortingOrder = self:GetCurrLayerDepth("Activity") + 40 -- -- self:AddUIEffect("ui_guizutequan", self.rightBigIcon, "Activity", Vector3(-4,-30.5,0), 1, false,nil,nil,nil,nil,nil,UIPartical.RenderingOther_List.UIBackward) -- self:AddUIEffect("ui_guizutequan", self.iconEffect, "Activity", Vector3(-4,-30.5,0), 1, true,nil,nil,nil,nil,nil,nil) lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("supremeVip_activate_view")) lua_resM:setOutsideImageSprite(self, self.sloganImg_img, GameResPath.GetSupremeVipIcon("supremeVip_des_4_pointfilter"), true) self.sup_vip_type = RoleManager.Instance.mainRoleInfo.sup_vip_type self.price_tmp.text = self.model:GetActivateSupremeVipCost() self.price2_tmp.text = "4998" SetAnchoredPositionY(self.rightBigIcon,30) SetAnchoredPositionY(self.iconEffect,30) if self.tween_id then TweenLite.Stop(self.tween_id) self.tween_id = nil end -- self.tween_id =TweenLite.to(self, self.rightBigIcon,TweenLite.UiAnimationType.ANCHORED_POSY,37, 1.8, nil,TweenFunc.PINGPONG,true) end function SupremeVipActivateView:AddEvent() local on_click = function ( click_obj ) if self.closeBtn_obj == click_obj then self:Close() elseif self.activateBtn_obj == click_obj then--激活 local limit_vip = self.model:GetSupremeIconOpenVipLv() if self.mainVo.vip_flag and self.mainVo.vip_flag >= limit_vip then if self.model:IsForeverSupremeVip() or self.model:IsMomentSupremeVip() then Message.show("已经是贵族了","fault") else local ok_function = function() self.model:Fire(SupremeVipConst.REQUEST_CCMD_EVENT,45102,0)--请求激活一阶贵族 end local cost = self.model:GetActivateSupremeVipCost() if RoleManager.Instance.mainRoleInfo.jin>=cost then--够钱直接买 ok_function() return end local function use_function( toggle_tip_data,call_fun_sum ) GlobalEventSystem:Fire(EventName.OPEN_COM_TOGGLE_TIP_VIEW, toggle_tip_data) end local function recharge_open_call_back( ) self:Close() end local buy_tip_data = { gold_type = 1,--货币类型 cost_price = cost,--消耗金额 ok_callback = ok_function,--成功 no_need_toggle = true, -- toggle_function = toggle_function,--多选 recharge_open_call_back = recharge_open_call_back, togglePriceStr = HtmlColorTxt(cost, ColorUtil.YELLOW_DARK).." 激活贵族?", use_function = use_function,--最终调用 } CustomActivityModel:getInstance():BuyTips(buy_tip_data) -- local jump_recharge_callback = function() -- self:Close() -- end -- local data = { -- titleText = "激活贵族", -- price = cost, -- priceText = " "..HtmlColorTxt(cost, ColorUtil.YELLOW_DARK).." 激活贵族?", -- ok_callback = ok_function, -- insufficientText = "", -- no_need_toggle = true, -- jump_recharge_callback = jump_recharge_callback, -- -- toggle_function = toggle_function, -- } -- GlobalEventSystem:Fire(EventName.OPEN_COM_TOGGLE_TIP_VIEW, data) end else Message.show("升到VIP"..limit_vip.."才能激活贵族哦","fault") end end end AddClickEvent(self.closeBtn_obj, on_click,1) AddClickEvent(self.activateBtn_obj, on_click,1) end function SupremeVipActivateView:ChangeShowSupremeRight(index) self.choose_index = index self.rightTitle_tmp.text = string.format("特权%s:%s",index,SupremeVipConst.SupremeVipRight[index].name) self.rightdes_tmp.text = SupremeVipConst.SupremeVipRight[index].des -- if index == 1 then -- lua_resM:setOutsideImageSprite(self, self.rightBigIcon_img, GameResPath.GetSkillIcon("109101"), true) -- else -- lua_resM:setOutsideImageSprite(self, self.rightBigIcon_img, GameResPath.GetSupremeVipIcon("supremeVip_right_big_icon_"..index), true) -- end if self.choose_index == 3 then self:AddUIEffect("ui_guizutequan_godstone", self.extraEffect, "Activity", Vector3(-4,-30.5,0), 1, false,-1,nil,nil,nil,nil) lua_resM:setImageSprite(self, self.rightBigIcon_img, "uiComponent_asset","com_empty") elseif self.choose_index == 4 then self:AddUIEffect("ui_guizutequan_nojump", self.extraEffect, "Activity", Vector3(-4,-30.5,0), 1, false,-1,nil,nil,nil,nil) lua_resM:setImageSprite(self, self.rightBigIcon_img, "uiComponent_asset","com_empty") else self:ClearUIEffect(self.extraEffect) lua_resM:setOutsideImageSprite(self, self.rightBigIcon_img, GameResPath.GetSupremeVipIcon("supremeVip_right_big_icon_"..index), true) end end function SupremeVipActivateView:UpdateView() local click_callback = function(index) self:ChangeShowSupremeRight(index) self:UpdateRightItemPos(index) self:AutoChangeIndex() self:UpdateSmallTab() end if not self.item_list_com then self.item_list_com = self:AddUIComponent(UI.ItemListCreator) end local info = { data_list = {{},{},{},{},{},{},{}}, item_con = self.Content, item_class = SupremeVipRightItem, item_width = 162, item_height = 46, -- space_x = 0, space_y = 8, start_x = 116, start_y = -33-8, scroll_view = self.ScrollView, -- create_frequency = 0.01, reuse_item_num = 7, on_update_item = function(item, i, v) item:SetData(i,click_callback) self.item_list_com:IterateItems(function( item, i ) item:OnClick(1) end) end, final_callback = function() self.item_list_com:IterateItems(function( item, i ) item:OnClick(1) end) end, } self.item_list_com:UpdateItems(info) self.icon_canvas = self.rightBigIcon:GetComponent(typeof(UnityEngine.Canvas)) self.icon_canvas.sortingOrder = self:GetCurrLayerDepth("Activity") + 40 -- self:AddUIEffect("ui_guizutequan", self.rightBigIcon, "Activity", Vector3(-4,-30.5,0), 1, false,nil,nil,nil,nil,nil,UIPartical.RenderingOther_List.UIBackward) self:AddUIEffect("ui_guizutequan", self.iconEffect, "Activity", Vector3(-4,-30.5,0), 1, true,nil,nil,nil,nil,nil,nil) end function SupremeVipActivateView:UpdateRightItemPos(index) if self.item_list_com then self.item_list_com:IterateItems(function( item, i ) local pos_y = -33 if i < index then pos_y = pos_y - (i-1)*(46+8) elseif i == index then pos_y = pos_y - (i-1)*(46+8) -8 elseif i > index then pos_y = pos_y - (i-2)*(46+8) -8-8 -55 end item:SetAnchoredPosition(116,pos_y) end) end SetSizeDeltaY(self.Content,(46+5)*7+33-8+30) -- SetAnchoredPositionY(self.Content,33+(index-1)*(46+22)+10) end function SupremeVipActivateView:AutoChangeIndex() if self.delay_handler then TimerQuest.CancelQuest(GlobalTimerQuest, self.delay_handler) self.delay_handler = nil end local function delay_method( ) local next_index = self.choose_index < 7 and self.choose_index+1 or 1 self.item_list_com:IterateItems(function( item, i ) item:OnClick(next_index) end) local pos_y = 0 if next_index == 6 then pos_y = 32 elseif next_index == 7 then pos_y = 32 end SetAnchoredPositionY(self.Content,pos_y) end self.delay_handler = setTimeout(delay_method, 6) end function SupremeVipActivateView:UpdateSmallTab( ) for i=1,7 do if i == self.choose_index then lua_resM:setImageSprite(self, self["smallTab"..i.."_img"], "supremeVip_asset","supremeVip_small_tab_2") else lua_resM:setImageSprite(self, self["smallTab"..i.."_img"], "supremeVip_asset","supremeVip_small_tab_1") end end end function SupremeVipActivateView:DestroySuccess( ) if self.tween_id then TweenLite.Stop(self.tween_id) self.tween_id = nil end if self.delay_handler then TimerQuest.CancelQuest(GlobalTimerQuest, self.delay_handler) self.delay_handler = nil end self:ClearUIEffect(self.iconEffect) self:ClearUIEffect(self.extraEffect) end