local TimeSettingPanel = import(".TimeSettingPanelTog") local GroupPartnerStatMember = import(".GroupPartnerStatMember") local GroupPartnerStatPlay = import(".GroupPartnerStatPlay") local GroupNumberInputView = import(".GroupNumberInputView") -- 开桌统计 local GroupMngPartnerStatView = {} local M = GroupMngPartnerStatView function GroupMngPartnerStatView.new(gid, rootView, player) local self = M self.class = "GroupMngPartnerStatView" self.group_id = gid self._data_choosePlayyer = player self:InitView() return self end function M:initData() self.lst_record.numItems = 0 self.record_data = {} self.ctr_search = self._view:GetController('search') local now_time = os.date("*t", now) local today = os.time({ year = now_time.year, month = now_time.month, day = now_time.day, hour = 0, min = 0, sec = 0 }) self.begin_time = today self.end_time = today + 86400 print("lingmeng initData") self:GetRecordData(0) --self:ShowPeopleNum() end -- function M:ShowPeopleNum() -- local fgCtr = ControllerManager.GetController(NewGroupController) -- fgCtr:FG_GetMembersCount(self.group_id,function(res) -- ViewUtil.CloseModalWait() -- if res.ReturnCode == 0 then -- self._view:GetChild('tex_memb_num').text = res.Data.member_num -- self._view:GetChild('tex_total_hp').text = d2ad(res.Data.hp_num1+res.Data.otherHp) -- end -- end) -- end function M:InitView() self._view = UIPackage.CreateObjectFromURL("ui://NewGroup/View_GroupPartnerStat") -- if group.lev ~= 3 then -- self._view:GetController("mng").selectedIndex = 1 -- end local lst_mgr_index = self._view:GetChild("lst_mgr_index") -- lst_mgr_index.visible = false -- if group.lev == 1 then -- lst_mgr_index.visible = true -- end self.lst_record = self._view:GetChild("lst_record") self.lst_record:SetVirtual() self.lst_record.itemRenderer = function(index, obj) self:OnRenderRecordItem(index, obj) end self.lst_record.scrollPane.onPullUpRelease:Set(function() self:GetRecordData(self.lst_record.numItems) end) self.time_panel = TimeSettingPanel.new(self._view, self._view:GetChild("btn_date1"), self._view:GetChild("btn_date2"), -308, 0, function() self.begin_time, self.end_time = self.time_panel:GetDate() self.record_data = {} self.record_data.numItems = 0 self:GetRecordData(0) end, true) local ctr_page = self._view:GetController("type") ctr_page.onChanged:Set(function() self.record_data = {} self.lst_record.numItems = 0 if ctr_page.selectedIndex == 0 then local now_time = os.date("*t", now) local today = os.time({ year = now_time.year, month = now_time.month, day = now_time.day, hour = 0, min = 0, sec = 0 }) self.begin_time = today self.end_time = today + 86400 else local now_time = os.date("*t", now) local today = os.time({ year = now_time.year, month = now_time.month, day = now_time.day, hour = 0, min = 0, sec = 0 }) self.begin_time = today - 86400 * ctr_page.selectedIndex self.end_time = today - 86400 * (ctr_page.selectedIndex - 1) end self:GetRecordData(0) end) -- self._view:GetChild("btn_search").onClick:Set(function() -- self.record_data = {} -- self.lst_record.numItems = 0 -- self.begin_time, self.end_time = self.time_panel:GetDate() -- self:GetRecordData(0) -- end) -- 搜索玩家 local ctr_search = self._view:GetController('search') self._view:GetChild('btn_search').onClick:Set( function() --printlog("aaaaaaaaaa1111111111111111111111111111111111111111111111") ViewUtil.ShowModalWait(nil) local text = self._view:GetChild('tex_id').text local qid, qnick if text == "" then ViewUtil.CloseModalWait() ViewUtil.ErrorTip(nil, '输入不能为空') return end qid = tonumber(text) or 0 qnick = text local time_type = self._view:GetController("type").selectedIndex if self.begin_time ~= nil and self.end_time ~= nil then time_type = 0 end local fgCtr = ControllerManager.GetController(NewGroupController) fgCtr:FG_FindPartnerStat( self.group_id, qid, 0, 6, time_type, self.begin_time, self.end_time, function(res) -- printlog("aaaaaaaaaaaaaaaa22222222222222222222222222222") -- pt(res) ViewUtil.CloseModalWait() if self._is_destroy then return end if res.ReturnCode ~= 0 then ViewUtil.ErrorTip(res.ReturnCode, '找不到成员') else self._view:GetChild('tex_id').text = '' ctr_search.selectedIndex = 1 local item_result = self._view:GetChild('lst_member_find') item_result:RemoveChildrenToPool() for j = 1, #res.Data.members do local tem = item_result:AddItemFromPool() self:FillRecordItem(res.Data.members[j], tem) end end end ) end ) local btn_back = self._view:GetChild('btn_back') btn_back.onClick:Set( function() self.lst_record.numItems = #self.record_data end ) self.btn_totalWin = self._view:GetChild('btn_totalWin') self.btn_totalWin.onClick:Set( function() self.btn_totalRound:GetController("type").selectedIndex = 0 self.btn_total:GetController("type").selectedIndex = 0 self.btn_reward:GetController("type").selectedIndex = 0 local type = self.btn_totalWin:GetController("type") type.selectedIndex = (type.selectedIndex + 1) % 3 if type.selectedIndex == 1 then table.sort(self.record_data, function(a, b) return a.total_win > b.total_win end) elseif type.selectedIndex == 2 then table.sort(self.record_data, function(a, b) return a.total_win < b.total_win end) else table.sort(self.record_data, function(a, b) return a.total_round > b.total_round end) end self.lst_record:RefreshVirtualList() end ) self.btn_totalRound = self._view:GetChild('btn_totalRound') self.btn_totalRound.onClick:Set( function() self.btn_totalWin:GetController("type").selectedIndex = 0 self.btn_total:GetController("type").selectedIndex = 0 self.btn_reward:GetController("type").selectedIndex = 0 local type = self.btn_totalRound:GetController("type") type.selectedIndex = (type.selectedIndex + 1) % 3 if type.selectedIndex == 1 then table.sort(self.record_data, function(a, b) return a.total_round > b.total_round end) elseif type.selectedIndex == 2 then table.sort(self.record_data, function(a, b) return a.total_round < b.total_round end) else table.sort(self.record_data, function(a, b) return a.total_round > b.total_round end) end self.lst_record:RefreshVirtualList() end ) self.btn_total = self._view:GetChild('btn_total') self.btn_total.onClick:Set( function() self.btn_totalWin:GetController("type").selectedIndex = 0 self.btn_totalRound:GetController("type").selectedIndex = 0 self.btn_reward:GetController("type").selectedIndex = 0 local type = self.btn_total:GetController("type") type.selectedIndex = (type.selectedIndex + 1) % 3 if type.selectedIndex == 1 then table.sort(self.record_data, function(a, b) return a.win_round > b.win_round end) elseif type.selectedIndex == 2 then table.sort(self.record_data, function(a, b) return a.win_round < b.win_round end) else table.sort(self.record_data, function(a, b) return a.total_round > b.total_round end) end self.lst_record:RefreshVirtualList() end ) self.btn_reward = self._view:GetChild('btn_reward') self.btn_reward.onClick:Set( function() self.btn_totalWin:GetController("type").selectedIndex = 0 self.btn_totalRound:GetController("type").selectedIndex = 0 self.btn_total:GetController("type").selectedIndex = 0 local type = self.btn_reward:GetController("type") type.selectedIndex = (type.selectedIndex + 1) % 3 if type.selectedIndex == 1 then table.sort(self.record_data, function(a, b) return a.reward_hp > b.reward_hp end) elseif type.selectedIndex == 2 then table.sort(self.record_data, function(a, b) return a.reward_hp < b.reward_hp end) else table.sort(self.record_data, function(a, b) return a.total_round > b.total_round end) end self.lst_record:RefreshVirtualList() end ) end function M:GetRecordData(index) local group = DataManager.groups:get(self.group_id) pt("lingmeng GetRecordData", self.group_id, self._data_choosePlayyer, group.lev) -- if group.lev == 1 and self._data_choosePlayyer.uid == DataManager.SelfUser.account_id then -- self:RecursionGetRankData(0) -- else self.record_data = {} self.lst_record.numItems = 0 self:RecursionGetRecoedData(0) -- end end function M:RefrenRecordData(data) self._data_choosePlayyer = data local group = DataManager.groups:get(self.group_id) pt("lingmeng GetRecordData2", self.group_id, self._data_choosePlayyer, group.lev) self.record_data = {} self.lst_record.numItems = 0 self:RecursionGetRecoedData(0) end function M:RecursionGetRecoedData(index) ViewUtil.ShowModalWait("正在获取数据中") local fgCtr = ControllerManager.GetController(NewGroupController) fgCtr:FG_GetPartnerStatMember(self.group_id, self._data_choosePlayyer.uid, self._data_choosePlayyer.parentId or self._data_choosePlayyer.uid, index * 67, 67, 0, self.begin_time, self.end_time, function(res) if res.ReturnCode == 0 then local members = res.Data.members if members and #members > 0 then for i = 1, #members do self.record_data[#self.record_data + 1] = members[i] end self:RecursionGetRecoedData(index + 1) else ViewUtil.CloseModalWait() self.lst_record.numItems = #self.record_data end else ViewUtil.CloseModalWait() ViewUtil.ErrorTip(res.ReturnCode) return end end) end function M:RecursionGetRankData(index) ViewUtil.ShowModalWait() local fgCtr = ControllerManager.GetController(NewGroupController) fgCtr:FG_GetMemberRank(self.group_id, 0, index * 67, 67, self.begin_time, self.end_time, 0, function(res) if res.ReturnCode == 0 then local ranks = res.Data.ranks if ranks and #ranks > 0 then for i = 1, #ranks do self.record_data[#self.record_data + 1] = ranks[i] end self:RecursionGetRankData(index + 1) else ViewUtil.CloseModalWait() self.lst_record.numItems = #self.record_data end else ViewUtil.CloseModalWait() ViewUtil.ErrorTip(res.ReturnCode) return end end) end -- 显示奖励 local function __showRewardsValue(rtype, cur_value, max_value, mng) local str = "" if not mng then str = string.format("%s%%/%s%%", cur_value, max_value) else str = string.format("%s%%", cur_value) end return str end function M:FillRecordItem(data, obj) local group = DataManager.groups:get(self.group_id) obj:GetChild("tex_name").text = ViewUtil.stringEllipsis(data.nick) .. "(" .. data.total .. ")" obj:GetChild("tex_id").text = "ID:" .. data.uid local tex_total_score = obj:GetChild("tex_total_score") local ctr_show_total = obj:GetController("show_total") if data._total_hp then tex_total_score.text = data._total_hp ctr_show_total.selectedIndex = 1 else ctr_show_total.selectedIndex = 0 end obj:GetChild("tex_round_valid").text = d2ad(data.reward_hp + data.total_win) --d2ad(data.reward_hp) --data.valid_round / 100 obj:GetChild("tex_round_total").text = data.total_round obj:GetChild("tex_total").text = d2ad(data.total_win) obj:GetChild("tex_round_youxiao").text = data.valid_round / 100 local btn_check_members = obj:GetChild("btn_check_members") btn_check_members.onClick:Set(function() ViewUtil.ShowModalWait(self._root_view) local fgCtr = ControllerManager.GetController(NewGroupController) fgCtr:FG_GetTotalHp(self.group_id, data.uid, function(res) ViewUtil.CloseModalWait() if res.ReturnCode == 0 then local hp = d2ad(res.Data.hp) tex_total_score.text = hp data._total_hp = hp data.total = res.Data.total_member - 1 obj:GetChild("tex_name").text = data.nick .. "(" .. data.total .. ")" ctr_show_total.selectedIndex = 1 end end) end) local btn_award = obj:GetChild("btn_award") btn_award.text = d2ad(data.reward_hp) --d2ad(data.reward_hp+data.total_win) btn_award.onClick:Set(function() local time_type = self._view:GetController("type").selectedIndex local gniv = GroupPartnerStatPlay.new(self.group_id, data.uid, data.partnerLev, DataManager.SelfUser.account_id, time_type, self.begin_time, self.end_time) gniv:Show() end) local btn_detail = obj:GetChild("btn_detail") btn_detail.onClick:Set(function() local time_type = self._view:GetController("type").selectedIndex --printlog("ccccccccccwwwwwwwwwwwwwwwwwwwwwwwwwwww ",self.begin_time," ",self.end_time) local gniv = GroupPartnerStatMember.new(self.group_id, data.uid, 0, self.begin_time, self.end_time) gniv:Show() end) local btnMen = obj:GetChild("btnMen") -- btnMen.text = d2ad(data.autoscore) local menControl = obj:GetController("menkan") if group.lev == 1 or (group.lev == 3 and group.partnerLev > 0) then if (DataManager.SelfUser.account_id ~= data.uid) then menControl.selectedIndex = 1 btnMen.text = d2ad(data.autoscore) btnMen.touchable = true else btnMen.text = d2ad(data.autoscore) menControl.selectedIndex = 1 btnMen.touchable = false end else menControl.selectedIndex = 0 end btnMen.onClick:Set(function() local gfiv = GroupNumberInputView.new(self._root_view, function(num) local fgCtr = ControllerManager.GetController(NewGroupController) fgCtr:FG_SetPartnerThreshold(self.group_id, data.uid, num, function(res) ViewUtil.CloseModalWait() if res.ReturnCode ~= 0 then ViewUtil.ErrorTip(res.ReturnCode, "设置失败") else ViewUtil.ShowBannerOnScreenCenter("设置成功") btnMen.text = num data.autoscore = ad2d(num) end end) end, 0) gfiv:Show() end) end function M:FillRecordItem2(data, obj) obj:GetChild('tex_name').text = data.nick obj:GetChild('tex_id').text = data.uid obj:GetChild('tex_total').text = d2ad(data.total_win) obj:GetChild('tex_round_total').text = data.total_round obj:GetChild('tex_win').text = data.win_round or 0 obj:GetChild('tex_reward').text = d2ad(data.reward_hp) end function M:OnRenderRecordItem(index, obj) local data = self.record_data[index + 1] self:FillRecordItem2(data, obj) end return M