150 lines
5.0 KiB
Lua
150 lines
5.0 KiB
Lua
----- 东海寻仙-限时豪礼 -----
|
|
local this = {}
|
|
local sortingOrder
|
|
-- local activeData
|
|
local configData
|
|
local itemList = {}
|
|
local ids
|
|
|
|
--按钮图片
|
|
local StateImageName = {
|
|
"s_slbz_1anniuongse", "s_slbz_1anniuhuangse"
|
|
}
|
|
|
|
function this:InitComponent(gameObject)
|
|
this.spLoader = SpriteLoader.New()
|
|
this.gameObject = gameObject
|
|
this.panel = Util.GetGameObject(gameObject, "Panel")
|
|
this.rewardPre = Util.GetGameObject(this.panel, "RewardPre")
|
|
this.scrollRoot = Util.GetGameObject(this.panel, "ScrollRoot")
|
|
this.timeText = Util.GetGameObject(this.panel, "TimeText"):GetComponent("Text")
|
|
this.timer = Timer.New()
|
|
|
|
this.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.scrollRoot.transform,
|
|
this.rewardPre, nil, Vector2.New(this.scrollRoot.transform.rect.width, this.scrollRoot.transform.rect.height),
|
|
1, 1, Vector2.New(0, 4))
|
|
this.scrollView.moveTween.MomentumAmount = 1
|
|
this.scrollView.moveTween.Strength = 2
|
|
end
|
|
|
|
function this:BindEvent()
|
|
|
|
end
|
|
|
|
function this:AddListener()
|
|
end
|
|
|
|
function this:RemoveListener()
|
|
end
|
|
|
|
function this:OnShow(_sortingOrder)
|
|
sortingOrder = _sortingOrder
|
|
ids = FindFairyManager.GetGiftActiveBtnState(DirectBuyType.XSHL)
|
|
this.OnShowPanelData()
|
|
end
|
|
|
|
function this:OnClose()
|
|
if this.timer then
|
|
this.timer:Stop()
|
|
this.timer = nil
|
|
end
|
|
end
|
|
|
|
function this:OnDestroy()
|
|
this.spLoader:Destroy()
|
|
this.scrollView = nil
|
|
end
|
|
|
|
--显示面板
|
|
function this.OnShowPanelData()
|
|
local activeData = FindFairyManager.GetGiftBtnState()
|
|
this.RemainTimeDown(this.timeText, activeData[1].server.endTime - GetTimeStamp())
|
|
if #activeData == 0 then return end
|
|
|
|
this.scrollView:SetData(activeData, function(index, root)
|
|
this.SetShow(root, activeData[index])
|
|
end)
|
|
this.scrollView:SetIndex(1)
|
|
end
|
|
|
|
--显示每条数据
|
|
function this.SetShow(root, data)
|
|
local title = Util.GetGameObject(root, "Title"):GetComponent("Text")
|
|
local content = Util.GetGameObject(root, "Content")
|
|
local stateBtn = Util.GetGameObject(root, "StateBtn")
|
|
local stateBtnImage = Util.GetGameObject(root, "StateBtn"):GetComponent("Image")
|
|
local stateBtnText = Util.GetGameObject(root, "StateBtn/Text"):GetComponent("Text")
|
|
local progress = Util.GetGameObject(root, "Progress"):GetComponent("Text")
|
|
|
|
title.text = GetLanguageStrById(data.native.Name)
|
|
ResetItemView(root, content.transform, itemList, 4, 0.9, sortingOrder, false, data.native.RewardShow)
|
|
|
|
stateBtn:GetComponent("Button").interactable = data.server.buyTimes < data.native.Limit
|
|
if data.server.buyTimes < data.native.Limit then --未购买
|
|
stateBtnImage.sprite = this.spLoader:LoadSprite(StateImageName[1])
|
|
stateBtnText.text = string.format(MoneyUtil.GetMoneyUnitName(), MoneyUtil.GetMoney(data.native.Price)) --..MoneyUtil.GetMoneyUnitName()
|
|
else
|
|
Util.SetGray(stateBtn, true)
|
|
stateBtnText.text = Language[10828]
|
|
end
|
|
Util.AddOnceClick(stateBtn, function()
|
|
--直购商品
|
|
PayManager.Pay(data.native.Id, function(id)
|
|
this.RechargeSuccessFunc(id)
|
|
end)
|
|
end)
|
|
|
|
if data.native.Limit - data.server.buyTimes == 0 then
|
|
progress.text = Language[10829]
|
|
else
|
|
progress.text = Language[10566] .. (data.native.Limit - data.server.buyTimes)
|
|
end
|
|
end
|
|
|
|
--刷新倒计时显示
|
|
function this.RemainTimeDown(_timeTextExpert, timeDown)
|
|
if timeDown > 0 then
|
|
_timeTextExpert.enabled = true
|
|
_timeTextExpert.text = Language[10026] .. this.TimeStampToDateString(timeDown)
|
|
if this.timer then
|
|
this.timer:Stop()
|
|
this.timer = nil
|
|
end
|
|
this.timer = Timer.New(function()
|
|
_timeTextExpert.text = Language[10026] .. this.TimeStampToDateString(timeDown)
|
|
if timeDown < 0 then
|
|
_timeTextExpert.enabled = false
|
|
this.timer:Stop()
|
|
this.timer = nil
|
|
configData = ConfigManager.GetConfigData(ConfigName.RechargeCommodityConfig, ids[1])
|
|
if configData.DailyUpdate ~= 1 then
|
|
PopupTipPanel.ShowTip(Language[10027])
|
|
require("Modules/FindFairy/FindFairyPanel"):OnShow()
|
|
else
|
|
this:OnShow(sortingOrder)
|
|
end
|
|
end
|
|
timeDown = timeDown - 1
|
|
end, 1, -1, true)
|
|
this.timer:Start()
|
|
else
|
|
_timeTextExpert.enabled = false
|
|
end
|
|
end
|
|
|
|
function this.TimeStampToDateString(second)
|
|
local day = math.floor(second / (24 * 3600))
|
|
local minute = math.floor(second / 60) % 60
|
|
local sec = second % 60
|
|
local hour = math.floor(math.floor(second - day * 24 * 3600 - sec - minute * 60) / 3600)
|
|
return string.format(Language[10702], day, hour, minute, sec)
|
|
end
|
|
|
|
function this.RechargeSuccessFunc(id)
|
|
FirstRechargeManager.RefreshAccumRechargeValue(id)
|
|
OperatingManager.RefreshGiftGoodsBuyTimes(GoodsTypeDef.DirectPurchaseGift, id)
|
|
this.OnShowPanelData()
|
|
end
|
|
|
|
return this
|