tmp
This commit is contained in:
parent
e07eb6a961
commit
f04108a58d
@ -12,6 +12,7 @@ local CONST_PATHS = {
|
||||
BattleConst = "app/module/battle/battle_const",
|
||||
HeroConst = "app/module/hero/hero_const",
|
||||
FormationConst = "app/module/formation/formation_const",
|
||||
ShopConst = "app/module/shop/shop_const",
|
||||
}
|
||||
|
||||
if EDITOR_MODE then
|
||||
|
||||
14
lua/app/module/shop/shop_const.lua
Normal file
14
lua/app/module/shop/shop_const.lua
Normal file
@ -0,0 +1,14 @@
|
||||
local ShopConst = class("ShopConst", BaseModule)
|
||||
|
||||
ShopConst.ACT_GIFT_TYPE = {
|
||||
FIRST_RECHARGE_GIFT = 1, -- 首冲
|
||||
COIN_GIFT = 2, -- 金币不足礼包
|
||||
BEGINNER_GIFT = 4,
|
||||
LEVEL_GIFT = 5, -- 助力礼包
|
||||
}
|
||||
|
||||
ShopConst.ACT_GIFT_ID = {
|
||||
BEGINNER_GIFT = 40102 -- 新手礼包ID
|
||||
}
|
||||
|
||||
return ShopConst
|
||||
10
lua/app/module/shop/shop_const.lua.meta
Normal file
10
lua/app/module/shop/shop_const.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cf915672156e6b5479a21292dec4c073
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
197
lua/app/ui/shop/cell/base_gift_cell__.lua
Normal file
197
lua/app/ui/shop/cell/base_gift_cell__.lua
Normal file
@ -0,0 +1,197 @@
|
||||
local BaseGiftCell = class("BaseGiftCell", BaseCell)
|
||||
local MAX_REWARD_COUNT = 4
|
||||
|
||||
-- 目前礼包样式一致,章节/新手/助力/成长/金币礼包本计划继承,但考虑到后续扩展,还是每个单独写吧
|
||||
|
||||
function BaseGiftCell:init()
|
||||
local uiMap = self.baseObject:genAllChildren()
|
||||
self.bg = uiMap["gift_cell.bg"]
|
||||
|
||||
self.leftArrow = uiMap["gift_cell.left_arrow"]
|
||||
self.rightArrow = uiMap["gift_cell.right_arrow"]
|
||||
|
||||
self.offImg = uiMap["gift_cell.bg.off_img"]
|
||||
self.offText = uiMap["gift_cell.bg.off_img.text"]
|
||||
|
||||
self.limitImg = uiMap["gift_cell.bg.limit_img"]
|
||||
self.limitText = uiMap["gift_cell.bg.limit_img.text"]
|
||||
|
||||
self.titleText = uiMap["gift_cell.bg.title_text"]
|
||||
|
||||
self.reweardLayout = uiMap["gift_cell.bg.reward_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_HORIZONTAL_OR_VERTICAL_LAYOUT) -- RefreshLayout()
|
||||
if not self.rewardCellList then
|
||||
self.rewardCellList = {}
|
||||
for i = 1, MAX_REWARD_COUNT do
|
||||
self.rewardCellList[i] = CellManager:addCellComp(uiMap["gift_cell.bg.reward_node.reward_cell_" .. i], GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
|
||||
end
|
||||
end
|
||||
|
||||
-- 不限时时使用1类型 否则使用2类型
|
||||
self.originPriceImg1 = uiMap["gift_cell.bg.origin_price_1"]
|
||||
self.originPriceText1 = uiMap["gift_cell.bg.origin_price_1.text"]
|
||||
self.priceText1 = uiMap["gift_cell.bg.price_1"]
|
||||
|
||||
self.originPriceImg2 = uiMap["gift_cell.bg.origin_price_2"]
|
||||
self.originPriceText2 = uiMap["gift_cell.bg.origin_price_2.text"]
|
||||
self.priceText2 = uiMap["gift_cell.bg.price_2"]
|
||||
|
||||
self.timeImg = uiMap["gift_cell.bg.time_img"]
|
||||
self.timeText = uiMap["gift_cell.bg.time_img.text"]
|
||||
end
|
||||
|
||||
-- 需要重写的部分 ********************************************************
|
||||
|
||||
-- 箭头部分
|
||||
function BaseGiftCell:showArrow()
|
||||
end
|
||||
|
||||
function BaseGiftCell:onClickLeftArrow()
|
||||
end
|
||||
|
||||
function BaseGiftCell:onClickRightArrow()
|
||||
end
|
||||
|
||||
-- 超值标识
|
||||
function BaseGiftCell:getOffValue()
|
||||
end
|
||||
|
||||
-- 限购标识
|
||||
function BaseGiftCell:getLimitValue()
|
||||
end
|
||||
|
||||
-- 标题
|
||||
function BaseGiftCell:getTitleValue()
|
||||
end
|
||||
|
||||
-- 配置表奖励
|
||||
function BaseGiftCell:getRewardList()
|
||||
end
|
||||
|
||||
-- 截至时间戳
|
||||
function BaseGiftCell:getTimeStamp()
|
||||
end
|
||||
|
||||
-- 原始价格与最终价格 rechargeId
|
||||
function BaseGiftCell:getPriceRechargeId()
|
||||
return 1, 1
|
||||
end
|
||||
|
||||
-- 重写部分结束 ********************************************************
|
||||
|
||||
function BaseGiftCell:refresh()
|
||||
self:refreshArrow()
|
||||
self:refreshOffNode()
|
||||
self:refreshLimitNode()
|
||||
self:refreshTitle()
|
||||
self:refreshRewards()
|
||||
self:refreshPriceNode()
|
||||
self:refershTimeNode()
|
||||
end
|
||||
|
||||
-- 左右箭头显示与事件
|
||||
function BaseGiftCell:refreshArrow()
|
||||
self.leftArrow:setVisible(self:showArrow())
|
||||
self.rightArrow:setVisible(self:showArrow())
|
||||
|
||||
self.leftArrow:addClickListener(function()
|
||||
self:onClickLeftArrow()
|
||||
end)
|
||||
self.rightArrow:addClickListener(function()
|
||||
self:onClickRightArrow()
|
||||
end)
|
||||
end
|
||||
|
||||
-- 超值标识
|
||||
function BaseGiftCell:refreshOffNode()
|
||||
local offValue = self:getOffValue()
|
||||
if offValue then
|
||||
self.offImg:setVisible(true)
|
||||
self.offText:setText(offValue)
|
||||
else
|
||||
self.offImg:setVisible(false)
|
||||
end
|
||||
end
|
||||
|
||||
-- 限购标识
|
||||
function BaseGiftCell:refreshLimitNode()
|
||||
local limitValue = self:getLimitValue()
|
||||
if limitValue then
|
||||
self.limitImg:setVisible(true)
|
||||
self.limitText:setText(limitValue)
|
||||
else
|
||||
self.limitImg:setVisible(false)
|
||||
end
|
||||
end
|
||||
|
||||
-- 标题
|
||||
function BaseGiftCell:refreshTitle()
|
||||
self.titleText:setText(self:getTitleValue())
|
||||
end
|
||||
|
||||
-- 奖励
|
||||
function BaseGiftCell:refreshRewards()
|
||||
local rewardList = self:getRewardList()
|
||||
local count = rewardList and #rewardList or 0
|
||||
for i = 1, MAX_REWARD_COUNT do
|
||||
if i <= count then
|
||||
self.rewardCellList[i]:setActive(true)
|
||||
self.rewardCellList[i]:refreshByConfig(rewardList[i])
|
||||
else
|
||||
self.rewardCellList[i]:setActive(false)
|
||||
end
|
||||
end
|
||||
self.reweardLayout:RefreshLayout()
|
||||
end
|
||||
|
||||
function BaseGiftCell:refreshPriceNode()
|
||||
local originRechargeId, rechargeId = self:getPriceRechargeId()
|
||||
local originPrice = GFunc.getFormatPrice(originRechargeId)
|
||||
local price = GFunc.getFormatPrice(rechargeId)
|
||||
if self:getTimeStamp() then -- 使用2类型
|
||||
self.originPriceImg1:setVisible(false)
|
||||
self.originPriceText1:setVisible(false)
|
||||
self.priceText1:setVisible(false)
|
||||
|
||||
self.originPriceImg2:setVisible(true)
|
||||
self.originPriceText2:setVisible(true)
|
||||
self.priceText2:setVisible(true)
|
||||
|
||||
self.originPriceText2:setText(originPrice)
|
||||
self.priceText2:setText(price)
|
||||
else -- 使用1类型
|
||||
self.originPriceImg1:setVisible(true)
|
||||
self.originPriceText1:setVisible(true)
|
||||
self.priceText1:setVisible(true)
|
||||
|
||||
self.originPriceImg2:setVisible(false)
|
||||
self.originPriceText2:setVisible(false)
|
||||
self.priceText2:setVisible(false)
|
||||
|
||||
self.originPriceText1:setText(originPrice)
|
||||
self.priceText1:setText(price)
|
||||
end
|
||||
end
|
||||
|
||||
function BaseGiftCell:refershTimeNode()
|
||||
local timeStamp = self:getTimeStamp()
|
||||
if timeStamp then
|
||||
local leftTime = timeStamp - Time:getServerTime()
|
||||
if leftTime < 0 then
|
||||
leftTime = 0
|
||||
end
|
||||
self.timeImg:setVisible(true)
|
||||
if leftTime > 0 then
|
||||
self.timeText:setText(Time:formatNumTimeStr(leftTime))
|
||||
else
|
||||
self.timeImg:setVisible(false)
|
||||
end
|
||||
else
|
||||
self.timeImg:setVisible(false)
|
||||
end
|
||||
end
|
||||
|
||||
function BaseGiftCell:setVisible(visible)
|
||||
self.baseObject:setVisible(visible)
|
||||
end
|
||||
|
||||
return BaseGiftCell
|
||||
10
lua/app/ui/shop/cell/base_gift_cell__.lua.meta
Normal file
10
lua/app/ui/shop/cell/base_gift_cell__.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc75240d72d01dc43b4f3a005d138f8c
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
101
lua/app/ui/shop/cell/beginner_sell_cell.lua
Normal file
101
lua/app/ui/shop/cell/beginner_sell_cell.lua
Normal file
@ -0,0 +1,101 @@
|
||||
local BeginnerSellCell = class("BeginnerSellCell", BaseCell)
|
||||
local MAX_REWARD_COUNT = 4
|
||||
local BASE_CELL_HEIGHT = 320
|
||||
|
||||
function BeginnerSellCell:init()
|
||||
local uiMap = self.baseObject:genAllChildren()
|
||||
self.bg = uiMap["gift_cell.bg"]
|
||||
|
||||
self.leftArrow = uiMap["gift_cell.left_arrow"]
|
||||
self.rightArrow = uiMap["gift_cell.right_arrow"]
|
||||
|
||||
self.offImg = uiMap["gift_cell.bg.off_img"]
|
||||
self.offText = uiMap["gift_cell.bg.off_img.text"]
|
||||
|
||||
self.limitImg = uiMap["gift_cell.bg.limit_img"]
|
||||
self.limitText = uiMap["gift_cell.bg.limit_img.text"]
|
||||
|
||||
self.titleText = uiMap["gift_cell.bg.title_text"]
|
||||
|
||||
self.reweardLayout = uiMap["gift_cell.bg.reward_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_HORIZONTAL_OR_VERTICAL_LAYOUT) -- RefreshLayout()
|
||||
if not self.rewardCellList then
|
||||
self.rewardCellList = {}
|
||||
for i = 1, MAX_REWARD_COUNT do
|
||||
self.rewardCellList[i] = CellManager:addCellComp(uiMap["gift_cell.bg.reward_node.reward_cell_" .. i], GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
|
||||
end
|
||||
end
|
||||
|
||||
-- 不限时时使用1类型 否则使用2类型
|
||||
self.originPriceImg1 = uiMap["gift_cell.bg.origin_price_1"]
|
||||
self.originPriceText1 = uiMap["gift_cell.bg.origin_price_1.text"]
|
||||
self.priceText1 = uiMap["gift_cell.bg.price_1"]
|
||||
|
||||
self.originPriceImg2 = uiMap["gift_cell.bg.origin_price_2"]
|
||||
self.originPriceText2 = uiMap["gift_cell.bg.origin_price_2.text"]
|
||||
self.priceText2 = uiMap["gift_cell.bg.price_2"]
|
||||
|
||||
self.timeImg = uiMap["gift_cell.bg.time_img"]
|
||||
self.timeText = uiMap["gift_cell.bg.time_img.text"]
|
||||
end
|
||||
|
||||
function BeginnerSellCell:refresh()
|
||||
local actGiftId = GConst.ShopConst.ACT_GIFT_ID.BEGINNER_GIFT
|
||||
local cfgInfo = ConfigManager:getConfig("act_gift")[actGiftId]
|
||||
-- 超值
|
||||
if cfgInfo.value then
|
||||
self.offImg:setVisible(true)
|
||||
self.offText:setText(tostring(cfgInfo.value * 100) .. "%")
|
||||
else
|
||||
self.offImg:setVisible(false)
|
||||
end
|
||||
-- 限购
|
||||
self.limitText:setText("限购1次TD") -- 章节礼包默认限购1次 TODOJ
|
||||
-- 标题
|
||||
self.titleText:setText("新手礼包TD") -- TODOJ
|
||||
-- 奖励
|
||||
local rewardList = cfgInfo.reward
|
||||
local count = rewardList and #rewardList or 0
|
||||
for i = 1, MAX_REWARD_COUNT do
|
||||
if i <= count then
|
||||
self.rewardCellList[i]:getBaseObject():setActive(true)
|
||||
self.rewardCellList[i]:refreshByConfig(rewardList[i])
|
||||
else
|
||||
self.rewardCellList[i]:getBaseObject():setActive(false)
|
||||
end
|
||||
end
|
||||
self.reweardLayout:RefreshLayout()
|
||||
-- 价格(使用1类型,且不显示原价)
|
||||
self.originPriceImg1:setVisible(false)
|
||||
self.originPriceText1:setVisible(false)
|
||||
self.priceText1:setVisible(true)
|
||||
|
||||
self.originPriceImg2:setVisible(false)
|
||||
self.originPriceText2:setVisible(false)
|
||||
self.priceText2:setVisible(false)
|
||||
|
||||
self.priceText1:setText(GFunc.getFormatPrice(cfgInfo.recharge_id))
|
||||
-- 限时(隐藏)
|
||||
self.timeImg:setVisible(false)
|
||||
|
||||
self:addClickListener(function()
|
||||
self:onClickGift(actGiftId)
|
||||
end)
|
||||
end
|
||||
|
||||
function BeginnerSellCell:getCellHeight()
|
||||
return BASE_CELL_HEIGHT -- 新手礼包固定1个
|
||||
end
|
||||
|
||||
function BeginnerSellCell:getIsOpen()
|
||||
return true -- TOODJ
|
||||
end
|
||||
|
||||
function BeginnerSellCell:setVisible(visible)
|
||||
self.baseObject:setVisible(visible)
|
||||
end
|
||||
|
||||
function BeginnerSellCell:onClickGift(id)
|
||||
Logger.logHighlight("Click id:%s", id) -- TODOJ
|
||||
end
|
||||
|
||||
return BeginnerSellCell
|
||||
10
lua/app/ui/shop/cell/beginner_sell_cell.lua.meta
Normal file
10
lua/app/ui/shop/cell/beginner_sell_cell.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 49dcb2ca91052ea45a769729b7325d05
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
104
lua/app/ui/shop/cell/chapter_cell.lua
Normal file
104
lua/app/ui/shop/cell/chapter_cell.lua
Normal file
@ -0,0 +1,104 @@
|
||||
local ChapterCell = class("ChapterCell", BaseCell)
|
||||
local MAX_REWARD_COUNT = 4
|
||||
|
||||
-- 目前礼包样式一致,章节/新手/助力/成长/金币礼包都通用
|
||||
|
||||
function ChapterCell:init()
|
||||
local uiMap = self.baseObject:genAllChildren()
|
||||
self.bg = uiMap["gift_cell.bg"]
|
||||
|
||||
self.leftArrow = uiMap["gift_cell.left_arrow"]
|
||||
self.rightArrow = uiMap["gift_cell.right_arrow"]
|
||||
|
||||
self.offImg = uiMap["gift_cell.bg.off_img"]
|
||||
self.offText = uiMap["gift_cell.bg.off_img.text"]
|
||||
|
||||
self.limitImg = uiMap["gift_cell.bg.limit_img"]
|
||||
self.limitText = uiMap["gift_cell.bg.limit_img.text"]
|
||||
|
||||
self.titleText = uiMap["gift_cell.bg.title_text"]
|
||||
|
||||
self.reweardLayout = uiMap["gift_cell.bg.reward_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_HORIZONTAL_OR_VERTICAL_LAYOUT) -- RefreshLayout()
|
||||
if not self.rewardCellList then
|
||||
self.rewardCellList = {}
|
||||
for i = 1, MAX_REWARD_COUNT do
|
||||
self.rewardCellList[i] = CellManager:addCellComp(uiMap["gift_cell.bg.reward_node.reward_cell_" .. i], GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
|
||||
end
|
||||
end
|
||||
|
||||
-- 不限时时使用1类型 否则使用2类型
|
||||
self.originPriceImg1 = uiMap["gift_cell.bg.origin_price_1"]
|
||||
self.originPriceText1 = uiMap["gift_cell.bg.origin_price_1.text"]
|
||||
self.priceText1 = uiMap["gift_cell.bg.price_1"]
|
||||
|
||||
self.originPriceImg2 = uiMap["gift_cell.bg.origin_price_2"]
|
||||
self.originPriceText2 = uiMap["gift_cell.bg.origin_price_2.text"]
|
||||
self.priceText2 = uiMap["gift_cell.bg.price_2"]
|
||||
|
||||
self.timeImg = uiMap["gift_cell.bg.time_img"]
|
||||
self.timeText = uiMap["gift_cell.bg.time_img.text"]
|
||||
end
|
||||
|
||||
function ChapterCell:refresh(idx, cfgInfo, totalCount, arrowCallback, clickCallback)
|
||||
-- 箭头
|
||||
local showLeftArrow = true
|
||||
local showRightArrow = true
|
||||
if idx == 1 then
|
||||
showLeftArrow = false
|
||||
end
|
||||
if idx == totalCount then
|
||||
showRightArrow = false
|
||||
end
|
||||
self.leftArrow:setVisible(showLeftArrow)
|
||||
self.rightArrow:setVisible(showRightArrow)
|
||||
|
||||
self.leftArrow:addClickListener(function()
|
||||
arrowCallback(1)
|
||||
end)
|
||||
self.rightArrow:addClickListener(function()
|
||||
arrowCallback(-1)
|
||||
end)
|
||||
-- 超值
|
||||
self.offText:setText(tostring(cfgInfo.value * 100) .. "%")
|
||||
-- 限购
|
||||
self.limitText:setText("限购1次TD") -- 章节礼包默认限购1次 TODOJ
|
||||
-- 标题
|
||||
self.titleText:setText("第" .. tostring(cfgInfo.chapter) .. "章礼包TD") -- TODOJ
|
||||
-- 奖励
|
||||
local rewardList = cfgInfo.reward
|
||||
local count = rewardList and #rewardList or 0
|
||||
for i = 1, MAX_REWARD_COUNT do
|
||||
if i <= count then
|
||||
self.rewardCellList[i]:getBaseObject():setActive(true)
|
||||
self.rewardCellList[i]:refreshByConfig(rewardList[i])
|
||||
else
|
||||
self.rewardCellList[i]:getBaseObject():setActive(false)
|
||||
end
|
||||
end
|
||||
self.reweardLayout:RefreshLayout()
|
||||
-- 价格(使用1类型)
|
||||
self.originPriceImg1:setVisible(true)
|
||||
self.originPriceText1:setVisible(true)
|
||||
self.priceText1:setVisible(true)
|
||||
|
||||
self.originPriceImg2:setVisible(false)
|
||||
self.originPriceText2:setVisible(false)
|
||||
self.priceText2:setVisible(false)
|
||||
|
||||
self.originPriceText1:setText(GFunc.getFormatPrice(cfgInfo.original))
|
||||
self.priceText1:setText(GFunc.getFormatPrice(cfgInfo.recharge_id))
|
||||
-- 限时(隐藏)
|
||||
self.timeImg:setVisible(false)
|
||||
|
||||
if clickCallback then
|
||||
self:addClickListener(function()
|
||||
clickCallback(idx)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function ChapterCell:setVisible(visible)
|
||||
self.baseObject:setVisible(visible)
|
||||
end
|
||||
|
||||
return ChapterCell
|
||||
10
lua/app/ui/shop/cell/chapter_cell.lua.meta
Normal file
10
lua/app/ui/shop/cell/chapter_cell.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d83d1e8c37389e4eb88dd51f2fcbde8
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
59
lua/app/ui/shop/cell/chapter_sell_cell.lua
Normal file
59
lua/app/ui/shop/cell/chapter_sell_cell.lua
Normal file
@ -0,0 +1,59 @@
|
||||
local ChapterSellCell = class("ChapterSellCell", BaseCell)
|
||||
local CHAPTER_CELL = "app/ui/shop/cell/chapter_cell"
|
||||
local BASE_CELL_HEIGHT = 320
|
||||
|
||||
function ChapterSellCell:init()
|
||||
local uiMap = self.baseObject:genAllChildren()
|
||||
self.scrollRectObj = uiMap["chapter_sell_cell.scroll_rect"]
|
||||
self.contentObj = uiMap["chapter_sell_cell.scroll_rect.viewport.content"]
|
||||
self.scrollRect = self.scrollRectObj:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||
self.scrollRect:addInitCallback(function()
|
||||
return CHAPTER_CELL
|
||||
end)
|
||||
self.scrollRect:addRefreshCallback(function(idx, cell)
|
||||
if self.actChapterCfg and self.actChapterCfg[idx] then
|
||||
cell:refresh(idx, self.actChapterCfg[idx], #self.actChapterCfg,
|
||||
function (add)
|
||||
self.contentObj:addAnchoredPosition(add*720)
|
||||
end,
|
||||
function(idx)
|
||||
self:onClickGift(self.actChapterCfg[idx].id)
|
||||
end)
|
||||
end
|
||||
end)
|
||||
self.scrollRect:clearCells()
|
||||
|
||||
self.cellHeight = BASE_CELL_HEIGHT
|
||||
end
|
||||
|
||||
function ChapterSellCell:refresh()
|
||||
-- 暂无数据部分 测试用 TODOJ
|
||||
local tmpIds = {303, 203, 103} -- {103, 203, 303}
|
||||
self.actChapterCfg = {}
|
||||
local actChapterCfg = ConfigManager:getConfig("act_chapter_store")
|
||||
for i = 1, #tmpIds do
|
||||
local cfgInfo = clone(actChapterCfg[tmpIds[i]])
|
||||
cfgInfo.id = tmpIds[i]
|
||||
table.insert(self.actChapterCfg, cfgInfo)
|
||||
end
|
||||
self.scrollRect:refillCells(#self.actChapterCfg)
|
||||
self.contentObj:setAnchoredPositionX(0)
|
||||
end
|
||||
|
||||
function ChapterSellCell:getCellHeight()
|
||||
return BASE_CELL_HEIGHT -- 章节礼包横向展开
|
||||
end
|
||||
|
||||
function ChapterSellCell:getIsOpen()
|
||||
return true -- TOODJ
|
||||
end
|
||||
|
||||
function ChapterSellCell:setVisible(visible)
|
||||
self.baseObject:setVisible(visible)
|
||||
end
|
||||
|
||||
function ChapterSellCell:onClickGift(id)
|
||||
Logger.logHighlight("Click id:%s", id) -- TODOJ
|
||||
end
|
||||
|
||||
return ChapterSellCell
|
||||
10
lua/app/ui/shop/cell/chapter_sell_cell.lua.meta
Normal file
10
lua/app/ui/shop/cell/chapter_sell_cell.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 15313f1ba35cfcd46bb95876a7801283
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
103
lua/app/ui/shop/cell/coin_sell_cell.lua
Normal file
103
lua/app/ui/shop/cell/coin_sell_cell.lua
Normal file
@ -0,0 +1,103 @@
|
||||
local CoinSellCell = class("CoinSellCell", BaseCell)
|
||||
local MAX_REWARD_COUNT = 4
|
||||
local BASE_CELL_HEIGHT = 320
|
||||
|
||||
function CoinSellCell:init()
|
||||
local uiMap = self.baseObject:genAllChildren()
|
||||
self.bg = uiMap["gift_cell.bg"]
|
||||
|
||||
self.leftArrow = uiMap["gift_cell.left_arrow"]
|
||||
self.rightArrow = uiMap["gift_cell.right_arrow"]
|
||||
|
||||
self.offImg = uiMap["gift_cell.bg.off_img"]
|
||||
self.offText = uiMap["gift_cell.bg.off_img.text"]
|
||||
|
||||
self.limitImg = uiMap["gift_cell.bg.limit_img"]
|
||||
self.limitText = uiMap["gift_cell.bg.limit_img.text"]
|
||||
|
||||
self.titleText = uiMap["gift_cell.bg.title_text"]
|
||||
|
||||
self.reweardLayout = uiMap["gift_cell.bg.reward_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_HORIZONTAL_OR_VERTICAL_LAYOUT) -- RefreshLayout()
|
||||
if not self.rewardCellList then
|
||||
self.rewardCellList = {}
|
||||
for i = 1, MAX_REWARD_COUNT do
|
||||
self.rewardCellList[i] = CellManager:addCellComp(uiMap["gift_cell.bg.reward_node.reward_cell_" .. i], GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
|
||||
end
|
||||
end
|
||||
|
||||
-- 不限时时使用1类型 否则使用2类型
|
||||
self.originPriceImg1 = uiMap["gift_cell.bg.origin_price_1"]
|
||||
self.originPriceText1 = uiMap["gift_cell.bg.origin_price_1.text"]
|
||||
self.priceText1 = uiMap["gift_cell.bg.price_1"]
|
||||
|
||||
self.originPriceImg2 = uiMap["gift_cell.bg.origin_price_2"]
|
||||
self.originPriceText2 = uiMap["gift_cell.bg.origin_price_2.text"]
|
||||
self.priceText2 = uiMap["gift_cell.bg.price_2"]
|
||||
|
||||
self.timeImg = uiMap["gift_cell.bg.time_img"]
|
||||
self.timeText = uiMap["gift_cell.bg.time_img.text"]
|
||||
end
|
||||
|
||||
function CoinSellCell:refresh()
|
||||
-- 暂无数据格式 测试用 TODOJ
|
||||
local actGiftId = 20102
|
||||
local cfgInfo = ConfigManager:getConfig("act_gift")[actGiftId]
|
||||
-- 超值
|
||||
self.offText:setText(tostring(cfgInfo.value * 100) .. "%")
|
||||
-- 限购
|
||||
self.limitText:setText("限购" .. tostring(cfgInfo.limit) .. "次TD") -- TODOJ
|
||||
-- 标题
|
||||
self.titleText:setText("金币礼包TD") -- TODOJ
|
||||
-- 奖励
|
||||
local rewardList = cfgInfo.reward
|
||||
local count = rewardList and #rewardList or 0
|
||||
for i = 1, MAX_REWARD_COUNT do
|
||||
if i <= count then
|
||||
self.rewardCellList[i]:getBaseObject():setActive(true)
|
||||
self.rewardCellList[i]:refreshByConfig(rewardList[i])
|
||||
else
|
||||
self.rewardCellList[i]:getBaseObject():setActive(false)
|
||||
end
|
||||
end
|
||||
self.reweardLayout:RefreshLayout()
|
||||
-- 价格(使用2类型,且不显示原价)
|
||||
self.originPriceImg1:setVisible(false)
|
||||
self.originPriceText1:setVisible(false)
|
||||
self.priceText1:setVisible(false)
|
||||
|
||||
self.originPriceImg2:setVisible(false)
|
||||
self.originPriceText2:setVisible(false)
|
||||
self.priceText2:setVisible(true)
|
||||
|
||||
self.priceText2:setText(GFunc.getFormatPrice(cfgInfo.recharge_id))
|
||||
-- 限时
|
||||
self.timeImg:setVisible(true)
|
||||
self:updateTime()
|
||||
|
||||
self:addClickListener(function()
|
||||
self:onClickGift(actGiftId)
|
||||
end)
|
||||
end
|
||||
|
||||
function CoinSellCell:getCellHeight()
|
||||
return BASE_CELL_HEIGHT -- 固定1个
|
||||
end
|
||||
|
||||
function CoinSellCell:getIsOpen()
|
||||
return true -- TOODJ
|
||||
end
|
||||
|
||||
function CoinSellCell:setVisible(visible)
|
||||
self.baseObject:setVisible(visible)
|
||||
end
|
||||
|
||||
function CoinSellCell:onClickGift(id)
|
||||
Logger.logHighlight("Click id:%s", id) -- TODOJ
|
||||
end
|
||||
|
||||
function CoinSellCell:updateTime()
|
||||
local leftTime = 3600 -- 数据结构暂无 临时测试 TODOJ
|
||||
self.timeText:setText(Time:formatNumTimeStr(leftTime))
|
||||
end
|
||||
|
||||
return CoinSellCell
|
||||
10
lua/app/ui/shop/cell/coin_sell_cell.lua.meta
Normal file
10
lua/app/ui/shop/cell/coin_sell_cell.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3011d7c0a218224a8e6601dd1c992cd
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
89
lua/app/ui/shop/cell/grow_cell.lua
Normal file
89
lua/app/ui/shop/cell/grow_cell.lua
Normal file
@ -0,0 +1,89 @@
|
||||
local GrowCell = class("GrowCell", BaseCell)
|
||||
local MAX_REWARD_COUNT = 4
|
||||
|
||||
function GrowCell:init()
|
||||
local uiMap = self.baseObject:genAllChildren()
|
||||
self.bg = uiMap["gift_cell.bg"]
|
||||
|
||||
self.leftArrow = uiMap["gift_cell.left_arrow"]
|
||||
self.rightArrow = uiMap["gift_cell.right_arrow"]
|
||||
|
||||
self.offImg = uiMap["gift_cell.bg.off_img"]
|
||||
self.offText = uiMap["gift_cell.bg.off_img.text"]
|
||||
|
||||
self.limitImg = uiMap["gift_cell.bg.limit_img"]
|
||||
self.limitText = uiMap["gift_cell.bg.limit_img.text"]
|
||||
|
||||
self.titleText = uiMap["gift_cell.bg.title_text"]
|
||||
|
||||
self.reweardLayout = uiMap["gift_cell.bg.reward_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_HORIZONTAL_OR_VERTICAL_LAYOUT) -- RefreshLayout()
|
||||
if not self.rewardCellList then
|
||||
self.rewardCellList = {}
|
||||
for i = 1, MAX_REWARD_COUNT do
|
||||
self.rewardCellList[i] = CellManager:addCellComp(uiMap["gift_cell.bg.reward_node.reward_cell_" .. i], GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
|
||||
end
|
||||
end
|
||||
|
||||
-- 不限时时使用1类型 否则使用2类型
|
||||
self.originPriceImg1 = uiMap["gift_cell.bg.origin_price_1"]
|
||||
self.originPriceText1 = uiMap["gift_cell.bg.origin_price_1.text"]
|
||||
self.priceText1 = uiMap["gift_cell.bg.price_1"]
|
||||
|
||||
self.originPriceImg2 = uiMap["gift_cell.bg.origin_price_2"]
|
||||
self.originPriceText2 = uiMap["gift_cell.bg.origin_price_2.text"]
|
||||
self.priceText2 = uiMap["gift_cell.bg.price_2"]
|
||||
|
||||
self.timeImg = uiMap["gift_cell.bg.time_img"]
|
||||
self.timeText = uiMap["gift_cell.bg.time_img.text"]
|
||||
end
|
||||
|
||||
function GrowCell:refresh(idx, cfgInfo, clickCallback)
|
||||
-- 超值
|
||||
self.offText:setText(tostring(cfgInfo.value) .. "%")
|
||||
-- 限购
|
||||
self.limitText:setText("限购" .. tostring(cfgInfo.limit) .. "次TD") -- TODOJ
|
||||
-- 标题
|
||||
self.titleText:setText("成长礼包TD") -- TODOJ
|
||||
-- 奖励
|
||||
local rewardList = cfgInfo.reward
|
||||
local count = rewardList and #rewardList or 0
|
||||
for i = 1, MAX_REWARD_COUNT do
|
||||
if i <= count then
|
||||
self.rewardCellList[i]:getBaseObject():setActive(true)
|
||||
self.rewardCellList[i]:refreshByConfig(rewardList[i])
|
||||
else
|
||||
self.rewardCellList[i]:getBaseObject():setActive(false)
|
||||
end
|
||||
end
|
||||
self.reweardLayout:RefreshLayout()
|
||||
-- 价格(使用2类型)
|
||||
self.originPriceImg1:setVisible(false)
|
||||
self.originPriceText1:setVisible(false)
|
||||
self.priceText1:setVisible(false)
|
||||
|
||||
self.originPriceImg2:setVisible(false)
|
||||
self.originPriceText2:setVisible(false)
|
||||
self.priceText2:setVisible(true)
|
||||
|
||||
self.priceText2:setText(GFunc.getFormatPrice(cfgInfo.recharge_id))
|
||||
-- 限时
|
||||
self.timeImg:setVisible(true)
|
||||
self:updateTime()
|
||||
|
||||
if clickCallback then
|
||||
self:addClickListener(function()
|
||||
clickCallback(cfgInfo.id)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function GrowCell:setVisible(visible)
|
||||
self.baseObject:setVisible(visible)
|
||||
end
|
||||
|
||||
function GrowCell:updateTime()
|
||||
local leftTime = 3600 -- 数据结构暂无 临时测试 TODOJ
|
||||
self.timeText:setText(Time:formatNumTimeStr(leftTime))
|
||||
end
|
||||
|
||||
return GrowCell
|
||||
10
lua/app/ui/shop/cell/grow_cell.lua.meta
Normal file
10
lua/app/ui/shop/cell/grow_cell.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c7dad95a4d35f014fbe29f4d221fd858
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
58
lua/app/ui/shop/cell/grow_sell_cell.lua
Normal file
58
lua/app/ui/shop/cell/grow_sell_cell.lua
Normal file
@ -0,0 +1,58 @@
|
||||
local GrowSellCell = class("GrowSellCell", BaseCell)
|
||||
local GROW_CELL = "app/ui/shop/cell/grow_cell"
|
||||
local BASE_CELL_HEIGHT = 320
|
||||
|
||||
function GrowSellCell:init()
|
||||
local uiMap = self.baseObject:genAllChildren()
|
||||
self.scrollRectObj = uiMap["grow_sell_cell.scroll_rect"]
|
||||
self.contentObj = uiMap["grow_sell_cell.scroll_rect.viewport.content"]
|
||||
self.scrollRect = self.scrollRectObj:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||
self.scrollRect:addInitCallback(function()
|
||||
return GROW_CELL
|
||||
end)
|
||||
self.scrollRect:addRefreshCallback(function(idx, cell)
|
||||
if self.actGrowUpGiftCfg and self.actGrowUpGiftCfg[idx] then
|
||||
cell:refresh(idx, self.actGrowUpGiftCfg[idx], function()
|
||||
self:onClickGift(self.actGrowUpGiftCfg[idx].id)
|
||||
end)
|
||||
end
|
||||
end)
|
||||
self.scrollRect:clearCells()
|
||||
|
||||
self.cellHeight = BASE_CELL_HEIGHT
|
||||
end
|
||||
|
||||
function GrowSellCell:refresh()
|
||||
-- 暂无数据部分 测试用 TODOJ
|
||||
local tmpIds = {1014, 2014}
|
||||
self.actGrowUpGiftCfg = {}
|
||||
local actGrowUpGiftCfg = ConfigManager:getConfig("act_growup_gift")
|
||||
for i = 1, #tmpIds do
|
||||
local cfgInfo = clone(actGrowUpGiftCfg[tmpIds[i]])
|
||||
cfgInfo.id = tmpIds[i]
|
||||
table.insert(self.actGrowUpGiftCfg, cfgInfo)
|
||||
end
|
||||
self.scrollRect:refillCells(#self.actGrowUpGiftCfg)
|
||||
|
||||
self:getBaseObject():setSizeDeltaY(self:getCellHeight())
|
||||
self.scrollRectObj:setSizeDeltaY(self:getCellHeight())
|
||||
end
|
||||
|
||||
function GrowSellCell:getCellHeight()
|
||||
local cellCount = self.actGrowUpGiftCfg and #self.actGrowUpGiftCfg or 0
|
||||
return BASE_CELL_HEIGHT * cellCount
|
||||
end
|
||||
|
||||
function GrowSellCell:getIsOpen()
|
||||
return true -- TOODJ
|
||||
end
|
||||
|
||||
function GrowSellCell:setVisible(visible)
|
||||
self.baseObject:setVisible(visible)
|
||||
end
|
||||
|
||||
function GrowSellCell:onClickGift(id)
|
||||
Logger.logHighlight("Click id:%s", id) -- TODOJ
|
||||
end
|
||||
|
||||
return GrowSellCell
|
||||
10
lua/app/ui/shop/cell/grow_sell_cell.lua.meta
Normal file
10
lua/app/ui/shop/cell/grow_sell_cell.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3734b11b82b80834393166a49267ea2c
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
83
lua/app/ui/shop/cell/level_cell.lua
Normal file
83
lua/app/ui/shop/cell/level_cell.lua
Normal file
@ -0,0 +1,83 @@
|
||||
local LevelCell = class("LevelCell", BaseCell)
|
||||
local MAX_REWARD_COUNT = 4
|
||||
|
||||
function LevelCell:init()
|
||||
local uiMap = self.baseObject:genAllChildren()
|
||||
self.bg = uiMap["gift_cell.bg"]
|
||||
|
||||
self.leftArrow = uiMap["gift_cell.left_arrow"]
|
||||
self.rightArrow = uiMap["gift_cell.right_arrow"]
|
||||
|
||||
self.offImg = uiMap["gift_cell.bg.off_img"]
|
||||
self.offText = uiMap["gift_cell.bg.off_img.text"]
|
||||
|
||||
self.limitImg = uiMap["gift_cell.bg.limit_img"]
|
||||
self.limitText = uiMap["gift_cell.bg.limit_img.text"]
|
||||
|
||||
self.titleText = uiMap["gift_cell.bg.title_text"]
|
||||
|
||||
self.reweardLayout = uiMap["gift_cell.bg.reward_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_HORIZONTAL_OR_VERTICAL_LAYOUT) -- RefreshLayout()
|
||||
if not self.rewardCellList then
|
||||
self.rewardCellList = {}
|
||||
for i = 1, MAX_REWARD_COUNT do
|
||||
self.rewardCellList[i] = CellManager:addCellComp(uiMap["gift_cell.bg.reward_node.reward_cell_" .. i], GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
|
||||
end
|
||||
end
|
||||
|
||||
-- 不限时时使用1类型 否则使用2类型
|
||||
self.originPriceImg1 = uiMap["gift_cell.bg.origin_price_1"]
|
||||
self.originPriceText1 = uiMap["gift_cell.bg.origin_price_1.text"]
|
||||
self.priceText1 = uiMap["gift_cell.bg.price_1"]
|
||||
|
||||
self.originPriceImg2 = uiMap["gift_cell.bg.origin_price_2"]
|
||||
self.originPriceText2 = uiMap["gift_cell.bg.origin_price_2.text"]
|
||||
self.priceText2 = uiMap["gift_cell.bg.price_2"]
|
||||
|
||||
self.timeImg = uiMap["gift_cell.bg.time_img"]
|
||||
self.timeText = uiMap["gift_cell.bg.time_img.text"]
|
||||
end
|
||||
|
||||
function LevelCell:refresh(idx, cfgInfo, clickCallback)
|
||||
-- 超值
|
||||
self.offText:setText(tostring(cfgInfo.value) .. "%")
|
||||
-- 限购
|
||||
self.limitText:setText("限购1次TD") -- 默认限购1次 TODOJ
|
||||
-- 标题
|
||||
self.titleText:setText(tostring(cfgInfo.parameter) .. "级助力礼包TD") -- TODOJ
|
||||
-- 奖励
|
||||
local rewardList = cfgInfo.reward
|
||||
local count = rewardList and #rewardList or 0
|
||||
for i = 1, MAX_REWARD_COUNT do
|
||||
if i <= count then
|
||||
self.rewardCellList[i]:getBaseObject():setActive(true)
|
||||
self.rewardCellList[i]:refreshByConfig(rewardList[i])
|
||||
else
|
||||
self.rewardCellList[i]:getBaseObject():setActive(false)
|
||||
end
|
||||
end
|
||||
self.reweardLayout:RefreshLayout()
|
||||
-- 价格(使用1类型)
|
||||
self.originPriceImg1:setVisible(false)
|
||||
self.originPriceText1:setVisible(false)
|
||||
self.priceText1:setVisible(true)
|
||||
|
||||
self.originPriceImg2:setVisible(false)
|
||||
self.originPriceText2:setVisible(false)
|
||||
self.priceText2:setVisible(false)
|
||||
|
||||
self.priceText1:setText(GFunc.getFormatPrice(cfgInfo.recharge_id))
|
||||
-- 限时(隐藏)
|
||||
self.timeImg:setVisible(false)
|
||||
|
||||
if clickCallback then
|
||||
self:addClickListener(function()
|
||||
clickCallback(cfgInfo.id)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function LevelCell:setVisible(visible)
|
||||
self.baseObject:setVisible(visible)
|
||||
end
|
||||
|
||||
return LevelCell
|
||||
10
lua/app/ui/shop/cell/level_cell.lua.meta
Normal file
10
lua/app/ui/shop/cell/level_cell.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36fbab6ccc9948a4191206a7aa8d8735
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
58
lua/app/ui/shop/cell/level_sell_cell.lua
Normal file
58
lua/app/ui/shop/cell/level_sell_cell.lua
Normal file
@ -0,0 +1,58 @@
|
||||
local LevelSellCell = class("LevelSellCell", BaseCell)
|
||||
local LEVEL_CELL = "app/ui/shop/cell/level_cell"
|
||||
local BASE_CELL_HEIGHT = 320
|
||||
|
||||
function LevelSellCell:init()
|
||||
local uiMap = self.baseObject:genAllChildren()
|
||||
self.scrollRectObj = uiMap["level_sell_cell.scroll_rect"]
|
||||
self.contentObj = uiMap["level_sell_cell.scroll_rect.viewport.content"]
|
||||
self.scrollRect = self.scrollRectObj:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||
self.scrollRect:addInitCallback(function()
|
||||
return LEVEL_CELL
|
||||
end)
|
||||
self.scrollRect:addRefreshCallback(function(idx, cell)
|
||||
if self.actGiftCfg and self.actGiftCfg[idx] then
|
||||
cell:refresh(idx, self.actGiftCfg[idx], function()
|
||||
self:onClickGift(self.actGiftCfg[idx].id)
|
||||
end)
|
||||
end
|
||||
end)
|
||||
self.scrollRect:clearCells()
|
||||
|
||||
self.cellHeight = BASE_CELL_HEIGHT
|
||||
end
|
||||
|
||||
function LevelSellCell:refresh()
|
||||
-- 暂无数据部分 测试用 TODOJ
|
||||
local tmpIds = {50102, 50402}
|
||||
self.actGiftCfg = {}
|
||||
local actGiftCfg = ConfigManager:getConfig("act_gift")
|
||||
for i = 1, #tmpIds do
|
||||
local cfgInfo = clone(actGiftCfg[tmpIds[i]])
|
||||
cfgInfo.id = tmpIds[i]
|
||||
table.insert(self.actGiftCfg, cfgInfo)
|
||||
end
|
||||
self.scrollRect:refillCells(#self.actGiftCfg)
|
||||
|
||||
self:getBaseObject():setSizeDeltaY(self:getCellHeight())
|
||||
self.scrollRectObj:setSizeDeltaY(self:getCellHeight())
|
||||
end
|
||||
|
||||
function LevelSellCell:getCellHeight()
|
||||
local cellCount = self.actGiftCfg and #self.actGiftCfg or 0
|
||||
return BASE_CELL_HEIGHT * cellCount
|
||||
end
|
||||
|
||||
function LevelSellCell:getIsOpen()
|
||||
return true -- TOODJ
|
||||
end
|
||||
|
||||
function LevelSellCell:setVisible(visible)
|
||||
self.baseObject:setVisible(visible)
|
||||
end
|
||||
|
||||
function LevelSellCell:onClickGift(id)
|
||||
Logger.logHighlight("Click id:%s", id) -- TODOJ
|
||||
end
|
||||
|
||||
return LevelSellCell
|
||||
10
lua/app/ui/shop/cell/level_sell_cell.lua.meta
Normal file
10
lua/app/ui/shop/cell/level_sell_cell.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1da2708abce3d574cb5878bf216d9524
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
@ -2,6 +2,7 @@ local ShopComp = class("ShopComp", LuaComponent)
|
||||
|
||||
local TOP_HEIGHT = 136
|
||||
local BOTTOM_HEIGHT = 218
|
||||
local TITLE_HEIGHT = 54
|
||||
local PAGE_DISCOUNT = 1
|
||||
local PAGE_MAIN = 2
|
||||
local PAGE_MAIN_BOX_SELL_CELL = "app/ui/shop/cell/box_sell_cell"
|
||||
@ -9,22 +10,83 @@ local PAGE_MAIN_HOT_SELL_CELL = "app/ui/shop/cell/hot_sell_cell"
|
||||
local PAGE_MAIN_GEM_SELL_CELL = "app/ui/shop/cell/gem_sell_cell"
|
||||
local PAGE_MAIN_GOLD_SELL_CELL = "app/ui/shop/cell/gold_sell_cell"
|
||||
|
||||
local PAGE_DISCOUNT_CHAPTER_SELL_CELL = "app/ui/shop/cell/chapter_sell_cell" -- 章节
|
||||
local PAGE_DISCOUNT_BEGINNER_SELL_CELL = "app/ui/shop/cell/beginner_sell_cell" -- 新手
|
||||
local PAGE_DISCOUNT_LEVEL_SELL_CELL = "app/ui/shop/cell/level_sell_cell" -- 助力
|
||||
local PAGE_DISCOUNT_GROW_SELL_CELL = "app/ui/shop/cell/grow_sell_cell" -- 成长
|
||||
local PAGE_DISCOUNT_COIN_SELL_CELL = "app/ui/shop/cell/coin_sell_cell" -- 金币
|
||||
|
||||
function ShopComp:init()
|
||||
self.uiMap = self.baseObject:genAllChildren()
|
||||
|
||||
self.page = PAGE_MAIN -- 默认展示主要商品
|
||||
|
||||
self:initTitlePage()
|
||||
self:initMainPage()
|
||||
self:initDiscountPage()
|
||||
self.page = PAGE_MAIN
|
||||
self:switchPage(self.page)
|
||||
end
|
||||
|
||||
function ShopComp:initTitlePage()
|
||||
self.subTitleText1 = self.uiMap["shop_comp.title_node.btn_cell_1.text"]
|
||||
self.subTitleSelectText1 = self.uiMap["shop_comp.title_node.btn_cell_1.select_text"]
|
||||
self.subTitleIcon1 = self.uiMap["shop_comp.title_node.btn_cell_1.icon"]
|
||||
self.subTitleBtn1 = self.uiMap["shop_comp.title_node.btn_cell_1"]
|
||||
|
||||
self.subTitleText2 = self.uiMap["shop_comp.title_node.btn_cell_2.text"]
|
||||
self.subTitleSelectText2 = self.uiMap["shop_comp.title_node.btn_cell_2.select_text"]
|
||||
self.subTitleIcon2 = self.uiMap["shop_comp.title_node.btn_cell_2.icon"]
|
||||
self.subTitleBtn2 = self.uiMap["shop_comp.title_node.btn_cell_2"]
|
||||
|
||||
self.subTitleText1:setText("特惠商品TD") -- TODOJ 特惠商品
|
||||
self.subTitleSelectText1:setText("特惠商品TD") -- TODOJ 特惠商品
|
||||
self.subTitleText2:setText("主要商品TD") -- TODOJ 主要商品
|
||||
self.subTitleSelectText2:setText("主要商品TD") -- TODOJ 主要商品
|
||||
|
||||
self.subTitleBtn1:addClickListener(function()
|
||||
self:switchPage(PAGE_DISCOUNT)
|
||||
end)
|
||||
self.subTitleBtn2:addClickListener(function()
|
||||
self:switchPage(PAGE_MAIN)
|
||||
end)
|
||||
self:refreshTitle()
|
||||
end
|
||||
|
||||
function ShopComp:refreshTitle()
|
||||
if self.page == PAGE_DISCOUNT then
|
||||
self.subTitleText1:setAnchoredPositionY(GConst.NOT_VISIBLE_POS)
|
||||
self.subTitleSelectText1:setAnchoredPositionY(0)
|
||||
self.subTitleIcon1:setAnchoredPositionY(0)
|
||||
|
||||
self.subTitleText2:setAnchoredPositionY(0)
|
||||
self.subTitleSelectText2:setAnchoredPositionY(GConst.NOT_VISIBLE_POS)
|
||||
self.subTitleIcon2:setAnchoredPositionY(GConst.NOT_VISIBLE_POS)
|
||||
else
|
||||
self.subTitleText1:setAnchoredPositionY(0)
|
||||
self.subTitleSelectText1:setAnchoredPositionY(GConst.NOT_VISIBLE_POS)
|
||||
self.subTitleIcon1:setAnchoredPositionY(GConst.NOT_VISIBLE_POS)
|
||||
|
||||
self.subTitleText2:setAnchoredPositionY(GConst.NOT_VISIBLE_POS)
|
||||
self.subTitleSelectText2:setAnchoredPositionY(0)
|
||||
self.subTitleIcon2:setAnchoredPositionY(0)
|
||||
end
|
||||
end
|
||||
|
||||
function ShopComp:switchPage(page)
|
||||
if self.page ~= page then
|
||||
self.page = page
|
||||
self:refresh()
|
||||
end
|
||||
end
|
||||
|
||||
function ShopComp:initMainPage()
|
||||
self.mainNode = self.uiMap["shop_comp.main"]
|
||||
local scrollrect = self.uiMap["shop_comp.scrollrect"]
|
||||
local scrollrect = self.uiMap["shop_comp.main.scrollrect"]
|
||||
local height = self.baseObject:getTransform().rect.height
|
||||
height = height - TOP_HEIGHT - BOTTOM_HEIGHT
|
||||
height = height - TITLE_HEIGHT - TOP_HEIGHT - BOTTOM_HEIGHT
|
||||
local safeHeight = SafeAreaManager:getNotchScreenHeight()
|
||||
height = height - safeHeight
|
||||
scrollrect:setSizeDeltaY(height)
|
||||
|
||||
self.mainScrollContent = self.uiMap["shop_comp.main.scrollrect.viewport.content"]
|
||||
self.boxSellCell = self.uiMap["shop_comp.main.scrollrect.viewport.content.box_sell_cell"]:addLuaComponent(PAGE_MAIN_BOX_SELL_CELL)
|
||||
self.hotSellCell = self.uiMap["shop_comp.main.scrollrect.viewport.content.hot_sell_cell"]:addLuaComponent(PAGE_MAIN_HOT_SELL_CELL)
|
||||
@ -34,6 +96,18 @@ end
|
||||
|
||||
function ShopComp:initDiscountPage()
|
||||
self.discountNode = self.uiMap["shop_comp.discount"]
|
||||
local scrollrect = self.uiMap["shop_comp.discount.scrollrect"]
|
||||
local height = self.baseObject:getTransform().rect.height
|
||||
height = height - TITLE_HEIGHT - TOP_HEIGHT - BOTTOM_HEIGHT
|
||||
local safeHeight = SafeAreaManager:getNotchScreenHeight()
|
||||
height = height - safeHeight
|
||||
scrollrect:setSizeDeltaY(height)
|
||||
self.discountContent = self.uiMap["shop_comp.discount.scrollrect.viewport.content"]
|
||||
self.chapterSellCell = self.uiMap["shop_comp.discount.scrollrect.viewport.content.chapter_sell_cell"]:addLuaComponent(PAGE_DISCOUNT_CHAPTER_SELL_CELL)
|
||||
self.beginnerSellCell = self.uiMap["shop_comp.discount.scrollrect.viewport.content.beginner_sell_cell"]:addLuaComponent(PAGE_DISCOUNT_BEGINNER_SELL_CELL)
|
||||
self.levelSellCell = self.uiMap["shop_comp.discount.scrollrect.viewport.content.level_sell_cell"]:addLuaComponent(PAGE_DISCOUNT_LEVEL_SELL_CELL)
|
||||
self.growSellCell = self.uiMap["shop_comp.discount.scrollrect.viewport.content.grow_sell_cell"]:addLuaComponent(PAGE_DISCOUNT_GROW_SELL_CELL)
|
||||
self.coinSellCell = self.uiMap["shop_comp.discount.scrollrect.viewport.content.coin_sell_cell"]:addLuaComponent(PAGE_DISCOUNT_COIN_SELL_CELL)
|
||||
end
|
||||
|
||||
function ShopComp:updateMainList()
|
||||
@ -43,16 +117,69 @@ function ShopComp:refresh()
|
||||
if self.page == PAGE_DISCOUNT then
|
||||
self.mainNode:setAnchoredPositionX(GConst.NOT_VISIBLE_POS)
|
||||
self.discountNode:setAnchoredPositionX(0)
|
||||
self:refreshDiscountPage()
|
||||
else
|
||||
self.mainNode:setAnchoredPositionX(0)
|
||||
self.discountNode:setAnchoredPositionX(GConst.NOT_VISIBLE_POS)
|
||||
self:refreshMainPage()
|
||||
end
|
||||
self:refreshTitle()
|
||||
self:refreshDiscountPage()
|
||||
self:refreshMainPage()
|
||||
end
|
||||
|
||||
function ShopComp:refreshDiscountPage()
|
||||
|
||||
local y = 0
|
||||
local cellHeight = 0
|
||||
-- 章节
|
||||
if self.chapterSellCell:getIsOpen() then
|
||||
self.chapterSellCell:setVisible(true)
|
||||
self.chapterSellCell:refresh()
|
||||
self.chapterSellCell:getBaseObject():setAnchoredPositionY(0)
|
||||
cellHeight = self.chapterSellCell:getCellHeight()
|
||||
y = y + cellHeight
|
||||
else
|
||||
self.chapterSellCell:setVisible(false)
|
||||
end
|
||||
-- 新手
|
||||
if self.beginnerSellCell:getIsOpen() then
|
||||
self.beginnerSellCell:setVisible(true)
|
||||
self.beginnerSellCell:refresh()
|
||||
self.beginnerSellCell:getBaseObject():setAnchoredPositionY(-y)
|
||||
cellHeight = self.beginnerSellCell:getCellHeight()
|
||||
y = y + cellHeight
|
||||
else
|
||||
self.beginnerSellCell:setVisible(false)
|
||||
end
|
||||
-- 助力
|
||||
if self.levelSellCell:getIsOpen() then
|
||||
self.levelSellCell:setVisible(true)
|
||||
self.levelSellCell:refresh()
|
||||
self.levelSellCell:getBaseObject():setAnchoredPositionY(-y)
|
||||
cellHeight = self.levelSellCell:getCellHeight()
|
||||
y = y + cellHeight
|
||||
else
|
||||
self.levelSellCell:setVisible(false)
|
||||
end
|
||||
-- 成长
|
||||
if self.growSellCell:getIsOpen() then
|
||||
self.growSellCell:setVisible(true)
|
||||
self.growSellCell:refresh()
|
||||
self.growSellCell:getBaseObject():setAnchoredPositionY(-y)
|
||||
cellHeight = self.growSellCell:getCellHeight()
|
||||
y = y + cellHeight
|
||||
else
|
||||
self.growSellCell:setVisible(false)
|
||||
end
|
||||
-- 金币
|
||||
if self.coinSellCell:getIsOpen() then
|
||||
self.coinSellCell:setVisible(true)
|
||||
self.coinSellCell:refresh()
|
||||
self.coinSellCell:getBaseObject():setAnchoredPositionY(-y)
|
||||
cellHeight = self.coinSellCell:getCellHeight()
|
||||
y = y + cellHeight
|
||||
else
|
||||
self.coinSellCell:setVisible(false)
|
||||
end
|
||||
self.discountContent:setSizeDeltaY(y)
|
||||
end
|
||||
|
||||
function ShopComp:refreshMainPage()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user