From b21ed5a44e1926a33fdf893c4a2f4f9fd6a5cf4f Mon Sep 17 00:00:00 2001 From: jiaoyangna <3046463818@qq.com> Date: Thu, 1 Apr 2021 15:42:59 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A4=BC=E5=8C=85=E4=BF=AE=E6=94=B9=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DynamicActivityManager.lua | 49 ++--- .../~Lua/Modules/Recharge/View/GiftPre.lua | 174 +++++++++++------- 2 files changed, 128 insertions(+), 95 deletions(-) diff --git a/Assets/ManagedResources/~Lua/Modules/DynamicActivity/DynamicActivityManager.lua b/Assets/ManagedResources/~Lua/Modules/DynamicActivity/DynamicActivityManager.lua index a0cb0a6612..9e582c27de 100644 --- a/Assets/ManagedResources/~Lua/Modules/DynamicActivity/DynamicActivityManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/DynamicActivity/DynamicActivityManager.lua @@ -486,14 +486,14 @@ function this.GetGiftDataByType(ShopData) local lv = PlayerManager.level local shopData = {} 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]) for i = 1, #topspeedData do if lv >= topspeedData[i].data.shopItemData.LevelLinit[1] and lv <= topspeedData[i].data.shopItemData.LevelLinit[2] then table.insert(shopData,topspeedData[i]) 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]) for i = 1, #topspeedData do 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 limitNum = 0 for i = 1, #shopData do - if DataTypeIndex == DataType.Shop then - 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 + newData[#newData + 1] = this.CreatSingleData(shopData[i],DataTypeIndex,buyType) end return newData end -function this.CreatSingleData(shopData,DataTypeIndex,curSortId,buyType) +function this.CreatSingleData(shopData,DataTypeIndex,buyType) local _data = {} local data = {} + local curSortId = 0--临时一个数值 只用做排序用 if DataTypeIndex == DataType.Shop then data.shopData = shopData 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.boughtNum = ShopManager.GetShopItemHadBuyTimes(buyType, 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.price = data.finalNum - elseif DataTypeIndex == DataType.Direct then + elseif DataTypeIndex == DataType.Direct and rechargeCommodityConfig[shopData.goodsId].ShowType == buyType then data.shopData = shopData data.shopItemData = rechargeCommodityConfig[shopData.goodsId] data.shows = data.shopItemData.RewardShow data.tagName = GetLanguageStrById(data.shopItemData.Name) data.boughtNum = OperatingManager.GetGoodsBuyTime(GoodsTypeDef.DirectPurchaseGift,shopData.goodsId) 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.finalNum = MoneyUtil.GetMoney(data.shopItemData.Price) data.oriCostNum = nil @@ -583,9 +570,13 @@ function this.CreatSingleData(shopData,DataTypeIndex,curSortId,buyType) data.tipImageText = Language[11700] elseif data.shopItemData.DailyUpdate == 30 then data.tipImageText = Language[11357] + else + data.tipImageText = nil end data.price = string.format(MoneyUtil.GetMoneyUnitName(), data.finalNum) data.endTime = shopData.endTime + else + return nil end data.buyInfo = "剩余:"..data.limitNum - data.boughtNum.."次" _data.data = data diff --git a/Assets/ManagedResources/~Lua/Modules/Recharge/View/GiftPre.lua b/Assets/ManagedResources/~Lua/Modules/Recharge/View/GiftPre.lua index 4822e2cc87..cecdae03bc 100644 --- a/Assets/ManagedResources/~Lua/Modules/Recharge/View/GiftPre.lua +++ b/Assets/ManagedResources/~Lua/Modules/Recharge/View/GiftPre.lua @@ -163,14 +163,12 @@ function GiftPre:SetData(data,_parent,_rechargeNum,sortingOrder) rechargeNum = _rechargeNum self.data = data self.parent = _parent - - if self.data.data.tagName and self.data.data.tagName ~= "" then - self.tagIma.gameObject:SetActive(true) - self.tagText.text = self.data.data.tagName - else - self.tagIma.gameObject:SetActive(false) - end - + Util.SetParticleSortLayer(self.UI_Effect_MianBan_LiBao_button_01, sortingOrder or 0) + + self:SetTag() + self:SetTipTag() + + --设置礼包内容 if not self.itemList then self.itemList = {} end @@ -186,17 +184,31 @@ function GiftPre:SetData(data,_parent,_rechargeNum,sortingOrder) self.itemList[i].gameObject:SetActive(true) 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.tipText.text = self.data.data.tipImageText else self.tipImage.gameObject:SetActive(false) end - Util.SetParticleSortLayer(self.UI_Effect_MianBan_LiBao_button_01, sortingOrder or 0) - - self:SetIcon(self.data) - self:SetContent1() - self:Effect() end function GiftPre:Effect() @@ -222,48 +234,24 @@ function GiftPre:SetContent1() self.type2.gameObject:SetActive(false) self.tipRoot:SetActive(false) self.tip1:SetActive(false) - self.tip1_en:SetActive(false) self.tip2:SetActive(false) - self.tip2_en:SetActive(false) self.tip3:SetActive(false) - self.tip3_en:SetActive(false) self.tip4:SetActive(false) - self.tip4_en: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") + if self.data.DataType == DataType.Direct and self.data.buyType == DirectBuyType.DAILY_GIFT then - self.type2.gameObject:SetActive(true) - self.tagIma.gameObject:SetActive(true) - self.type2Text1.text = self.data.data.shows[1][2] - self.type2Text2.text=self.data.data.shopItemData.Rebate - if GetCurLanguage() == 0 then - self.type2Text1.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[0].txt1 - self.type2Icon1.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[0].icon1 - self.type2Text2.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[0].txt - self.type2Icon2.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[0].icon - self.type2Ima.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[0].ima - elseif GetCurLanguage() == 1 then - self.type2Text1.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[1].txt1 - self.type2Icon1.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[1].icon1 - self.type2Text2.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[1].txt - self.type2Icon2.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[1].icon - self.type2Ima.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[1].ima - else - self.type2Text1.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[2].txt1 - self.type2Icon1.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[2].icon1 - self.type2Text2.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[2].txt - self.type2Icon2.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[2].icon - self.type2Ima.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[2].ima - end + 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 - 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]--资格进度条 + 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) @@ -272,6 +260,38 @@ function GiftPre:SetContent1() 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.type2Text1.text = self.data.data.shows[1][2] + self.type2Text2.text=self.data.data.shopItemData.Rebate + if GetCurLanguage() == 0 then + self.type2Text1.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[0].txt1 + self.type2Icon1.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[0].icon1 + self.type2Text2.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[0].txt + self.type2Icon2.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[0].icon + self.type2Ima.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[0].ima + elseif GetCurLanguage() == 1 then + self.type2Text1.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[1].txt1 + self.type2Icon1.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[1].icon1 + self.type2Text2.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[1].txt + self.type2Icon2.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[1].icon + self.type2Ima.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[1].ima + else + self.type2Text1.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[2].txt1 + self.type2Icon1.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[2].icon1 + self.type2Text2.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[2].txt + self.type2Icon2.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[2].icon + self.type2Ima.gameObject:GetComponent("RectTransform").anchoredPosition = offSetX[2].ima + end +end + function GiftPre:SetTip() if self.data.data.shopData.id and self.data.data.shopData.id == 20091 then if GetCurLanguage() ~= 0 then @@ -306,46 +326,68 @@ function GiftPre:SetTip() end end -function GiftPre:SetIcon(_itemdata) - self.btnBuy.gameObject:SetActive(true) - self.isCanBuy = 0 +function GiftPre:SetIsCanBuy() + local 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 - self.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") + isCanBuy = (rechargeNum >= self.data.data.shopItemData.BuyRule[2] and 0 or 1) + self.btnBuy:GetComponent("Image").sprite = Util.LoadSprite(isCanBuy == 0 and "s_slbz_1anniuongse" or "s_slbz_1anniuhuangse") end - if self.isCanBuy == 0 then - self.isCanBuy = (_itemdata.data.limitNum - _itemdata.data.boughtNum > 0) and 0 or 2 + if isCanBuy == 0 then + isCanBuy = (self.data.data.limitNum - self.data.data.boughtNum > 0) and 0 or 2 end - self.btnBuy:GetComponent("Button").interactable = (self.isCanBuy == 0 or self.isCanBuy == 1) - 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 - self.price.text = _itemdata.data.price - self.buyInfo.text = self.isCanBuy == 2 and "" or _itemdata.data.buyInfo + return isCanBuy +end + +function GiftPre:SetIcon() if self.isCanBuy == 2 then self.icon.gameObject:SetActive(false) 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.time then self.time:Stop() self.time = nil end local fresh = _itemdata.data.endTime - GetTimeStamp() + if fresh <= 0 then + self.parent:RefreshData() + return + end self.buyInfo.text = Language[10469]..self.parent:SpecialTime(fresh) self.time = Timer.New(function() + fresh = fresh - 1 if fresh <= 0 then self.parent:RefreshData() return - end - self.buyInfo.text = Language[10469]..self.parent:SpecialTime(fresh) - fresh = fresh - 1 + end + self.buyInfo.text = Language[10469]..self.parent:SpecialTime(fresh) end,1,-1,true) self.time:Start() - end + end end + --设置红点 if _itemdata.data.finalNum == 0 and self.isCanBuy == 0 then self.redPoint.gameObject:SetActive(true) else