珍奇宝阁预设代码提交
parent
451a279458
commit
442877d3e0
File diff suppressed because it is too large
Load Diff
|
@ -12,11 +12,16 @@ local _PageInfo = {--后期可以做成tableInsert,icon名字都去读表
|
||||||
[2] = { --乾坤宝盒
|
[2] = { --乾坤宝盒
|
||||||
default = "q_qiankun_baoheanniu_02", lock = "q_qiankun_baoheanniu_02", select = "q_qiankun_baoheanniu_01",
|
default = "q_qiankun_baoheanniu_02", lock = "q_qiankun_baoheanniu_02", select = "q_qiankun_baoheanniu_01",
|
||||||
rpType = RedPointType.QianKunBox,panelType = PanelType.QianKunBox,
|
rpType = RedPointType.QianKunBox,panelType = PanelType.QianKunBox,
|
||||||
},
|
},
|
||||||
|
[3] = { --珍奇礼包
|
||||||
|
default = "z_zhenqibaoge_anniu_02", lock = "z_zhenqibaoge_anniu_02", select = "z_zhenqibaoge_anniu_01",
|
||||||
|
rpType = RedPointType.QianKunBox,panelType = PanelType.QianKunBox,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
local TimeLimitedCall = require("Modules/Operating/TimeLimitedCall")
|
local TimeLimitedCall = require("Modules/Operating/TimeLimitedCall")
|
||||||
local QianKunBox = require("Modules/Operating/QianKunBox")
|
local QianKunBox = require("Modules/Operating/QianKunBox")
|
||||||
|
local ZhenQiYiBaoPage=require("Modules/Operating/ZhenQiYiBaoPage")
|
||||||
--初始化组件(用于子类重写)
|
--初始化组件(用于子类重写)
|
||||||
function DynamicActivityPanel:InitComponent()
|
function DynamicActivityPanel:InitComponent()
|
||||||
orginLayer = 0
|
orginLayer = 0
|
||||||
|
@ -26,7 +31,8 @@ function DynamicActivityPanel:InitComponent()
|
||||||
|
|
||||||
this.PageList = {
|
this.PageList = {
|
||||||
[1] = TimeLimitedCall.new(self, Util.GetGameObject(self.transform, "bg/pageContent/page_1")),
|
[1] = TimeLimitedCall.new(self, Util.GetGameObject(self.transform, "bg/pageContent/page_1")),
|
||||||
[2] = QianKunBox.new(self, Util.GetGameObject(self.transform, "bg/pageContent/page_2"))
|
[2] = QianKunBox.new(self, Util.GetGameObject(self.transform, "bg/pageContent/page_2")),
|
||||||
|
[3] = ZhenQiYiBaoPage.new(self, Util.GetGameObject(self.transform, "bg/pageContent/page_4")),
|
||||||
}
|
}
|
||||||
|
|
||||||
-- 上部货币显示
|
-- 上部货币显示
|
||||||
|
@ -99,8 +105,11 @@ end
|
||||||
function this.OnPageTabChange(index, lastIndex)
|
function this.OnPageTabChange(index, lastIndex)
|
||||||
this._CurPageIndex = index
|
this._CurPageIndex = index
|
||||||
for i = 1, #this.PageList do
|
for i = 1, #this.PageList do
|
||||||
this.PageList[i]:OnHide()
|
if this.PageList[i] then
|
||||||
this.PageList[i].gameObject:SetActive(false)
|
this.PageList[i]:OnHide()
|
||||||
|
this.PageList[i].gameObject:SetActive(false)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
this.PageList[index]:OnShow(this.sortingOrder, _PageInfo[index].params and unpack(_PageInfo[index].params) or nil)
|
this.PageList[index]:OnShow(this.sortingOrder, _PageInfo[index].params and unpack(_PageInfo[index].params) or nil)
|
||||||
this.PageList[index].gameObject:SetActive(true)
|
this.PageList[index].gameObject:SetActive(true)
|
||||||
|
|
|
@ -153,13 +153,16 @@ end
|
||||||
--- 获取商品已经购买次数
|
--- 获取商品已经购买次数
|
||||||
function this.GetGoodsBuyTime(type, goodsId)
|
function this.GetGoodsBuyTime(type, goodsId)
|
||||||
if not giftGoodsInfoList[type] then
|
if not giftGoodsInfoList[type] then
|
||||||
return
|
--王振兴添加 防止没有查询到数据报错
|
||||||
|
return 0
|
||||||
end
|
end
|
||||||
for k,v in pairs(giftGoodsInfoList[type]) do
|
for k,v in pairs(giftGoodsInfoList[type]) do
|
||||||
if v.goodsId == goodsId then
|
if v.goodsId == goodsId then
|
||||||
return v.buyTimes
|
return v.buyTimes
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
--王振兴添加 防止没有查询到数据报错
|
||||||
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,170 @@
|
||||||
|
local ZhenQiYiBaoPage = quick_class("ZhenQiYiBaoPage")
|
||||||
|
local allData={}
|
||||||
|
local itemsGrid = {}--item重复利用
|
||||||
|
local this=ZhenQiYiBaoPage
|
||||||
|
function ZhenQiYiBaoPage:ctor(mainPanel, gameObject)
|
||||||
|
self.mainPanel = mainPanel
|
||||||
|
self.gameObject = gameObject
|
||||||
|
self:InitComponent(gameObject)
|
||||||
|
self:BindEvent()
|
||||||
|
end
|
||||||
|
|
||||||
|
function ZhenQiYiBaoPage:InitComponent(gameObject)
|
||||||
|
|
||||||
|
this.itemPre = Util.GetGameObject(gameObject, "ItemPre3")
|
||||||
|
this.scrollItem = Util.GetGameObject(gameObject, "scrollItem")
|
||||||
|
local rootHight = this.scrollItem.transform.rect.height
|
||||||
|
local width = this.scrollItem.transform.rect.width
|
||||||
|
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.scrollItem.transform,
|
||||||
|
this.itemPre, nil, Vector2.New(width, rootHight), 1, 1, Vector2.New(0, 35))
|
||||||
|
this.ScrollView.moveTween.MomentumAmount = 1
|
||||||
|
this.ScrollView.moveTween.Strength = 2
|
||||||
|
end
|
||||||
|
|
||||||
|
--绑定事件(用于子类重写)
|
||||||
|
function ZhenQiYiBaoPage:BindEvent()
|
||||||
|
end
|
||||||
|
|
||||||
|
--添加事件监听(用于子类重写)
|
||||||
|
function ZhenQiYiBaoPage:AddListener()
|
||||||
|
Game.GlobalEvent:AddEvent(GameEvent.MoneyPay.OnPayResultSuccess, this.RechargeSuccessFunc)
|
||||||
|
end
|
||||||
|
|
||||||
|
--移除事件监听(用于子类重写)
|
||||||
|
function ZhenQiYiBaoPage:RemoveListener()
|
||||||
|
Game.GlobalEvent:RemoveEvent(GameEvent.MoneyPay.OnPayResultSuccess, this.RechargeSuccessFunc)
|
||||||
|
end
|
||||||
|
local sortingOrder = 0
|
||||||
|
--界面打开时调用(用于子类重写)
|
||||||
|
function ZhenQiYiBaoPage:OnOpen()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
||||||
|
function ZhenQiYiBaoPage:OnShow(_sortingOrder)
|
||||||
|
sortingOrder = _sortingOrder
|
||||||
|
this:OnShowData()
|
||||||
|
end
|
||||||
|
function ZhenQiYiBaoPage:OnShowData()
|
||||||
|
allData = ConfigManager.GetAllConfigsDataByDoubleKey(ConfigName.RechargeCommodityConfig, "ShowType", 23, "Type", GoodsTypeDef.DirectPurchaseGift)
|
||||||
|
if allData then
|
||||||
|
this.SortData(allData)
|
||||||
|
this.ScrollView:SetData(allData, function (index, go)
|
||||||
|
this.SingleDataShow(go, allData[index])
|
||||||
|
end)
|
||||||
|
LogError(#allData)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
function ZhenQiYiBaoPage:SortData()
|
||||||
|
if allData==nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
table.sort(allData, function(a,b)
|
||||||
|
local aboughtNum = a.Limit - OperatingManager.GetGoodsBuyTime(GoodsTypeDef.DirectPurchaseGift, a.Id) > 0 and 2 or 1
|
||||||
|
local bboughtNum = b.Limit - OperatingManager.GetGoodsBuyTime(GoodsTypeDef.DirectPurchaseGift, b.Id) > 0 and 2 or 1
|
||||||
|
if aboughtNum == bboughtNum then
|
||||||
|
return a.Id < b.Id
|
||||||
|
else
|
||||||
|
return aboughtNum > bboughtNum
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
--刷新每一条的显示数据
|
||||||
|
function this.SingleDataShow(pre,value)
|
||||||
|
if pre==nil or value==nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
--绑定组件
|
||||||
|
local shopItemData = value
|
||||||
|
local price = Util.GetGameObject(pre, "btnBuy/price"):GetComponent("Text")
|
||||||
|
local buyInfo = Util.GetGameObject(pre, "buyInfo")
|
||||||
|
local btnBuy = Util.GetGameObject(pre, "btnBuy")
|
||||||
|
local grid = Util.GetGameObject(pre, "scrollView/grid")
|
||||||
|
local shadow = Util.GetGameObject(pre, "shadow")
|
||||||
|
--local goodData = OperatingManager.GetGiftGoodsInfo(GoodsTypeDef.DirectPurchaseGift, value.Id)
|
||||||
|
local boughtNum = OperatingManager.GetGoodsBuyTime(GoodsTypeDef.DirectPurchaseGift, value.Id) or 0
|
||||||
|
local shows = shopItemData.RewardShow
|
||||||
|
buyInfo:GetComponent("Text").text ="("..Language[10556].. boughtNum.."/".. shopItemData.Limit..Language[10054] ..")"
|
||||||
|
if shopItemData.Limit - boughtNum > 0 then
|
||||||
|
price.text = shopItemData.Price..Language[10538]
|
||||||
|
btnBuy:GetComponent("Button").enabled = true
|
||||||
|
Util.SetGray(btnBuy, false)
|
||||||
|
else
|
||||||
|
price.text = Language[10539]
|
||||||
|
btnBuy:GetComponent("Button").enabled = false
|
||||||
|
Util.SetGray(btnBuy, true)
|
||||||
|
end
|
||||||
|
--滚动条复用重设itemview
|
||||||
|
if itemsGrid[pre] then
|
||||||
|
for i = 1, 4 do
|
||||||
|
itemsGrid[pre][i].gameObject:SetActive(false)
|
||||||
|
end
|
||||||
|
for i = 1, #shows do
|
||||||
|
if itemsGrid[pre][i] then
|
||||||
|
itemsGrid[pre][i]:OnOpen(false, {shows[i][1],shows[i][2]}, 0.9,false,false,false,cursortingOrder)
|
||||||
|
itemsGrid[pre][i].gameObject:SetActive(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
itemsGrid[pre]={}
|
||||||
|
for i = 1, 4 do
|
||||||
|
itemsGrid[pre][i] = SubUIManager.Open(SubUIConfig.ItemView, grid.transform)
|
||||||
|
itemsGrid[pre][i].gameObject:SetActive(false)
|
||||||
|
local obj= newObjToParent(shadow,itemsGrid[pre][i].transform)
|
||||||
|
obj.transform:SetAsFirstSibling()
|
||||||
|
obj.transform:DOAnchorPos(Vector3(0,-3,0),0)
|
||||||
|
obj:GetComponent("RectTransform").transform.localScale=Vector3.one*1.1
|
||||||
|
obj.gameObject:SetActive(true)
|
||||||
|
end
|
||||||
|
for i = 1, #shows do
|
||||||
|
itemsGrid[pre][i]:OnOpen(false, {shows[i][1],shows[i][2]}, 0.9,false,false,false,cursortingOrder)
|
||||||
|
itemsGrid[pre][i].gameObject:SetActive(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
--local costId, finalNum, oriCostNum = ShopManager.calculateBuyCost(SHOP_TYPE.FINDTREASURE_GIFT, data.id, 1)
|
||||||
|
Util.AddOnceClick(btnBuy, function()
|
||||||
|
if shopItemData.Limit <= boughtNum then
|
||||||
|
PopupTipPanel.ShowTip(Language[10540])
|
||||||
|
else
|
||||||
|
--直购商品
|
||||||
|
if AppConst.isSDKLogin then
|
||||||
|
PayManager.Pay({ Id = value.Id })
|
||||||
|
else
|
||||||
|
NetManager.RequestBuyGiftGoods(value.Id, function(msg)
|
||||||
|
FirstRechargeManager.RefreshAccumRechargeValue(value.Id)
|
||||||
|
-- OperatingManager.RefreshGiftGoodsBuyTimes(GoodsTypeDef.DirectPurchaseGift, data.goodsId) -- 改成后端推了
|
||||||
|
this.OnShowData()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
--界面打开时调用(用于子类重写)
|
||||||
|
function ZhenQiYiBaoPage:OnOpen()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function this.RechargeSuccessFunc(id)
|
||||||
|
FirstRechargeManager.RefreshAccumRechargeValue(id)
|
||||||
|
--OperatingManager.RefreshGiftGoodsBuyTimes(GoodsTypeDef.GiftBuy, id)
|
||||||
|
this.OnShowData()
|
||||||
|
end
|
||||||
|
|
||||||
|
function ZhenQiYiBaoPage:OnClose()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--界面销毁时调用(用于子类重写)
|
||||||
|
function ZhenQiYiBaoPage:OnDestroy()
|
||||||
|
|
||||||
|
sortingOrder = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function ZhenQiYiBaoPage:OnHide()
|
||||||
|
|
||||||
|
sortingOrder = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
return ZhenQiYiBaoPage
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0730fd842af9c9842b623978ef76f3ad
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue