|
- -- 茶馆创建Layout
- local ClubCreate = class("ClubCreate" , cc.UIView);
- local ClubCestConfig = require("luaScript.Views.Club.Cest.ClubCestConfig")
-
- function ClubCreate:ctor()
- ClubCreate.super.ctor(self)
- local ui = loadUI("res/ui/ui_club/ui_club_create.ui")
- self.ui = ui;
- self:addChild(ui);
- end
-
- function ClubCreate:onEnter()
- ClubCreate.super.onEnter(self)
-
- if ClubCestConfig.CestOpen then
- self.ui.Items.TextField_clubName:setPlaceHolder(PLN.CLUB_CEST_INPUT_NAME)
- self.ui.Items.Text_Tip:setString(PLN.CLUB_CEST_CREATE_TIP)
- else
- self.ui.Items.TextField_clubName:setPlaceHolder(PLN.CLUB_INPUT_NAME)
- self.ui.Items.Text_Tip:setString(PLN.CLUB_CREATE_TIP)
- end
- --
-
-
- --关闭
- self.ui.Items.Button_close:registerClick(handler(self , self.onClose))
- --确认创建
- self.ui.Items.Button_confirm:registerClick(handler(self , self.onConfirm))
-
- --茶馆创建成功后会请求茶馆列表,请求成功就关闭创建ui
- self:bindEvent(app.club_php , "getClubListCallback" , handler(self , self.getClubListCallbackEnd));
-
- self:bindEvent(app.club_php , GAME_EVENT.CLUB_LIST , handler(self , self.getClubListCallbackEnd));
- end
-
- function ClubCreate:getClubListCallbackEnd()
- self:removeFromParent()
- end
-
- function ClubCreate:onClose()
- playBtnCloseEffect()
- self:removeFromParent()
- end
-
- -- 创建茶馆
- function ClubCreate:onConfirm()
- playBtnEffect()
- local text = self.ui.Items.TextField_clubName:getText();
- local length = string.utf8len(text);
- if length <= 1 or length > 8 then
- showTooltip("请输入2~8位有效名字");
- return;
- end
-
- if string.find(text, "%p") then
- showTooltip("名字中存在标点字符,请重新输入!");
- return;
- end
-
- if string.find(text, "%s") then
- showTooltip("名字中存在空格,请重新输入!");
- return;
- end
-
- app.club_php:requestCreateClub(text);
- end
-
- --输入茶馆昵称
- function ClubCreate:onClickInput()
- print("insert text")
- local insertStr = self.ui.Items.TextField:getString()
- local length = string.len(insertStr)
- if self.defalutLen == 0 then
- if length == 1 then
- if self:getIsNumber(insertStr) then
- self.ui.Items.TextBMFont:setText(insertStr)
- self.inputText = self.inputText..insertStr
- self.defalutLen = length
- else
- self.ui.Items.TextField:setText(self.inputText)
- end
- else
- self.ui.Items.TextField:setText(self.inputText)
- end
- else
- local disLen = length - self.defalutLen
- if disLen == 1 then
- local insertStr = string.sub(insertStr,self.defalutLen + 1,length)
- if self:getIsNumber(insertStr) then
- self.inputText = self.inputText..insertStr
- self.ui.Items.TextBMFont:setText(self.inputText)
- self.defalutLen = length
- else
- self.ui.Items.TextField:setText(self.inputText)
- end
- else
- self.ui.Items.TextField:setText(self.inputText)
- end
- end
- end
-
- return ClubCreate
|