104 lines
3.5 KiB
Lua
104 lines
3.5 KiB
Lua
----- --家园特权 -----
|
||
local this = {}
|
||
local HomeLand = ConfigManager.GetConfig(ConfigName.HomeLand)
|
||
local HomeLandLevel = ConfigManager.GetConfig(ConfigName.HomeLandLevel)
|
||
local HomeLandTask = ConfigManager.GetConfig(ConfigName.HomeLandTask)
|
||
--local price = ConfigManager.GetConfigData(ConfigName.RechargeCommodityConfig,1120).Price
|
||
--传入父脚本模块
|
||
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")
|
||
this.text1 = Util.GetGameObject(gameObject,"Content/Text1"):GetComponent("Text")
|
||
this.text2 = Util.GetGameObject(gameObject,"Content/Text2"):GetComponent("Text")
|
||
this.text3 = Util.GetGameObject(gameObject,"Content/Text3"):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.text1.text = "洞府各资源建筑(玉清居、祈福斋、望月居)产量<color=#d6821a>增加50%</color>"
|
||
this.text2.text = "每日可使用<color=#d6821a>五次特权加速</color>功能,每次可减少<color=#d6821a>8小时</color>建筑升级时间"
|
||
this.text3.text = "购买后赠送<color=#d6821a>唤元神符*2</color>以及<color=#d6821a>金币*150万</color>"
|
||
this.leftTime.text = "购买后持续30天"
|
||
--this.btnText.text = string.format("%s元",price)
|
||
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.text = "已激活"
|
||
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天",TimeToD(leftTime))
|
||
if leftTime <= 86400 then
|
||
this.leftTime.text = string.format("剩余:%s",TimeToFelaxible(leftTime))
|
||
end
|
||
this.timer = Timer.New(function ()
|
||
leftTime = leftTime - 1
|
||
if leftTime <= 86400 then
|
||
this.leftTime.text = string.format("剩余:%s",TimeToFelaxible(leftTime))
|
||
else
|
||
this.leftTime.text = string.format("剩余%s天",TimeToD(leftTime))
|
||
end
|
||
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 |