KLCommonItemTipsPanel.lua 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. ---@class KLCommonItemTipsPanel:UIKmlLuaPanelBase
  2. ---@field view KLCommonItemTipsPanelView
  3. local KLCommonItemTipsPanel = class(UIKmlLuaPanelBase)
  4. local this =KLCommonItemTipsPanel
  5. ---创建时调用一次
  6. function this:Init()
  7. end
  8. ---创建或者刷新界面数据时调用
  9. function this:Refresh()
  10. if self.args and self.args.showTips then
  11. GUI:Text_setString(self.view.tipContent, self.args.showTips)
  12. end
  13. self.cfgId = self.args.cfgId
  14. self.needCount = self.args.needCount or 1
  15. GUI:Item_setItemId(self.view.showItem, self.cfgId)
  16. local totalCount = SL:GetBagItemCount(self.cfgId)
  17. if self.needCount > totalCount then
  18. GUI:Text_setString(self.view.countInfo, string.format('<color="#ff0000">%d</color>/%d',totalCount, self.needCount))
  19. else
  20. GUI:Text_setString(self.view.countInfo, string.format('<color="#00ff00">%d</color>/%d',totalCount, self.needCount))
  21. end
  22. end
  23. ---注册UI事件和服务器消息
  24. function this:RegistEvents()
  25. GUI:AddOnClickEvent(self.view.btn_sure,self,self.OnClickSureButton)
  26. GUI:AddOnClickEvent(self.view.btn_cancel,self,self.CloseSelf)
  27. GUI:AddOnClickEvent(self.view.closeBtn,self,self.CloseSelf)
  28. end
  29. function this:Close()
  30. end
  31. function this:CloseSelf()
  32. GUI:UIPanel_Close('dev/ui/Common/Panel/KLCommonItemTips/KLCommonItemTipsPanel')
  33. end
  34. function this:OnClickSureButton()
  35. if self.args and self.args.callback then
  36. self.args.callback(self, self.args.callbackData)
  37. end
  38. self:CloseSelf()
  39. end
  40. return this