local UIUseItemPop = require('View/Common/UIUseItemPop') local UIGuildAlliesUseItemPop = UIViewClass(UIUseItemPop) local MAX_LIMIT_USE_COUNT = DataSheetManager.ConstData:GetDataByID("GuildAlliesBatchUseItemMax").IntValue local MIN_LIMIT_USE_COUNT = 1 function UIGuildAlliesUseItemPop:OnOpened(context) self:Init(context) end -- OVERRIDE function UIGuildAlliesUseItemPop:Init(context) self.requestFunc = context.requestFunc -- 使用回调方法 self.strategyCfg = context.strategyCfg -- 当前使用策略数据 UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, self.titleIDS) UIUtils.SetLabelText(self.txt_Tip, self.tipIDS) UIUtils.SetLabelText(self.lab_Buy, self.btnIDS) -- 最大使用数 self.maxCount = CTL.GuildAllies.GetAlliesMaxCount(context.strategyCfg) if self.maxCount > MAX_LIMIT_USE_COUNT then self.maxCount = MAX_LIMIT_USE_COUNT end self.useCount = MIN_LIMIT_USE_COUNT self:RefreshConsume(self.strategyCfg) end -- OVERRIDE function UIGuildAlliesUseItemPop:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() elseif comp == self.btn_Count then --输入数量弹窗 if not self.keyBoardView then self.keyBoardView = self.subView:OpenView( GetViewClass(Const_UI_Lua.UIEnum.UIKeypad), { parentView = self, x = 731, y = 110, minNum = 1, maxNum = self.maxCount } ) end elseif comp == self.btn_Minus then --减少 if self.useCount > MIN_LIMIT_USE_COUNT then self.useCount = self.useCount - 1 end self:RefreshConsume(self.strategyCfg) UIUtils.SetLabel(self.txt_Count, self.useCount) elseif comp == self.btn_Plus then --增加 if self.useCount < self.maxCount then self.useCount = self.useCount + 1 end self:RefreshConsume(self.strategyCfg) UIUtils.SetLabel(self.txt_Count, self.useCount) elseif comp == self.btn_Max then --最大数量 self.useCount = self.maxCount self:RefreshConsume(self.strategyCfg) elseif comp == self.btn_Buy then --消耗 self.requestFunc(self.useCount, table.unpack(self.context.requestParams)) self:CloseView() end end -- OVERRIDE function UIGuildAlliesUseItemPop:OnClosed() UIUtils.SetActive(self.group_GuildAlliesCost.gameObject, false) end -- OVERRIDE function UIGuildAlliesUseItemPop:ExcuteKeyBoardBack(count, paramData) self:keyPadCallback(count) self:RefreshConsume(self.strategyCfg) end function UIGuildAlliesUseItemPop:RefreshConsume(strategyCfg) UIUtils.SetActive(self.group_GuildAlliesCost.gameObject, false) if strategyCfg.Cost_Table[1] and strategyCfg.Cost_Table[2] then UIUtils.SetActive(self.group_GuildAlliesCost.gameObject, true) UIUtils.SetLabel(self.txt_Current, string.FormatByIdsId(Const_IDS.IDS_GuildDonate_ItemNum, MDL.Bag.GetItemCount(strategyCfg.Cost_Table[1].CostItemID))) -- 货币 UTL.Item.MoneyIcon(self.img_Icon, strategyCfg.Cost_Table[2].CostItemID) UIUtils.SetLabel(self.txt_Num, self.useCount * strategyCfg.Cost_Table[2].CostItemNum) elseif strategyCfg.Cost_Table[1] then UIUtils.SetLabel(self.txt_Current, string.FormatByIdsId(Const_IDS.IDS_GuildDonate_ItemNum, MDL.Bag.GetItemCount(strategyCfg.Cost_Table[1].CostItemID))) end UIUtils.SetLabel(self.txt_Count, self.useCount) end return UIGuildAlliesUseItemPop