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

86 lines
2.5 KiB

  1. --不够天数查看奖励界面
  2. GiftShowAllView = GiftShowAllView or BaseClass(BaseView)
  3. function GiftShowAllView:__init()
  4. self.base_file = "gift"
  5. self.layout_file = "GiftShowAllView"
  6. self.layer_name = "Activity"
  7. self.destroy_imm = true
  8. self.use_background = true
  9. self.is_set_zdepth = true
  10. self.close_mode = CloseMode.CloseDestroy
  11. self.model = GiftModel:getInstance()
  12. self.reward_item_list = {}
  13. self.load_callback = function ()
  14. self:LoadSuccess()
  15. self:addEvents()
  16. end
  17. self.open_callback = function ()
  18. self:setData()
  19. end
  20. self.close_callback = function ()
  21. end
  22. self.destroy_callback = function ()
  23. self:DestroySuccess()
  24. end
  25. end
  26. function GiftShowAllView:Open(type_id, need_day)
  27. self.type_id = tonumber(type_id)
  28. self.need_day = tonumber(need_day)
  29. BaseView.Open(self)
  30. end
  31. function GiftShowAllView:DestroySuccess()
  32. for _, item in pairs(self.reward_item_list) do
  33. item:ReleaseObj()
  34. end
  35. self.reward_item_list = {}
  36. end
  37. function GiftShowAllView:LoadSuccess()
  38. self.close_btn = self:GetChild("close_btn").gameObject
  39. self.name_text = self:GetChild("name_text"):GetComponent("Text")
  40. self.tips_text = self:GetChild("tips_text"):GetComponent("Text")
  41. self.sure_btn = self:GetChild("sure_btn").gameObject
  42. self.scroll_view = self:GetChild("scroll_view/Viewport/Content")
  43. end
  44. function GiftShowAllView:addEvents()
  45. local function click_func(target)
  46. if target == self.close_btn then
  47. self:Close()
  48. elseif target == self.sure_btn then
  49. self:Close()
  50. end
  51. end
  52. AddClickEvent(self.close_btn, click_func)
  53. AddClickEvent(self.sure_btn, click_func)
  54. end
  55. function GiftShowAllView:setData()
  56. local goods_base = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.type_id)
  57. local str_color = WordManager.GetGoodsColor(goods_base.color)
  58. self.name_text.text = Language.substitute("<color={0}>{1}</color>", str_color, Trim(goods_base.goods_name))
  59. local tips_str = "再登录<color='#31ee4a'>" .. self.need_day .. "</color>天即可领取下列奖励"
  60. self.tips_text.text = tips_str
  61. local config = self.model:getRewardConfig(self.type_id)
  62. if config then
  63. for i,v in ipairs(config.fixed_list) do
  64. local item = self.reward_item_list[i]
  65. if not item then
  66. item = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, self.scroll_view, nil, self.layer_name)
  67. item:SetItemSize(80, 80)
  68. self.reward_item_list[i] = item
  69. end
  70. local type_id = GoodsModel:getInstance():GetMappingTypeId(v.goods_type, v.goods_id)
  71. item:SetData(type_id, v.goods_count)
  72. item:SetVisible(true)
  73. end
  74. end
  75. end