源战役客户端
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.

90 lines
2.4 KiB

  1. SocialityGiftRecordReceiveView = SocialityGiftRecordReceiveView or BaseClass(BaseItem)
  2. local SocialityGiftRecordReceiveView = SocialityGiftRecordReceiveView
  3. function SocialityGiftRecordReceiveView:__init()
  4. self.base_file = "sociality"
  5. self.layout_file = "SocialityGiftRecordReceiveView"
  6. self.model = SocialityModel:getInstance()
  7. self:Load()
  8. end
  9. function SocialityGiftRecordReceiveView:Load_callback()
  10. self.nodes = {
  11. "ScrollView", "ScrollView/Viewport/Content",
  12. "empty:obj", "empty/girl:raw",
  13. "empty/image:raw",
  14. }
  15. self:GetChildren(self.nodes)
  16. -- self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 22302)
  17. lua_resM:setOutsideRawImage(self, self.girl_raw, GameResPath.GetRoleBg("team_empty_bg_267_589"), false)
  18. lua_resM:setOutsideRawImage(self, self.image_raw, GameResPath.GetViewBigBg("com_empty_bg1"))
  19. self:AddEvents()
  20. if self.need_refreshData then
  21. -- self:UpdateView()
  22. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 22302)
  23. end
  24. end
  25. function SocialityGiftRecordReceiveView:AddEvents( )
  26. local function update_recive_view()
  27. if self.call_back then
  28. self.call_back()
  29. end
  30. self:UpdateView()
  31. end
  32. self:BindEvent(self.model,SocialityModel.UPDATE_RECEIVE_VIEW,update_recive_view)
  33. end
  34. function SocialityGiftRecordReceiveView:UpdateView( )
  35. local info = self.model:GetReceiveInfo(2)
  36. if not info then
  37. self.empty_obj:SetActive(true)
  38. return
  39. end
  40. local arg = {"time",}
  41. local condition = {Array.UPPER}
  42. SortTools.MoreKeysSorter(info, arg, condition)
  43. table.sort( info, function ( a,b )
  44. return a.time > b.time
  45. end )
  46. if not self.item_list_com then
  47. self.item_list_com = self:AddUIComponent(UI.ItemListCreator)
  48. end
  49. local info = {
  50. data_list = info,
  51. item_con = self.Content,
  52. item_class = SocialityReceiveItem,
  53. item_width = 915,
  54. item_height = 106,
  55. space_y = 3,
  56. scroll_view = self.ScrollView,
  57. create_frequency = 0.02,
  58. reuse_item_num = 7,
  59. on_update_item = function(item, i, v)
  60. item:SetData(v)
  61. end,
  62. }
  63. self.item_list_com:UpdateItems(info)
  64. end
  65. function SocialityGiftRecordReceiveView:SetData(call_back)
  66. self.call_back = call_back
  67. if self.is_loaded then
  68. self.need_refreshData = false
  69. -- self:UpdateView()
  70. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 22302)
  71. else
  72. self.need_refreshData = true
  73. end
  74. end
  75. function SocialityGiftRecordReceiveView:__delete( )
  76. end