|
|
- -- <*
- -- @Author: huangcong
- -- @Description: 社团感谢列表红包item
- -- *>
- GuildSupportInfoMainThankItem = GuildSupportInfoMainThankItem or BaseClass(BaseItem)
- GuildSupportInfoMainThankItem.Width = 208
- GuildSupportInfoMainThankItem.Height = 266
- local GuildSupportInfoMainThankItem = GuildSupportInfoMainThankItem
- function GuildSupportInfoMainThankItem:__init(parent_wnd,prefab_asset,layer_name)
- self.base_file = "guild"
- self.layout_file = "GuildSupportInfoMainThankItem"
- self.parent_wnd = parent_wnd
- self.layer_name = layer_name
- self.model = GuildModel:getInstance()
- self.item_list = {}
- self:Load()
- end
-
- function GuildSupportInfoMainThankItem:Load_callback()
- self.nodes = {
- "get_btn:imgex", "desc:tmp", "bg:img","descImg:img", "nameText:tmp",
- "nameScroll", "nameScroll/Viewport/nameCon", "touch:obj",
- }
- self:GetChildren(self.nodes)
-
- self.desc_tmp.text = "协助者"
-
- if not self.transform.gameObject.activeSelf then
- self.transform.gameObject:SetActive(true)
- end
- self:AddEvents()
- if self.need_refreshData then
- self:UpdateView()
- end
- end
-
- function GuildSupportInfoMainThankItem:AddEvents( )
- local function click_event(target)
- if target == self.touch_obj then
- if self.data then
- if self.data.is_send == 0 then --可以发
- if self.data.type == GuildModel.SupportThankType.Normal then
- self.model:Fire(GuildModel.OPEN_GUILD_SUPPORT_THANK_VIEW, GuildModel.SupportType.Thank, self.data)
- elseif self.data.type == GuildModel.SupportThankType.SpellList then
- self.model:Fire(GuildModel.OPEN_GUILD_SL_THANK_VIEW, true, self.data)
- end
- else
- Message.show("已经感谢过了哦!","fault")
- end
- end
- end
- end
- AddClickEvent(self.touch_obj, click_event)
- end
-
- function GuildSupportInfoMainThankItem:UpdateView( )
- if self.data then
- -- 根据红包领取情况加载按钮状态
- self.get_btn_imgex.gray = false
- local icon_res, btn_gray = "guild_support_send_pointfilter", false -- 按钮资源和灰化
- if self.data.is_send == 0 then -- 还没发的红包,置顶
- icon_res = "guild_support_send_pointfilter"
- btn_gray = false
- else
- icon_res = "guild_support_have_send_pointfilter"
- btn_gray = true
- end
- lua_resM:setImageSprite(self, self.get_btn_imgex, "guildSupport_asset", icon_res, true)
- SetImageGray(self.bg_img,btn_gray)
- SetImageGray(self.descImg_img,btn_gray)
- local cfg
- if self.data.type == GuildModel.SupportThankType.Normal then
- cfg = self.model:GetGuildSupportCfg(self.data.support_cfg_id)
- self.nameText_tmp.text = cfg and cfg.mod_name or ""
- elseif self.data.type == GuildModel.SupportThankType.SpellList then
- cfg = Config.Guildorder[self.data.support_cfg_id]
- self.nameText_tmp.text = cfg and Trim(cfg.name) or ""
- end
- self:UpdateItemList()
- end
- end
-
- function GuildSupportInfoMainThankItem:SetData( data )
- self.data = data
- if self.is_loaded then
- self.need_refreshData = false
- self:UpdateView()
- else
- self.need_refreshData = true
- end
- end
-
- function GuildSupportInfoMainThankItem:UpdateItemList( )
- local info = self.data.role_list
- for k,v in pairs(self.item_list) do
- v:SetVisible(false)
- end
- if not info or #info == 0 then return end
- local item
- local offer_x = 90
- local offer_y = 0
- -- 如果是社团拼单的感谢,则需要根据情况筛选掉假人数据
- if self.data.type == GuildModel.SupportThankType.SpellList then
- if #info > 1 then -- 超过1人的情况就要筛选掉假人
- info = DeepCopy(self.data.role_list)
- for k = #info, 1, -1 do
- if info[k].role_id < 10 then
- table.remove(info, k)
- end
- end
- end
- end
- for k, v in ipairs(info) do
- item = self.item_list[k]
- if not item then
- item = GuildSupportInfoMainThankNameItem.New(self.nameCon,nil,self.layer_name)
- self.item_list[k] = item
- end
- item:SetData(v, k, self.data.type)
- -- item:SetPosition(1, -GuildSupportInfoMainThankNameItem.Height*(k - 1) - 1)
- item:SetVisible(true)
- end
- -- SetSizeDeltaY(self.itemCon,GuildSupportInfoMainThankNameItem.Height*#info)
- end
-
- function GuildSupportInfoMainThankItem:__delete( )
- for k, v in ipairs(self.item_list) do
- v:DeleteMe()
- v = nil
- end
- self.item_list = {}
- end
-
|