117 lines
3.6 KiB
Lua
117 lines
3.6 KiB
Lua
|
|
-- 合伙人玩法奖励
|
||
|
|
|
||
|
|
local GroupPartnerBanPlaysNewView = {}
|
||
|
|
|
||
|
|
local M = GroupPartnerBanPlaysNewView
|
||
|
|
|
||
|
|
function GroupPartnerBanPlaysNewView.new(group_id,uid)
|
||
|
|
setmetatable(M, {__index = BaseWindow})
|
||
|
|
local self = setmetatable({}, {__index = M})
|
||
|
|
self.class = "GroupPartnerBanPlaysNewView"
|
||
|
|
self._close_destroy = true
|
||
|
|
self.group_id = group_id
|
||
|
|
self.uid = uid
|
||
|
|
self.allplays_data = {}
|
||
|
|
self:initView()
|
||
|
|
return self
|
||
|
|
end
|
||
|
|
|
||
|
|
function M:initView(url)
|
||
|
|
BaseWindow.init(self, "ui://NewGroup/Win_PartnerBanPlaysNew")
|
||
|
|
|
||
|
|
self.lst_allplays = self._view:GetChild("lst_allplays")
|
||
|
|
self.lst_allplays:SetVirtual()
|
||
|
|
self.lst_allplays.itemRenderer = function(index, obj)
|
||
|
|
self:OnRenderAllPlaysItem(index, obj)
|
||
|
|
end
|
||
|
|
self:GetBanPlaysData()
|
||
|
|
end
|
||
|
|
|
||
|
|
-- 获取奖励设置数据
|
||
|
|
function M:GetBanPlaysData()
|
||
|
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||
|
|
fgCtr:FG_GetAllplays2(self.group_id,self.uid, function(res)
|
||
|
|
ViewUtil.CloseModalWait()
|
||
|
|
if self._is_destroy then
|
||
|
|
return
|
||
|
|
end
|
||
|
|
if res.ReturnCode ~= 0 then
|
||
|
|
ViewUtil.ErrorTip(res.ReturnCode, "获取所有玩法失败")
|
||
|
|
else
|
||
|
|
--把列表转成map
|
||
|
|
local pids = res.Data.pids
|
||
|
|
self.pisMap = {}
|
||
|
|
for i,v in ipairs(pids) do
|
||
|
|
self.pisMap[v] = 1
|
||
|
|
end
|
||
|
|
local group = DataManager.groups:get(self.group_id)
|
||
|
|
local allplays = group.playList
|
||
|
|
for i=1,#allplays do
|
||
|
|
self.allplays_data[i] = allplays[i]
|
||
|
|
end
|
||
|
|
self.lst_allplays.numItems = #self.allplays_data
|
||
|
|
end
|
||
|
|
end)
|
||
|
|
end
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
-- 填充奖励设置对象
|
||
|
|
function M:OnRenderAllPlaysItem(index, obj)
|
||
|
|
local data = self.allplays_data[index + 1]
|
||
|
|
local group = DataManager.groups:get(self.group_id)
|
||
|
|
|
||
|
|
local play_name = group:getPlayName(data.id)
|
||
|
|
obj:GetChild("tex_name").text = data.name
|
||
|
|
|
||
|
|
local choose_play = obj:GetChild('choose_play')
|
||
|
|
choose_play.selected = self.pisMap[data.id] and self.pisMap[data.id] == 1
|
||
|
|
choose_play.onClick:Set(function()
|
||
|
|
if self.pisMap[data.id] and self.pisMap[data.id] == 1 then
|
||
|
|
self.pisMap[data.id] = nil
|
||
|
|
else
|
||
|
|
self.pisMap[data.id] = 1
|
||
|
|
end
|
||
|
|
local pidsl = {}
|
||
|
|
for k,v in pairs(self.pisMap) do
|
||
|
|
table.insert(pidsl,k)
|
||
|
|
end
|
||
|
|
if #pidsl == 0 then
|
||
|
|
pidsl = nil
|
||
|
|
end
|
||
|
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||
|
|
fgCtr:FG_SetBanPlayid2(self.group_id,self.uid,pidsl, function(res)
|
||
|
|
ViewUtil.CloseModalWait()
|
||
|
|
if self._is_destroy then
|
||
|
|
return
|
||
|
|
end
|
||
|
|
if res.ReturnCode ~= 0 then
|
||
|
|
ViewUtil.ErrorTip(res.ReturnCode, "设置玩法失败")
|
||
|
|
else
|
||
|
|
|
||
|
|
end
|
||
|
|
end)
|
||
|
|
end)
|
||
|
|
|
||
|
|
-- obj:GetChild("gxbtn").selected = data.ban==1
|
||
|
|
|
||
|
|
-- obj:GetChild("gxbtn").onClick:Set(function()
|
||
|
|
-- local bans = data.ban
|
||
|
|
-- local fgCtr = ControllerManager.GetController(NewGroupController)
|
||
|
|
-- fgCtr:FG_SetBanPlayid(self.group_id,data.pid,data.ban,self.uid, function(res)
|
||
|
|
-- ViewUtil.CloseModalWait()
|
||
|
|
-- if self._is_destroy then
|
||
|
|
-- return
|
||
|
|
-- end
|
||
|
|
-- if res.ReturnCode ~= 0 then
|
||
|
|
-- ViewUtil.ErrorTip(res.ReturnCode, "设置玩法失败")
|
||
|
|
-- else
|
||
|
|
-- local banoks = res.Data.allplays
|
||
|
|
-- obj:GetChild("gxbtn").selected = banoks[1].banok==1
|
||
|
|
-- self:GetBanPlaysData()
|
||
|
|
-- end
|
||
|
|
-- end)
|
||
|
|
-- end)
|
||
|
|
end
|
||
|
|
|
||
|
|
return M
|