源战役客户端
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.
 
 
 
 
 

167 lines
4.7 KiB

SupremeVipTabItem = SupremeVipTabItem or BaseClass(BaseItem)
local SupremeVipTabItem = SupremeVipTabItem
function SupremeVipTabItem:__init()
self.base_file = "supremeVip"
self.layout_file = "SupremeVipTabItem"
self.model = SupremeVipModel:getInstance()
self.have_supreme_vip_right = false --是否拥有此项特权功能
self:Load()
end
function SupremeVipTabItem:Load_callback()
self.nodes = {
"touch_bg/leftBg/leftDes:tmp",
"touch_bg/titleImg:obj",
"touch_bg/leftBg/leftNum:tmp",
"touch_bg/selectBg:obj",
"touch_bg/bg:obj:img",
"touch_bg/leftBg:obj",
"touch_bg/redDot:obj",
"touch_bg:obj",
"touch_bg/get_bg:obj",
"touch_bg/tabIcon:img",
"touch_bg/tabName:img",
"touch_bg/clock:obj",
}
self:GetChildren(self.nodes)
self:AddEvents()
if self.need_refreshData then
self:UpdateView()
end
if self.need_reclick then
self:SetSelected(self.selected)
end
end
function SupremeVipTabItem:AddEvents( )
local on_click = function ( click_obj )
if self.touch_bg_obj == click_obj then
self.click_callback(self.index)
end
end
AddClickEvent(self.touch_bg_obj, on_click)
--刷新兑换剩余次数
local function update_exchange_rest_counts()
self:UpdateExchangeRestCounts()
end
self:BindEvent(self.model, SupremeVipConst.REFRESH_EXCHANGE_REST_COUNTS,update_exchange_rest_counts)
--刷新红点
local function on_update_red(tab_id)
if self.is_loaded then
self:UpdateRedDot()
end
end
self:BindEvent(self.model, SupremeVipConst.ANS_UPDATE_RED_DOT,on_update_red)
end
function SupremeVipTabItem:UpdateRedDot( )
if not self.is_loaded or not self.redDot_obj then return end
local red = false
local show_clock = false
if self.index == 1 then
red = self.model:GetDailyGiftRed() or self.model:GetSevenLoginRed() or false
elseif self.index == 2 then
red = self.model:GetDiamondExchangeRed() or false
elseif self.index == 3 then
-- red = self.model:GetTrainDrugExchangeRed()
elseif self.index == 4 then
red = self.model:GetShopRed() or false
if not red then--如果没有红点,检查下是不是应该占时钟标志
show_clock = self.model:GetMoneyLeftRed() or false
end
end
self.redDot_obj:SetActive(red)
self.clock_obj:SetActive(show_clock)
end
function SupremeVipTabItem:UpdateView( )
self:UpdateExchangeRestCounts()
self:UpdateRedDot()
self.titleImg_obj:SetActive(self.index == 2 or self.index == 3)
local rest_daily_gift_counts = self.model:GetExchangeRestCount(SupremeVipConst.ExchangeType.DailyGift)--拿到剩余的兑换次数
-- self.get_bg_obj:SetActive(false)
-- if not self.model:IsForeverSupremeVip() then -- 一阶贵族
-- else
-- if rest_daily_gift_counts == 2 then
-- elseif rest_daily_gift_counts == 1 then
-- else
-- self.get_bg_obj:SetActive(self.index == 1)
-- end
-- end
-- local sup_vip_type = RoleManager.Instance.mainRoleInfo.sup_vip_type
-- self:SetGray((self.index == 2 or self.index == 3) and sup_vip_type < 2)
lua_resM:setImageSprite(self, self.tabIcon_img, "supremeVip_asset","supremeVip_tab_icon_"..self.index,true)
end
--刷新兑换剩余次数
function SupremeVipTabItem:UpdateExchangeRestCounts( )
if self.exchange_type ~= 0 then
self.leftBg_obj:SetActive(true)
local sup_vip_type = RoleManager.Instance.mainRoleInfo.sup_vip_type
if sup_vip_type == 2 then
local num = self.model:GetExchangeRestCount(self.exchange_type)
local num_color = num == 0 and ColorUtil.RED_DARK or ColorUtil.GREEN_TIPS
self.leftDes_tmp.text = string.format("今日剩余:<%s>%s</color>", num_color, num)
else
self.leftDes_tmp.text = ""
end
else
self.leftBg_obj:SetActive(false)
end
end
function SupremeVipTabItem:SetData(index,click_callback)
self.index = index
self.click_callback = click_callback
if self.index == 2 then
self.exchange_type = SupremeVipConst.ExchangeType.Diamond
elseif self.index == 3 then
self.exchange_type = SupremeVipConst.ExchangeType.TrainDrug
else
self.exchange_type = 0
end
if self.is_loaded then
self.need_refreshData = false
self:UpdateView()
else
self.need_refreshData = true
end
end
function SupremeVipTabItem:SetSelected(bool)
self.selected = bool
if self.is_loaded then
self.need_reclick = false
self.selectBg_obj:SetActive(bool)
self.bg_obj:SetActive(not bool)
if bool then
lua_resM:setImageSprite(self, self.tabName_img, "supremeVip_asset","supremeVip_tab_name_"..self.index.."_2",true)
else
lua_resM:setImageSprite(self, self.tabName_img, "supremeVip_asset","supremeVip_tab_name_"..self.index.."_1",true)
end
else
self.need_reclick = true
end
end
--一阶贵族时候要置灰永久特权贵族的按钮
function SupremeVipTabItem:SetGray(bool)
SetImageGray(self.bg_img,bool)
end
function SupremeVipTabItem:__delete( )
end