|
--[[@------------------------------------------------------------------
|
|
@description:源能转盘兑换请求界面
|
|
@author:huangcong
|
|
----------------------------------------------------------------------]]
|
|
PowerTurnTableExchangeReqView = PowerTurnTableExchangeReqView or BaseClass(BaseView)
|
|
local PowerTurnTableExchangeReqView = PowerTurnTableExchangeReqView
|
|
|
|
function PowerTurnTableExchangeReqView:__init()
|
|
self.base_file = "powerTurnTable"
|
|
self.layout_file = "PowerTurnTableExchangeReqView"
|
|
self.layer_name = "Top"
|
|
self.destroy_imm = true
|
|
self.use_background = true
|
|
self.change_scene_close = true
|
|
self.append_to_ctl_queue = false --是否要添加进界面堆栈
|
|
self.need_show_money = false --是否要显示顶部的金钱栏
|
|
self.model = PowerTurnTableModel:getInstance()
|
|
self.is_set_zdepth = true
|
|
self.blur_activity_bg = true
|
|
self.cur_num = 1
|
|
self.load_callback = function ()
|
|
self:LoadSuccess()
|
|
self:AddEvent()
|
|
end
|
|
self.open_callback = function ( )
|
|
self:OpenSuccess()
|
|
end
|
|
self.destroy_callback = function ( )
|
|
self:DestroySuccess()
|
|
end
|
|
end
|
|
|
|
function PowerTurnTableExchangeReqView:DestroySuccess()
|
|
if self.awardItem then
|
|
UIObjPool:getInstance():PushItem(UIObjPool.UIType.AwardItem, self.awardItem)
|
|
self.awardItem = nil
|
|
end
|
|
|
|
if self.addNumComponent then
|
|
if self.change_count_id then
|
|
self.addNumComponent:UnBind(self.change_count_id)
|
|
self.change_count_id = nil
|
|
end
|
|
self.addNumComponent:DeleteMe()
|
|
self.addNumComponent = nil
|
|
end
|
|
end
|
|
|
|
function PowerTurnTableExchangeReqView:LoadSuccess()
|
|
local nodes = {
|
|
"Window:raw", "Window/windowCloseBtn:obj", "Window/windowTitleText:tmp", "cancelBtn:obj", "confirmBtn:obj",
|
|
"icon", "nameText:tmp", "num_con",
|
|
}
|
|
self:GetChildren(nodes)
|
|
self.windowTitleText_tmp.text = "提示"
|
|
lua_resM:setOutsideRawImage(self, self.Window_raw, GameResPath.GetViewBigBg("tips_comm_bg6"),false)
|
|
self.awardItem = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem,self.icon)
|
|
self.awardItem:SetItemSize(78,78)
|
|
self.awardItem:SetIsAct(true)
|
|
self.awardItem:SetDataWithMapId(self.data.reward[2],self.data.reward[3])
|
|
local goods_name = GoodsModel:getInstance():getGoodsName(self.data.reward[2], true)
|
|
self.nameText_tmp.text = goods_name
|
|
self:SetNumConInfo()
|
|
if self.need_load_again then
|
|
self:UpdateView()
|
|
end
|
|
end
|
|
|
|
function PowerTurnTableExchangeReqView:AddEvent()
|
|
local function onBtnClickHandler(target,x,y)
|
|
if target == self.windowCloseBtn_obj or self.cancelBtn_obj == target then
|
|
self:Close()
|
|
elseif target == self.confirmBtn_obj then--兑换
|
|
if self.data then
|
|
self:Close()
|
|
self.model:Fire(PowerTurnTableModel.REQUEST_INFO,33503,self.data.sub_type,self.data.id,self.cur_num)
|
|
end
|
|
end
|
|
end
|
|
AddClickEvent(self.windowCloseBtn_obj,onBtnClickHandler,1)
|
|
AddClickEvent(self.cancelBtn_obj,onBtnClickHandler,1)
|
|
AddClickEvent(self.confirmBtn_obj,onBtnClickHandler,1)
|
|
end
|
|
|
|
function PowerTurnTableExchangeReqView:Open( data )
|
|
self.data = data
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function PowerTurnTableExchangeReqView:OpenSuccess( )
|
|
self:UpdateView()
|
|
end
|
|
|
|
function PowerTurnTableExchangeReqView:UpdateView( )
|
|
if not self.is_loaded then
|
|
self.need_load_again = true
|
|
return
|
|
end
|
|
end
|
|
|
|
--设置购买数据
|
|
function PowerTurnTableExchangeReqView:SetNumConInfo( )
|
|
if not self.addNumComponent then
|
|
self.addNumComponent = AddNumberComponent.New(self.num_con)
|
|
self.addNumComponent:SetComponentWidth(240)
|
|
end
|
|
local function onChangeCountHandler(count)
|
|
self:SetCountNum(count)
|
|
end
|
|
self.change_count_id = self.addNumComponent:Bind(ComponentEvent.AddNumberComponent.CHANGE_COUNT, onChangeCountHandler)
|
|
self.addNumComponent:SetVisibleCalcBtn(false)
|
|
local max_num = 1
|
|
if self.data and self.data.max_num then
|
|
max_num = self.data.max_num
|
|
end
|
|
self.addNumComponent:InitData(1, max_num, 1, 1, 2)
|
|
end
|
|
|
|
function PowerTurnTableExchangeReqView:SetCountNum( count )
|
|
self.cur_num = count
|
|
end
|