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.

81 lines
2.2 KiB

  1. -- 设置公告
  2. local ClubSetNotice = class("ClubSetNotice" , cc.UIView);
  3. function ClubSetNotice:ctor(data)
  4. ClubSetNotice.super.ctor(self)
  5. local ui = loadUI("res/ui/ui_club/ui_club_set_notice.ui")
  6. self.ui = ui;
  7. self:addChild(ui);
  8. --茶馆数据
  9. self.clubInfo = data;
  10. end
  11. function ClubSetNotice:onEnter()
  12. ClubSetNotice.super.onEnter(self)
  13. --关闭
  14. self.ui.Items.Button_close:registerClick(handler(self , self.onClose))
  15. --确定修改
  16. self.ui.Items.Button_confirm:registerClick(handler(self , self.onConfirm))
  17. --暂停显示
  18. self.ui.Items.Button_pauseShow:registerClick(handler(self , self.onCancel))
  19. self.ui.Items.TextField_notice:setMaxLength(50);
  20. if self.clubInfo.notice and self.clubInfo.notice ~= "" then
  21. self.ui.Items.TextField_notice:setText(self.clubInfo.notice)
  22. self.ui.Items.Text_normal:setVisible(false)
  23. self.ui.Items.Button_pauseShow:setVisible(true)
  24. self.ui.Items.Button_confirm:setVisible(false)
  25. else
  26. self.ui.Items.Button_pauseShow:setVisible(false)
  27. self.ui.Items.Button_confirm:setVisible(true)
  28. self.ui.Items.Text_normal:setVisible(true)
  29. end
  30. --绑定
  31. self:bindTextNoticeTouch();
  32. end
  33. function ClubSetNotice:onClose()
  34. playBtnCloseEffect()
  35. self:removeFromParent()
  36. end
  37. --确定修改
  38. function ClubSetNotice:onConfirm()
  39. --参数1:管理员ID 参数2:玩家id 参数3:公告内容
  40. local notice = self.ui.Items.TextField_notice:getText();
  41. if notice == "" then
  42. showTooltip("内容不能为空!");
  43. return;
  44. end
  45. --self.clubInfo.notice = notice
  46. app.club_php:requestUpdateNotice(self.clubInfo.clubId,notice)
  47. self:onClose()
  48. end
  49. --暂停显示
  50. function ClubSetNotice:onCancel()
  51. app.club_php:requestUpdateNotice(self.clubInfo.clubId,"")
  52. self.clubInfo.notice = ""
  53. self:onClose()
  54. end
  55. function ClubSetNotice:bindTextNoticeTouch()
  56. local nodeName = self.ui.Items.TextField_notice;
  57. local function onTouchEnded(touch , event)
  58. self.ui.Items.Text_normal:setVisible(false)
  59. local notice = nodeName:getText();
  60. if notice == "" then
  61. elseif notice ~= self.clubInfo.notice then
  62. self.ui.Items.Button_pauseShow:setVisible(false)
  63. self.ui.Items.Button_confirm:setVisible(true)
  64. end
  65. end
  66. nodeName:addEventListener(onTouchEnded)
  67. end
  68. return ClubSetNotice