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.

143 lines
3.1 KiB

  1. -- 成员列表Layout
  2. local eMail = class("eMail" , cc.UIView);
  3. local MailEvent = require("luaScript.Protocol.Mail.MailEvent")
  4. local PAGE_COUNT = 50
  5. function eMail:ctor(clubId,searchData)
  6. eMail.super.ctor(self)
  7. self.clubId = clubId
  8. --单个茶馆数据
  9. self.clubInfo = app.club_php.clubList[clubId]
  10. self.curPage = 1
  11. self.totolPage = 1
  12. self:loadUI()
  13. end
  14. function eMail:loadUI()
  15. local ui = loadUI("res/ui/ui_dating/ui_dating_mail.ui")
  16. self.ui = ui;
  17. self:addChild(ui);
  18. end
  19. function eMail:onEnter()
  20. eMail.super.onEnter(self)
  21. self:initView()
  22. self:registerButton()
  23. self:initBindEvent()
  24. local localData ={
  25. type = 1,
  26. }
  27. app.mail_php:requestMail(localData)
  28. end
  29. function eMail:onEMail(data)
  30. if not data then
  31. return
  32. end
  33. self.curPage = 1
  34. local mailList = {}
  35. mailList = app.mail_php.mails
  36. if #mailList > 0 then
  37. self.ui.Items.Text_nodata:setVisible(false)
  38. end
  39. self:updatePlayerList(mailList)
  40. end
  41. function eMail:updatePlayerList(data)
  42. local mListView = self.ui.Items.ScrollView
  43. mListView:removeAllChildren()
  44. self.mailList = data
  45. self.totolPage = math.ceil(table.nums(self.mailList)/PAGE_COUNT)
  46. local startIndex = (self.curPage-1) * PAGE_COUNT + 1
  47. local endIndex = startIndex + PAGE_COUNT - 1
  48. for i=startIndex,endIndex do
  49. local v = self.mailList[i]
  50. if v then
  51. self:createItem(v)
  52. end
  53. end
  54. self.ui.Items.ScrollView:requestDoLayout()
  55. self.ui.Items.ScrollView:doLayout()
  56. mListView:jumpToTopOnSizeChanged()
  57. --self.ui.Items.Text_Cur_page:setString(self.curPage)
  58. --self.ui.Items.Text_Total_page:setString("/"..self.totolPage)
  59. end
  60. function eMail:createItem(mailData)
  61. local matchUI = self.ui.Items.Layout_mail_item:getCopied()
  62. autoAdaptWidth(matchUI)
  63. matchUI.Items = getUIItems(matchUI)
  64. --邮件标题
  65. matchUI.Items.Text_mail_title:setText(tostring(mailData.title))
  66. --邮件时间
  67. local time = os.date("%m-%d",mailData.time)
  68. matchUI.Items.Text_mail_time:setText(tostring(time))
  69. --邮件状态
  70. matchUI.Items.Text_mail_staus:setVisible(tonumber(mailData.read_state) == 1)
  71. --查看邮件按钮
  72. matchUI.Items.Button_look:setVisible(tonumber(mailData.read_state) == 0)
  73. local function readEMail()
  74. local parm = {
  75. ids = mailData.id
  76. }
  77. app.mail_php:requestReadMail(parm)
  78. local view = import("luaScript.Views.Main.eMailAward"):new(mailData.content)
  79. view:setAnchorPoint(cc.p(0.5, 0.5))
  80. app:showWaitDialog(view)
  81. end
  82. matchUI:registerClick(function ()
  83. readEMail()
  84. end)
  85. matchUI.Items.Button_look:registerClick(function ()
  86. readEMail()
  87. end)
  88. self.ui.Items.ScrollView:addChild(matchUI)
  89. end
  90. function eMail:initBindEvent()
  91. --绑定请求成员列表成功回调事件
  92. self:bindEvent(app.mail_php , MailEvent.UPDATE_MAIL , handler(self , self.onEMail))
  93. end
  94. function eMail:registerButton()
  95. self.ui.Items.ButtonClose:registerClick(handler(self , self.onClose))
  96. end
  97. function eMail:initView()
  98. self.ui.Items.Layout_mail_item:setVisible(false)
  99. self.ui.Items.ScrollView:hideAllBar()
  100. self.ui.Items.ScrollView:getInnerContainer():setAutoSize(true)
  101. end
  102. function eMail:onClose()
  103. playBtnCloseEffect()
  104. self:removeFromParent()
  105. end
  106. return eMail