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

118 line
3.5 KiB

  1. ChildNiceRecordView = ChildNiceRecordView or BaseClass(BaseView)
  2. local ChildNiceRecordView = ChildNiceRecordView
  3. function ChildNiceRecordView:__init()
  4. self.base_file = "child"
  5. self.layout_file = "ChildNiceRecordView"
  6. self.layer_name = "UI"
  7. --self.destroy_imm = true
  8. self.use_background = true
  9. self.change_scene_close = true --是否切换场景时关闭(弹出界面使用)
  10. --self.append_to_ctl_queue = true --是否要添加进界面堆栈
  11. self.hide_maincancas = true --全屏界面需要放开隐藏主UI
  12. self.blur_activity_bg = true
  13. self.model = ChildModel:GetInstance()
  14. self.task_record_list = {}
  15. self.load_callback = function ()
  16. self:LoadSuccess()
  17. self:AddEvent()
  18. end
  19. self.open_callback = function ( )
  20. self:OpenSuccess()
  21. end
  22. self.destroy_callback = function ( )
  23. self:DestroySuccess()
  24. end
  25. end
  26. function ChildNiceRecordView:Open(data,callBack)
  27. self.data = data
  28. self.callBack = callBack
  29. BaseView.Open(self)
  30. end
  31. function ChildNiceRecordView:LoadSuccess()
  32. local nodes = {
  33. "none/empty/girl:raw", "none/empty/talkBg:raw",
  34. "none/empty/btn_go_main:obj",
  35. }
  36. self:GetChildren(nodes)
  37. self.Content = self:GetChild("ScrollView/Viewport/Content")
  38. self.Window_img = self:GetChild("Window"):GetComponent("Image")
  39. self.none_obj = self:GetChild("none").gameObject
  40. -- lua_resM:setOutsideImageSprite(self, self.Window_img, GameResPath.GetViewBigBg("child_nice_record_bg"), false)
  41. local closeWin_callback = function()
  42. self:Close()
  43. end
  44. self.tabWindowComponent = UITabWindow.New(self.transform, {}, select_callback, closeWin_callback,self.background_wnd, nil, UITabWindow.SizeSmallNoTab, false,nil,true)
  45. self.tabWindowComponent:SetBackgroundRes("chat_dress_bg2")
  46. self.tabWindowComponent:SetTitleText("点赞记录")
  47. lua_resM:setOutsideRawImage(self, self.girl_raw, GameResPath.GetRoleBg("team_empty_bg_267_589"))
  48. lua_resM:setOutsideRawImage(self, self.talkBg_raw, GameResPath.GetViewBigBg("com_empty_bg1"))
  49. end
  50. function ChildNiceRecordView:AddEvent()
  51. self.model:Fire(ChildConst.CHILD_REQ_EVENT, 16508) -- 宝宝点赞记录
  52. local function updata_child_record_info_fun(vo)
  53. self:UpdateView(vo)
  54. end
  55. self.updata_child_record_info = self.model:Bind(ChildConst.UPDATA_CHILD_NICE_RECORD_INFO, updata_child_record_info_fun) --
  56. local function clickHandler(target)
  57. if target == self.btn_go_main_obj then
  58. self:Close()
  59. self.model:Fire(ChildConst.OPEN_CHILD_TRAIN_VIEW)
  60. self.model:Fire(ChildConst.PLAY_SHOW_BABY_EFFECT)
  61. end
  62. end
  63. AddClickEvent(self.btn_go_main_obj, clickHandler, 1)
  64. end
  65. function ChildNiceRecordView:OpenSuccess()
  66. --self:UpdateView()
  67. end
  68. function ChildNiceRecordView:UpdateView(vo)
  69. if vo and TableSize(vo) > 0 then
  70. self.none_obj:SetActive(false)
  71. for k,v in pairs(vo) do
  72. local item = self.task_record_list[k]
  73. if item == nil then
  74. item = ChildNiceRecordItem.New(self.Content)
  75. self.task_record_list[k] = item
  76. end
  77. self.task_record_list[k]:SetData(v,k)
  78. --ChildMainTaskItem
  79. end
  80. else
  81. self.none_obj:SetActive(true)
  82. end
  83. end
  84. function ChildNiceRecordView:DestroySuccess( )
  85. if self.tabWindowComponent then
  86. self.tabWindowComponent:DeleteMe()
  87. self.tabWindowComponent = nil
  88. end
  89. if self.updata_child_record_info then
  90. self.model:UnBind(self.updata_child_record_info)
  91. self.updata_child_record_info = nil
  92. end
  93. for i, v in ipairs(self.task_record_list) do
  94. v:DeleteMe()
  95. v = nil
  96. end
  97. self.task_record_list = {}
  98. end
  99. function ChildNiceRecordView:SetCallBack(callBack)
  100. self.callBack = callBack
  101. end