368 lines
13 KiB
Lua
368 lines
13 KiB
Lua
local ShopComp = class("ShopComp", LuaComponent)
|
|
|
|
local CHAPTER_CELL = "app/ui/shop/cell/chapter_cell"
|
|
local CORE_SOUL_MAIN_CELL = "app/ui/shop/cell/core_soul_main_cell"
|
|
local DAILY_MAIN_CELL = "app/ui/shop/cell/daily_main_cell"
|
|
local GEM_MAIN_CELL = "app/ui/shop/cell/gem_main_cell"
|
|
local GOLD_MAIN_CELL = "app/ui/shop/cell/gold_main_cell"
|
|
local SKIN_CELL = "app/ui/shop/cell/force_skin_shop_cell"
|
|
|
|
local PAGE_TYPE = {
|
|
SHOP = 1,
|
|
SKIN = 2,
|
|
}
|
|
|
|
function ShopComp:init()
|
|
local uiMap = self.baseObject:genAllChildren()
|
|
self.bg = uiMap["shop_comp.bg"]
|
|
self.scrollrectNode = uiMap["shop_comp.bg.scrollrect"]
|
|
self.chapterTitleBg = uiMap["shop_comp.bg.scrollrect.viewport.content.chapter_title_bg"]
|
|
self.coreSoulTitleBg = uiMap["shop_comp.bg.scrollrect.viewport.content.core_soul_title_bg"]
|
|
self.dailyTitleBg = uiMap["shop_comp.bg.scrollrect.viewport.content.daily_title_bg"]
|
|
self.gemTitleBg = uiMap["shop_comp.bg.scrollrect.viewport.content.gem_title_bg"]
|
|
self.goldTitleBg = uiMap["shop_comp.bg.scrollrect.viewport.content.gold_title_bg"]
|
|
self.goldCd = uiMap["shop_comp.bg.scrollrect.viewport.content.gold_title_bg.cd"]
|
|
self.content = uiMap["shop_comp.bg.scrollrect.viewport.content"]
|
|
self.chapterContent = uiMap["shop_comp.bg.scrollrect.viewport.content.chapter_scrollrect.viewport.content"]
|
|
|
|
uiMap["shop_comp.bg.scrollrect.viewport.content.chapter_title_bg.title"]:setText(I18N:getGlobalText(I18N.GlobalConst.SHOP_DESC_10))
|
|
uiMap["shop_comp.bg.scrollrect.viewport.content.core_soul_title_bg.title"]:setText(I18N:getGlobalText(I18N.GlobalConst.CORE_SUMMON_DESC_13))
|
|
uiMap["shop_comp.bg.scrollrect.viewport.content.daily_title_bg.title"]:setText(I18N:getGlobalText(I18N.GlobalConst.SHOP_DESC_28))
|
|
uiMap["shop_comp.bg.scrollrect.viewport.content.gem_title_bg.title"]:setText(ModuleManager.ItemManager:getItemName(GConst.ItemConst.ITEM_ID_GEM))
|
|
uiMap["shop_comp.bg.scrollrect.viewport.content.gold_title_bg.title"]:setText(ModuleManager.ItemManager:getItemName(GConst.ItemConst.ITEM_ID_GOLD))
|
|
|
|
self.chapterScrollrect = uiMap["shop_comp.bg.scrollrect.viewport.content.chapter_scrollrect"]
|
|
-- self.coreSoulMainCell = uiMap["shop_comp.bg.scrollrect.viewport.content.core_soul_main_cell"]
|
|
self.dailyCell = uiMap["shop_comp.bg.scrollrect.viewport.content.daily_cell"]
|
|
self.gemCell = uiMap["shop_comp.bg.scrollrect.viewport.content.gem_cell"]
|
|
self.goldCell = uiMap["shop_comp.bg.scrollrect.viewport.content.gold_cell"]
|
|
|
|
local scrollrect = uiMap["shop_comp.bg.scrollrect.viewport.content.chapter_scrollrect"]
|
|
self.chapterScrollrectComp = scrollrect:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
|
self.chapterScrollrectComp:addInitCallback(function()
|
|
return CHAPTER_CELL
|
|
end)
|
|
self.chapterScrollrectComp:addRefreshCallback(function(idx, cell)
|
|
if self.chapterList[idx] then
|
|
cell:refresh(self.chapterList[idx], idx, #self.chapterList, function (add)
|
|
self.chapterContent:addAnchoredPosition(add * 670)
|
|
end)
|
|
end
|
|
end)
|
|
self.chapterScrollrectComp:clearCells()
|
|
|
|
self.dailyCells = {}
|
|
for i = 1, 3 do
|
|
self.dailyCells[i] = uiMap["shop_comp.bg.scrollrect.viewport.content.new_cell"]
|
|
end
|
|
|
|
self.scrollrectSkinNode = uiMap["shop_comp.bg.scrollrect_skin"]
|
|
self.txTitleSkin = uiMap["shop_comp.bg.scrollrect_skin.title.tx_title"]
|
|
|
|
-- 页签
|
|
self.tagNode = uiMap["shop_comp.bg.tag"]
|
|
self.btnShop = uiMap["shop_comp.bg.tag.btn_shop"]
|
|
self.txShop = uiMap["shop_comp.bg.tag.btn_shop.tx_desc"]
|
|
self.btnSkin = uiMap["shop_comp.bg.tag.btn_skin"]
|
|
self.txSkin = uiMap["shop_comp.bg.tag.btn_skin.tx_desc"]
|
|
|
|
self.btnShopSoul = uiMap["shop_comp.bg.scrollrect.viewport.content.core_soul_title_bg.btn_shop_soul"]
|
|
self.imgShopIcon = uiMap["shop_comp.bg.scrollrect.viewport.content.core_soul_title_bg.btn_shop_soul.bg.img_shop_icon"]
|
|
self.txShopNum = uiMap["shop_comp.bg.scrollrect.viewport.content.core_soul_title_bg.btn_shop_soul.bg.tx_shop_num"]
|
|
self.soulSpine = uiMap["shop_comp.bg.scrollrect.viewport.content.core_soul_title_bg.btn_shop_soul.ui_spine_obj"]
|
|
|
|
self.curPage = PAGE_TYPE.SHOP
|
|
self.txShop:setText(I18N:getGlobalText(I18N.GlobalConst.MAIN_BTN_1))
|
|
self.txSkin:setText(I18N:getGlobalText(I18N.GlobalConst.SKIN_FORCE_DESC_4))
|
|
self.txTitleSkin:setText(I18N:getGlobalText(I18N.GlobalConst.SKIN_FORCE_DESC_5))
|
|
|
|
self.btnShop:addClickListener(function()
|
|
if self.curPage == PAGE_TYPE.SHOP then
|
|
return
|
|
end
|
|
self.curPage = PAGE_TYPE.SHOP
|
|
self:refresh()
|
|
end)
|
|
self.btnSkin:addClickListener(function()
|
|
if self.curPage == PAGE_TYPE.SKIN then
|
|
return
|
|
end
|
|
self.curPage = PAGE_TYPE.SKIN
|
|
self:refresh()
|
|
end)
|
|
|
|
self.btnShopSoul:addClickListener(function()
|
|
ModuleManager.SummonManager:showSummonShopCommerceUI(3)
|
|
end)
|
|
self:bind(DataManager.ShopData, "isDirty", function()
|
|
self:refresh(nil, true)
|
|
end)
|
|
-- self:bind(DataManager.HeroData, "isDirty", function()
|
|
-- self:refresh(nil, true)
|
|
-- end)
|
|
|
|
-- self:bind(DataManager.ForceEquipData, "isDirty", function()
|
|
-- self:refresh(nil, true)
|
|
-- end)
|
|
-- self:bind(DataManager.CollectionData, "isDirty", function()
|
|
-- self:refresh(nil, true)
|
|
-- end)
|
|
-- self:bind(DataManager.BagData.ItemData, "isDirty", function(binder, value)
|
|
-- self:refresh(nil, true)
|
|
-- end)
|
|
self:bind(DataManager.PaymentData, "isDirty", function()
|
|
self:refresh(nil, true)
|
|
end)
|
|
|
|
-- local rect = self.baseObject:getRectSize()
|
|
-- local height = rect.height - 390
|
|
-- self.bgHeight = math.max(height, 1015)
|
|
-- self.bg:setSizeDeltaY(self.bgHeight)
|
|
|
|
-- 审核模式屏蔽皮肤
|
|
-- self.btnSkin:setActive(not GFunc.isShenhe())
|
|
end
|
|
|
|
function ShopComp:refresh(showIdx, noShowIdx)
|
|
-- if showIdx ~= nil then
|
|
-- if showIdx == ModuleManager.ShopManager.COMMERCE_TYPE.FORCE_SKIN then
|
|
-- self.curPage = PAGE_TYPE.SKIN
|
|
-- else
|
|
-- self.curPage = PAGE_TYPE.SHOP
|
|
-- end
|
|
-- end
|
|
|
|
-- if self.curPage == PAGE_TYPE.SHOP then
|
|
-- self:refreshShop(showIdx, noShowIdx)
|
|
-- elseif self.curPage == PAGE_TYPE.SKIN then
|
|
-- self:refreshSkin()
|
|
-- end
|
|
|
|
-- self.btnShop:setSprite(GConst.ATLAS_PATH.COMMON, self.curPage == PAGE_TYPE.SHOP and "common_menu_6" or "common_menu_5")
|
|
-- self.btnSkin:setSprite(GConst.ATLAS_PATH.COMMON, self.curPage == PAGE_TYPE.SKIN and "common_menu_6" or "common_menu_5")
|
|
self:refreshShop(showIdx, noShowIdx)
|
|
|
|
-- if DataManager.ShopData:showRedPoint() then
|
|
-- self.btnShop:addRedPoint(75, 23, 0.9)
|
|
-- else
|
|
-- self.btnShop:removeRedPoint()
|
|
-- end
|
|
end
|
|
|
|
function ShopComp:updateTime()
|
|
end
|
|
|
|
function ShopComp:refreshShop(showIdx, noShowIdx)
|
|
self.scrollrectNode:setActive(true)
|
|
self.scrollrectSkinNode:setActive(false)
|
|
|
|
self.showIdx = showIdx or self.showIdx
|
|
self:updateList(noShowIdx)
|
|
|
|
-- if self.showIdx then -- 指定跳转
|
|
-- if self.showIdx == ModuleManager.ShopManager.COMMERCE_TYPE.CHAPTER_GIFT then
|
|
-- BIReportV2:postOperation(BIReportV2.OPERATION_UI_NAME.SHOP_CHAPTER)
|
|
-- elseif self.showIdx == ModuleManager.ShopManager.COMMERCE_TYPE.DAILY_STORE then
|
|
-- BIReportV2:postOperation(BIReportV2.OPERATION_UI_NAME.SHOP_DAILY_STORE)
|
|
-- elseif self.showIdx == ModuleManager.ShopManager.COMMERCE_TYPE.GEM_STORE then
|
|
-- BIReportV2:postOperation(BIReportV2.OPERATION_UI_NAME.SHOP_GEM_STORE)
|
|
-- elseif self.showIdx == ModuleManager.ShopManager.COMMERCE_TYPE.GOLD_STORE then
|
|
-- BIReportV2:postOperation(BIReportV2.OPERATION_UI_NAME.SHOP_GOLD_STORE)
|
|
-- else
|
|
-- BIReportV2:postOperation(BIReportV2.OPERATION_UI_NAME.MAIN_SHOP)
|
|
-- end
|
|
-- else
|
|
-- BIReportV2:postOperation(BIReportV2.OPERATION_UI_NAME.MAIN_SHOP)
|
|
-- end
|
|
self.showIdx = nil
|
|
end
|
|
|
|
function ShopComp:refreshSkin()
|
|
self.scrollrectNode:setActive(false)
|
|
self.scrollrectSkinNode:setActive(true)
|
|
|
|
local list = DataManager.ForceData:getSkinIdsShopSort()
|
|
if self.scrollrectSkinComp == nil then
|
|
self.scrollrectSkinComp = self.scrollrectSkinNode:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
|
self.scrollrectSkinComp:addInitCallback(function()
|
|
return SKIN_CELL
|
|
end)
|
|
self.scrollrectSkinComp:addRefreshCallback(function(index, cell)
|
|
cell:refresh(list[index])
|
|
end)
|
|
end
|
|
local count = #list
|
|
if self.scrollrectSkinComp:getTotalCount() == nil or self.scrollrectSkinComp:getTotalCount() <= 0 then
|
|
self.scrollrectSkinComp:refillCells(count)
|
|
elseif self.scrollrectSkinComp:getTotalCount() ~= count then
|
|
self.scrollrectSkinComp:clearCells()
|
|
self.scrollrectSkinComp:refillCells(count)
|
|
else
|
|
self.scrollrectSkinComp:updateAllCell()
|
|
end
|
|
end
|
|
|
|
function ShopComp:updateList(noShowIdx)
|
|
local height = -80
|
|
height = self:updateChapterList(height)
|
|
-- height = self:updateCoreSoulCell(height)
|
|
height = self:updateDailyCell(height)
|
|
height = self:updateGemCell(height)
|
|
height = self:updateGoldCell(height)
|
|
height = height - 50
|
|
|
|
self.content:setSizeDeltaY(math.abs(height))
|
|
|
|
local scrollHeight = self.scrollrectNode:getRectHeight()
|
|
local maxPosY = math.abs(height) - scrollHeight
|
|
|
|
if not noShowIdx and self.beginPosY then
|
|
self.content:setAnchoredPositionY(math.min(maxPosY, self.beginPosY))
|
|
elseif not noShowIdx and self.rpPosY then
|
|
self.content:setAnchoredPositionY(math.min(maxPosY, self.rpPosY - 80))
|
|
end
|
|
self.beginPosY = nil
|
|
self.rpPosY = nil
|
|
end
|
|
|
|
function ShopComp:updateChapterList(offsetY)
|
|
-- 没有新手礼包
|
|
if CS.BF.BFMain.IsShenhe then
|
|
self.chapterTitleBg:setActive(false)
|
|
self.chapterScrollrect:setActive(false)
|
|
self.chapterScrollrect:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_SCROLL_RECT).enabled = false
|
|
return offsetY
|
|
end
|
|
|
|
self.chapterList = DataManager.GiftPopData:getPopGiftListByGiftType(PayManager.PURCHARSE_ACT_TYPE.GIFT_POP_CHAPTER)
|
|
if #self.chapterList <= 0 then
|
|
self.chapterTitleBg:setActive(false)
|
|
self.chapterScrollrect:setActive(false)
|
|
self.chapterScrollrect:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_SCROLL_RECT).enabled = false
|
|
return offsetY
|
|
else
|
|
self.chapterTitleBg:setActive(true)
|
|
self.chapterScrollrect:setActive(true)
|
|
self.chapterScrollrect:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_SCROLL_RECT).enabled = true
|
|
end
|
|
|
|
if self.showIdx == ModuleManager.ShopManager.COMMERCE_TYPE.CHAPTER_GIFT then
|
|
self.beginPosY = math.abs(offsetY)
|
|
end
|
|
|
|
self.chapterTitleBg:setAnchoredPositionY(offsetY)
|
|
offsetY = offsetY -75
|
|
self.chapterScrollrect:setAnchoredPositionY(offsetY)
|
|
offsetY = offsetY - 390
|
|
|
|
local currCount = self.chapterScrollrectComp:getTotalCount()
|
|
self.chapterScrollrectComp:refillCells(#self.chapterList)
|
|
if currCount == nil or currCount <= 0 then
|
|
self.chapterContent:setAnchoredPositionX(-(#self.chapterList-1)*670)
|
|
end
|
|
return offsetY
|
|
end
|
|
|
|
-- function ShopComp:updateCoreSoulCell(offsetY)
|
|
-- -- self.imgShopIcon:setSprite(GConst.ATLAS_PATH.ICON_ITEM, ModuleManager.ItemManager:getItemIcon(GConst.ItemConst.SOUL_SHOP_GOLD))
|
|
-- -- self.txShopNum:setText(DataManager.BagData.ItemData:getItemNumById(GConst.ItemConst.SOUL_SHOP_GOLD))
|
|
-- self.txShopNum:setText(I18N:getGlobalText(I18N.GlobalConst.CORE_SUMMON_DESC_21))
|
|
-- self.coreSoulTitleBg:setActive(false)
|
|
-- self.coreSoulMainCell:setActive(false)
|
|
|
|
-- if DataManager.SummonData:getSummonShopSoulUnlock(3) then
|
|
-- self.soulSpine:setActive(true)
|
|
-- else
|
|
-- self.soulSpine:setActive(false)
|
|
-- end
|
|
|
|
-- if not DataManager.ShopData:isCoreSoulOpen() then
|
|
-- return offsetY
|
|
-- end
|
|
-- self.coreSoulTitleBg:setActive(true)
|
|
-- self.coreSoulMainCell:setActive(true)
|
|
-- if self.showIdx == ModuleManager.ShopManager.COMMERCE_TYPE.CORE_SOUL_STORE then
|
|
-- self.beginPosY = math.abs(offsetY)
|
|
-- end
|
|
-- if self.rpPosY == nil then
|
|
-- self.rpPosY = DataManager.ShopData:hasCoreSoulRedPoint() and math.abs(offsetY) or nil
|
|
-- end
|
|
|
|
-- self.coreSoulTitleBg:setAnchoredPositionY(offsetY)
|
|
-- offsetY = offsetY - 75
|
|
-- self.coreSoulMainCell:setAnchoredPositionY(offsetY)
|
|
-- offsetY = offsetY - 450
|
|
|
|
-- local cell = self.coreSoulMainCell:addLuaComponent(CORE_SOUL_MAIN_CELL)
|
|
-- cell:refresh()
|
|
|
|
-- return offsetY
|
|
-- end
|
|
|
|
function ShopComp:updateDailyCell(offsetY)
|
|
self.dailyCell:setActive(false)
|
|
self.dailyTitleBg:setActive(false)
|
|
if not DataManager.ShopData:isDailyOpen() then
|
|
return offsetY
|
|
end
|
|
self.dailyTitleBg:setActive(true)
|
|
self.dailyCell:setActive(true)
|
|
if self.showIdx == ModuleManager.ShopManager.COMMERCE_TYPE.DAILY_STORE then
|
|
self.beginPosY = math.abs(offsetY)
|
|
end
|
|
if self.rpPosY == nil then
|
|
self.rpPosY = DataManager.ShopData:hasDailyRedPoint() and math.abs(offsetY) or nil
|
|
end
|
|
|
|
self.dailyTitleBg:setAnchoredPositionY(offsetY)
|
|
offsetY = offsetY - 96
|
|
self.dailyCell:setAnchoredPositionY(offsetY)
|
|
offsetY = offsetY - 670
|
|
|
|
local cell = self.dailyCell:addLuaComponent(DAILY_MAIN_CELL)
|
|
cell:refresh()
|
|
|
|
return offsetY
|
|
end
|
|
|
|
function ShopComp:updateGemCell(offsetY)
|
|
if self.showIdx == ModuleManager.ShopManager.COMMERCE_TYPE.GEM_STORE then
|
|
self.beginPosY = math.abs(offsetY)
|
|
end
|
|
|
|
self.gemTitleBg:setAnchoredPositionY(offsetY)
|
|
offsetY = offsetY - 70
|
|
self.gemCell:setAnchoredPositionY(offsetY)
|
|
if CS.BF.BFMain.IsShenhe then
|
|
offsetY = offsetY - 1762
|
|
else
|
|
offsetY = offsetY - 615
|
|
end
|
|
local cell = self.gemCell:addLuaComponent(GEM_MAIN_CELL)
|
|
cell:refresh()
|
|
|
|
return offsetY
|
|
end
|
|
|
|
function ShopComp:updateGoldCell(offsetY)
|
|
self.goldTitleBg:setActive(true)
|
|
self.goldCell:setActive(true)
|
|
if self.showIdx == ModuleManager.ShopManager.COMMERCE_TYPE.GOLD_STORE then
|
|
self.beginPosY = math.abs(offsetY)
|
|
end
|
|
if self.rpPosY == nil then
|
|
self.rpPosY = DataManager.ShopData:hasGoldRedPoint() and math.abs(offsetY) or nil
|
|
end
|
|
|
|
self.goldTitleBg:setAnchoredPositionY(offsetY)
|
|
offsetY = offsetY - 70
|
|
self.goldCell:setAnchoredPositionY(offsetY)
|
|
offsetY = offsetY - 322
|
|
|
|
local cell = self.goldCell:addLuaComponent(GOLD_MAIN_CELL)
|
|
cell:refresh()
|
|
|
|
return offsetY
|
|
end
|
|
|
|
return ShopComp |