2021-12-15 14:34:21 +08:00
|
|
|
|
local RechargeViewNew = {}
|
|
|
|
|
local growData = {}
|
|
|
|
|
function RechargeViewNew:New(gameObject)
|
|
|
|
|
local b = {}
|
|
|
|
|
b.gameObject = gameObject
|
|
|
|
|
b.transform = gameObject.transform
|
|
|
|
|
setmetatable(b, { __index = RechargeViewNew })
|
|
|
|
|
return b
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--添加事件监听(用于子类重写)
|
|
|
|
|
function RechargeViewNew:AddListener()
|
2021-12-16 11:59:18 +08:00
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.MoneyPay.OnPayResultSuccess,self.SetGrowGift,self)
|
2021-12-15 14:34:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
|
|
|
|
function RechargeViewNew:RemoveListener()
|
2021-12-16 11:59:18 +08:00
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.MoneyPay.OnPayResultSuccess,self.SetGrowGift,self)
|
2021-12-15 14:34:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function RechargeViewNew:InitComponent()
|
|
|
|
|
self.spLoader = SpriteLoader.New()
|
|
|
|
|
self.shopViewRoot = Util.GetGameObject(self.gameObject, "root")
|
|
|
|
|
if not self.shopView then
|
|
|
|
|
self.shopView = SubUIManager.Open(SubUIConfig.ShopView, self.shopViewRoot.transform)
|
|
|
|
|
-- 修改商品栏的位置
|
|
|
|
|
self.shopView:SetItemContentPosition(Vector3.New(0, 710, 0))
|
|
|
|
|
end
|
|
|
|
|
-- 显示特权信息
|
|
|
|
|
--===================成长礼包================
|
|
|
|
|
self.grow = Util.GetGameObject(self.gameObject,"growPack/Content")
|
|
|
|
|
self.tip = Util.GetGameObject(self.grow,"Tip"):GetComponent("Text")
|
|
|
|
|
self.icon = Util.GetGameObject(self.grow,"Icon"):GetComponent("Image")
|
2022-10-20 17:48:00 +08:00
|
|
|
|
self.name = Util.GetGameObject(self.grow,"Name"):GetComponent("Image")
|
|
|
|
|
self.name.sprite=self.spLoader:LoadSprite("gm_mingwang_title")
|
2021-12-15 14:34:21 +08:00
|
|
|
|
self.progress = Util.GetGameObject(self.grow,"Progress/Image")
|
|
|
|
|
self.value = Util.GetGameObject(self.grow,"Progress/Text"):GetComponent("Text")
|
|
|
|
|
self.reward = Util.GetGameObject(self.grow,"Reward")
|
|
|
|
|
self.btnLeft = Util.GetGameObject(self.grow,"btnLeft")
|
|
|
|
|
self.btnRight = Util.GetGameObject(self.grow,"btnRight")
|
|
|
|
|
self.btnGet = Util.GetGameObject(self.grow,"btnGet")
|
|
|
|
|
self.price = Util.GetGameObject(self.btnGet,"cost/Text"):GetComponent("Text")
|
|
|
|
|
self.cost = Util.GetGameObject(self.btnGet,"cost")
|
|
|
|
|
self.btnText = Util.GetGameObject(self.btnGet,"Text")
|
|
|
|
|
self.btnRed = Util.GetGameObject(self.btnGet,"red")
|
2022-01-17 13:16:18 +08:00
|
|
|
|
self.leftRed = Util.GetGameObject(self.btnLeft,"Red")
|
|
|
|
|
self.rightRed = Util.GetGameObject(self.btnRight,"Red")
|
2021-12-16 10:46:11 +08:00
|
|
|
|
self.endTimeBg = Util.GetGameObject(self.gameObject,"growPack/Time")
|
|
|
|
|
self.endTimeBg.gameObject:SetActive(false)
|
2021-12-15 14:34:21 +08:00
|
|
|
|
self.ItemList = {}
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
function RechargeViewNew:BindEvent()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
|
|
|
function RechargeViewNew:OnOpen(_activityConfig,_index,parent)
|
|
|
|
|
self.actConfig = _activityConfig
|
|
|
|
|
self.pageIndex = _index
|
|
|
|
|
self.parent = parent
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function RechargeViewNew:OnSortingOrderChange()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function RechargeViewNew:OnShow(_sortingOrder)
|
|
|
|
|
self.gameObject:SetActive(true)
|
|
|
|
|
self.sortingOrder = _sortingOrder
|
|
|
|
|
self.shopView:ShowShop(SHOP_TYPE.SOUL_STONE_SHOP, self.sortingOrder)
|
|
|
|
|
self:SetGrowGift()
|
|
|
|
|
end
|
|
|
|
|
|
2022-01-17 13:16:18 +08:00
|
|
|
|
--==============================成长礼包部分==========================(rechargeViewNew和EveryDayGiftNew中有完全相同的部分,复制过去)
|
2021-12-15 14:34:21 +08:00
|
|
|
|
function RechargeViewNew:SetGrowGift()
|
2022-10-20 17:48:00 +08:00
|
|
|
|
growData = DynamicActivityManager.GetGiftDataByType({{2,95}})
|
|
|
|
|
local rechargeNum =BagManager.GetItemCountById(1351) --VipManager.GetChargedNum()--已经充值的金额
|
2021-12-15 14:34:21 +08:00
|
|
|
|
table.sort(growData,function (a,b)
|
|
|
|
|
return a.data.shopItemData.BuyRule[2] < b.data.shopItemData.BuyRule[2]
|
|
|
|
|
end)
|
2021-12-16 19:22:46 +08:00
|
|
|
|
--计算当前声望等级
|
2023-06-06 19:38:21 +08:00
|
|
|
|
if DynamicActivityManager.curLevel == 0 or DynamicActivityManager.curLevel == 1 then
|
2021-12-15 14:34:21 +08:00
|
|
|
|
for i = 1, #growData do
|
2022-10-20 17:48:00 +08:00
|
|
|
|
if rechargeNum < DynamicActivityManager.GetMingWangLv(growData[i].data.shopItemData.BuyRule[2]) then
|
2021-12-20 15:02:14 +08:00
|
|
|
|
if rechargeNum ~= 0 then
|
|
|
|
|
DynamicActivityManager.curLevel = i
|
|
|
|
|
if DynamicActivityManager.Index == 0 then
|
|
|
|
|
DynamicActivityManager.Index = DynamicActivityManager.curLevel
|
|
|
|
|
end
|
|
|
|
|
break
|
|
|
|
|
else
|
|
|
|
|
DynamicActivityManager.curLevel = 1
|
|
|
|
|
DynamicActivityManager.Index = 1
|
2021-12-17 11:28:37 +08:00
|
|
|
|
end
|
2021-12-15 14:34:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-12-16 19:22:46 +08:00
|
|
|
|
--如果所有都没有,说明超范围了
|
2021-12-17 11:28:37 +08:00
|
|
|
|
if DynamicActivityManager.curLevel == 0 then
|
|
|
|
|
DynamicActivityManager.curLevel = #growData
|
|
|
|
|
if DynamicActivityManager.Index == 0 then
|
2021-12-17 14:13:41 +08:00
|
|
|
|
DynamicActivityManager.Index = DynamicActivityManager.curLevel
|
2021-12-17 11:28:37 +08:00
|
|
|
|
end
|
2021-12-16 19:22:46 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-12-20 15:02:14 +08:00
|
|
|
|
Log("当前声望Level:"..tostring(DynamicActivityManager.curLevel).." Index:"..tostring(DynamicActivityManager.Index))
|
2021-12-16 19:22:46 +08:00
|
|
|
|
--如果有当前声望数据,就显示,没有就显示上一档位
|
2022-10-20 17:48:00 +08:00
|
|
|
|
--local data = not not growData[DynamicActivityManager.Index] and growData[DynamicActivityManager.Index] or growData[DynamicActivityManager.Index-1]
|
|
|
|
|
local data=growData[DynamicActivityManager.Index]
|
2023-06-06 17:16:28 +08:00
|
|
|
|
if data==nil then
|
|
|
|
|
return
|
|
|
|
|
end
|
2021-12-16 19:22:46 +08:00
|
|
|
|
self:RefreshReward(data)
|
|
|
|
|
|
2021-12-15 14:34:21 +08:00
|
|
|
|
Util.AddOnceClick(self.btnLeft,function ()
|
2021-12-16 19:22:46 +08:00
|
|
|
|
if growData[DynamicActivityManager.Index - 1] then
|
|
|
|
|
DynamicActivityManager.Index = DynamicActivityManager.Index - 1
|
|
|
|
|
self:RefreshReward(growData[DynamicActivityManager.Index])
|
2021-12-15 14:34:21 +08:00
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
Util.AddOnceClick(self.btnRight,function ()
|
2021-12-16 19:22:46 +08:00
|
|
|
|
if growData[DynamicActivityManager.Index + 1] then
|
|
|
|
|
DynamicActivityManager.Index = DynamicActivityManager.Index + 1
|
|
|
|
|
self:RefreshReward(growData[DynamicActivityManager.Index])
|
2021-12-15 14:34:21 +08:00
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
--刷新奖励、按钮显示
|
|
|
|
|
function RechargeViewNew:RefreshReward(Data)
|
2022-10-20 17:48:00 +08:00
|
|
|
|
local rechargeNum =BagManager.GetItemCountById(1351) --VipManager.GetChargedNum()--已经充值的金额
|
2021-12-16 19:22:46 +08:00
|
|
|
|
self.btnLeft:SetActive(not not growData[DynamicActivityManager.Index - 1])--左按钮显示
|
|
|
|
|
self.btnRight:SetActive(not not growData[DynamicActivityManager.Index + 1])--右按钮显示
|
|
|
|
|
-- LogPink(DynamicActivityManager.Index.." 金额:"..tostring(Data.data.shopItemData.BuyRule[2]).." 限购:"..tostring(Data.data.limitNum).." 已购:"..tostring(Data.data.boughtNum).." rechargeNum:"..tostring(rechargeNum))
|
2022-10-20 17:48:00 +08:00
|
|
|
|
local text = 1
|
2021-12-16 19:22:46 +08:00
|
|
|
|
local num = 0
|
|
|
|
|
if DynamicActivityManager.Index < 2 then
|
2023-08-29 17:58:24 +08:00
|
|
|
|
num = growData[1].data.shopItemData.BuyRule[2]
|
2021-12-16 19:22:46 +08:00
|
|
|
|
elseif DynamicActivityManager.Index + 1 > #growData then
|
2022-10-20 17:48:00 +08:00
|
|
|
|
text = #growData
|
2021-12-16 19:22:46 +08:00
|
|
|
|
num = growData[#growData].data.shopItemData.BuyRule[2]
|
|
|
|
|
else
|
2022-10-20 17:48:00 +08:00
|
|
|
|
text = DynamicActivityManager.Index
|
2021-12-16 19:22:46 +08:00
|
|
|
|
num = growData[DynamicActivityManager.Index].data.shopItemData.BuyRule[2]
|
|
|
|
|
end
|
2022-10-20 17:48:00 +08:00
|
|
|
|
num=DynamicActivityManager.GetMingWangLv(num)
|
|
|
|
|
local aaa=growData[DynamicActivityManager.curLevel].data.shopItemData.BuyRule[2]
|
2021-12-17 16:05:51 +08:00
|
|
|
|
if DynamicActivityManager.curLevel <= 2 then
|
2022-11-22 15:30:03 +08:00
|
|
|
|
--self.tip.text = string.format("再获得%s积分升至名望1",num - rechargeNum)
|
2022-10-20 17:48:00 +08:00
|
|
|
|
elseif DynamicActivityManager.curLevel + 1 >= #growData and rechargeNum >= DynamicActivityManager.GetMingWangLv(aaa) then
|
2022-11-22 15:30:03 +08:00
|
|
|
|
--self.tip.text = ""
|
2021-12-17 11:28:37 +08:00
|
|
|
|
else
|
2022-11-22 15:30:03 +08:00
|
|
|
|
--self.tip.text = string.format("再获得%s积分升至名望%s",DynamicActivityManager.GetMingWangLv(aaa) - rechargeNum,DynamicActivityManager.curLevel+1)
|
2021-12-17 11:28:37 +08:00
|
|
|
|
end
|
2022-11-22 15:30:03 +08:00
|
|
|
|
self.tip.text="每充值1元可以获得10点名望经验"
|
2021-12-16 19:22:46 +08:00
|
|
|
|
local size = rechargeNum/num
|
2021-12-15 14:34:21 +08:00
|
|
|
|
size = size > 1 and 1 or size
|
2021-12-16 19:22:46 +08:00
|
|
|
|
self.icon.sprite = self.spLoader:LoadSprite("t_tequan_vip"..text)
|
2021-12-15 14:34:21 +08:00
|
|
|
|
self.progress:GetComponent("RectTransform").sizeDelta = Vector3.New(483*size,12,0)
|
2021-12-16 19:22:46 +08:00
|
|
|
|
self.value.text = string.format("%s/%s",rechargeNum,num)
|
2021-12-15 14:34:21 +08:00
|
|
|
|
self.price.text = Data.data.price
|
|
|
|
|
self.btnRed:SetActive(false)
|
2022-10-25 10:23:48 +08:00
|
|
|
|
local needNum=DynamicActivityManager.GetMingWangLv(Data.data.shopItemData.BuyRule[2]-1)
|
2021-12-15 14:34:21 +08:00
|
|
|
|
if Data.data.limitNum - Data.data.boughtNum > 0 then
|
|
|
|
|
self.btnText:SetActive(false)
|
|
|
|
|
self.cost:SetActive(true)
|
|
|
|
|
self.btnGet:GetComponent("Button").interactable = true
|
|
|
|
|
Util.SetGray(self.btnGet, false)
|
2022-10-20 17:48:00 +08:00
|
|
|
|
if rechargeNum >= needNum then
|
2023-11-09 10:52:24 +08:00
|
|
|
|
self.btnGet:GetComponent("Image").sprite = self.spLoader:LoadSprite("Btn_hz_cheng_01")
|
2022-01-17 13:16:18 +08:00
|
|
|
|
if BagManager.GetTotalItemNum(Data.data.costId) >= Data.data.price then
|
2021-12-15 14:34:21 +08:00
|
|
|
|
self.btnRed:SetActive(true)
|
|
|
|
|
end
|
|
|
|
|
else
|
2023-11-09 10:52:24 +08:00
|
|
|
|
self.btnGet:GetComponent("Image").sprite = self.spLoader:LoadSprite("Btn_hz_cheng_01")
|
2021-12-15 14:34:21 +08:00
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
self.btnText:SetActive(true)
|
|
|
|
|
self.cost:SetActive(false)
|
|
|
|
|
self.btnGet:GetComponent("Button").interactable = false
|
|
|
|
|
Util.SetGray(self.btnGet, true)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Util.AddOnceClick(self.btnGet,function ()
|
|
|
|
|
-- LogGreen(tostring(Data.data.limitNum).." "..tostring(Data.data.boughtNum))
|
|
|
|
|
if Data.data.limitNum - Data.data.boughtNum > 0 then
|
|
|
|
|
-- LogYellow(tostring(rechargeNum).." "..tostring(Data.data.shopItemData.BuyRule[2]))
|
2022-10-20 17:48:00 +08:00
|
|
|
|
if rechargeNum >= needNum then
|
2021-12-15 14:34:21 +08:00
|
|
|
|
-- LogPink(tostring(BagManager.GetItemCountById(Data.data.costId)).." "..tostring(Data.data.shopItemData.BuyRule[2]))
|
2022-01-26 13:40:13 +08:00
|
|
|
|
if BagManager.GetItemCountById(Data.data.costId) >= Data.data.price then
|
2021-12-15 14:34:21 +08:00
|
|
|
|
-- LogBlue(tostring(Data.data.shopItemData.buyType).." "..tostring(Data.data.shopData.id))
|
|
|
|
|
ShopManager.RequestBuyShopItem(Data.buyType, Data.data.shopData.id, 1, function()
|
|
|
|
|
self:SetGrowGift()
|
|
|
|
|
CheckRedPointStatus(RedPointType.DailyGift)
|
|
|
|
|
CheckRedPointStatus(RedPointType.GrowthPackage)
|
|
|
|
|
end)
|
|
|
|
|
else
|
|
|
|
|
NotEnoughPopup:Show(Data.data.costId)
|
|
|
|
|
end
|
|
|
|
|
else
|
2022-10-20 17:48:00 +08:00
|
|
|
|
PopupTipPanel.ShowTip(string.format("名望等级不足,请升至%s级后才可购买!",DynamicActivityManager.Index))
|
2021-12-15 14:34:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not self.ItemList then
|
|
|
|
|
self.ItemList = {}
|
|
|
|
|
end
|
|
|
|
|
for i = 1, #self.ItemList do
|
|
|
|
|
self.ItemList[i].gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
for i = 1, #Data.data.shows do
|
|
|
|
|
if not self.ItemList[i] then
|
|
|
|
|
self.ItemList[i] = SubUIManager.Open(SubUIConfig.ItemView,self.reward.transform)
|
|
|
|
|
end
|
|
|
|
|
self.ItemList[i]:OnOpen(false, {Data.data.shows[i][1],Data.data.shows[i][2],Data.data.shows[i][3]}, 0.9,false,false,false,self.sortingOrder)
|
|
|
|
|
self.ItemList[i].gameObject:SetActive(true)
|
|
|
|
|
end
|
2022-01-17 13:16:18 +08:00
|
|
|
|
|
|
|
|
|
--左右按钮红点检测
|
|
|
|
|
if growData[DynamicActivityManager.Index - 1] then
|
|
|
|
|
for i = DynamicActivityManager.Index - 1, 1,-1 do
|
|
|
|
|
local curData = growData[i]
|
|
|
|
|
if curData.data.limitNum - curData.data.boughtNum > 0 and
|
|
|
|
|
BagManager.GetTotalItemNum(curData.data.costId) >= curData.data.price and
|
2022-10-25 10:23:48 +08:00
|
|
|
|
rechargeNum >=DynamicActivityManager.GetMingWangLv(curData.data.shopItemData.BuyRule[2]-1) then
|
2022-01-17 13:16:18 +08:00
|
|
|
|
self.leftRed:SetActive(true)
|
|
|
|
|
break
|
|
|
|
|
else
|
|
|
|
|
self.leftRed:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if growData[DynamicActivityManager.Index + 1] then
|
2022-10-20 17:48:00 +08:00
|
|
|
|
for i = DynamicActivityManager.Index + 1, 20 do
|
2022-01-17 13:16:18 +08:00
|
|
|
|
local curData = growData[i]
|
|
|
|
|
if curData and curData.data.limitNum - curData.data.boughtNum > 0 and
|
|
|
|
|
BagManager.GetTotalItemNum(curData.data.costId) >= curData.data.price and
|
2022-10-25 10:23:48 +08:00
|
|
|
|
rechargeNum >= DynamicActivityManager.GetMingWangLv(curData.data.shopItemData.BuyRule[2]-1) then
|
2022-01-17 13:16:18 +08:00
|
|
|
|
self.rightRed:SetActive(true)
|
|
|
|
|
break
|
|
|
|
|
else
|
|
|
|
|
self.rightRed:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-12-15 14:34:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function RechargeViewNew:OnClose()
|
|
|
|
|
self.gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function RechargeViewNew:OnDestroy()
|
|
|
|
|
self.spLoader:Destroy()
|
|
|
|
|
if self.shopView then
|
|
|
|
|
SubUIManager.Close(self.shopView)
|
|
|
|
|
self.shopView = nil
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return RechargeViewNew
|
|
|
|
|
|