|
--[[@------------------------------------------------------------------
|
|
@description:首充附加主页签
|
|
@author:huangcong
|
|
----------------------------------------------------------------------]]
|
|
RechargeAddTab = RechargeAddTab or BaseClass(BaseItem)
|
|
|
|
RechargeAddTab.Width = 138
|
|
RechargeAddTab.Height = 158
|
|
local RechargeAddTab = RechargeAddTab
|
|
function RechargeAddTab:__init()
|
|
self.base_file = "rechargeActivity"
|
|
self.layout_file = "RechargeAddTab"
|
|
self.model = RechargeActivityModel:getInstance()
|
|
self.need_red = false
|
|
|
|
self:Load()
|
|
end
|
|
|
|
function RechargeAddTab:Load_callback()
|
|
local nodes = {
|
|
"nameImg:img:obj", "bg:img:obj", "redDot:obj", "select_bg:obj","nameGrayImg:obj:img",
|
|
}
|
|
self:GetChildren(nodes)
|
|
|
|
self:InitEvent()
|
|
if self.need_refreshData then
|
|
self:SetData(self.data,self.index)
|
|
end
|
|
end
|
|
|
|
function RechargeAddTab:__delete()
|
|
|
|
end
|
|
|
|
function RechargeAddTab:InitEvent()
|
|
local function clickHandler(target)
|
|
if target == self.bg_obj then
|
|
if self.callback then
|
|
self.callback(self.data,self.index)
|
|
end
|
|
end
|
|
end
|
|
AddClickEvent(self.bg_obj, clickHandler, 1)
|
|
|
|
-- local tabRedFunc = function (id, flag)
|
|
-- if id == VipModel.TabType.PurchaseGift then
|
|
-- self:SetData()
|
|
-- end
|
|
-- end
|
|
-- self:BindEvent(self.model, VipModel.UPDATE_VIP_VIEW_RED, tabRedFunc)--更新红点顺便更新界面
|
|
end
|
|
|
|
function RechargeAddTab:SetData(data,index)
|
|
self.data = data or self.data
|
|
self.index = index or self.index
|
|
if self.is_loaded then
|
|
self.need_refreshData = false
|
|
else
|
|
self.need_refreshData = true
|
|
return
|
|
end
|
|
if not self.data or not self.data.product_cfg then return end
|
|
lua_resM:setOutsideImageSprite(self, self.nameImg_img, GameResPath.GetRechargeActivityImage("recharge_add_tab_name_"..self.data.product_cfg.product_id), true)
|
|
lua_resM:setOutsideImageSprite(self, self.nameGrayImg_img, GameResPath.GetRechargeActivityImage("recharge_add_tab_name_gray_"..self.data.product_cfg.product_id), true)
|
|
|
|
local red_bool = false
|
|
for k,v in pairs(self.data.award_cfg) do
|
|
if v.state == 1 then
|
|
red_bool = true
|
|
break
|
|
end
|
|
end
|
|
if not red_bool then
|
|
local need_find_add_recharge_list = CookieWrapper.Instance:GetCookie(CookieLevelType.Account,CookieKey.RECHARGE_ADD_RED) or {}
|
|
red_bool = need_find_add_recharge_list[self.data.product_cfg.product_id] or false
|
|
end
|
|
self.redDot_obj:SetActive(red_bool)
|
|
self:SetSelect(self.choose_index)
|
|
end
|
|
|
|
function RechargeAddTab:SetSelect( index )
|
|
self.choose_index = index
|
|
if self.is_loaded then
|
|
self.select_bg_obj:SetActive(self.index == self.choose_index)
|
|
self.bg_obj:SetActive(self.index ~= self.choose_index)
|
|
self.nameGrayImg_obj:SetActive(self.index ~= self.choose_index)
|
|
self.nameImg_obj:SetActive(self.index == self.choose_index)
|
|
else
|
|
self.need_refreshData = true
|
|
end
|
|
end
|
|
|
|
function RechargeAddTab:SetCallBack( callback )
|
|
self.callback = callback
|
|
end
|
|
|