|
|
- -- <*
- -- @Author: msh
- -- @Description: 界面view
- -- *>
- ChildShowBabyView = ChildShowBabyView or BaseClass(BaseView)
- local ChildShowBabyView = ChildShowBabyView
-
- function ChildShowBabyView:__init()
- self.base_file = "child"
- self.layout_file = "ChildShowBabyView"
- self.layer_name = "Activity"
- self.destroy_imm = true
- self.use_background = G_USING_BG --全屏界面默认使用这个参数
- --self.hide_maincancas = true --全屏界面需要放开隐藏主UI
- self.change_scene_close = true
- self.append_to_ctl_queue = false --是否要添加进界面堆栈
- self.need_show_money = false --是否要显示顶部的金钱栏
-
- self.model = ChildModel:getInstance()
- self.send_limit = ChildConst.ShowBabyTextLenLimit
-
- self.load_callback = function ()
- self:LoadSuccess()
- self:AddEvent()
- end
- self.open_callback = function ( )
- self:OpenSuccess()
- end
- self.switch_callback = function(index)
- self:SwitchTab(index)
- end
- self.destroy_callback = function ( )
- self:DestroySuccess()
- end
- end
-
- function ChildShowBabyView:Open( )
- --self.data = data
- BaseView.Open(self)
- end
-
- function ChildShowBabyView:LoadSuccess()
- local nodes = {
- "btn_close:obj", "showCSBtn:obj",
- "showGuildBtn:obj", "showBtn:obj:img",
- "showWorldBtn:obj","bg:raw",
- }
- self:GetChildren(nodes)
- self.input_text = self:GetChild("input"):GetComponent("InputField")
- lua_resM:setOutsideRawImage(self,self.bg_raw,GameResPath.GetViewBigBg("tips_comm_bg6"),false)
- self:ChangeShowText()
- self:UpdateBaseView( )
- end
-
- function ChildShowBabyView:UpdateBaseView( )
-
- end
-
- function ChildShowBabyView:AddEvent()
- local on_click = function ( click_obj )
- if self.showBtn_obj == click_obj then
- self:ChangeShowText()
- elseif self.showWorldBtn_obj == click_obj then -- 世界晒娃
- if RoleManager.Instance.mainRoleInfo.level >= Config.Moduleid[110].open_lv then
- self.model:Fire(ChildConst.CHILD_REQ_EVENT, 16509,ChatModel.CHANNEL_WORLD)
- else
- Message.show("等级不足"..Config.Moduleid[110].open_lv, "fault")
- end
- elseif self.showCSBtn_obj == click_obj then -- 跨服晒
- if RoleManager.Instance.mainRoleInfo.level >= Config.ConfigOpenLv.ChatOpenLevel.CROSS then
- self.model:Fire(ChildConst.CHILD_REQ_EVENT, 16509,ChatModel.CHANNEL_CROSS)
- else
- Message.show("等级不足"..Config.ConfigOpenLv.ChatOpenLevel.CROSS, "fault")
- end
- --Message.show("2")
- elseif self.showGuildBtn_obj == click_obj then -- 社团晒
- if RoleManager.Instance.mainRoleInfo.level >= Config.ConfigOpenLv.ChatOpenLevel.GUILD and ( RoleManager.Instance:GetMainRoleVo().guild_id and RoleManager.Instance:GetMainRoleVo().guild_id ~= 0) then
- self.model:Fire(ChildConst.CHILD_REQ_EVENT, 16509,ChatModel.CHANNEL_GUILD)
- else
- Message.show("社团频道还未开启哦", "fault")
- end
- elseif self.btn_close_obj == click_obj then
- self:Close()
- end
- end
- AddClickEvent(self.showBtn_obj, on_click)
- AddClickEvent(self.showWorldBtn_obj, on_click)
- AddClickEvent(self.showCSBtn_obj, on_click)
- AddClickEvent(self.showGuildBtn_obj, on_click)
- AddClickEvent(self.btn_close_obj, on_click)
-
- self.input_text.onValueChanged:AddListener(function()
- local len = utf8len(self.input_text.text)
- if len > self.send_limit then
- self.input_text.text = string.sub(self.input_text.text, 1, self.send_limit-len-1) --减去多出来的字符
-
- self.tip_time = self.tip_time or 0
- if Status.NowTime - self.tip_time > 0.1 then
- Message.show(string.format("最多可输入%d个字符", self.send_limit))
- self.tip_time = Status.NowTime
- end
- end
- -- 判断是否是人为输入
- -- local is_need_name = self.input_text.text == ChildConst.ShowBabyText[self.last_index or 1]
- self.model:SetShowBabyStr( self.input_text.text, is_need_name )
- end)
- end
-
- function ChildShowBabyView:ChangeShowText( )
- local cfg = ChildConst.ShowBabyText
- local index = math.random(1, #cfg)
- if self.last_index and index == self.last_index then -- 不跟上一套重复
- local new_index = index + 1
- index = new_index <= #cfg and new_index or 1
- end
- self.last_index = index
- local childList = self.model:GetChildInfo()
- local child_name = childList.child_name
- self.input_text.text = string.format(cfg[index], "<" .. child_name .. ">")
- self.model:SetShowBabyStr( self.input_text.text)
- end
-
- function ChildShowBabyView:OpenSuccess()
- self:UpdateView()
- end
-
- function ChildShowBabyView:UpdateView()
-
- end
-
- function ChildShowBabyView:SwitchTab( index )
-
- end
-
- function ChildShowBabyView:DestroySuccess( )
-
- end
|