----- --家园特权 ----- local this = {} local HomeLand = ConfigManager.GetConfig(ConfigName.HomeLand) local HomeLandLevel = ConfigManager.GetConfig(ConfigName.HomeLandLevel) local HomeLandTask = ConfigManager.GetConfig(ConfigName.HomeLandTask) --传入父脚本模块 local parent --传入特效层级 local sortingOrder=0 local data=nil function this:InitComponent(gameObject) this.spLoader = SpriteLoader.New() this.cancelBtn = Util.GetGameObject(gameObject,"BtnCancel") this.leftTime = Util.GetGameObject(gameObject,"leftTime"):GetComponent("Text") this.btn = Util.GetGameObject(gameObject,"Content/BtnDo") this.btnText = Util.GetGameObject(gameObject,"Content/BtnDo/Text"):GetComponent("Text") end function this:BindEvent() Util.AddClick(this.cancelBtn,function() parent:ClosePanel() end) Util.AddClick(this.btn,function() PayManager.Pay(1120, function() HomeLandManager.CheckPrivilege(function () HomeLandManager.CheckPrivilege() this:Refresh() end) end) end) end function this:AddListener() end function this:RemoveListener() end function this:OnShow(_parent,_args) data = _args parent=_parent sortingOrder =_parent.sortingOrder parent.contents:GetComponent("Image").enabled = false this:Refresh() end function this:Refresh() this.leftTime.text = "(有效时间30天)" this.btnText = "激活特权" Util.SetGray(this.btn,false) this.btn:GetComponent("Button").enabled = true local data = PrivilegeManager.GetSerData(4022) if data and data.endTime > GetTimeStamp() then this.leftTime.text = "(有效时间30天)" this.btnText = "已激活" Util.SetGray(this.btn,true) this.btn:GetComponent("Button").enabled = false if this.timer then this.timer:Stop() this.timer = nil end local leftTime = data.endTime - GetTimeStamp() this.leftTime.text = string.format("(剩余时间%s)",TimeToFelaxible(leftTime)) this.timer = Timer.New(function () leftTime = leftTime - 1 this.leftTime.text = string.format("(剩余时间%s)",TimeToFelaxible(leftTime)) end,1,-1) this.timer:Start() end end function this:OnClose() if this.timer then this.timer:Stop() this.timer = nil end data=nil if parent then parent.contents:GetComponent("Image").enabled = true end end function this:OnDestroy() this.spLoader:Destroy() end return this