291 lines
7.4 KiB
Lua
291 lines
7.4 KiB
Lua
|
|
-- 能量包
|
||
|
|
local GroupTakeLogView = import(".MngView.GroupTakeLogView")
|
||
|
|
local GroupRewardsLogView = import(".MngView.GroupRewardsLogView")
|
||
|
|
local GroupNumberInputView = import(".MngView.GroupNumberInputView")
|
||
|
|
local GroupBankLogView = import(".MngView.GroupBankLogView")
|
||
|
|
|
||
|
|
local GroupMngFagPackView = {}
|
||
|
|
|
||
|
|
local M = GroupMngFagPackView
|
||
|
|
|
||
|
|
function GroupMngFagPackView.new(gid, blur_view,ctrNum,uid)
|
||
|
|
setmetatable(M, {__index = BaseWindow})
|
||
|
|
local self = setmetatable({}, {__index = M})
|
||
|
|
|
||
|
|
self.class = "GroupMngFagPackView"
|
||
|
|
self._close_destroy = true
|
||
|
|
self.group_id = gid
|
||
|
|
self.blur_view = blur_view
|
||
|
|
self.ctrNum=ctrNum
|
||
|
|
self.shouyiData = {}
|
||
|
|
self.uid = uid
|
||
|
|
self:init("ui://NewGroup/Win_bxx")
|
||
|
|
self:FillView()
|
||
|
|
return self
|
||
|
|
end
|
||
|
|
|
||
|
|
function M:FillView()
|
||
|
|
|
||
|
|
self.Ctr=self._view:GetController("ctr")
|
||
|
|
self.Ctr.selectedIndex=1
|
||
|
|
|
||
|
|
self.lst_bxx = self._view:GetChild('bxx_list')
|
||
|
|
self.lst_bxx:SetVirtual()
|
||
|
|
self.lst_bxx.itemRenderer = function(index, item)
|
||
|
|
self:fillGameItem(index, item)
|
||
|
|
end
|
||
|
|
|
||
|
|
|
||
|
|
self.lst_bxx.onClickItem:Add(
|
||
|
|
function(pas)
|
||
|
|
if self.currentSelectItem == pas.data then return end
|
||
|
|
local name=pas.data.icon
|
||
|
|
self.currentGameItemName=name
|
||
|
|
self.lst_bxx.numItems=self.ctrNum
|
||
|
|
end
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
self.playerJF=self._view:GetChild('tex_player')
|
||
|
|
self.bankJF=self._view:GetChild('tex_bank')
|
||
|
|
|
||
|
|
self.ctr_page = self._view:GetController("type")
|
||
|
|
self.ctr_page.onChanged:Set(function()
|
||
|
|
if self.ctr_page.selectedIndex == 0 then
|
||
|
|
if self.shouyiData.day_rewad then
|
||
|
|
self._view:GetChild("tex_total").text = d2ad(self.shouyiData.day_rewad)
|
||
|
|
end
|
||
|
|
elseif self.ctr_page.selectedIndex == 1 then
|
||
|
|
if self.shouyiData.day_rewad_1 then
|
||
|
|
self._view:GetChild("tex_total").text = d2ad(self.shouyiData.day_rewad_1)
|
||
|
|
end
|
||
|
|
elseif self.ctr_page.selectedIndex == 2 then
|
||
|
|
if self.shouyiData.day_rewad_2 then
|
||
|
|
self._view:GetChild("tex_total").text = d2ad(self.shouyiData.day_rewad_2)
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end)
|
||
|
|
|
||
|
|
self._view:GetChild("btn_bankinfo").onClick:Set(function()
|
||
|
|
local gtlv = GroupBankLogView.new(self.blur_view, self.group_id,self.uid)
|
||
|
|
gtlv:Show()
|
||
|
|
end)
|
||
|
|
|
||
|
|
local btn_cr = self._view:GetChild('btn_qd')
|
||
|
|
btn_cr.onClick:Set(
|
||
|
|
function()
|
||
|
|
|
||
|
|
local gniv = GroupNumberInputView.new(nil, function(num)
|
||
|
|
|
||
|
|
local value = limit
|
||
|
|
if otype == 1 then
|
||
|
|
value = value + ad2d(num)
|
||
|
|
elseif otype == - 1 then
|
||
|
|
value = value - ad2d(num)
|
||
|
|
else
|
||
|
|
value = ad2d(num)
|
||
|
|
end
|
||
|
|
|
||
|
|
if value < 0 then
|
||
|
|
ViewUtil.ErrorTip(1,"输入数据异常!")
|
||
|
|
end
|
||
|
|
|
||
|
|
ViewUtil.ShowModalWait()
|
||
|
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||
|
|
fgCtr:FG_SAVEBankInfo(self.group_id, value,self.uid ,function(res1)
|
||
|
|
ViewUtil.CloseModalWait()
|
||
|
|
pt(res1)
|
||
|
|
if (res1.ReturnCode == 0) then
|
||
|
|
self:SetBank(res1.Data.hp,res1.Data.b_hp)
|
||
|
|
ViewUtil.ErrorTip(100011000,"积分存取成功!")
|
||
|
|
else
|
||
|
|
ViewUtil.ErrorTip(res1.ReturnCode,"存取积分失败!")
|
||
|
|
end
|
||
|
|
end)
|
||
|
|
|
||
|
|
end, 0, nil)
|
||
|
|
gniv:Show()
|
||
|
|
|
||
|
|
|
||
|
|
end
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
local btn_qc = self._view:GetChild('btn_qc')
|
||
|
|
btn_qc.onClick:Set(
|
||
|
|
function()
|
||
|
|
|
||
|
|
local gniv = GroupNumberInputView.new(nil, function(num)
|
||
|
|
|
||
|
|
local value = limit
|
||
|
|
if otype == 1 then
|
||
|
|
value = value + ad2d(num)
|
||
|
|
elseif otype == - 1 then
|
||
|
|
value = value - ad2d(num)
|
||
|
|
else
|
||
|
|
value = ad2d(num)
|
||
|
|
end
|
||
|
|
|
||
|
|
if value < 0 then
|
||
|
|
ViewUtil.ErrorTip(1,"输入数据异常!")
|
||
|
|
end
|
||
|
|
|
||
|
|
ViewUtil.ShowModalWait()
|
||
|
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||
|
|
fgCtr:FG_TakeBankInfo(self.group_id, value,self.uid, function(res1)
|
||
|
|
ViewUtil.CloseModalWait()
|
||
|
|
pt(res1)
|
||
|
|
if (res1.ReturnCode == 0) then
|
||
|
|
self:SetBank(res1.Data.hp,res1.Data.b_hp)
|
||
|
|
ViewUtil.ErrorTip(100011000,"积分取出成功!")
|
||
|
|
else
|
||
|
|
ViewUtil.ErrorTip(res1.ReturnCode,"获取积分失败!")
|
||
|
|
end
|
||
|
|
end)
|
||
|
|
|
||
|
|
end, 0, nil)
|
||
|
|
gniv:Show()
|
||
|
|
|
||
|
|
end
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
---------------------------
|
||
|
|
self._view:GetChild("btn_take_log").onClick:Set(function()
|
||
|
|
local gtlv = GroupTakeLogView.new(self.blur_view, self.group_id,self.uid)
|
||
|
|
gtlv:Show()
|
||
|
|
end)
|
||
|
|
self._view:GetChild("btn_hp_info").onClick:Set(function()
|
||
|
|
local grlv = GroupRewardsLogView.new(self.blur_view, self.group_id,self.uid)
|
||
|
|
grlv:Show()
|
||
|
|
end)
|
||
|
|
self._view:GetChild("btn_take").onClick:Set(function()
|
||
|
|
local gniv = GroupNumberInputView.new(self.blur_view, function(num)
|
||
|
|
if ad2d(num) > self._total_hp then
|
||
|
|
ViewUtil.ErrorTip(nil, "奖励池积分不足")
|
||
|
|
return
|
||
|
|
end
|
||
|
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||
|
|
fgCtr:FG_TakeHp(self.group_id, ad2d(num), self.uid,function(res)
|
||
|
|
if num == 0 then
|
||
|
|
ViewUtil.ErrorTip(nil, "提取值必须大于0")
|
||
|
|
return
|
||
|
|
end
|
||
|
|
if res.ReturnCode ~= 0 then
|
||
|
|
ViewUtil.ErrorTip(res.ReturnCode, "提取能量包失败")
|
||
|
|
else
|
||
|
|
self._total_hp = res.Data.r_hp
|
||
|
|
self._view:GetChild("tex_left").text = d2ad(self._total_hp)
|
||
|
|
end
|
||
|
|
end)
|
||
|
|
end, 1, d2ad(self._total_hp), "ui://NewGroup/Win_TakeHp")
|
||
|
|
gniv:Show()
|
||
|
|
end)
|
||
|
|
|
||
|
|
--self:initBankData()
|
||
|
|
self:initShouyiData()
|
||
|
|
self.lst_bxx.numItems=self.ctrNum
|
||
|
|
end
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
function M:initBankData()
|
||
|
|
ViewUtil.ShowModalWait()
|
||
|
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||
|
|
fgCtr:FG_GetBankInfo(self.group_id, self.uid,function(res)
|
||
|
|
pt(res)
|
||
|
|
ViewUtil.CloseModalWait()
|
||
|
|
if res.ReturnCode ~= 0 then
|
||
|
|
ViewUtil.ErrorTip(res.ReturnCode, "获取银行数据失败")
|
||
|
|
else
|
||
|
|
self:SetBank(res.Data.total_hp,res.Data.bank_hp)
|
||
|
|
self.Ctr.selectedIndex=0
|
||
|
|
|
||
|
|
end
|
||
|
|
|
||
|
|
end)
|
||
|
|
end
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
function M:initShouyiData()
|
||
|
|
ViewUtil.ShowModalWait()
|
||
|
|
self.shouyiData = {}
|
||
|
|
self._view:GetChild("tex_total").text = 0
|
||
|
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||
|
|
fgCtr:FG_GetTakeInfo(self.group_id,self.uid ,function(res)
|
||
|
|
ViewUtil.CloseModalWait()
|
||
|
|
if res.ReturnCode ~= 0 then
|
||
|
|
ViewUtil.ErrorTip(res.ReturnCode, "获取保险箱数据失败")
|
||
|
|
else
|
||
|
|
local data = res.Data
|
||
|
|
self.ctr_page.selectedIndex = 0
|
||
|
|
self.shouyiData = data
|
||
|
|
self._view:GetChild("tex_left").text = d2ad(data.total_hp)
|
||
|
|
self._view:GetChild("tex_total").text = d2ad(data.day_rewad)
|
||
|
|
--self._view:GetChild("tex_totalshouyi").text = 0
|
||
|
|
self._total_hp = data.total_hp
|
||
|
|
self.Ctr.selectedIndex=1
|
||
|
|
end
|
||
|
|
end)
|
||
|
|
end
|
||
|
|
|
||
|
|
function M:SetCallback(callback)
|
||
|
|
self.callback = callback
|
||
|
|
end
|
||
|
|
|
||
|
|
|
||
|
|
function M:SetBank(totalHp,bankHp)
|
||
|
|
self.playerJF.text=totalHp/1000
|
||
|
|
self.bankJF.text=bankHp/1000
|
||
|
|
end
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
function M:fillGameItem(index, item)
|
||
|
|
if index~=0 then
|
||
|
|
item.icon="ui://NewGroup/button_cqg"
|
||
|
|
if self.currentGameItemName==nil then
|
||
|
|
item.icon="ui://NewGroup/button_cqg_xz"
|
||
|
|
end
|
||
|
|
else
|
||
|
|
item.icon="ui://NewGroup/button_sjjl"
|
||
|
|
end
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
if self.currentGameItemName==item.icon then
|
||
|
|
item.icon=item.icon.."_xz"
|
||
|
|
if index~=0 then
|
||
|
|
self:initBankData()
|
||
|
|
else
|
||
|
|
self:initShouyiData()
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
end
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
-- 销毁窗口
|
||
|
|
function M:Destroy(remove_map)
|
||
|
|
if self.callback then
|
||
|
|
self.callback()
|
||
|
|
end
|
||
|
|
BaseWindow.Destroy(self,remove_map)
|
||
|
|
ImageLoad.Clear(self.class)
|
||
|
|
end
|
||
|
|
|
||
|
|
return M
|