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.

85 lines
2.0 KiB

  1. ---
  2. -- ================================================================
  3. -- 文件名: NoticeAiDaoRiView.lua
  4. -- 描述: 哀悼日活动
  5. -- 版权: Copyright © 2016-2019 公司名称 版权所有
  6. -- 作者: Administrator
  7. -- 创建日期: 2020-04-03
  8. -- 更新日期: 2020-04-03
  9. -- 备注:
  10. -- ================================================================
  11. --
  12. local NoticeAiDaoRiView = class("NoticeAiDaoRiView", cc.UIView);
  13. function NoticeAiDaoRiView:ctor(notice,endCallback)
  14. NoticeAiDaoRiView.super.ctor(self)
  15. if notice then
  16. self.notice = string.split(notice,"\n")
  17. end
  18. self.endCallback = endCallback
  19. end
  20. ---
  21. -- 进入界面
  22. --
  23. function NoticeAiDaoRiView:onEnter()
  24. self:loadUI();
  25. self:initViews();
  26. self:initEvents();
  27. end
  28. ---
  29. -- 加载UI布局
  30. --
  31. function NoticeAiDaoRiView:loadUI()
  32. self.ui = loadUI("res/ui/ui_dating/ui_notice_aidaori.ui");
  33. self:addChild(self.ui);
  34. end
  35. ---
  36. -- 初始化界面
  37. --
  38. function NoticeAiDaoRiView:initViews()
  39. self.ui.Items.ScrollView:hideAllBar()
  40. self.ui.Items.ScrollView:getInnerContainer():setAutoSize(true)
  41. self.ui.Items.Layout_content:setVisible(false)
  42. for k,v in ipairs(self.notice) do
  43. if k == 1 then
  44. self.ui.Items.Text:setText(v)
  45. else
  46. local content = self.ui.Items.Layout_content:getCopied()
  47. content.Items = getUIItems(content)
  48. content.Items.Text_1:setText(v)
  49. self.ui.Items.ScrollView:addChild(content)
  50. content:requestDoLayout()
  51. content:doLayout()
  52. end
  53. end
  54. self.ui.Items.ScrollView:requestDoLayout()
  55. self.ui.Items.ScrollView:doLayout()
  56. self.ui.Items.ScrollView:jumpToTopOnSizeChanged()
  57. self.ui.Items.Button_Confirm:registerClick(handler(self, self.onBtnConfirmClicked));
  58. end
  59. ---
  60. -- 初始化自定义事件
  61. --
  62. function NoticeAiDaoRiView:initEvents()
  63. end
  64. function NoticeAiDaoRiView:onBtnConfirmClicked()
  65. self:removeFromParent();
  66. end
  67. function NoticeAiDaoRiView:onExit()
  68. NoticeAiDaoRiView.super.onExit(self);
  69. if self.endCallback and type(self.endCallback) == "function" then
  70. self.endCallback()
  71. end
  72. end
  73. return NoticeAiDaoRiView;