-- 牌友圈设置界面 local GroupMngSettingView = {} local M = GroupMngSettingView function GroupMngSettingView.new(gid) setmetatable(M, { __index = BaseWindow }) local self = setmetatable({}, { __index = M }) self.class = "GroupMngSettingView" self._close_destroy = true self.group_id = gid -- self._full = true self:init("ui://NewGroup/Win_GroupSetting") self:FillView() return self end function M:initData() end function M:FillView() local tex_name = self._view:GetChild("tex_name") local tex_notice = self._view:GetChild("tex_notice") local ctr_ban = self._view:GetController("ban") local ctr_dissolve_time = self._view:GetController("dissolve_time") local ctr_kick_time = self._view:GetController("kick_time") local ctr_apply = self._view:GetController("apply") local ctr_alliance = self._view:GetController("alliance") local ctr_pt = self._view:GetController("pt") local ctr_wq = self._view:GetController("wq") local ctr_es = self._view:GetController("es") local ctr_ua = self._view:GetController("ua") local ctl_show_num = self._view:GetController("showAll") local btn_chat_input = self._view:GetChild("btn_chat_input") local btn_chat_voice = self._view:GetChild("btn_chat_voice") local group = DataManager.groups:get(self.group_id) tex_name.text = group.name tex_notice.text = group.notice ctr_ban.selectedIndex = group.ban and 1 or 0 ctr_dissolve_time.selectedIndex = group.dissolve_opt - 1 ctr_kick_time.selectedIndex = group.kick_opt - 1 ctr_alliance.selectedIndex = group.type - 1 ctr_apply.selectedIndex = group.apply or 0 btn_chat_input.selected = not group.ban_chat1 btn_chat_voice.selected = not group.ban_chat2 if group.show_num == 0 then ctl_show_num.selectedIndex = 0 else ctl_show_num.selectedIndex = 1 self._view:GetChild("txt_show_num").text = tostring(group.show_num) end local option = group.option or 0 ctr_pt.selectedIndex = bit:_and(option, 1) > 0 and 1 or 0 ctr_wq.selectedIndex = bit:_and(option, 2) > 0 and 1 or 0 ctr_es.selectedIndex = bit:_and(option, 4) > 0 and 1 or 0 ctr_ua.selectedIndex = bit:_and(option, 8) > 0 and 1 or 0 self._view:GetChild("btn_ok").onClick:Set(function() ViewUtil.ShowModalWait2() local data = {} data.id = self.group_id data.name = tex_name.text data.notice = tex_notice.text data.ban = ctr_ban.selectedIndex == 1 data.dissolve_opt = ctr_dissolve_time.selectedIndex + 1 data.kick_opt = ctr_kick_time.selectedIndex + 1 data.apply = ctr_alliance.selectedIndex == 1 and ctr_apply.selectedIndex or 0 data.ban_chat1 = not btn_chat_input.selected data.ban_chat2 = not btn_chat_voice.selected local fgCtr = ControllerManager.GetController(NewGroupController) local pt = ctr_pt.selectedIndex local wq = ctr_wq.selectedIndex local es = ctr_es.selectedIndex local ua = ctr_ua.selectedIndex local option = 0 if ctr_pt.selectedIndex == 1 then option = bit:_or(option, 1) end if ctr_wq.selectedIndex == 1 then option = bit:_or(option, 2) end if ctr_es.selectedIndex == 1 then option = bit:_or(option, 4) end if ctr_ua.selectedIndex == 1 then option = bit:_or(option, 8) end local showNum = 0 if ctl_show_num.selectedIndex == 1 then local strShowNum = self._view:GetChild("txt_show_num").text if strShowNum ~= nil and strShowNum ~= "" then showNum = tonumber(self._view:GetChild("txt_show_num").text) end end fgCtr:FG_UpdateGroupInfo(data, function(res) ViewUtil.CloseModalWait2() if res.ReturnCode ~= 0 then ViewUtil.ErrorTip(res.ReturnCode, "设置大联盟失败。") else ViewUtil.ErrorTip(-1, "设置成功") group.name = name group.notice = notice group.ban = ban group.ban_ip = ban_ip group.ban_gps = ban_gps group.apply = apply group.option = option group.ban_chat1 = ban_chat1 group.ban_chat2 = ban_chat2 end end) end) end return M