You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
2.8 KiB

  1. -- 茶馆创建Layout
  2. local ClubCreate = class("ClubCreate" , cc.UIView);
  3. local ClubCestConfig = require("luaScript.Views.Club.Cest.ClubCestConfig")
  4. function ClubCreate:ctor()
  5. ClubCreate.super.ctor(self)
  6. local ui = loadUI("res/ui/ui_club/ui_club_create.ui")
  7. self.ui = ui;
  8. self:addChild(ui);
  9. end
  10. function ClubCreate:onEnter()
  11. ClubCreate.super.onEnter(self)
  12. if ClubCestConfig.CestOpen then
  13. self.ui.Items.TextField_clubName:setPlaceHolder(PLN.CLUB_CEST_INPUT_NAME)
  14. self.ui.Items.Text_Tip:setString(PLN.CLUB_CEST_CREATE_TIP)
  15. else
  16. self.ui.Items.TextField_clubName:setPlaceHolder(PLN.CLUB_INPUT_NAME)
  17. self.ui.Items.Text_Tip:setString(PLN.CLUB_CREATE_TIP)
  18. end
  19. --
  20. --关闭
  21. self.ui.Items.Button_close:registerClick(handler(self , self.onClose))
  22. --确认创建
  23. self.ui.Items.Button_confirm:registerClick(handler(self , self.onConfirm))
  24. --茶馆创建成功后会请求茶馆列表,请求成功就关闭创建ui
  25. self:bindEvent(app.club_php , "getClubListCallback" , handler(self , self.getClubListCallbackEnd));
  26. self:bindEvent(app.club_php , GAME_EVENT.CLUB_LIST , handler(self , self.getClubListCallbackEnd));
  27. end
  28. function ClubCreate:getClubListCallbackEnd()
  29. self:removeFromParent()
  30. end
  31. function ClubCreate:onClose()
  32. playBtnCloseEffect()
  33. self:removeFromParent()
  34. end
  35. -- 创建茶馆
  36. function ClubCreate:onConfirm()
  37. playBtnEffect()
  38. local text = self.ui.Items.TextField_clubName:getText();
  39. local length = string.utf8len(text);
  40. if length <= 1 or length > 8 then
  41. showTooltip("请输入2~8位有效名字");
  42. return;
  43. end
  44. if string.find(text, "%p") then
  45. showTooltip("名字中存在标点字符,请重新输入!");
  46. return;
  47. end
  48. if string.find(text, "%s") then
  49. showTooltip("名字中存在空格,请重新输入!");
  50. return;
  51. end
  52. app.club_php:requestCreateClub(text);
  53. end
  54. --输入茶馆昵称
  55. function ClubCreate:onClickInput()
  56. print("insert text")
  57. local insertStr = self.ui.Items.TextField:getString()
  58. local length = string.len(insertStr)
  59. if self.defalutLen == 0 then
  60. if length == 1 then
  61. if self:getIsNumber(insertStr) then
  62. self.ui.Items.TextBMFont:setText(insertStr)
  63. self.inputText = self.inputText..insertStr
  64. self.defalutLen = length
  65. else
  66. self.ui.Items.TextField:setText(self.inputText)
  67. end
  68. else
  69. self.ui.Items.TextField:setText(self.inputText)
  70. end
  71. else
  72. local disLen = length - self.defalutLen
  73. if disLen == 1 then
  74. local insertStr = string.sub(insertStr,self.defalutLen + 1,length)
  75. if self:getIsNumber(insertStr) then
  76. self.inputText = self.inputText..insertStr
  77. self.ui.Items.TextBMFont:setText(self.inputText)
  78. self.defalutLen = length
  79. else
  80. self.ui.Items.TextField:setText(self.inputText)
  81. end
  82. else
  83. self.ui.Items.TextField:setText(self.inputText)
  84. end
  85. end
  86. end
  87. return ClubCreate