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