|
|
- -- <*
- -- @Author: Saber
- -- @Description: 社团修改公告界面
- -- *>
-
- GuildEditAnnounceView = GuildEditAnnounceView or BaseClass(BaseView)
- local GuildEditAnnounceView = GuildEditAnnounceView
-
- function GuildEditAnnounceView:__init()
- self.base_file = "guild"
- self.layout_file = "GuildEditAnnounceView"
- self.layer_name = "Activity"
- self.destroy_imm = true
- self.use_background = true
- self.blur_activity_bg = true
- self.use_show_anim = true
- self.use_hide_anim = true
-
- self.model = GuildModel:getInstance()
- -- 除以2是因为中文编码算2个字符,就直接按照全中文来,海外版本需要移除
- self.send_limit = stringtotable(self.model:GetGuildKvByKey("announce_len").val)[2] / 2
- self.load_callback = function ()
- self:LoadSuccess()
- self:AddEvent()
- end
- self.open_callback = function ( )
- self.model:Fire(GuildModel.REQUEST_CCMD_EVENT, 40019) --获取社团修改信息界面信息
- self:UpdateView()
- self:UpdateBasicAnnounce()
- end
- self.switch_callback = function(index)
- self:SwitchTab(index)
- end
- self.destroy_callback = function ( )
- self:DestroySuccess()
- end
- end
-
- function GuildEditAnnounceView:Open( )
- --self.data = data
- BaseView.Open(self)
- end
-
- function GuildEditAnnounceView:LoadSuccess()
- local nodes = {
- "window:raw",
- "window/close:obj", "save_btn:obj", "cancel_btn:obj",
- "announce:tmpInput", "cur_text_num:tmp",
- "free_tips:tmp", "change_tips:tmp",
- }
- self:GetChildren(nodes)
-
- lua_resM:setOutsideRawImage(self, self.window_raw, GameResPath.GetViewBigBg("tips_comm_bg6"))
- end
-
- function GuildEditAnnounceView:AddEvent()
- local function click_event(target)
- if target == self.close_obj or target == self.cancel_btn_obj then
- self:Close()
- elseif target == self.save_btn_obj then
- self:OnClickSaveAnnounceBtn()
- end
- end
- AddClickEvent(self.close_obj, click_event, LuaSoundManager.SOUND_UI.NONE)
- AddClickEvent(self.cancel_btn_obj, click_event, LuaSoundManager.SOUND_UI.NONE)
- AddClickEvent(self.save_btn_obj, click_event, LuaSoundManager.SOUND_UI.NONE)
-
- local function update_view()
- self:UpdateView()
- end
- self:BindEvent(self.model, GuildModel.UPDATE_GUILD_ANNOUNCE_TIMES, update_view)
-
- self.announce_tmpInput.onValueChanged:AddListener(function()
- local len = utf8len(self.announce_tmpInput.text)
- if len > self.send_limit then
- self.announce_tmpInput.text = GetInputLimitResultStr(self.announce_tmpInput.text, self.send_limit) --减去多出来的字符
-
- self.tip_time = self.tip_time or 0
- if Status.NowTime-self.tip_time > 0.2 then
- Message.show(string.format("最多可输入%d个字符", self.send_limit))
- self.tip_time = Status.NowTime
- self:SetFontNum(self.send_limit)
- end
- else
- self:SetFontNum(len)
- end
- end)
- end
-
- function GuildEditAnnounceView:UpdateView()
- local times_data = self.model:GetGuildAnnounceTimesData()
- self.change_tips_tmp.text = string.format("<color=%s>%s以上</color>才可修改社团公告",
- ColorUtil.PURPLE_DARK, Trim(Config.Guildpos[GuildModel.GuildPosition.ViceLeader].name))
- if times_data then
- self.free_tips_tmp.text = string.format("每天可免费修改%s次(<color=%s>%s</color>/%s)", times_data.free_times,
- times_data.remain_times > 0 and ColorUtil.GREEN_DARK or ColorUtil.RED_DARK,
- times_data.remain_times, times_data.free_times)
- else
- self.free_tips_tmp.text = ""
- end
- end
-
- function GuildEditAnnounceView:UpdateBasicAnnounce( )
- self.announce_tmpInput.text = self.model:GetGuildAnnounce()
- end
-
- function GuildEditAnnounceView:SetFontNum( num )
- self.cur_text_num_tmp.text = string.format("字数:<color=%s>%s</color>/%s",
- num < self.send_limit and ColorUtil.GREEN_DARK or ColorUtil.RED_DARK, num, self.send_limit)
- end
-
- function GuildEditAnnounceView:OnClickSaveAnnounceBtn( )
- local _, title_filter = LanguageFilter.FilterMsg(self.announce_tmpInput.text)
- if title_filter == false then
- Message.show("社团公告有敏感词")
- return
- end
-
- if self.announce_tmpInput.text ~= "" then
- self.model:Fire(GuildModel.RequestSetAnnounceEvt, self.announce_tmpInput.text, 1)
- else
- Message.show("请输入公告~")
- end
- end
-
- function GuildEditAnnounceView:DestroySuccess( )
-
- end
|