ChildHandbookItem = ChildHandbookItem or BaseClass(BaseItem) function ChildHandbookItem:__init() self.base_file = "child" self.layout_file = "ChildHandbookItem" self.is_delay_callback = true -- self.use_local_view = true self.model = ChildModel:GetInstance() self:Load() end function ChildHandbookItem:Load_callback() self.nodes = { "bg/name_txt:tmp", "bg:obj:img","bg/chosen_con:obj","bg/lock_con:obj","bg/active_con:obj","bg/red_dot:obj", "bg/icon:img", "bg/fight_num:txt", } self:GetChildren(self.nodes) self:InitEvent() -- lua_resM:setOutsideImageSprite(self, self.bg_img, GameResPath.GetChildIcon("child_hand_book_bg2"), false) if self.need_refreshData then self:UpdateView( ) self:SetChosen(self.isChosen) self:SetRedDot(self.isRedDot) end end function ChildHandbookItem:InitEvent() local function onBtnClickHandler(target, x, y) if target == self.bg_obj then --self.callback(self) if self.type == ChildConst.ChildHandbookItemType.CanActive then self.model:Fire(ChildConst.CHILD_REQ_EVENT, 16536,self.data.suit_type,self.data.toy_id) -- 激活 else UIToolTipMgr:getInstance():AppendGoodsTips(self.data.toy_id,nil, nil,nil,nil,nil,false,false) end end end AddClickEvent(self.bg_obj, onBtnClickHandler) end function ChildHandbookItem:SetData(data, check_effect) self.data = data or self.data self.last_type = self.type self.type = nil self.check_effect = check_effect local num = GoodsModel:getInstance():GetTypeGoodsNum(data.toy_id) if not data.isActive and num > 0 then --可激活 self.type = ChildConst.ChildHandbookItemType.CanActive elseif not data.isActive and num <= 0 then ---不可激活,锁 self.type = ChildConst.ChildHandbookItemType.Lock else self.type = ChildConst.ChildHandbookItemType.IsActive -- 已经激活 end if self.is_loaded then self:UpdateView( ) else self.need_refreshData = true end end function ChildHandbookItem:UpdateView( ) self.fight_num_txt.text = "f"..GetFighting(stringtotable(self.data.attr_list)) lua_resM:setOutsideImageSprite(self, self.icon_img, GameResPath.GetChildHandbookIcon(self.data.toy_id), true) local data = self.data if self.check_effect then self.check_effect = false if (not self.is_in_effect) and self.last_type ~= ChildConst.ChildHandbookItemType.IsActive and self.type == ChildConst.ChildHandbookItemType.IsActive then -- 可激活到激活 self.is_in_effect = true local function call_back( ) self.is_in_effect = false end self:ClearUIEffect(self.icon) self:AddUIEffect("ui_hunliqiudianliang", self.icon, "Activity", Vector3(0, 60 ,0), 4, false, 0.6, nil, call_back) end end self.chosen_con_obj:SetActive(false) self.lock_con_obj:SetActive(false) self.active_con_obj:SetActive(false) self.icon_img.color = Color(1,1,1) self.icon_img.gray = false -- self.fight_bg_img.gray = false -- local num = GoodsModel:getInstance():GetTypeGoodsNum(data.fashion_id) ---激活 if self.type == ChildConst.ChildHandbookItemType.CanActive then --可激活 self.active_con_obj:SetActive(true) self.icon_img.color = Color(114/255,111/255,111/255) elseif self.type == ChildConst.ChildHandbookItemType.Lock then --不可激活,锁 self.lock_con_obj:SetActive(true) self.icon_img.gray = true -- self.fight_bg_img.gray = true else end self.name_txt_tmp.text = data.toy_name or "" end function ChildHandbookItem:SetChosen(bool) self.isChosen = bool if self.is_loaded then if bool then self.chosen_con_obj:SetActive(true) else self.chosen_con_obj:SetActive(false) end else self.need_refreshData = true end end function ChildHandbookItem:SetRedDot(bool) self.isRedDot = bool if self.is_loaded then --print("============>>> YiRan:ChildHandbookItem [start:83] vehicle_id :",vehicle_id,"self.isRedDot:",self.isRedDot) self.red_dot_obj:SetActive(self.isRedDot) else self.need_refreshData = true end end