-- <*
|
|
-- @Author: Saber
|
|
-- @Description: 藏宝图 活动描述item节点
|
|
-- *>
|
|
TreasureMapDescScrollItem = TreasureMapDescScrollItem or BaseClass(BaseItem)
|
|
local TreasureMapDescScrollItem = TreasureMapDescScrollItem
|
|
|
|
function TreasureMapDescScrollItem:__init(parent_wnd,prefab_asset,layer_name)
|
|
self.base_file = "treasureMap"
|
|
self.layout_file = "TreasureMapDescScrollItem"
|
|
self.parent_wnd = parent_wnd
|
|
self.layer_name = layer_name
|
|
|
|
self.model = TreasureMapModel:getInstance()
|
|
self:Load()
|
|
end
|
|
|
|
function TreasureMapDescScrollItem:Load_callback()
|
|
local nodes = {
|
|
"title:obj", "title/title_lb:tmp",
|
|
"desc1:tmp",
|
|
"desc2:tmp",
|
|
"jump_click_lb:obj:tmp",
|
|
}
|
|
self:GetChildren(nodes)
|
|
|
|
|
|
self:AddEvents()
|
|
if self.need_refreshData then
|
|
self:UpdateView()
|
|
end
|
|
end
|
|
|
|
function TreasureMapDescScrollItem:AddEvents( )
|
|
local function click_event(target)
|
|
if target == self.jump_click_lb_obj then
|
|
if self.data and self.data.click_callback then
|
|
self.data.click_callback()
|
|
end
|
|
end
|
|
end
|
|
AddClickEvent(self.jump_click_lb_obj, click_event)
|
|
end
|
|
|
|
function TreasureMapDescScrollItem:SetData( data )
|
|
self.height = 0
|
|
self.data = data
|
|
if self.is_loaded then
|
|
self.need_refreshData = false
|
|
self.height = self:UpdateView()
|
|
else
|
|
self.need_refreshData = true
|
|
end
|
|
return self.height
|
|
end
|
|
|
|
function TreasureMapDescScrollItem:InitNodes( )
|
|
self.title_obj:SetActive(false)
|
|
self.desc1_tmp.text = ""
|
|
self.desc2_tmp.text = ""
|
|
self.jump_click_lb_obj:SetActive(false)
|
|
self.jump_click_lb_tmp.text = ""
|
|
end
|
|
|
|
function TreasureMapDescScrollItem:UpdateView( )
|
|
local height = 0
|
|
self:InitNodes()
|
|
if self.data then
|
|
if self.data.title then
|
|
self.title_obj:SetActive(true)
|
|
self.title_lb_tmp.text = self.data.title
|
|
height = 26
|
|
elseif self.data.desc1 then
|
|
self.desc1_tmp.text = self.data.desc1
|
|
if self.data.click_callback then -- 存在回调
|
|
self.jump_click_lb_obj:SetActive(true)
|
|
self.jump_click_lb_tmp.text = self.data.click_callback_desc
|
|
SetAnchoredPositionX(self.jump_click_lb, 34 + self.desc1_tmp.preferredWidth)
|
|
end
|
|
height = 24
|
|
elseif self.data.desc2 then
|
|
self.desc2_tmp.text = self.data.desc2
|
|
height = self.desc2_tmp.preferredHeight + 5
|
|
end
|
|
end
|
|
return height + (self.data.height_offset or 0)
|
|
end
|
|
|
|
function TreasureMapDescScrollItem:__delete( )
|
|
|
|
end
|