源战役客户端
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

133 строки
4.7 KiB

1 месяц назад
  1. -- <*
  2. -- @Author: huangcong
  3. -- @Description: 社团感谢列表红包item
  4. -- *>
  5. GuildSupportInfoMainThankItem = GuildSupportInfoMainThankItem or BaseClass(BaseItem)
  6. GuildSupportInfoMainThankItem.Width = 208
  7. GuildSupportInfoMainThankItem.Height = 266
  8. local GuildSupportInfoMainThankItem = GuildSupportInfoMainThankItem
  9. function GuildSupportInfoMainThankItem:__init(parent_wnd,prefab_asset,layer_name)
  10. self.base_file = "guild"
  11. self.layout_file = "GuildSupportInfoMainThankItem"
  12. self.parent_wnd = parent_wnd
  13. self.layer_name = layer_name
  14. self.model = GuildModel:getInstance()
  15. self.item_list = {}
  16. self:Load()
  17. end
  18. function GuildSupportInfoMainThankItem:Load_callback()
  19. self.nodes = {
  20. "get_btn:imgex", "desc:tmp", "bg:img","descImg:img", "nameText:tmp",
  21. "nameScroll", "nameScroll/Viewport/nameCon", "touch:obj",
  22. }
  23. self:GetChildren(self.nodes)
  24. self.desc_tmp.text = "协助者"
  25. if not self.transform.gameObject.activeSelf then
  26. self.transform.gameObject:SetActive(true)
  27. end
  28. self:AddEvents()
  29. if self.need_refreshData then
  30. self:UpdateView()
  31. end
  32. end
  33. function GuildSupportInfoMainThankItem:AddEvents( )
  34. local function click_event(target)
  35. if target == self.touch_obj then
  36. if self.data then
  37. if self.data.is_send == 0 then --可以发
  38. if self.data.type == GuildModel.SupportThankType.Normal then
  39. self.model:Fire(GuildModel.OPEN_GUILD_SUPPORT_THANK_VIEW, GuildModel.SupportType.Thank, self.data)
  40. elseif self.data.type == GuildModel.SupportThankType.SpellList then
  41. self.model:Fire(GuildModel.OPEN_GUILD_SL_THANK_VIEW, true, self.data)
  42. end
  43. else
  44. Message.show("已经感谢过了哦!","fault")
  45. end
  46. end
  47. end
  48. end
  49. AddClickEvent(self.touch_obj, click_event)
  50. end
  51. function GuildSupportInfoMainThankItem:UpdateView( )
  52. if self.data then
  53. -- 根据红包领取情况加载按钮状态
  54. self.get_btn_imgex.gray = false
  55. local icon_res, btn_gray = "guild_support_send_pointfilter", false -- 按钮资源和灰化
  56. if self.data.is_send == 0 then -- 还没发的红包,置顶
  57. icon_res = "guild_support_send_pointfilter"
  58. btn_gray = false
  59. else
  60. icon_res = "guild_support_have_send_pointfilter"
  61. btn_gray = true
  62. end
  63. lua_resM:setImageSprite(self, self.get_btn_imgex, "guildSupport_asset", icon_res, true)
  64. SetImageGray(self.bg_img,btn_gray)
  65. SetImageGray(self.descImg_img,btn_gray)
  66. local cfg
  67. if self.data.type == GuildModel.SupportThankType.Normal then
  68. cfg = self.model:GetGuildSupportCfg(self.data.support_cfg_id)
  69. self.nameText_tmp.text = cfg and cfg.mod_name or ""
  70. elseif self.data.type == GuildModel.SupportThankType.SpellList then
  71. cfg = Config.Guildorder[self.data.support_cfg_id]
  72. self.nameText_tmp.text = cfg and Trim(cfg.name) or ""
  73. end
  74. self:UpdateItemList()
  75. end
  76. end
  77. function GuildSupportInfoMainThankItem:SetData( data )
  78. self.data = data
  79. if self.is_loaded then
  80. self.need_refreshData = false
  81. self:UpdateView()
  82. else
  83. self.need_refreshData = true
  84. end
  85. end
  86. function GuildSupportInfoMainThankItem:UpdateItemList( )
  87. local info = self.data.role_list
  88. for k,v in pairs(self.item_list) do
  89. v:SetVisible(false)
  90. end
  91. if not info or #info == 0 then return end
  92. local item
  93. local offer_x = 90
  94. local offer_y = 0
  95. -- 如果是社团拼单的感谢,则需要根据情况筛选掉假人数据
  96. if self.data.type == GuildModel.SupportThankType.SpellList then
  97. if #info > 1 then -- 超过1人的情况就要筛选掉假人
  98. info = DeepCopy(self.data.role_list)
  99. for k = #info, 1, -1 do
  100. if info[k].role_id < 10 then
  101. table.remove(info, k)
  102. end
  103. end
  104. end
  105. end
  106. for k, v in ipairs(info) do
  107. item = self.item_list[k]
  108. if not item then
  109. item = GuildSupportInfoMainThankNameItem.New(self.nameCon,nil,self.layer_name)
  110. self.item_list[k] = item
  111. end
  112. item:SetData(v, k, self.data.type)
  113. -- item:SetPosition(1, -GuildSupportInfoMainThankNameItem.Height*(k - 1) - 1)
  114. item:SetVisible(true)
  115. end
  116. -- SetSizeDeltaY(self.itemCon,GuildSupportInfoMainThankNameItem.Height*#info)
  117. end
  118. function GuildSupportInfoMainThankItem:__delete( )
  119. for k, v in ipairs(self.item_list) do
  120. v:DeleteMe()
  121. v = nil
  122. end
  123. self.item_list = {}
  124. end