礼包修改提交

dev_chengFeng
jiaoyangna 2021-04-01 15:42:59 +08:00
parent b663c351b3
commit b21ed5a44e
2 changed files with 128 additions and 95 deletions

View File

@ -486,14 +486,14 @@ function this.GetGiftDataByType(ShopData)
local lv = PlayerManager.level local lv = PlayerManager.level
local shopData = {} local shopData = {}
for i = 1,#ShopData do for i = 1,#ShopData do
if ShopData[i][1] == 1 and RECHARGEABLE then if ShopData[i][1] == DataType.Direct and RECHARGEABLE then
local topspeedData = this.ResetShopData(OperatingManager.GetGiftGoodsInfoList(ShopData[i][2]), ShopData[i][3], ShopData[i][1]) local topspeedData = this.ResetShopData(OperatingManager.GetGiftGoodsInfoList(ShopData[i][2]), ShopData[i][3], ShopData[i][1])
for i = 1, #topspeedData do for i = 1, #topspeedData do
if lv >= topspeedData[i].data.shopItemData.LevelLinit[1] and lv <= topspeedData[i].data.shopItemData.LevelLinit[2] then if lv >= topspeedData[i].data.shopItemData.LevelLinit[1] and lv <= topspeedData[i].data.shopItemData.LevelLinit[2] then
table.insert(shopData,topspeedData[i]) table.insert(shopData,topspeedData[i])
end end
end end
elseif ShopData[i][1] == 2 then elseif ShopData[i][1] == DataType.Shop then
local topspeedData = this.ResetShopData(ShopManager.GetShopDataByType(ShopData[i][2]).storeItem, ShopData[i][2], ShopData[i][1]) local topspeedData = this.ResetShopData(ShopManager.GetShopDataByType(ShopData[i][2]).storeItem, ShopData[i][2], ShopData[i][1])
for i = 1, #topspeedData do for i = 1, #topspeedData do
if (not topspeedData[i].data.shopItemData.ShowRule) or (rechargeNum >= topspeedData[i].data.shopItemData.ShowRule[2]) then if (not topspeedData[i].data.shopItemData.ShowRule) or (rechargeNum >= topspeedData[i].data.shopItemData.ShowRule[2]) then
@ -524,38 +524,15 @@ function this.ResetShopData(shopData, buyType, DataTypeIndex)
local boughtNum = 0 local boughtNum = 0
local limitNum = 0 local limitNum = 0
for i = 1, #shopData do for i = 1, #shopData do
if DataTypeIndex == DataType.Shop then newData[#newData + 1] = this.CreatSingleData(shopData[i],DataTypeIndex,buyType)
boughtNum = ShopManager.GetShopItemHadBuyTimes(buyType, shopData[i].id)
limitNum = ShopManager.GetShopItemLimitBuyCount(shopData[i].id)
local curSortId = 0--临时一个数值 只用做排序用
if limitNum == -1 then
curSortId = 3
elseif limitNum - boughtNum > 0 then
curSortId = 2
end
newData[#newData + 1] = this.CreatSingleData(shopData[i],DataTypeIndex,curSortId,buyType)
elseif DataTypeIndex == DataType.Direct then
--所有直购 进行筛选 类型一致的取出
if rechargeCommodityConfig[shopData[i].goodsId].ShowType == buyType then
boughtNum = OperatingManager.GetGoodsBuyTime(DataTypeIndex, shopData[i].goodsId)
limitNum = rechargeCommodityConfig[ shopData[i].goodsId].Limit
local curSortId = 0--临时一个数值 只用做排序用
if limitNum == -1 then
curSortId = 2
elseif limitNum - boughtNum > 0 then
curSortId = 1
end
--DataTypeIndex 1 商品 2 直购商品
newData[#newData + 1] = this.CreatSingleData(shopData[i],DataTypeIndex,curSortId,buyType)
end
end
end end
return newData return newData
end end
function this.CreatSingleData(shopData,DataTypeIndex,curSortId,buyType) function this.CreatSingleData(shopData,DataTypeIndex,buyType)
local _data = {} local _data = {}
local data = {} local data = {}
local curSortId = 0--临时一个数值 只用做排序用
if DataTypeIndex == DataType.Shop then if DataTypeIndex == DataType.Shop then
data.shopData = shopData data.shopData = shopData
data.shopItemData = shopItemConfig[shopData.id] data.shopItemData = shopItemConfig[shopData.id]
@ -564,16 +541,26 @@ function this.CreatSingleData(shopData,DataTypeIndex,curSortId,buyType)
data.tagName = GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.ItemConfig,data.shows[1][1]).Name) data.tagName = GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.ItemConfig,data.shows[1][1]).Name)
data.boughtNum = ShopManager.GetShopItemHadBuyTimes(buyType, shopData.id) data.boughtNum = ShopManager.GetShopItemHadBuyTimes(buyType, shopData.id)
data.limitNum = ShopManager.GetShopItemLimitBuyCount(shopData.id) data.limitNum = ShopManager.GetShopItemLimitBuyCount(shopData.id)
if data.limitNum == -1 then
curSortId = 3
elseif data.limitNum - data.boughtNum > 0 then
curSortId = 2
end
data.costId,data.finalNum,data.oriCostNum = ShopManager.calculateBuyCost(buyType, shopData.id, 1) data.costId,data.finalNum,data.oriCostNum = ShopManager.calculateBuyCost(buyType, shopData.id, 1)
data.costId,data.finalNum,data.oriCostNum = ShopManager.calculateBuyCost(buyType, shopData.id, 1) data.costId,data.finalNum,data.oriCostNum = ShopManager.calculateBuyCost(buyType, shopData.id, 1)
data.price = data.finalNum data.price = data.finalNum
elseif DataTypeIndex == DataType.Direct then elseif DataTypeIndex == DataType.Direct and rechargeCommodityConfig[shopData.goodsId].ShowType == buyType then
data.shopData = shopData data.shopData = shopData
data.shopItemData = rechargeCommodityConfig[shopData.goodsId] data.shopItemData = rechargeCommodityConfig[shopData.goodsId]
data.shows = data.shopItemData.RewardShow data.shows = data.shopItemData.RewardShow
data.tagName = GetLanguageStrById(data.shopItemData.Name) data.tagName = GetLanguageStrById(data.shopItemData.Name)
data.boughtNum = OperatingManager.GetGoodsBuyTime(GoodsTypeDef.DirectPurchaseGift,shopData.goodsId) data.boughtNum = OperatingManager.GetGoodsBuyTime(GoodsTypeDef.DirectPurchaseGift,shopData.goodsId)
data.limitNum = rechargeCommodityConfig[shopData.goodsId].Limit data.limitNum = rechargeCommodityConfig[shopData.goodsId].Limit
if data.limitNum == -1 then
curSortId = 2
elseif data.limitNum - data.boughtNum > 0 then
curSortId = 1
end
data.costId = nil data.costId = nil
data.finalNum = MoneyUtil.GetMoney(data.shopItemData.Price) data.finalNum = MoneyUtil.GetMoney(data.shopItemData.Price)
data.oriCostNum = nil data.oriCostNum = nil
@ -583,9 +570,13 @@ function this.CreatSingleData(shopData,DataTypeIndex,curSortId,buyType)
data.tipImageText = Language[11700] data.tipImageText = Language[11700]
elseif data.shopItemData.DailyUpdate == 30 then elseif data.shopItemData.DailyUpdate == 30 then
data.tipImageText = Language[11357] data.tipImageText = Language[11357]
else
data.tipImageText = nil
end end
data.price = string.format(MoneyUtil.GetMoneyUnitName(), data.finalNum) data.price = string.format(MoneyUtil.GetMoneyUnitName(), data.finalNum)
data.endTime = shopData.endTime data.endTime = shopData.endTime
else
return nil
end end
data.buyInfo = "剩余:"..data.limitNum - data.boughtNum.."" data.buyInfo = "剩余:"..data.limitNum - data.boughtNum..""
_data.data = data _data.data = data

