源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

204 rivejä
6.6 KiB

--#贵族主界面
SupremeVipBaseView = SupremeVipBaseView or BaseClass(BaseView)
local SupremeVipBaseView = SupremeVipBaseView
function SupremeVipBaseView:__init()
self.base_file = "supremeVip"
self.layout_file = "SupremeVipBaseView"
self.layer_name = "UI"
self.destroy_imm = true
self.use_background = true
self.change_scene_close = true
self.hide_maincancas = false --是否隐藏主界面
-- self.append_to_ctl_queue = true --是否要添加进界面堆栈
self.need_show_money = false --是否要显示顶部的金钱栏
self.is_set_zdepth = true
self.model = SupremeVipModel:getInstance()
self.mainVo = RoleManager.Instance.mainRoleInfo
self.model:Fire(SupremeVipConst.REQUEST_CCMD_EVENT,45104)--查询商城限购数据
if self.model.login_red then
self.model.login_red = false
self.model:Fire(SupremeVipConst.UPDATE_SUPREME_VIP_MAIN_BUTTON_RED)
end
self.item_list = {}
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 SupremeVipBaseView:Open(index)
self.current_index = index or 1
BaseView.Open(self)
end
function SupremeVipBaseView:LoadSuccess()
local nodes = {
"closeBtn:obj", "tabCon", "bg:raw", "con", "titleImg:img","moneyCOn", "find_right:obj",
"rightDayBg:obj:img", "rightForeverBg:obj:img", "activity_btn:obj", "rightForeverText:tmp","rightDayText:tmp",
}
self:GetChildren(nodes)
if not self.money_view then
self.money_view = UIMoneyView.New(self.moneyCOn)
end
self.money_view:SetPosition(-61.5,2.5)
self.money_view:SetData()
-- self.money_view:ChangeShowFlag("smallWindow2")
lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("supremeVip_view"))
lua_resM:setOutsideImageSprite(self, self.rightForeverBg_img, GameResPath.GetSupremeVipIcon("right_show_bg2_pointfilter"), true)
lua_resM:setOutsideImageSprite(self, self.rightDayBg_img, GameResPath.GetSupremeVipIcon("right_show_bg1_pointfilter"), true)
lua_resM:setOutsideImageSprite(self, self.titleImg_img, GameResPath.GetSupremeVipIcon("supremeVip_title_1_pointfilter"), true)
end
function SupremeVipBaseView:AddEvent()
local on_click = function ( click_obj )
if self.closeBtn_obj == click_obj then
self:Close()
elseif self.find_right_obj == click_obj then--查看特权
self.model:Fire(SupremeVipConst.OPEN_SUPREME_VIP_FIND_RIGHT_VIEW)
elseif self.activity_btn_obj == click_obj then--激活永久
self.model:Fire(SupremeVipConst.OPEN_SUPREME_VIP_BUY_VIEW)
end
end
AddClickEvent(self.closeBtn_obj, on_click,1)
AddClickEvent(self.find_right_obj, on_click,1)
AddClickEvent(self.activity_btn_obj, on_click,1)
local function refresh_all_view()
self:UpdateView()
end
self:BindEvent(self.model, SupremeVipConst.REFRESH_SUPREME_VIP_DATA,refresh_all_view)
end
function SupremeVipBaseView:UpdateView()
local click_callback = function(index)
for i,v in ipairs(self.item_list) do
v:SetSelected(index == i)
end
self:SwitchTab(index)
end
for k,v in pairs(self.item_list) do
v:SetVisible(false,true)
end
for i=1,4 do
local item = self.item_list[i]
if not item then
item = SupremeVipTabItem.New(self.tabCon)
self.item_list[i] = item
end
item:SetVisible(true)
item:SetData(i,click_callback)
if i == 1 then
item:SetAnchoredPosition(3,0)
elseif i == 2 then
item:SetAnchoredPosition(97,-81)
elseif i == 3 then
item:SetAnchoredPosition(3,-163)
elseif i == 4 then
item:SetAnchoredPosition(97,-243)
end
end
--初始选中
for i,v in ipairs(self.item_list) do
v:SetSelected(self.current_index == i)
end
self:SwitchTab(self.current_index)
self:UpdateLeftView()
end
function SupremeVipBaseView:SwitchTab( index )
self.current_index = index
if index == 1 then
if self.main_view == nil then--领取礼包
self.main_view = SupremeVipMainView.New(self.con)
end
self.main_view:SetData()
self:PopUpChild(self.main_view)
elseif index == 2 then--钻石兑换
if self.diamond_exchange_view == nil then
self.diamond_exchange_view = SupremeVipDiamondExchangeView.New(self.con)
end
self.diamond_exchange_view:SetData()
self:PopUpChild(self.diamond_exchange_view)
elseif index == 3 then--培养丹
self.model.is_first_open_train_drug = false
if self.train_drug_exchange_view == nil then
self.train_drug_exchange_view = SupremeVipTrainDrugExchangeView.New(self.con)
end
self.train_drug_exchange_view:SetData()
self:PopUpChild(self.train_drug_exchange_view)
self.model:Fire(SupremeVipConst.UPDATE_RED_DOT,SupremeVipConst.RED_DOT_TYPE.TrainDrugExchange)
elseif index == 4 then--星钻商城
self.model.is_first_open_shop = false
if self.shop_view == nil then
self.shop_view = SupremeVipShopView.New(self.con)
end
self.shop_view:SetData()
self:PopUpChild(self.shop_view)
self.model:Fire(SupremeVipConst.UPDATE_RED_DOT,SupremeVipConst.RED_DOT_TYPE.Shop)
self.model:Fire(SupremeVipConst.UPDATE_RED_DOT,SupremeVipConst.RED_DOT_TYPE.MoneyLeft)
end
end
function SupremeVipBaseView:DestroySuccess( )
if self.diamond_exchange_view then
self.diamond_exchange_view:DeleteMe()
end
self.diamond_exchange_view = nil
if self.main_view then
self.main_view:DeleteMe()
end
self.main_view = nil
if self.shop_view then
self.shop_view:DeleteMe()
end
self.shop_view = nil
if self.train_drug_exchange_view then
self.train_drug_exchange_view:DeleteMe()
end
self.train_drug_exchange_view = nil
for i, v in pairs(self.item_list) do
v:DeleteMe()
v = nil
end
self.item_list = {}
if self.money_view then
self.money_view:DeleteMe()
self.money_view = nil
end
end
--更新左边界面
function SupremeVipBaseView:UpdateLeftView( )
if not self.is_loaded then return end
local sup_vip_type = RoleManager.Instance.mainRoleInfo.sup_vip_type
self.activity_btn_obj:SetActive(sup_vip_type == 1)
self.rightDayBg_obj:SetActive(sup_vip_type == 1)
self.rightForeverBg_obj:SetActive(sup_vip_type == 2)
self.rightForeverText_tmp.text = sup_vip_type == 2 and "您已是最高阶贵族" or "升级贵族,可享更多特权"
-- local day_time,true_day,hour_time,true_hour,minute_time = self.model:GetLeftMomentSupremeVipDay()
-- if true_day < 1 then
-- if true_hour < 1 then
-- self.rightDayText_tmp.text = sup_vip_type == 1 and "剩余"..minute_time.."分钟" or ""
-- else
-- self.rightDayText_tmp.text = sup_vip_type == 1 and "剩余"..hour_time.."小时" or ""
-- end
-- else--超过一天显示天
-- self.rightDayText_tmp.text = sup_vip_type == 1 and "剩余"..day_time.."天" or ""
-- end
end