GetWayTipsItem = GetWayTipsItem or BaseClass(BaseItem)
|
|
|
|
function GetWayTipsItem:__init()
|
|
self.base_file = "common"
|
|
self.layout_file = "GetWayTipsItem"
|
|
self.data = nil
|
|
self:Load()
|
|
|
|
end
|
|
|
|
function GetWayTipsItem:Load_callback()
|
|
self.btnGo = self:GetChild("btnGo").gameObject
|
|
self.icon = self:GetChild("icon"):GetComponent("Image")
|
|
self.name = self:GetChild("point/name"):GetComponent("Text")
|
|
self.clickBg = self:GetChild("clickBg").gameObject
|
|
|
|
self:InitEvent()
|
|
end
|
|
|
|
function GetWayTipsItem:InitEvent()
|
|
local function onBtnClickHandler(target)
|
|
if self.data then
|
|
if target == self.btnGo or target == self.clickBg then
|
|
OpenFun.Open(unpack(self.data))
|
|
|
|
end
|
|
end
|
|
--关闭获取途径界面
|
|
GlobalEventSystem:Fire(EventName.CLICK_GET_WAY_ITEM)
|
|
end
|
|
|
|
AddClickEvent(self.btnGo,onBtnClickHandler)
|
|
AddClickEvent(self.clickBg,onBtnClickHandler)
|
|
|
|
end
|
|
|
|
function GetWayTipsItem:SetData(strs)
|
|
if strs == nil or Trim(strs) == "" then
|
|
return
|
|
end
|
|
local cfg_index = 1
|
|
local array = {}
|
|
local is_more = string.find(strs,"@")
|
|
if is_more then
|
|
array = Split(strs,"@")
|
|
for k,v in pairs(array) do
|
|
array[k] = tonumber(v)
|
|
end
|
|
cfg_index = array[1]
|
|
else
|
|
cfg_index = tonumber(strs)
|
|
array[1] = cfg_index
|
|
end
|
|
local data = OpenFun.LinkWin[cfg_index]
|
|
if not data then
|
|
print("******没有对应的获取途径配置******")
|
|
return
|
|
end
|
|
self.data = array
|
|
lua_resM:setImageSprite(self, self.icon, "mainui_asset", data.icon_res)
|
|
self.name.text = data.name or "未定义:OpenFun.lua"
|
|
end
|