changhong/lua_probject/base_project/Game/View/NewGroup/GroupMngFagPackView.lua

258 lines
6.8 KiB
Lua
Raw Normal View History

2025-06-19 23:51:18 +08:00
-- 能量包
2025-05-24 14:29:14 +08:00
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
2025-06-19 23:51:18 +08:00
function GroupMngFagPackView.new(gid, blur_view, ctrNum, uid)
setmetatable(M, { __index = BaseWindow })
local self = setmetatable({}, { __index = M })
2025-05-24 14:29:14 +08:00
2025-06-19 23:51:18 +08:00
self.class = "GroupMngFagPackView"
self._close_destroy = true
self.group_id = gid
self.blur_view = blur_view
self.ctrNum = ctrNum
2025-05-24 14:29:14 +08:00
self.shouyiData = {}
self.uid = uid
2025-06-19 23:51:18 +08:00
self:init("ui://NewGroup/Win_bxx")
self:FillView()
return self
2025-05-24 14:29:14 +08:00
end
function M:FillView()
2025-06-19 23:51:18 +08:00
self.Ctr = self._view:GetController("ctr")
self.Ctr.selectedIndex = 1
2025-05-24 14:29:14 +08:00
self.lst_bxx = self._view:GetChild('bxx_list')
2025-06-19 23:51:18 +08:00
self.lst_bxx:SetVirtual()
self.lst_bxx.itemRenderer = function(index, item)
self:fillGameItem(index, item)
end
2025-05-24 14:29:14 +08:00
self.lst_bxx.onClickItem:Add(
2025-06-19 23:51:18 +08:00
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')
2025-05-24 14:29:14 +08:00
self.ctr_page = self._view:GetController("type")
2025-06-19 23:51:18 +08:00
self.ctr_page.onChanged:Set(function()
2025-05-24 14:29:14 +08:00
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
2025-06-19 23:51:18 +08:00
end)
2025-05-24 14:29:14 +08:00
self._view:GetChild("btn_bankinfo").onClick:Set(function()
2025-06-19 23:51:18 +08:00
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
)
2025-05-24 14:29:14 +08:00
local btn_qc = self._view:GetChild('btn_qc')
2025-06-19 23:51:18 +08:00
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
)
2025-05-24 14:29:14 +08:00
---------------------------
2025-06-19 23:51:18 +08:00
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)
2025-05-24 14:29:14 +08:00
if ad2d(num) > self._total_hp then
ViewUtil.ErrorTip(nil, "奖励池积分不足")
return
end
2025-06-19 23:51:18 +08:00
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()
2025-05-24 14:29:14 +08:00
self:initShouyiData()
2025-06-19 23:51:18 +08:00
self.lst_bxx.numItems = self.ctrNum
2025-05-24 14:29:14 +08:00
end
function M:initBankData()
ViewUtil.ShowModalWait()
2025-06-19 23:51:18 +08:00
local fgCtr = ControllerManager.GetController(NewGroupController)
fgCtr:FG_GetBankInfo(self.group_id, self.uid, function(res)
2025-05-24 14:29:14 +08:00
pt(res)
ViewUtil.CloseModalWait()
2025-06-19 23:51:18 +08:00
if res.ReturnCode ~= 0 then
2025-05-24 14:29:14 +08:00
ViewUtil.ErrorTip(res.ReturnCode, "获取银行数据失败")
else
2025-06-19 23:51:18 +08:00
self:SetBank(res.Data.total_hp, res.Data.bank_hp)
self.Ctr.selectedIndex = 0
2025-05-24 14:29:14 +08:00
end
end)
end
function M:initShouyiData()
ViewUtil.ShowModalWait()
self.shouyiData = {}
self._view:GetChild("tex_total").text = 0
local fgCtr = ControllerManager.GetController(NewGroupController)
2025-06-19 23:51:18 +08:00
fgCtr:FG_GetTakeInfo(self.group_id, self.uid, function(res)
2025-05-24 14:29:14 +08:00
ViewUtil.CloseModalWait()
2025-06-19 23:51:18 +08:00
if res.ReturnCode ~= 0 then
ViewUtil.ErrorTip(res.ReturnCode, "获取保险箱数据失败")
else
local data = res.Data
2025-05-24 14:29:14 +08:00
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
2025-06-19 23:51:18 +08:00
self.Ctr.selectedIndex = 1
2025-05-24 14:29:14 +08:00
end
end)
end
function M:SetCallback(callback)
2025-06-19 23:51:18 +08:00
self.callback = callback
2025-05-24 14:29:14 +08:00
end
2025-06-19 23:51:18 +08:00
function M:SetBank(totalHp, bankHp)
self.playerJF.text = totalHp / 100
self.bankJF.text = bankHp / 100
2025-05-24 14:29:14 +08:00
end
function M:fillGameItem(index, item)
2025-06-19 23:51:18 +08:00
if index ~= 0 then
item.icon = "ui://NewGroup/button_cqg"
if self.currentGameItemName == nil then
item.icon = "ui://NewGroup/button_cqg_xz"
2025-05-24 14:29:14 +08:00
end
else
2025-06-19 23:51:18 +08:00
item.icon = "ui://NewGroup/button_sjjl"
2025-05-24 14:29:14 +08:00
end
2025-06-19 23:51:18 +08:00
if self.currentGameItemName == item.icon then
item.icon = item.icon .. "_xz"
if index ~= 0 then
2025-05-24 14:29:14 +08:00
self:initBankData()
else
self:initShouyiData()
end
end
end
-- 销毁窗口
function M:Destroy(remove_map)
2025-06-19 23:51:18 +08:00
if self.callback then
self.callback()
end
BaseWindow.Destroy(self, remove_map)
ImageLoad.Clear(self.class)
2025-05-24 14:29:14 +08:00
end
2025-06-19 23:51:18 +08:00
return M