KLShopMainPanel.lua 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. ---@class KLShopMainPanel:UIKmlLuaPanelBase
  2. ---@field view KLShopMainPanelView
  3. local KLShopMainPanel = class(UIKmlLuaPanelBase)
  4. local this =KLShopMainPanel
  5. function this:AsyncLoadUI()
  6. end
  7. ---创建时调用一次
  8. function this:Init()
  9. --print ("123")
  10. end
  11. ---注册UI事件和服务器消息
  12. function this:RegistEvents()
  13. GUI:SetToggleOnValueChange(self.view.tog_shop, self, self.ShopToggle)
  14. GUI:SetToggleOnValueChange(self.view.tog_recharge, self, self.RechargeToggle)
  15. GUI:AddOnClickEvent(self.view.btn_close, self, self.CloseBtnOnClick)
  16. end
  17. function this:ShopToggle(control,_)
  18. if GUI:Toggle_getIsOn(control) == "1" then
  19. GUI:UIPanel_Open("dev/ui/ShopMall/Panel/KLShopMall/KLShopMallPanel",_,_,self.Page)
  20. GUI:UIPanel_Close("dev/outui/ShopMain/Panel/KLRecharge/KLRechargePanel")
  21. end
  22. end
  23. function this:RechargeToggle(control,_)
  24. if GUI:Toggle_getIsOn(control) == "1" then
  25. self.Page = nil
  26. GUI:UIPanel_Close("dev/ui/ShopMall/Panel/KLShopMall/KLShopMallPanel")
  27. GUI:UIPanel_Open("dev/outui/ShopMain/Panel/KLRecharge/KLRechargePanel")
  28. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_RECHARGE_ACTION, {type=1, action="panel"})
  29. SL:HideMainPanel()
  30. end
  31. end
  32. function this:CloseBtnOnClick()
  33. SL:ShowMainPanel()
  34. self:CloseAllSubPanel()
  35. end
  36. ---界面显示时调用一次
  37. function this:Show()
  38. end
  39. ---创建或者刷新界面数据时调用
  40. function this:Refresh()
  41. if self.args then
  42. local togNum = 1
  43. local type = type(self.args)
  44. if type == 'number' then--只跳转到对应页签
  45. togNum = self.args
  46. else--跳转到对应页签下的子页签(比如商城下面的某个页签)
  47. togNum = tonumber(self.args[1])
  48. self.Page = tonumber(self.args[2])
  49. end
  50. if togNum == 1 then
  51. GUI:Toggle_setIsOn(self.view.tog_shop,true)
  52. elseif togNum == 2 then
  53. GUI:Toggle_setIsOn(self.view.tog_recharge,true)
  54. GUI:UIPanel_Close("dev/ui/ShopMall/Panel/KLShopMall/KLShopMallPanel")
  55. GUI:UIPanel_Open("dev/outui/ShopMain/Panel/KLRecharge/KLRechargePanel")
  56. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_RECHARGE_ACTION, {type=1, action="panel"})
  57. SL:HideMainPanel()
  58. else
  59. GUI:Toggle_setIsOn(self.view.tog_shop,true)
  60. end
  61. else
  62. GUI:Toggle_setIsOn(self.view.tog_shop,true)
  63. end
  64. end
  65. function this:CloseAllSubPanel()
  66. GUI:UIPanel_Close("dev/outui/ShopMain/Panel/KLShopMain/KLShopMainPanel")
  67. GUI:UIPanel_Close("dev/outui/ShopMain/Panel/KLRecharge/KLRechargePanel")
  68. GUI:UIPanel_Close("dev/ui/ShopMall/Panel/KLShopMall/KLShopMallPanel")
  69. end
  70. function this:Close()
  71. SL:ShowMainPanel()
  72. self:CloseAllSubPanel()
  73. end
  74. return this