review
This commit is contained in:
parent
6eea9de2e5
commit
3dbfc8458c
@ -31,8 +31,7 @@ function FourteenDayExchangeUI:onLoadRootComplete()
|
||||
self.txNum = uiMap["fourteen_day_exchange_ui.content.item.tx_num"]
|
||||
self.btnAdd = uiMap["fourteen_day_exchange_ui.content.item"]
|
||||
|
||||
self.exchangeList = DataManager.FourteenDayData:getExchangeShowIds()
|
||||
|
||||
self.exchangeList = DataManager.FourteenDayData:getExchangeShowIdsSort()
|
||||
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_FOURTEEN_TITLE_3))
|
||||
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_FOURTEEN_DESC_9))
|
||||
|
||||
@ -40,7 +39,7 @@ function FourteenDayExchangeUI:onLoadRootComplete()
|
||||
return "app/ui/activity/fourteen_day/cell/fourteen_day_exchange_cell"
|
||||
end)
|
||||
self.scrollrectComp:addRefreshCallback(function(index, cell)
|
||||
cell:refresh(self.exchangeList[index])
|
||||
cell:refresh(self.exchangeList[index].id)
|
||||
end)
|
||||
self.scrollrectComp:clearCells()
|
||||
self.scrollrectComp:refillCells(#self.exchangeList)
|
||||
@ -59,6 +58,7 @@ end
|
||||
|
||||
function FourteenDayExchangeUI:onRefresh()
|
||||
DataManager.FourteenDayData:onShowExchangeView()
|
||||
self.exchangeList = DataManager.FourteenDayData:getExchangeShowIdsSort()
|
||||
|
||||
self.txNum:setText(DataManager.FourteenDayData:getExchangeItemNum())
|
||||
self.scrollrectComp:updateAllCell()
|
||||
|
||||
@ -34,7 +34,7 @@ function FourteenDayGiftUI:onLoadRootComplete()
|
||||
return "app/ui/activity/fourteen_day/cell/fourteen_day_gift_cell"
|
||||
end)
|
||||
self.scrollrectComp:addRefreshCallback(function(index, cell)
|
||||
cell:refresh(self.giftList[index])
|
||||
cell:refresh(self.giftList[index].id)
|
||||
end)
|
||||
|
||||
self.btnClose:addClickListener(function()
|
||||
|
||||
@ -72,8 +72,6 @@ end
|
||||
function FourteenDayTaskUI:onRefresh()
|
||||
self.taskStage = DataManager.FourteenDayData:getStageTaskId(self.curStage)
|
||||
self.taskList = DataManager.FourteenDayData:getStageSubTaskIdsSort(self.curStage)
|
||||
Logger.printTable(self.curStage)
|
||||
Logger.printTable(self.taskList)
|
||||
self.scrollrectComp:clearCells()
|
||||
self.scrollrectComp:refillCells(#self.taskList)
|
||||
|
||||
|
||||
@ -10,7 +10,6 @@ function FourteenDayData:ctor()
|
||||
end
|
||||
|
||||
function FourteenDayData:clear()
|
||||
self.data.isDirty = false
|
||||
DataManager:unregisterCrossDayFunc("FourteenDayData")
|
||||
DataManager:unregisterTryOpenFunc("FourteenDayData")
|
||||
end
|
||||
@ -22,10 +21,12 @@ end
|
||||
function FourteenDayData:init(data)
|
||||
data = data or GConst.EMPTY_TABLE
|
||||
|
||||
if EDITOR_MODE then
|
||||
Logger.logHighlight("新手14天乐数据初始化")
|
||||
Logger.printTable(data)
|
||||
end
|
||||
|
||||
self.openTs = data.open_at // 1000
|
||||
self.openTs = data.open_at and data.open_at // 1000 or 0
|
||||
self.activeDays = data.active_days or 0-- 活动开启后的登陆天数、阶段数
|
||||
self.bountyStatus = data.funds
|
||||
self.tasksStatus = data.tasks
|
||||
@ -46,10 +47,9 @@ function FourteenDayData:init(data)
|
||||
if not self:isActiveTime() then
|
||||
return
|
||||
end
|
||||
Logger.logHighlight("14天乐跨天")
|
||||
-- Logger.logHighlight("14天乐跨天")
|
||||
|
||||
self.activeDays = self.activeDays + 1
|
||||
self:getExchangeShowIds()
|
||||
self:setDirty()
|
||||
end)
|
||||
-- 注册任务进度监听
|
||||
@ -417,8 +417,8 @@ end
|
||||
-- 是否有兑换红点
|
||||
function FourteenDayData:hasExchangeRedPoint()
|
||||
local isFullUnlock = true
|
||||
for index, id in ipairs(self:getExchangeShowIds()) do
|
||||
if not self:isExchangeUnlock(id) then
|
||||
for index, data in ipairs(self:getExchangeShowIdsSort()) do
|
||||
if not self:isExchangeUnlock(data.id) then
|
||||
isFullUnlock = false
|
||||
break
|
||||
end
|
||||
@ -441,31 +441,34 @@ function FourteenDayData:getExchangeCfg()
|
||||
end
|
||||
|
||||
-- 获取显示的id列表
|
||||
function FourteenDayData:getExchangeShowIds()
|
||||
local unlock = {}
|
||||
local lock = {}
|
||||
local soldOut = {}
|
||||
for id, data in ipairs(self:getExchangeCfg()) do
|
||||
if self:getExchangeRemainTime(id) <= 0 then
|
||||
table.insert(soldOut, id)
|
||||
elseif not self:isExchangeUnlock(id) then
|
||||
table.insert(lock, id)
|
||||
else
|
||||
table.insert(unlock, id)
|
||||
end
|
||||
end
|
||||
table.sort(unlock)
|
||||
table.sort(lock)
|
||||
table.sort(soldOut)
|
||||
function FourteenDayData:getExchangeShowIdsSort()
|
||||
local result = {}
|
||||
local ids = table.keys(self:getExchangeCfg())
|
||||
for index, id in ipairs(ids) do
|
||||
local sort = id + 10000000000
|
||||
|
||||
return table.addArray(unlock, table.addArray(lock, soldOut))
|
||||
if self:isExchangeUnlock(id) then
|
||||
sort = sort - 10000000
|
||||
end
|
||||
|
||||
if self:getExchangeRemainTime(id) > 0 then
|
||||
sort = sort - 10000
|
||||
end
|
||||
table.insert(result, {id = id, sort = sort})
|
||||
end
|
||||
|
||||
table.sort(result, function (a, b)
|
||||
return a.sort < b.sort
|
||||
end)
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
-- 获取兑换所需最小道具数
|
||||
function FourteenDayData:getExchangeMinNum()
|
||||
local minExchange
|
||||
for index, id in ipairs(self:getExchangeShowIds()) do
|
||||
local temp = self:getExchangeCostNum(id)
|
||||
for index, data in ipairs(self:getExchangeShowIdsSort()) do
|
||||
local temp = self:getExchangeCostNum(data.id)
|
||||
if minExchange == nil or minExchange > temp then
|
||||
minExchange = temp
|
||||
end
|
||||
@ -520,7 +523,6 @@ function FourteenDayData:onReceivedExchangeReward(id)
|
||||
end
|
||||
|
||||
self.exchangeStatus[id] = self.exchangeStatus[id] + 1
|
||||
self:getExchangeShowIds()
|
||||
self:setDirty()
|
||||
end
|
||||
|
||||
@ -547,27 +549,26 @@ end
|
||||
function FourteenDayData:getGiftIdsSort()
|
||||
local gifts = DataManager.ShopData:getGiftsByType(PayManager.PURCHARSE_ACT_TYPE.FOURTEEN_DAY_GIFT)
|
||||
|
||||
local free = {}
|
||||
local unSoldOut = {}
|
||||
local soldOut = {}
|
||||
local result = {}
|
||||
local ids = table.keys(gifts)
|
||||
for index, id in ipairs(ids) do
|
||||
local sort = id + 10000000000
|
||||
|
||||
if self:isFreeGift(id) then
|
||||
sort = sort - 10000000
|
||||
end
|
||||
|
||||
for id, data in pairs(gifts) do
|
||||
if data.recharge_id then
|
||||
if self:getGiftRemainTime(id) > 0 then
|
||||
table.insert(unSoldOut, id)
|
||||
else
|
||||
table.insert(soldOut, id)
|
||||
end
|
||||
else
|
||||
table.insert(free, id)
|
||||
sort = sort - 10000
|
||||
end
|
||||
table.insert(result, {id = id, sort = sort})
|
||||
end
|
||||
|
||||
table.sort(free)
|
||||
table.sort(unSoldOut)
|
||||
table.sort(soldOut)
|
||||
table.sort(result, function (a, b)
|
||||
return a.sort < b.sort
|
||||
end)
|
||||
|
||||
return table.addArray(free, table.addArray(unSoldOut, soldOut))
|
||||
return result
|
||||
end
|
||||
|
||||
-- 礼包剩余购买次数
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user