-- <*
|
|
-- @Author: huangcong
|
|
-- @Description: 活动右侧特殊tips弹窗
|
|
-- *>
|
|
CommonActTipView = CommonActTipView or BaseClass(BaseView)
|
|
local CommonActTipView = CommonActTipView
|
|
|
|
function CommonActTipView:__init()
|
|
self.base_file = "common"
|
|
self.layout_file = "CommonActTipView"
|
|
self.layer_name = "Main"
|
|
self.destroy_imm = true
|
|
self.use_background = false --全屏界面默认使用这个参数,非全屏界面自行设置
|
|
self.anim_time = 0.5
|
|
self.is_animating = false -- 是否在动画中
|
|
self.show_time_str = false--是否显示剩余时间
|
|
self.show_time_elapse = false --剩余时间显示
|
|
self.auto_close_time = 20--关闭时间
|
|
self.item_list = {}
|
|
self.model = CommonModel:getInstance()
|
|
|
|
self.load_callback = function ()
|
|
self:LoadSuccess()
|
|
self:AddEvent()
|
|
end
|
|
self.open_callback = function ( )
|
|
self:UpdateView()
|
|
end
|
|
self.destroy_callback = function ( )
|
|
self:DestroySuccess()
|
|
end
|
|
end
|
|
|
|
--[[ view_data = { -- 界面数据
|
|
desc = "完成首次充值领极品奖励",
|
|
awardList = {},
|
|
winId = 159,
|
|
subId = 1,
|
|
}
|
|
]]
|
|
function CommonActTipView:Open(view_data)
|
|
self.view_data = view_data
|
|
print("huangcong:CommonActTipView [start:43] :", self.view_data)
|
|
PrintTable(self.view_data)
|
|
print("huangcong:CommonActTipView [end]")
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function CommonActTipView:LoadSuccess()
|
|
local nodes = {
|
|
"goBtn:obj", "timeText:tmp", "closeBtn:obj", "nameText:tmp", "iconImage:img:obj","awardScroll", "awardScroll/Viewport/awardCon",
|
|
}
|
|
self:GetChildren(nodes)
|
|
|
|
end
|
|
|
|
function CommonActTipView:AddEvent()
|
|
local function click_event(target)
|
|
if target == self.closeBtn_obj then
|
|
self:HideAnim() -- 播放关闭效果,并检查邀请缓存
|
|
elseif target == self.goBtn_obj or target == self.iconImage_obj then
|
|
if self.view_data and self.view_data.winId and self.view_data.subId then
|
|
self:HideAnim()
|
|
OpenFun.Open(self.view_data.winId,self.view_data.subId)
|
|
end
|
|
end
|
|
end
|
|
AddClickEvent(self.closeBtn_obj, click_event)
|
|
AddClickEvent(self.goBtn_obj, click_event)
|
|
|
|
local function close_event( ... )
|
|
if not self.is_loaded or self._use_delete_method then return end
|
|
self:HideAnim() -- 播放关闭效果,并检查邀请缓存
|
|
end
|
|
self:BindEvent(GlobalEventSystem, EventName.CLOSE_COMMON_ACT_TIPS, close_event)--更新界面
|
|
end
|
|
|
|
-- 更新邀请内容
|
|
function CommonActTipView:UpdateView()
|
|
self.nameText_tmp.text = self.view_data and self.view_data.desc or ""
|
|
--资源可能有多个地址,默认activityIcon
|
|
local ab_name, res_name = "activityIcon_asset", ""
|
|
local is_out_res = false
|
|
if self.view_data.winId and self.view_data.subId then
|
|
local fun_vo = OpenFun.LinkWin[self.view_data.winId.."@"..self.view_data.subId]
|
|
if fun_vo then
|
|
res_name = fun_vo.icon_res
|
|
lua_resM:setImageSprite(self, self.iconImage_img, ab_name, res_name,false)
|
|
end
|
|
end
|
|
|
|
self:UpdateItemList()
|
|
|
|
-- 动画重点坐标初始化
|
|
self.start_anim_pos_x = 378 - ClientConfig.iphone_x_offset_right
|
|
self.end_anim_pos_x = 0 - ClientConfig.iphone_x_offset_right
|
|
SetAnchoredPositionX(self.transform, self.start_anim_pos_x)
|
|
|
|
-- 自动关闭倒计时
|
|
self:StartAutoCloseTimer()
|
|
-- 播放弹出动画
|
|
self:ShowAnim()
|
|
end
|
|
|
|
-- 自动关闭倒计时
|
|
function CommonActTipView:StartAutoCloseTimer( )
|
|
local end_time = self.auto_close_time + TimeUtil:getServerTime( )
|
|
self:ClearAutoCloseTimer()
|
|
local function auto_close_func()
|
|
local left_time = end_time - TimeUtil:getServerTime( )
|
|
if left_time >= 0 then
|
|
if self.view_data.end_time then
|
|
self.timeText_tmp.text = HtmlColorTxt(TimeUtil:convertTime(self.view_data.end_time - TimeUtil:getServerTime( )), "#0ce148")
|
|
else
|
|
self.timeText_tmp.text = HtmlColorTxt(TimeUtil:convertTime(left_time), "#0ce148")
|
|
end
|
|
else
|
|
self:ClearAutoCloseTimer()
|
|
self:HideAnim() -- 播放关闭效果,并检查邀请缓存
|
|
end
|
|
end
|
|
self.auto_close_func_id = GlobalTimerQuest:AddPeriodQuest(auto_close_func, 1, -1)
|
|
end
|
|
function CommonActTipView:ClearAutoCloseTimer( )
|
|
if self.auto_close_func_id then
|
|
GlobalTimerQuest:CancelQuest(self.auto_close_func_id)
|
|
self.auto_close_func_id = nil
|
|
end
|
|
end
|
|
|
|
-- 弹出动画
|
|
function CommonActTipView:ShowAnim()
|
|
local function anim_callback()
|
|
self.is_animating = false
|
|
end
|
|
self:ClearViewAnimId()
|
|
self.is_animating = true
|
|
self.view_anim_id = TweenLite.to(self, self.transform, TweenLite.UiAnimationType.ANCHORED_POSX,
|
|
self.end_anim_pos_x, self.anim_time, anim_callback, TweenFunc.EASE_OUT_QUINT)
|
|
end
|
|
-- 播放关闭动画,并检测缓存是否还有其他邀请没有处理
|
|
function CommonActTipView:HideAnim()
|
|
local function anim_callback()
|
|
self.is_animating = false
|
|
self.waiting = true
|
|
local cache_count = self.model:GetActTipDataCacheCount()
|
|
if cache_count > 0 then
|
|
self.view_data = self.model:PopActTipDataCache()
|
|
cache_count = self.model:GetActTipDataCacheCount()
|
|
if self.view_data then
|
|
self:UpdateView()
|
|
end
|
|
else
|
|
self:Close()
|
|
end
|
|
end
|
|
self:ClearViewAnimId()
|
|
self.is_animating = true
|
|
self.view_anim_id = TweenLite.to(self, self.transform, TweenLite.UiAnimationType.ANCHORED_POSX,
|
|
self.start_anim_pos_x, self.anim_time, anim_callback, TweenFunc.EASE_OUT_QUINT)
|
|
end
|
|
function CommonActTipView:ClearViewAnimId( )
|
|
if self.view_anim_id then
|
|
TweenLite.Stop(self.view_anim_id)
|
|
self.view_anim_id = nil
|
|
end
|
|
end
|
|
|
|
function CommonActTipView:DestroySuccess( )
|
|
for i,item in pairs(self.item_list) do
|
|
UIObjPool:getInstance():PushItem(UIObjPool.UIType.AwardItem, item)
|
|
end
|
|
self.item_list = {}
|
|
|
|
self:ClearViewAnimId()
|
|
self:ClearAutoCloseTimer()
|
|
end
|
|
|
|
|
|
function CommonActTipView:UpdateItemList( )
|
|
for k,v in pairs(self.item_list) do
|
|
v:SetVisible(false,nil,true)
|
|
end
|
|
self.col_num = 3
|
|
local item_list = self.view_data.awardList
|
|
if not item_list or TableSize(item_list) == 0 then return end
|
|
local len = #item_list
|
|
--如果比最大高度要高 那就只能滚动了
|
|
local offer_x = 1
|
|
local offer_y = -1
|
|
local space_x = 10
|
|
local space_y = 0
|
|
local item_width = 47
|
|
local x = 0
|
|
local y = 0
|
|
for i, v in ipairs(item_list) do
|
|
local item = self.item_list[i]
|
|
if item == nil then
|
|
item = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem,self.awardCon)
|
|
item:SetItemSize(47,47)
|
|
item:SetGoodsVo(v[4])
|
|
self.item_list[i] = item
|
|
end
|
|
local goods_Id, lock = GoodsModel:getInstance():GetMappingTypeId(v[1], v[2])
|
|
local goodVo = GoodsModel:getInstance():GetGoodsBasicByTypeId(goods_Id)
|
|
local stren_data = nil
|
|
if v[4] then
|
|
stren_data = EquipModel:getInstance():GetBagEquipAwaraItemInfo(v[4])
|
|
stren_data.equip_key = "EquipView"
|
|
end
|
|
if goodVo then
|
|
item:SetData(goods_Id, v[3], goodVo.color, stren_data, lock,true,nil)
|
|
else
|
|
-- error("没有找到物品信息 "..v.typeId)
|
|
end
|
|
item:SetVisible(true,nil,true)
|
|
x = (item_width+space_x)*(i-1) + offer_x
|
|
y = 0
|
|
item:SetPosition(x,y)
|
|
end
|
|
SetSizeDeltaX(self.awardCon,#item_list*(47+10)+10)
|
|
end
|