View File

@ -163,14 +163,12 @@ function GiftPre:SetData(data,_parent,_rechargeNum,sortingOrder)
rechargeNum = _rechargeNum rechargeNum = _rechargeNum
self.data = data self.data = data
self.parent = _parent self.parent = _parent
Util.SetParticleSortLayer(self.UI_Effect_MianBan_LiBao_button_01, sortingOrder or 0)
if self.data.data.tagName and self.data.data.tagName ~= "" then self:SetTag()
self.tagIma.gameObject:SetActive(true) self:SetTipTag()
self.tagText.text = self.data.data.tagName
else
self.tagIma.gameObject:SetActive(false)
end
--设置礼包内容
if not self.itemList then if not self.itemList then
self.itemList = {} self.itemList = {}
end end
@ -186,17 +184,31 @@ function GiftPre:SetData(data,_parent,_rechargeNum,sortingOrder)
self.itemList[i].gameObject:SetActive(true) self.itemList[i].gameObject:SetActive(true)
end end
if self.data.data.tipImageText and self.data.data.tagName and self.data.data.tagName ~= "" then --设置按钮
self:SetBtn(self.data)
--设置礼包标题
self:SetContent1()
--设置特效
self:Effect()
end
--设置礼包名称(红色标签)
function GiftPre:SetTag()
if self.data.data.tagName and self.data.data.tagName ~= "" and not (self.data.DataType == DataType.Shop and self.data.buyType == SHOP_TYPE.VIP_GIFT) then
self.tagIma.gameObject:SetActive(true)
self.tagText.text = self.data.data.tagName
else
self.tagIma.gameObject:SetActive(false)
end
end
--设置礼包限购标签
function GiftPre:SetTipTag()
if self.data.data.tipImageText and self.data.data.tipImageText ~= "" then
self.tipImage.gameObject:SetActive(true) self.tipImage.gameObject:SetActive(true)
self.tipText.text = self.data.data.tipImageText self.tipText.text = self.data.data.tipImageText
else else
self.tipImage.gameObject:SetActive(false) self.tipImage.gameObject:SetActive(false)
end end
Util.SetParticleSortLayer(self.UI_Effect_MianBan_LiBao_button_01, sortingOrder or 0)
self:SetIcon(self.data)
self:SetContent1()
self:Effect()
end end
function GiftPre:Effect() function GiftPre:Effect()
@ -222,18 +234,41 @@ function GiftPre:SetContent1()
self.type2.gameObject:SetActive(false) self.type2.gameObject:SetActive(false)
self.tipRoot:SetActive(false) self.tipRoot:SetActive(false)
self.tip1:SetActive(false) self.tip1:SetActive(false)
self.tip1_en:SetActive(false)
self.tip2:SetActive(false) self.tip2:SetActive(false)
self.tip2_en:SetActive(false)
self.tip3:SetActive(false) self.tip3:SetActive(false)
self.tip3_en:SetActive(false)
self.tip4:SetActive(false) self.tip4:SetActive(false)
self.tip4_en:SetActive(false)
self.tip5:SetActive(false) self.tip5:SetActive(false)
self.tip1_en:SetActive(false)
self.tip2_en:SetActive(false)
self.tip3_en:SetActive(false)
self.tip4_en:SetActive(false)
self.btnBuy:GetComponent("Image").sprite = Util.LoadSprite("s_slbz_1anniuhuangse") self.btnBuy:GetComponent("Image").sprite = Util.LoadSprite("s_slbz_1anniuhuangse")
if self.data.DataType == DataType.Direct and self.data.buyType == DirectBuyType.DAILY_GIFT then if self.data.DataType == DataType.Direct and self.data.buyType == DirectBuyType.DAILY_GIFT then
self:SetType2()
elseif self.data.DataType == DataType.Direct and (self.data.buyType == DirectBuyType.WEEK_GIFT or self.data.buyType == DirectBuyType.MONTH_GIFT) then
self.grid:GetComponent("RectTransform").anchoredPosition = offSetX[1].scroll
self.upLayout.gameObject:SetActive(false)
elseif self.data.DataType == DataType.Shop and self.data.buyType == SHOP_TYPE.VIP_GIFT then
local str = ""..rechargeNum.."/"..self.data.data.shopItemData.BuyRule[2]..Language[11698]
self:SetType1("累计充值",self.data.data.shopItemData.BuyRule[2],str)
elseif (self.data.DataType == DataType.Direct and self.data.buyType == DirectBuyType.FINDTREASURE_GIFT) or
(self.data.DataType == DataType.Shop and self.data.buyType == SHOP_TYPE.FINDTREASURE_GIFT) then
self.tipRoot:SetActive(true)
self:SetTip()
end
LayoutRebuilder.ForceRebuildLayoutImmediate(self.upLayout.transform)
end
function GiftPre:SetType1(type1Text1,num,type1Text3)
self.type1.gameObject:SetActive(true)
CreatNumberPrefab(tostring(num),self.numList)
self.type1Text1.text = "累计充值"
self.type1Text3.text = type1Text3
end
function GiftPre:SetType2()
self.type2.gameObject:SetActive(true) self.type2.gameObject:SetActive(true)
self.tagIma.gameObject:SetActive(true)
self.type2Text1.text = self.data.data.shows[1][2] self.type2Text1.text = self.data.data.shows[1][2]
self.type2Text2.text=self.data.data.shopItemData.Rebate self.type2Text2.text=self.data.data.shopItemData.Rebate
if GetCurLanguage() == 0 then if GetCurLanguage() == 0 then
@ -255,21 +290,6 @@ function GiftPre:SetContent1()
self.type2Icon2.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[2].icon self.type2Icon2.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[2].icon
self.type2Ima.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[2].ima self.type2Ima.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[2].ima
end end
elseif self.data.DataType == DataType.Direct and (self.data.buyType == DirectBuyType.WEEK_GIFT or self.data.buyType == DirectBuyType.MONTH_GIFT) then
self.grid:GetComponent("RectTransform").anchoredPosition = offSetX[1].scroll
self.upLayout.gameObject:SetActive(false)
elseif self.data.DataType == DataType.Shop and self.data.buyType == SHOP_TYPE.VIP_GIFT then
self.type1.gameObject:SetActive(true)
self.tagIma.gameObject:SetActive(false)
CreatNumberPrefab(tostring(self.data.data.shopItemData.BuyRule[2]),self.numList)
self.type1Text1.text = "累计充值"
self.type1Text3.text = ""..rechargeNum.."/"..self.data.data.shopItemData.BuyRule[2]..Language[11698]--资格进度条
elseif (self.data.DataType == DataType.Direct and self.data.buyType == DirectBuyType.FINDTREASURE_GIFT) or
(self.data.DataType == DataType.Shop and self.data.buyType == SHOP_TYPE.FINDTREASURE_GIFT) then
self.tipRoot:SetActive(true)
self:SetTip()
end
LayoutRebuilder.ForceRebuildLayoutImmediate(self.upLayout.transform)
end end
function GiftPre:SetTip() function GiftPre:SetTip()
@ -306,46 +326,68 @@ function GiftPre:SetTip()
end end
end end
function GiftPre:SetIcon(_itemdata) function GiftPre:SetIsCanBuy()
self.btnBuy.gameObject:SetActive(true) local isCanBuy = 0
self.isCanBuy = 0 self.btnBuy:GetComponent("Image").sprite = Util.LoadSprite("s_slbz_1anniuhuangse")
--如果是成长礼包 有一个1的状态 并且按钮图片有变化
if self.data.DataType == DataType.Shop and self.data.buyType == SHOP_TYPE.VIP_GIFT then if self.data.DataType == DataType.Shop and self.data.buyType == SHOP_TYPE.VIP_GIFT then
self.isCanBuy = (rechargeNum >= self.data.data.shopItemData.BuyRule[2] and 0 or 1) isCanBuy = (rechargeNum >= self.data.data.shopItemData.BuyRule[2] and 0 or 1)
self.btnBuy:GetComponent("Image").sprite = Util.LoadSprite(self.isCanBuy == 0 and "s_slbz_1anniuongse" or "s_slbz_1anniuhuangse") self.btnBuy:GetComponent("Image").sprite = Util.LoadSprite(isCanBuy == 0 and "s_slbz_1anniuongse" or "s_slbz_1anniuhuangse")
end end
if self.isCanBuy == 0 then if isCanBuy == 0 then
self.isCanBuy = (_itemdata.data.limitNum - _itemdata.data.boughtNum > 0) and 0 or 2 isCanBuy = (self.data.data.limitNum - self.data.data.boughtNum > 0) and 0 or 2
end end
self.btnBuy:GetComponent("Button").interactable = (self.isCanBuy == 0 or self.isCanBuy == 1) return isCanBuy
if _itemdata.DataType == DataType.Shop then
self.icon.gameObject:SetActive(true)
self.icon.sprite = Util.LoadSprite(GetResourcePath(itemConfig[_itemdata.data.shopItemData.Cost[1][1]].ResourceID))
else
self.icon.gameObject:SetActive(false)
end end
self.price.text = _itemdata.data.price
self.buyInfo.text = self.isCanBuy == 2 and "" or _itemdata.data.buyInfo function GiftPre:SetIcon()
if self.isCanBuy == 2 then if self.isCanBuy == 2 then
self.icon.gameObject:SetActive(false) self.icon.gameObject:SetActive(false)
self.price.text = "已购买" self.price.text = "已购买"
else
if self.data.DataType == DataType.Shop then
self.icon.gameObject:SetActive(true)
self.icon.sprite = Util.LoadSprite(GetResourcePath(itemConfig[self.data.data.shopItemData.Cost[1][1]].ResourceID))
else
self.icon.gameObject:SetActive(false)
end
self.price.text = self.data.data.price
end
end
function GiftPre:SetBtn(_itemdata)
self.btnBuy.gameObject:SetActive(true)
self.isCanBuy = self:SetIsCanBuy()
self.btnBuy:GetComponent("Button").interactable = (self.isCanBuy == 0 or self.isCanBuy == 1)
--设置icon
self:SetIcon()
--设置按钮提示 -- 已经购买不显示(特权礼包需要显示时间)
self.buyInfo.text = self.isCanBuy == 2 and "" or _itemdata.data.buyInfo
if self.isCanBuy == 2 then
if self.data.DataType == DataType.Direct and self.data.buyType == DirectBuyType.FINDTREASURE_GIFT then if self.data.DataType == DataType.Direct and self.data.buyType == DirectBuyType.FINDTREASURE_GIFT then
if self.time then if self.time then
self.time:Stop() self.time:Stop()
self.time = nil self.time = nil
end end
local fresh = _itemdata.data.endTime - GetTimeStamp() local fresh = _itemdata.data.endTime - GetTimeStamp()
self.buyInfo.text = Language[10469]..self.parent:SpecialTime(fresh)
self.time = Timer.New(function()
if fresh <= 0 then if fresh <= 0 then
self.parent:RefreshData() self.parent:RefreshData()
return return
end end
self.buyInfo.text = Language[10469]..self.parent:SpecialTime(fresh) self.buyInfo.text = Language[10469]..self.parent:SpecialTime(fresh)
self.time = Timer.New(function()
fresh = fresh - 1 fresh = fresh - 1
if fresh <= 0 then
self.parent:RefreshData()
return
end
self.buyInfo.text = Language[10469]..self.parent:SpecialTime(fresh)
end,1,-1,true) end,1,-1,true)
self.time:Start() self.time:Start()
end end
end end
--设置红点
if _itemdata.data.finalNum == 0 and self.isCanBuy == 0 then if _itemdata.data.finalNum == 0 and self.isCanBuy == 0 then
self.redPoint.gameObject:SetActive(true) self.redPoint.gameObject:SetActive(true)
else else