2020-08-25 15:46:38 +08:00
|
|
|
|
local GiftView = quick_class("GiftView")
|
2020-05-15 16:52:35 +08:00
|
|
|
|
local shopItemConfig = ConfigManager.GetConfig(ConfigName.StoreConfig)
|
|
|
|
|
local rechargeCommodityConfig = ConfigManager.GetConfig(ConfigName.RechargeCommodityConfig)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
local rechargeNum
|
2020-05-15 16:52:35 +08:00
|
|
|
|
|
|
|
|
|
local DataType={
|
|
|
|
|
Shop = 1,--商品
|
|
|
|
|
Direct = 2,--直购
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-13 11:47:13 +08:00
|
|
|
|
local timerList={}--时间预设容器
|
|
|
|
|
|
2020-05-25 19:16:23 +08:00
|
|
|
|
local Title_BG_NAME = {
|
2021-01-26 17:08:39 +08:00
|
|
|
|
[DirectBuyType.DAILY_GIFT] = "l_mrlb_banner_zh",
|
|
|
|
|
[DirectBuyType.FINDTREASURE_GIFT] = "t_tqsc_banner_zh",
|
|
|
|
|
[SHOP_TYPE.VIP_GIFT] = "c_czlb_banner_zh",--成长礼包
|
2020-05-25 19:16:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-15 16:52:35 +08:00
|
|
|
|
function GiftView:ctor(mainPanel, gameObject)
|
|
|
|
|
self.mainPanel = mainPanel
|
|
|
|
|
self.gameObject = gameObject
|
|
|
|
|
self:InitComponent(gameObject)
|
|
|
|
|
self:BindEvent()
|
|
|
|
|
self.ItemList = {}
|
|
|
|
|
end
|
|
|
|
|
|
2020-12-26 11:47:16 +08:00
|
|
|
|
|
|
|
|
|
--添加事件监听(用于子类重写)
|
|
|
|
|
function GiftView:AddListener()
|
2021-01-05 16:29:13 +08:00
|
|
|
|
-- Game.GlobalEvent:AddEvent(GameEvent.GrowGift.RechargeGift, GiftView.refresh)
|
2020-12-26 11:47:16 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
|
|
|
|
function GiftView:RemoveListener()
|
2021-01-05 16:29:13 +08:00
|
|
|
|
-- Game.GlobalEvent:RemoveEvent(GameEvent.GrowGift.RechargeGift, GiftView.refresh)
|
2020-12-26 11:47:16 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
2020-05-15 16:52:35 +08:00
|
|
|
|
function GiftView:InitComponent(gameObject)
|
|
|
|
|
self.itemPre = Util.GetGameObject(gameObject, "rzyBg/ItemPre")
|
2020-06-03 19:09:01 +08:00
|
|
|
|
self.itemPre2 = Util.GetGameObject(gameObject, "rzyBg/ItemPre2")
|
|
|
|
|
self.itemPre3 = Util.GetGameObject(gameObject, "rzyBg/ItemPre3")--成长礼包
|
2020-05-15 16:52:35 +08:00
|
|
|
|
self.bg = Util.GetGameObject(gameObject, "rzyBg")
|
2020-05-25 19:16:23 +08:00
|
|
|
|
self.titleBg = Util.GetGameObject(gameObject, "rzyBg/bg"):GetComponent("Image")
|
2020-09-24 20:02:27 +08:00
|
|
|
|
self.dayGiftIcon=Util.GetGameObject(gameObject,"rzyBg/dailygift")
|
2020-05-15 16:52:35 +08:00
|
|
|
|
self.freeBtn=Util.GetGameObject(gameObject,"rzyBg/freeBtn")
|
|
|
|
|
self.freeBtnAnim=Util.GetGameObject(gameObject,"rzyBg/freeBtn/UI_effect_TanSuo_Box"):GetComponent("Animator")
|
|
|
|
|
self.redPoint=Util.GetGameObject(gameObject,"rzyBg/freeBtn/redPoint")
|
2020-08-22 10:09:30 +08:00
|
|
|
|
self.endTime = Util.GetGameObject(gameObject, "rzyBg/Image/endTime"):GetComponent("Text")
|
2020-06-03 19:09:01 +08:00
|
|
|
|
self.endTimeBg = Util.GetGameObject(gameObject, "rzyBg/Image")
|
2020-09-24 20:02:27 +08:00
|
|
|
|
self.oneKey = Util.GetGameObject(gameObject, "oneKey")
|
|
|
|
|
self.buyAllBtn = Util.GetGameObject(self.oneKey, "Button")
|
|
|
|
|
self.oriPrice = Util.GetGameObject(self.oneKey, "oriPrice"):GetComponent("Text")
|
|
|
|
|
self.nowPrice = Util.GetGameObject(self.oneKey, "nowPrice"):GetComponent("Text")
|
2020-08-25 11:42:55 +08:00
|
|
|
|
Util.SetGray(self.buyAllBtn,false)
|
|
|
|
|
self.buyAllBtn:GetComponent("Button").interactable = true
|
2020-05-15 16:52:35 +08:00
|
|
|
|
self.scrollItem = Util.GetGameObject(gameObject, "rzyBg/scrollItem")
|
2020-06-03 19:09:01 +08:00
|
|
|
|
self.tip3 = Util.GetGameObject(gameObject, "rzyBg/tip3")
|
2020-05-15 16:52:35 +08:00
|
|
|
|
self.lightList = {
|
|
|
|
|
Util.GetGameObject(self.freeBtnAnim.transform,"bg_ray"),
|
|
|
|
|
Util.GetGameObject(self.freeBtnAnim.transform,"yinying/ray 1"),
|
|
|
|
|
Util.GetGameObject(self.freeBtnAnim.transform,"yinying/ray 2"),
|
|
|
|
|
Util.GetGameObject(self.freeBtnAnim.transform,"yinying/ray 3"),
|
|
|
|
|
Util.GetGameObject(self.freeBtnAnim.transform,"yinying/ray 4"),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-- 设置循环滚动,万一礼包内容不停地加
|
|
|
|
|
local rootHight = self.scrollItem.transform.rect.height
|
|
|
|
|
local width = self.scrollItem.transform.rect.width
|
|
|
|
|
self.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.scrollItem.transform,
|
|
|
|
|
self.itemPre, nil, Vector2.New(width, rootHight), 1, 1, Vector2.New(0, 35))
|
|
|
|
|
self.scrollView.moveTween.MomentumAmount = 1
|
|
|
|
|
self.scrollView.moveTween.Strength = 2
|
2020-06-03 19:09:01 +08:00
|
|
|
|
|
|
|
|
|
self.scrollView2 = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.scrollItem.transform,
|
|
|
|
|
self.itemPre2, nil, Vector2.New(width, rootHight), 1, 1, Vector2.New(0, 35))
|
|
|
|
|
self.scrollView2.moveTween.MomentumAmount = 1
|
|
|
|
|
self.scrollView2.moveTween.Strength = 2
|
|
|
|
|
--成长礼包的滚动条
|
|
|
|
|
self.scrollView3 = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.scrollItem.transform,
|
|
|
|
|
self.itemPre3, nil, Vector2.New(width, rootHight), 1, 1, Vector2.New(0, 35))
|
|
|
|
|
self.scrollView3.moveTween.MomentumAmount = 1
|
|
|
|
|
self.scrollView3.moveTween.Strength = 2
|
2020-05-15 16:52:35 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function GiftView:BindEvent()
|
2020-08-22 10:09:30 +08:00
|
|
|
|
Util.AddClick(self.buyAllBtn,function ()
|
2020-09-09 18:47:17 +08:00
|
|
|
|
PayManager.Pay(1004, function(id)
|
|
|
|
|
FirstRechargeManager.RefreshAccumRechargeValue(1004)
|
|
|
|
|
PlayerPrefs.SetInt(PlayerManager.uid.."czlb", 0)
|
|
|
|
|
CheckRedPointStatus(RedPointType.DailyGift)
|
|
|
|
|
CheckRedPointStatus(RedPointType.GrowthPackage)
|
|
|
|
|
timerList={}
|
|
|
|
|
self:RefreshGiftData()
|
|
|
|
|
end)
|
2020-08-22 10:09:30 +08:00
|
|
|
|
end)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
end
|
2020-12-26 11:47:16 +08:00
|
|
|
|
local curBuyType = 0
|
2020-05-15 16:52:35 +08:00
|
|
|
|
function GiftView:OnShow(_sortingOrder, buyType)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
rechargeNum= VipManager.GetChargedNum()--已经充值的金额
|
2020-12-26 11:47:16 +08:00
|
|
|
|
curBuyType = buyType
|
2021-02-26 10:37:39 +08:00
|
|
|
|
self:RefreshData(buyType,true,true)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function GiftView:OnSortingOrderChange(cursortingOrder)
|
|
|
|
|
for i, v in pairs(self.ItemList) do
|
|
|
|
|
for j = 1, #self.ItemList[i] do
|
|
|
|
|
self.ItemList[i][j]:SetEffectLayer(cursortingOrder)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2020-12-26 11:47:16 +08:00
|
|
|
|
|
2021-01-26 17:08:39 +08:00
|
|
|
|
-- function GiftView.refresh()
|
2021-01-05 16:29:13 +08:00
|
|
|
|
-- LogYellow("收到了GameEvent.GrowGift.RechargeGift")
|
|
|
|
|
-- GiftView:RefreshData(curBuyType)
|
|
|
|
|
-- end
|
2020-12-26 11:47:16 +08:00
|
|
|
|
|
2020-05-15 16:52:35 +08:00
|
|
|
|
------日周月礼包------
|
|
|
|
|
-- 根据选择的页签刷新数据
|
2021-02-26 10:37:39 +08:00
|
|
|
|
function GiftView:RefreshData(buyType,isTop,isAni)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
-- 当前选中的页签
|
|
|
|
|
self.buyType = buyType
|
2020-05-25 19:16:23 +08:00
|
|
|
|
self.titleBg.sprite = Util.LoadSprite(Title_BG_NAME[buyType])
|
2020-06-08 13:57:30 +08:00
|
|
|
|
CheckRedPointStatus(RedPointType.GrowthPackage)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
-- 刷新商品数据
|
2021-02-26 10:37:39 +08:00
|
|
|
|
self:RefreshGiftData(isTop,isAni)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
-- 刷新剩余时间
|
|
|
|
|
self:GetRemainTime()
|
2020-09-24 20:02:27 +08:00
|
|
|
|
-- 刷新一键购买显示
|
|
|
|
|
self:RefreshOneKeyShow()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 刷新一键购买显示
|
|
|
|
|
function GiftView:RefreshOneKeyShow()
|
|
|
|
|
-- 计算总价
|
|
|
|
|
local ori = 0
|
|
|
|
|
ori = ori + MoneyUtil.GetMoney(rechargeCommodityConfig[1001].Price)
|
|
|
|
|
ori = ori + MoneyUtil.GetMoney(rechargeCommodityConfig[1002].Price)
|
|
|
|
|
ori = ori + MoneyUtil.GetMoney(rechargeCommodityConfig[1003].Price)
|
|
|
|
|
-- 计算现价
|
|
|
|
|
local now = 0
|
|
|
|
|
now = now + MoneyUtil.GetMoney(rechargeCommodityConfig[1004].Price)
|
|
|
|
|
|
2021-03-18 10:27:36 +08:00
|
|
|
|
-- self.oriPrice.text = Language[10582]..MoneyUtil.GetMoneyMark()..ori
|
|
|
|
|
-- self.nowPrice.text = Language[10644]..MoneyUtil.GetMoneyMark()..now
|
2021-03-18 14:10:23 +08:00
|
|
|
|
self.oriPrice.text = string.format("原价:%s元",ori)
|
|
|
|
|
self.nowPrice.text = string.format("现价:%s元",now)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 刷新礼包的数据
|
2021-02-26 10:37:39 +08:00
|
|
|
|
function GiftView:RefreshGiftData(isTop,isAni)
|
2020-08-22 10:09:30 +08:00
|
|
|
|
self:isBought()
|
2020-06-03 19:09:01 +08:00
|
|
|
|
self.scrollView.gameObject:SetActive(false)
|
|
|
|
|
self.scrollView2.gameObject:SetActive(false)
|
|
|
|
|
self.scrollView3.gameObject:SetActive(false)--成长礼包
|
2020-06-13 11:47:13 +08:00
|
|
|
|
|
2020-05-15 16:52:35 +08:00
|
|
|
|
local shopData = {}
|
2020-06-03 19:09:01 +08:00
|
|
|
|
if self.buyType ~= DirectBuyType.FINDTREASURE_GIFT and self.buyType ~= SHOP_TYPE.VIP_GIFT then--充值+每日礼包界面
|
2020-05-15 16:52:35 +08:00
|
|
|
|
--这个界面 普通商品只有 GoodsTypeDef.DirectPurchaseGift
|
|
|
|
|
shopData = self:ResetShopData(OperatingManager.GetGiftGoodsInfoList(GoodsTypeDef.DirectPurchaseGift), self.buyType, DataType.Direct)
|
|
|
|
|
table.sort(shopData,function(a,b)
|
|
|
|
|
if a.sortId == b.sortId then
|
|
|
|
|
return a.data.goodsId < b.data.goodsId
|
|
|
|
|
else
|
|
|
|
|
return a.sortId > b.sortId
|
|
|
|
|
end
|
|
|
|
|
end)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
local callBack = function(index, item)
|
|
|
|
|
self:RefreshShowData(item, shopData[index].data, self.buyType, shopData[index].DataType)
|
|
|
|
|
end
|
2021-02-26 10:37:39 +08:00
|
|
|
|
self.scrollView:SetData(shopData, callBack,not isTop,not isAni)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
self.scrollView.gameObject:SetActive(true)
|
|
|
|
|
elseif self.buyType == DirectBuyType.FINDTREASURE_GIFT then--特权礼包界面
|
2020-05-15 16:52:35 +08:00
|
|
|
|
--两部分组成 寻宝特权在商品里 极速探索礼包在直购里
|
|
|
|
|
local topspeedData = self:ResetShopData(ShopManager.GetShopDataByType(SHOP_TYPE.FINDTREASURE_GIFT).storeItem, self.buyType, DataType.Shop)
|
2020-07-31 13:35:15 +08:00
|
|
|
|
if RECHARGEABLE then--(是否开启充值)
|
|
|
|
|
shopData = self:ResetShopData(OperatingManager.GetGiftGoodsInfoList(GoodsTypeDef.DirectPurchaseGift), self.buyType, DataType.Direct)
|
|
|
|
|
end
|
2020-05-15 16:52:35 +08:00
|
|
|
|
for i = 1, #topspeedData do
|
|
|
|
|
table.insert(shopData,topspeedData[i])
|
|
|
|
|
end
|
|
|
|
|
table.sort(shopData,function(a,b)
|
2020-09-03 15:14:08 +08:00
|
|
|
|
if a.sortId == b.sortId then
|
2020-11-02 14:36:21 +08:00
|
|
|
|
if a.DataType == b.DataType and a.DataType == DataType.Direct and b.DataType == DataType.Direct then
|
|
|
|
|
return rechargeCommodityConfig[a.data.goodsId].Sequence < rechargeCommodityConfig[b.data.goodsId].Sequence
|
|
|
|
|
else
|
|
|
|
|
return a.DataType > b.DataType
|
|
|
|
|
end
|
2020-09-03 15:14:08 +08:00
|
|
|
|
else
|
|
|
|
|
return a.sortId > b.sortId
|
|
|
|
|
end
|
2020-05-15 16:52:35 +08:00
|
|
|
|
end)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
local callBack = function(index, item)
|
|
|
|
|
self:RefreshShowData(item, shopData[index].data, self.buyType, shopData[index].DataType)
|
|
|
|
|
end
|
2021-02-26 10:37:39 +08:00
|
|
|
|
self.scrollView2:SetData(shopData, callBack,not isTop,not isAni)
|
2021-01-05 16:29:13 +08:00
|
|
|
|
self:TimeCountDown()
|
2020-06-03 19:09:01 +08:00
|
|
|
|
self.scrollView2.gameObject:SetActive(true)
|
|
|
|
|
|
|
|
|
|
elseif self.buyType == SHOP_TYPE.VIP_GIFT then--成长礼包界面
|
2020-06-13 11:47:13 +08:00
|
|
|
|
--每次重新登录会显示红点
|
|
|
|
|
PlayerPrefs.SetInt(PlayerManager.uid.."czlb", 1)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
shopData = self:ResetShopData(ShopManager.GetShopDataByType(SHOP_TYPE.VIP_GIFT).storeItem, self.buyType, DataType.Shop)
|
2020-06-13 11:47:13 +08:00
|
|
|
|
|
2020-06-03 19:09:01 +08:00
|
|
|
|
--如果未达到充值要求不显示某些档位商品
|
|
|
|
|
for i = 1, #shopData do
|
|
|
|
|
if rechargeNum < shopItemConfig[shopData[i].data.id].ShowRule[2] then
|
|
|
|
|
shopData[i] = nil
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--(礼包类型-成长礼包,页面的类型-SHOP_TYPE.VIP_GIFT,商品)
|
|
|
|
|
table.sort(shopData,function(a,b)
|
|
|
|
|
if a.sortId == b.sortId then
|
|
|
|
|
return a.data.id < b.data.id
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
local callBack = function(index, item)
|
|
|
|
|
self:RefreshShowData(item, shopData[index].data, self.buyType, shopData[index].DataType)
|
|
|
|
|
end
|
2021-02-26 10:37:39 +08:00
|
|
|
|
self.scrollView3:SetData(shopData, callBack,not isTop,not isAni)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
self.scrollView3.gameObject:SetActive(true)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
self:RefreshFreeData()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 商店数据重组
|
|
|
|
|
function GiftView:ResetShopData(shopData, buyType, DataTypeIndex)
|
|
|
|
|
local newData = {}
|
|
|
|
|
local boughtNum = 0
|
|
|
|
|
local limitNum = 0
|
|
|
|
|
for i = 1, #shopData do
|
|
|
|
|
if DataTypeIndex == DataType.Shop then
|
|
|
|
|
boughtNum = ShopManager.GetShopItemHadBuyTimes(SHOP_TYPE.FINDTREASURE_GIFT, 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] = {data = shopData[i],DataType = DataTypeIndex,sortId = curSortId}
|
|
|
|
|
elseif DataTypeIndex == DataType.Direct then
|
|
|
|
|
--所有直购 进行筛选 类型一致的取出
|
|
|
|
|
if rechargeCommodityConfig[shopData[i].goodsId].ShowType == buyType then
|
|
|
|
|
boughtNum = OperatingManager.GetGoodsBuyTime(GoodsTypeDef.DirectPurchaseGift, 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] = {data = shopData[i],DataType = DataTypeIndex,sortId = curSortId}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return newData
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--每种礼包的剩余时间
|
|
|
|
|
function GiftView:GetRemainTime()
|
2020-06-08 13:57:30 +08:00
|
|
|
|
|
|
|
|
|
local localSelf = self
|
|
|
|
|
local freshTime = 0--剩余时间
|
|
|
|
|
|
|
|
|
|
--成长礼包不显示时间
|
|
|
|
|
local isGrowthGift = self.buyType == SHOP_TYPE.VIP_GIFT
|
|
|
|
|
self.endTimeBg:SetActive(not isGrowthGift)--成长礼包 没有倒计时
|
2020-09-24 20:02:27 +08:00
|
|
|
|
self.oneKey:SetActive(not isGrowthGift)
|
2020-06-08 13:57:30 +08:00
|
|
|
|
if isGrowthGift then--特权商城界面+成长礼包
|
2020-05-15 16:52:35 +08:00
|
|
|
|
if self.localTimer then
|
|
|
|
|
self.localTimer:Stop()
|
|
|
|
|
self.localTimer = nil
|
|
|
|
|
end
|
|
|
|
|
self.endTime.text= ""
|
|
|
|
|
return
|
2020-06-08 13:57:30 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--特权礼包计时器写入item刷新中了,计时器就停了
|
2020-06-13 11:47:13 +08:00
|
|
|
|
local isPrivilegeGift = self.buyType == DirectBuyType.FINDTREASURE_GIFT
|
2020-06-08 13:57:30 +08:00
|
|
|
|
if isPrivilegeGift then
|
2020-06-13 11:47:13 +08:00
|
|
|
|
self.endTimeBg:SetActive(not isPrivilegeGift)
|
2020-09-24 20:02:27 +08:00
|
|
|
|
self.oneKey:SetActive(not isPrivilegeGift)
|
2020-06-08 13:57:30 +08:00
|
|
|
|
self.endTime.text= ""
|
|
|
|
|
end
|
|
|
|
|
|
2020-06-13 11:47:13 +08:00
|
|
|
|
|
2020-06-08 13:57:30 +08:00
|
|
|
|
--每日礼包
|
|
|
|
|
local isDailyGift = self.buyType == DirectBuyType.DAILY_GIFT
|
|
|
|
|
if isDailyGift then
|
|
|
|
|
local datalist = OperatingManager.GetGiftGoodsInfoList(GoodsTypeDef.DirectPurchaseGift)
|
|
|
|
|
for i = 1, #datalist do
|
|
|
|
|
if rechargeCommodityConfig[datalist[i].goodsId].ShowType == self.buyType then
|
|
|
|
|
if freshTime <= 0 then
|
|
|
|
|
freshTime = datalist[i].endTime
|
|
|
|
|
end
|
2020-05-15 16:52:35 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2020-06-08 13:57:30 +08:00
|
|
|
|
|
2020-06-13 11:47:13 +08:00
|
|
|
|
|
2020-06-08 13:57:30 +08:00
|
|
|
|
if freshTime and freshTime > 0 then--时间已经耗尽
|
2020-05-15 16:52:35 +08:00
|
|
|
|
else
|
|
|
|
|
return
|
|
|
|
|
end
|
2020-06-08 13:57:30 +08:00
|
|
|
|
|
2020-05-15 16:52:35 +08:00
|
|
|
|
local UpDate = function()
|
|
|
|
|
if not localSelf.localTimer then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
local showfreshTime = freshTime - GetTimeStamp()
|
|
|
|
|
if showfreshTime > 0 then
|
|
|
|
|
-- 剩余小时
|
|
|
|
|
local formatTime, leftHour = TimeToHMS(showfreshTime)
|
|
|
|
|
if leftHour > 24 then
|
2021-03-02 16:53:12 +08:00
|
|
|
|
self.endTime.text = Language[11355]..TimeToDHMS(showfreshTime)--天时分秒
|
2020-05-15 16:52:35 +08:00
|
|
|
|
else
|
2021-03-02 16:53:12 +08:00
|
|
|
|
self.endTime.text = Language[11355]..self:TimeToHMS(showfreshTime)--时分秒
|
2020-05-15 16:52:35 +08:00
|
|
|
|
end
|
|
|
|
|
elseif showfreshTime == 0 then
|
|
|
|
|
-- 时间到刷一下数据
|
2020-06-03 19:09:01 +08:00
|
|
|
|
--Log("刷新时间到了")
|
2020-05-15 16:52:35 +08:00
|
|
|
|
self:RefreshGiftData()
|
|
|
|
|
elseif showfreshTime==-1 then --不刷新显示内容
|
|
|
|
|
self.endTime.text=""
|
|
|
|
|
end
|
|
|
|
|
end
|
2020-06-08 13:57:30 +08:00
|
|
|
|
|
2020-05-15 16:52:35 +08:00
|
|
|
|
if self.localTimer then
|
|
|
|
|
self.localTimer:Stop()
|
|
|
|
|
self.localTimer = nil
|
|
|
|
|
end
|
2020-06-08 13:57:30 +08:00
|
|
|
|
|
2020-05-15 16:52:35 +08:00
|
|
|
|
if not self.localTimer then
|
|
|
|
|
self.localTimer = Timer.New(UpDate, 1, -1, true)
|
|
|
|
|
self.localTimer:Start()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
UpDate()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--刷新每日免费礼包
|
|
|
|
|
function GiftView:RefreshFreeData()
|
2020-05-25 19:16:23 +08:00
|
|
|
|
local isDaily = self.buyType == DirectBuyType.DAILY_GIFT
|
|
|
|
|
self.freeBtn:SetActive(isDaily)
|
|
|
|
|
self.dayGiftIcon:SetActive(isDaily)
|
|
|
|
|
|
2020-05-15 16:52:35 +08:00
|
|
|
|
local freeData=ShopManager.GetShopDataByType(SHOP_TYPE.FREE_GIFT).storeItem
|
|
|
|
|
local boughtNum = ShopManager.GetShopItemHadBuyTimes(SHOP_TYPE.FREE_GIFT, freeData[1].id)
|
|
|
|
|
local limitNum = ShopManager.GetShopItemLimitBuyCount(freeData[1].id)
|
|
|
|
|
local isCanBuy = limitNum - boughtNum >= 1
|
|
|
|
|
self.freeBtnAnim.enabled=isCanBuy
|
|
|
|
|
self.redPoint:SetActive(isCanBuy)
|
|
|
|
|
-- 光效显隐
|
|
|
|
|
for _, light in ipairs(self.lightList) do
|
|
|
|
|
light:SetActive(isCanBuy)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local costId, finalNum, oriCostNum = ShopManager.calculateBuyCost(SHOP_TYPE.FREE_GIFT, freeData[1].id, 1)
|
|
|
|
|
CheckRedPointStatus(RedPointType.DailyGift)
|
2020-06-08 13:57:30 +08:00
|
|
|
|
CheckRedPointStatus(RedPointType.GrowthPackage)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
Util.AddOnceClick(self.freeBtn,function()
|
|
|
|
|
if isCanBuy then
|
|
|
|
|
self:BuyAction(costId, finalNum, SHOP_TYPE.FREE_GIFT, freeData[1].id)
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
2020-06-03 19:09:01 +08:00
|
|
|
|
--根据数字位数计算艺术字体后面的文字位置
|
|
|
|
|
function GiftView:SetTextPos(num1)
|
2020-08-26 19:08:21 +08:00
|
|
|
|
local x = (string.len(tostring(num1))-1)*18 - 60
|
2020-06-03 19:09:01 +08:00
|
|
|
|
return x
|
|
|
|
|
end
|
|
|
|
|
|
2020-08-22 10:09:30 +08:00
|
|
|
|
function GiftView:isBought()
|
|
|
|
|
local data = OperatingManager.GetGiftGoodsInfoList(GoodsTypeDef.DirectPurchaseGift)
|
|
|
|
|
for i = 1, #data do
|
|
|
|
|
if rechargeCommodityConfig[data[i].goodsId].ShowType == 14 then
|
|
|
|
|
if data[i].buyTimes >0 then
|
2020-08-25 11:42:55 +08:00
|
|
|
|
Util.SetGray(self.buyAllBtn,true)
|
|
|
|
|
self.buyAllBtn:GetComponent("Button").interactable = false
|
2020-08-22 10:09:30 +08:00
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2020-05-15 16:52:35 +08:00
|
|
|
|
--刷新每一条的显示数据
|
|
|
|
|
function GiftView:RefreshShowData(item, data, buyType, DataTypeIndex)
|
|
|
|
|
--绑定组件
|
2020-06-13 11:47:13 +08:00
|
|
|
|
local localSelf = self
|
2020-05-15 16:52:35 +08:00
|
|
|
|
local name = Util.GetGameObject(item, "context/text"):GetComponent("Text")
|
|
|
|
|
local icon = Util.GetGameObject(item, "btnBuy/icon")
|
|
|
|
|
local price = Util.GetGameObject(item, "btnBuy/price"):GetComponent("Text")
|
|
|
|
|
local buyInfo = Util.GetGameObject(item, "buyInfo"):GetComponent("Text")
|
|
|
|
|
local btnBuy = Util.GetGameObject(item, "btnBuy")
|
|
|
|
|
local grid = Util.GetGameObject(item, "scrollView/grid")
|
|
|
|
|
local shadow=Util.GetGameObject(item,"shadow")
|
|
|
|
|
local tipImage=Util.GetGameObject(item,"tipImage")
|
|
|
|
|
local tipImageText=Util.GetGameObject(item,"tipImage/Text"):GetComponent("Text")
|
2020-06-03 19:09:01 +08:00
|
|
|
|
local redPoint = Util.GetGameObject(item,"btnBuy/redPoint")
|
|
|
|
|
-- 设置tip显示
|
|
|
|
|
self:SetTipShow(Util.GetGameObject(item,"tip"), data, buyType, DataTypeIndex)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
-- 物品Item
|
|
|
|
|
local shows
|
|
|
|
|
local shopItemData
|
|
|
|
|
-- 购买数量与限购数量
|
2020-06-03 19:09:01 +08:00
|
|
|
|
local rechargeNum = VipManager.GetChargedNum()--已经充值的金额
|
2020-05-15 16:52:35 +08:00
|
|
|
|
local boughtNum = 0
|
|
|
|
|
local limitNum = 0
|
|
|
|
|
local costId, finalNum, oriCostNum
|
|
|
|
|
local isPrivilegeGift = buyType == DirectBuyType.FINDTREASURE_GIFT
|
2020-06-03 19:09:01 +08:00
|
|
|
|
local isGrowthGift = buyType == SHOP_TYPE.VIP_GIFT
|
|
|
|
|
self.tip3:SetActive(isGrowthGift)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
--道具商品 和 直购商品 获取数据的地方不一致
|
|
|
|
|
if DataTypeIndex == DataType.Shop then
|
2020-06-03 19:09:01 +08:00
|
|
|
|
if isPrivilegeGift then--特权商城
|
|
|
|
|
shopItemData = shopItemConfig[data.id]
|
|
|
|
|
shows = shopItemData.Goods
|
2021-01-28 17:29:41 +08:00
|
|
|
|
name.text = GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.ItemConfig,shows[1][1]).Name)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
boughtNum = ShopManager.GetShopItemHadBuyTimes(SHOP_TYPE.FINDTREASURE_GIFT, data.id)
|
|
|
|
|
limitNum = ShopManager.GetShopItemLimitBuyCount(data.id)
|
|
|
|
|
costId, finalNum, oriCostNum = ShopManager.calculateBuyCost(SHOP_TYPE.FINDTREASURE_GIFT, data.id, 1)
|
|
|
|
|
tipImage:SetActive(isPrivilegeGift)
|
|
|
|
|
if isPrivilegeGift then
|
2021-03-02 16:53:12 +08:00
|
|
|
|
tipImageText.text = Language[11356]
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end
|
|
|
|
|
elseif isGrowthGift then--成长礼包!!!!!!!!
|
|
|
|
|
local num = Util.GetGameObject(item, "context/number/num"):GetComponent("Text")
|
|
|
|
|
local yuan = Util.GetGameObject(item, "context/number/yuan")
|
2021-01-26 17:08:39 +08:00
|
|
|
|
local progress = Util.GetGameObject(item, "context/progress"):GetComponent("Text")
|
|
|
|
|
local numTextGrid = Util.GetGameObject(item, "NumTextPre")
|
2020-06-03 19:09:01 +08:00
|
|
|
|
shopItemData = shopItemConfig[data.id]
|
|
|
|
|
shows = shopItemData.Goods--奖励数据
|
2021-01-26 17:08:39 +08:00
|
|
|
|
local str = shopItemData.BuyRule[2]--需要充值的金额数
|
|
|
|
|
CreatNumberPrefab(tostring(str),numTextGrid,2)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
--设置艺术字体后面的文字位置
|
2021-01-26 17:08:39 +08:00
|
|
|
|
-- local x = self:SetTextPos(shopItemData.BuyRule[2])
|
|
|
|
|
-- yuan:GetComponent("RectTransform").anchoredPosition = Vector2.New(x, 0)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
|
2021-03-02 16:53:12 +08:00
|
|
|
|
progress.text = "("..rechargeNum.."/"..shopItemData.BuyRule[2]..Language[11698]--资格进度条
|
2020-06-03 19:09:01 +08:00
|
|
|
|
boughtNum = ShopManager.GetShopItemHadBuyTimes(SHOP_TYPE.VIP_GIFT, data.id)
|
|
|
|
|
limitNum = ShopManager.GetShopItemLimitBuyCount(data.id)
|
|
|
|
|
costId, finalNum, oriCostNum = ShopManager.calculateBuyCost(SHOP_TYPE.VIP_GIFT, data.id, 1)
|
2020-06-19 20:19:35 +08:00
|
|
|
|
-- 根据充值状态修改按钮图片
|
|
|
|
|
local isCanBuy = rechargeNum >= shopItemConfig[data.id].BuyRule[2]
|
|
|
|
|
btnBuy:GetComponent("Image").sprite = Util.LoadSprite(isCanBuy and "s_slbz_1anniuongse" or "s_slbz_1anniuhuangse")
|
|
|
|
|
|
2020-06-03 19:09:01 +08:00
|
|
|
|
tipImage:SetActive(isGrowthGift)
|
|
|
|
|
if isGrowthGift then
|
2021-03-02 16:53:12 +08:00
|
|
|
|
tipImageText.text = Language[11356]
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end
|
2020-05-15 16:52:35 +08:00
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
shopItemData = rechargeCommodityConfig[data.goodsId]
|
|
|
|
|
shows = shopItemData.RewardShow
|
2021-01-26 17:08:39 +08:00
|
|
|
|
name.text = GetLanguageStrById(shopItemData.Name)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
boughtNum = OperatingManager.GetGoodsBuyTime(GoodsTypeDef.DirectPurchaseGift, data.goodsId)
|
|
|
|
|
limitNum = shopItemData.Limit
|
2020-08-25 17:59:34 +08:00
|
|
|
|
costId, finalNum, oriCostNum = nil, MoneyUtil.GetMoney(shopItemData.Price), nil
|
2020-05-15 16:52:35 +08:00
|
|
|
|
tipImage:SetActive(isPrivilegeGift)
|
|
|
|
|
if isPrivilegeGift then
|
2020-05-25 19:16:23 +08:00
|
|
|
|
if shopItemData.DailyUpdate == 7 then
|
2021-03-02 16:53:12 +08:00
|
|
|
|
tipImageText.text = Language[11699]
|
2020-11-02 15:56:06 +08:00
|
|
|
|
elseif shopItemData.DailyUpdate == 15 then
|
2021-03-02 16:53:12 +08:00
|
|
|
|
tipImageText.text = Language[11700]
|
2020-05-25 19:16:23 +08:00
|
|
|
|
elseif shopItemData.DailyUpdate == 30 then
|
2021-03-02 16:53:12 +08:00
|
|
|
|
tipImageText.text = Language[11357]
|
2020-05-25 19:16:23 +08:00
|
|
|
|
end
|
2020-05-15 16:52:35 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2020-06-08 13:57:30 +08:00
|
|
|
|
|
2020-05-15 16:52:35 +08:00
|
|
|
|
--滚动条复用重设itemview
|
|
|
|
|
if self.ItemList[item] then
|
2020-06-03 19:09:01 +08:00
|
|
|
|
for i = 1, 5 do
|
2020-05-15 16:52:35 +08:00
|
|
|
|
self.ItemList[item][i].gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
for i = 1, #shows do
|
|
|
|
|
if self.ItemList[item][i] then
|
|
|
|
|
self.ItemList[item][i]:OnOpen(false, {shows[i][1],shows[i][2]}, 0.9,false,false,false,self.mainPanel.sortingOrder)
|
|
|
|
|
self.ItemList[item][i].gameObject:SetActive(true)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
self.ItemList[item]={}
|
2020-06-03 19:09:01 +08:00
|
|
|
|
for i = 1, 5 do
|
2020-05-15 16:52:35 +08:00
|
|
|
|
self.ItemList[item][i] = SubUIManager.Open(SubUIConfig.ItemView, grid.transform)
|
|
|
|
|
self.ItemList[item][i].gameObject:SetActive(false)
|
|
|
|
|
local obj= newObjToParent(shadow,self.ItemList[item][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
|
|
|
|
|
self.ItemList[item][i]:OnOpen(false, {shows[i][1],shows[i][2]}, 0.9,false,false,false,self.mainPanel.sortingOrder)
|
|
|
|
|
self.ItemList[item][i].gameObject:SetActive(true)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 设置按钮状态
|
|
|
|
|
local isCanBuy = limitNum - boughtNum >0
|
|
|
|
|
btnBuy:GetComponent("Button").interactable = isCanBuy
|
2020-06-03 19:09:01 +08:00
|
|
|
|
--btnBuy:SetActive(true)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
Util.SetGray(btnBuy,not isCanBuy)
|
|
|
|
|
icon:GetComponent("Image").enabled=isCanBuy
|
2020-06-08 13:57:30 +08:00
|
|
|
|
btnBuy:SetActive(true)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
if isCanBuy then
|
2020-06-03 19:09:01 +08:00
|
|
|
|
if DataTypeIndex == DataType.Shop then--商品类按钮上的文字位置(空格慎调整!!!)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
icon:SetActive(true)
|
|
|
|
|
icon:GetComponent("Image").sprite = SetIcon(shopItemData.Cost[1][1])
|
|
|
|
|
price.alignment="MiddleRight"
|
2020-08-24 23:58:33 +08:00
|
|
|
|
price.alignment = "MiddleLeft"
|
|
|
|
|
price.text = finalNum--..str
|
2020-06-03 19:09:01 +08:00
|
|
|
|
else--直购类按钮上的文字位置(空格慎调整!!!)
|
2020-08-24 23:58:33 +08:00
|
|
|
|
price.alignment = "MiddleCenter"
|
2020-05-15 16:52:35 +08:00
|
|
|
|
icon:SetActive(false)
|
2020-08-25 13:57:21 +08:00
|
|
|
|
price.text = string.format(MoneyUtil.GetMoneyUnitName(), finalNum)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
end
|
2021-03-02 16:53:12 +08:00
|
|
|
|
buyInfo.text = Language[10580]..limitNum - boughtNum..Language[10048]
|
2020-05-15 16:52:35 +08:00
|
|
|
|
else
|
|
|
|
|
price.alignment="MiddleCenter"
|
2021-03-02 16:53:12 +08:00
|
|
|
|
price.text=Language[10514]
|
2021-01-27 10:02:58 +08:00
|
|
|
|
buyInfo.text = ""
|
2020-06-08 13:57:30 +08:00
|
|
|
|
|
|
|
|
|
--特权 直购 按钮消失
|
|
|
|
|
if DataTypeIndex == DataType.Direct and isPrivilegeGift then
|
2021-01-27 10:02:58 +08:00
|
|
|
|
-- btnBuy:SetActive(false)
|
2020-06-08 13:57:30 +08:00
|
|
|
|
buyInfo.text=""
|
|
|
|
|
end
|
2020-05-15 16:52:35 +08:00
|
|
|
|
end
|
2020-05-25 19:16:23 +08:00
|
|
|
|
|
2021-01-27 10:02:58 +08:00
|
|
|
|
--为特权商城加的倒计时
|
|
|
|
|
local refreshTime = Util.GetGameObject(item,"refreshTime")
|
|
|
|
|
if refreshTime then
|
|
|
|
|
refreshTime:SetActive(false)
|
|
|
|
|
if DataTypeIndex == DataType.Direct and isPrivilegeGift then
|
|
|
|
|
local freshTime = 0
|
|
|
|
|
local datalist = OperatingManager.GetGiftGoodsInfoList(GoodsTypeDef.DirectPurchaseGift)--当前所有礼包数据
|
|
|
|
|
for i = 1, #datalist do
|
|
|
|
|
if rechargeCommodityConfig[datalist[i].goodsId].Id == data.goodsId then
|
|
|
|
|
if freshTime <= 0 then
|
|
|
|
|
freshTime = datalist[i].endTime
|
|
|
|
|
table.insert(timerList,{pre=refreshTime:GetComponent("Text"),freshTime=freshTime})
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-03-02 16:53:12 +08:00
|
|
|
|
refreshTime:GetComponent("Text").text=Language[10469]..self:SpecialTime(freshTime-GetTimeStamp())
|
2021-01-27 10:02:58 +08:00
|
|
|
|
end
|
|
|
|
|
refreshTime:SetActive(not isCanBuy)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 请求购买
|
2020-05-15 16:52:35 +08:00
|
|
|
|
Util.AddOnceClick(btnBuy, function()
|
|
|
|
|
if not isCanBuy then
|
2021-03-02 16:53:12 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[10515])
|
2020-05-15 16:52:35 +08:00
|
|
|
|
else
|
|
|
|
|
--道具商品
|
|
|
|
|
if DataTypeIndex == DataType.Shop then
|
2020-06-03 19:09:01 +08:00
|
|
|
|
if buyType == SHOP_TYPE.VIP_GIFT then
|
|
|
|
|
if rechargeNum >= shopItemConfig[data.id].BuyRule[2] then--充值金额达到要求
|
|
|
|
|
self:BuyAction(costId, finalNum, SHOP_TYPE.VIP_GIFT, data.id)--成长礼包
|
|
|
|
|
else--充值金额未达到要求
|
2021-03-02 16:53:12 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[11701])
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end
|
|
|
|
|
elseif buyType == DirectBuyType.FINDTREASURE_GIFT then
|
|
|
|
|
self:BuyAction(costId, finalNum, SHOP_TYPE.FINDTREASURE_GIFT, data.id)--特权商城
|
|
|
|
|
end
|
2020-06-08 13:57:30 +08:00
|
|
|
|
CheckRedPointStatus(RedPointType.GrowthPackage)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
else
|
|
|
|
|
--直购商品
|
2020-09-09 18:47:17 +08:00
|
|
|
|
PayManager.Pay( data.goodsId, function(id)
|
|
|
|
|
FirstRechargeManager.RefreshAccumRechargeValue(data.goodsId)
|
|
|
|
|
PlayerPrefs.SetInt(PlayerManager.uid.."czlb", 0)
|
|
|
|
|
CheckRedPointStatus(RedPointType.DailyGift)
|
|
|
|
|
CheckRedPointStatus(RedPointType.GrowthPackage)
|
|
|
|
|
timerList={}
|
|
|
|
|
self:RefreshGiftData()
|
|
|
|
|
end)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
2021-01-26 17:08:39 +08:00
|
|
|
|
local offSetX = {
|
2021-02-20 14:40:01 +08:00
|
|
|
|
[0] = { icon = Vector3.New(15.3,8,0),txt = Vector3.New(83.4,0.5,0),ima = Vector3.New(0,0,0),txt1 = Vector3.New(-162,0.5,0),icon1 = Vector3.New(-219.6,8,0)},
|
|
|
|
|
[1] = { icon = Vector3.New(219.86,8,0),txt = Vector3.New(288.5,0.5,0),ima = Vector3.New(20.19,0,0),txt1 = Vector3.New(-162,0.5,0),icon1 = Vector3.New(-219.6,8,0)},
|
|
|
|
|
[2] = { icon = Vector3.New(30,8,0),txt = Vector3.New(86.4,0.5,0),ima = Vector3.New(30,0,0),txt1 = Vector3.New(-105.7,0.5,0),icon1 = Vector3.New(-155.7,8,0)}
|
2021-01-26 17:08:39 +08:00
|
|
|
|
}
|
2020-06-03 19:09:01 +08:00
|
|
|
|
function GiftView:SetTipShow(tipRoot, data, buyType, DataTypeIndex)
|
|
|
|
|
if buyType == DirectBuyType.DAILY_GIFT then
|
|
|
|
|
local tip1=Util.GetGameObject(tipRoot,"tip1"):GetComponent("Image")
|
|
|
|
|
local tip1Text1=Util.GetGameObject(tipRoot,"tip1/text1"):GetComponent("Text")
|
|
|
|
|
local tip1Text2=Util.GetGameObject(tipRoot,"tip1/text2"):GetComponent("Text")
|
|
|
|
|
local tip2=Util.GetGameObject(tipRoot,"tip2"):GetComponent("Image")
|
|
|
|
|
local tip2Text=Util.GetGameObject(tipRoot,"tip2/text"):GetComponent("Text")
|
|
|
|
|
--道具商品 和 直购商品 获取数据的地方不一致
|
|
|
|
|
if DataTypeIndex == DataType.Shop then
|
|
|
|
|
local shopItemData = shopItemConfig[data.id]
|
|
|
|
|
-- 设置立赠提示
|
|
|
|
|
tip1.gameObject:SetActive(shopItemData.Goods[1][1] == 16 )
|
|
|
|
|
tip2.gameObject:SetActive(shopItemData.Goods[1][1] ~= 16)
|
|
|
|
|
tip1Text1.text=shopItemData.Goods[1][2]
|
|
|
|
|
tip1Text2.text=shopItemData.Rebate
|
|
|
|
|
tip2Text.text=shopItemData.Rebate
|
|
|
|
|
else
|
|
|
|
|
local shopItemData = rechargeCommodityConfig[data.goodsId]
|
|
|
|
|
-- 设置立赠提示
|
|
|
|
|
tip1.gameObject:SetActive(shopItemData.RewardShow[1][1] == 16 )
|
|
|
|
|
tip2.gameObject:SetActive(shopItemData.RewardShow[1][1] ~= 16)
|
|
|
|
|
tip1Text1.text=shopItemData.RewardShow[1][2]
|
|
|
|
|
tip1Text2.text=shopItemData.Rebate
|
|
|
|
|
tip2Text.text=shopItemData.Rebate
|
|
|
|
|
end
|
2021-01-26 17:08:39 +08:00
|
|
|
|
if GetCurLanguage() == 0 then
|
2021-02-20 14:40:01 +08:00
|
|
|
|
tip1Text1.gameObject:GetComponent("RectTransform").localPosition = offSetX[0].txt1
|
|
|
|
|
Util.GetGameObject(tipRoot,"tip1/icon_1"):GetComponent("RectTransform").localPosition = offSetX[0].icon1
|
2021-01-26 17:08:39 +08:00
|
|
|
|
tip1Text2.gameObject:GetComponent("RectTransform").localPosition = offSetX[0].txt
|
|
|
|
|
Util.GetGameObject(tipRoot,"tip1/icon_2"):GetComponent("RectTransform").localPosition = offSetX[0].icon
|
|
|
|
|
Util.GetGameObject(tipRoot,"tip1/Image"):GetComponent("RectTransform").localPosition = offSetX[0].ima
|
2021-02-20 14:40:01 +08:00
|
|
|
|
elseif GetCurLanguage() == 1 then
|
|
|
|
|
tip1Text1.gameObject:GetComponent("RectTransform").localPosition = offSetX[1].txt1
|
|
|
|
|
Util.GetGameObject(tipRoot,"tip1/icon_1"):GetComponent("RectTransform").localPosition = offSetX[1].icon1
|
2021-01-26 17:08:39 +08:00
|
|
|
|
tip1Text2.gameObject:GetComponent("RectTransform").localPosition = offSetX[1].txt
|
|
|
|
|
Util.GetGameObject(tipRoot,"tip1/icon_2"):GetComponent("RectTransform").localPosition = offSetX[1].icon
|
2021-02-20 14:40:01 +08:00
|
|
|
|
Util.GetGameObject(tipRoot,"tip1/Image"):GetComponent("RectTransform").localPosition = offSetX[1].ima
|
|
|
|
|
else
|
|
|
|
|
tip1Text1.gameObject:GetComponent("RectTransform").localPosition = offSetX[2].txt1
|
|
|
|
|
Util.GetGameObject(tipRoot,"tip1/icon_1"):GetComponent("RectTransform").localPosition = offSetX[2].icon1
|
|
|
|
|
tip1Text2.gameObject:GetComponent("RectTransform").localPosition = offSetX[2].txt
|
|
|
|
|
Util.GetGameObject(tipRoot,"tip1/icon_2"):GetComponent("RectTransform").localPosition = offSetX[2].icon
|
|
|
|
|
Util.GetGameObject(tipRoot,"tip1/Image"):GetComponent("RectTransform").localPosition = offSetX[2].ima
|
2021-01-26 17:08:39 +08:00
|
|
|
|
end
|
|
|
|
|
elseif buyType == DirectBuyType.FINDTREASURE_GIFT then
|
2020-06-03 19:09:01 +08:00
|
|
|
|
local tip1 = Util.GetGameObject(tipRoot,"tip1")
|
2021-01-26 17:08:39 +08:00
|
|
|
|
local tip1_en = Util.GetGameObject(tipRoot,"tip1_en")
|
2020-06-03 19:09:01 +08:00
|
|
|
|
local tip2 = Util.GetGameObject(tipRoot,"tip2")
|
2021-01-26 17:08:39 +08:00
|
|
|
|
local tip2_en = Util.GetGameObject(tipRoot,"tip2_en")
|
2020-06-03 19:09:01 +08:00
|
|
|
|
local tip3 = Util.GetGameObject(tipRoot,"tip3")
|
2021-01-26 17:08:39 +08:00
|
|
|
|
local tip3_en = Util.GetGameObject(tipRoot,"tip3_en")
|
2020-06-03 19:09:01 +08:00
|
|
|
|
local tip4 = Util.GetGameObject(tipRoot,"tip4")
|
2021-01-26 17:08:39 +08:00
|
|
|
|
local tip4_en = Util.GetGameObject(tipRoot,"tip4_en")
|
2020-08-27 16:05:46 +08:00
|
|
|
|
local tip5 = Util.GetGameObject(tipRoot,"tip5")
|
2020-11-03 17:04:45 +08:00
|
|
|
|
local tip6 = Util.GetGameObject(tipRoot,"tip6")
|
2020-06-03 19:09:01 +08:00
|
|
|
|
tip1:SetActive(false)
|
2021-01-26 17:08:39 +08:00
|
|
|
|
tip1_en:SetActive(false)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
tip2:SetActive(false)
|
2021-01-26 17:08:39 +08:00
|
|
|
|
tip2_en:SetActive(false)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
tip3:SetActive(false)
|
2021-01-26 17:08:39 +08:00
|
|
|
|
tip3_en:SetActive(false)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
tip4:SetActive(false)
|
2021-01-26 17:08:39 +08:00
|
|
|
|
tip4_en:SetActive(false)
|
2020-08-27 16:05:46 +08:00
|
|
|
|
tip5:SetActive(false)
|
2020-11-03 17:04:45 +08:00
|
|
|
|
tip6:SetActive(false)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
if DataTypeIndex == DataType.Shop then
|
|
|
|
|
if data.id == 20091 then
|
2021-01-26 17:08:39 +08:00
|
|
|
|
if GetCurLanguage() ~= 0 then
|
|
|
|
|
tip1_en:SetActive(true)
|
|
|
|
|
else
|
|
|
|
|
tip1:SetActive(true)
|
|
|
|
|
end
|
2020-06-03 19:09:01 +08:00
|
|
|
|
elseif data.id == 20092 then
|
2021-01-26 17:08:39 +08:00
|
|
|
|
if GetCurLanguage() ~= 0 then
|
|
|
|
|
tip2_en:SetActive(true)
|
|
|
|
|
else
|
|
|
|
|
tip2:SetActive(true)
|
|
|
|
|
end
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end
|
|
|
|
|
elseif DataTypeIndex == DataType.Direct then
|
|
|
|
|
if data.goodsId == 4002 then
|
2021-01-26 17:08:39 +08:00
|
|
|
|
if GetCurLanguage() ~= 0 then
|
|
|
|
|
tip3_en:SetActive(true)
|
|
|
|
|
else
|
|
|
|
|
tip3:SetActive(true)
|
|
|
|
|
end
|
2020-06-03 19:09:01 +08:00
|
|
|
|
elseif data.goodsId == 4001 then
|
2021-01-26 17:08:39 +08:00
|
|
|
|
if GetCurLanguage() ~= 0 then
|
|
|
|
|
tip4_en:SetActive(true)
|
|
|
|
|
else
|
|
|
|
|
tip4:SetActive(true)
|
|
|
|
|
end
|
2020-08-27 16:05:46 +08:00
|
|
|
|
elseif data.goodsId == 4003 then
|
|
|
|
|
tip5:SetActive(true)
|
2020-11-03 17:04:45 +08:00
|
|
|
|
elseif data.goodsId == 7105 then
|
|
|
|
|
tip6:SetActive(true)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
2020-05-15 16:52:35 +08:00
|
|
|
|
--购买点击事件
|
|
|
|
|
function GiftView:BuyAction(costId, costNum, shopType, itemId)
|
|
|
|
|
local haveNum = BagManager.GetItemCountById(costId)
|
2021-01-26 17:08:39 +08:00
|
|
|
|
local costName = GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.ItemConfig, costId).Name)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
--Log("需要消耗的道具ID" .. costId)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
if haveNum < costNum then
|
|
|
|
|
NotEnoughPopup:Show(costId)
|
|
|
|
|
else
|
|
|
|
|
local isPopUp = RedPointManager.PlayerPrefsGetStr(PlayerManager.uid .. shopType)
|
|
|
|
|
local currentTime = os.date("%Y%m%d", PlayerManager.serverTime)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
if (isPopUp ~= currentTime and costNum ~= 0) or (shopType == SHOP_TYPE.VIP_GIFT and isPopUp ~= currentTime and costNum ~= 0) then
|
2021-03-02 16:53:12 +08:00
|
|
|
|
local str = string.format(Language[11360], costNum, costName)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
MsgPanel.ShowTwo(str, function()
|
|
|
|
|
end, function(isShow)
|
|
|
|
|
if (isShow) then
|
|
|
|
|
local currentTime = os.date("%Y%m%d", PlayerManager.serverTime)
|
|
|
|
|
RedPointManager.PlayerPrefsSetStr(PlayerManager.uid .. shopType, currentTime)
|
|
|
|
|
end
|
|
|
|
|
ShopManager.RequestBuyShopItem(shopType, itemId, 1, function()
|
|
|
|
|
self:RefreshGiftData()
|
|
|
|
|
CheckRedPointStatus(RedPointType.DailyGift)
|
2020-06-08 13:57:30 +08:00
|
|
|
|
CheckRedPointStatus(RedPointType.GrowthPackage)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
|
2021-03-02 16:53:12 +08:00
|
|
|
|
end) end, Language[10731], Language[10732],nil,true)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
else
|
|
|
|
|
ShopManager.RequestBuyShopItem(shopType, itemId, 1, function()
|
|
|
|
|
self:RefreshGiftData()
|
|
|
|
|
CheckRedPointStatus(RedPointType.DailyGift)
|
2020-06-08 13:57:30 +08:00
|
|
|
|
CheckRedPointStatus(RedPointType.GrowthPackage)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function GiftView:OnHide()
|
|
|
|
|
if self.localTimer then
|
|
|
|
|
self.localTimer:Stop()
|
|
|
|
|
self.localTimer = nil
|
|
|
|
|
end
|
2020-06-13 11:47:13 +08:00
|
|
|
|
if self.localTimerV2 then
|
|
|
|
|
self.localTimerV2:Stop()
|
|
|
|
|
self.localTimerV2 = nil
|
|
|
|
|
end
|
|
|
|
|
timerList = {}
|
2020-05-15 16:52:35 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function GiftView:OnDestroy()
|
|
|
|
|
self.scrollView=nil
|
2020-06-03 19:09:01 +08:00
|
|
|
|
self.scrollView2=nil
|
2020-06-08 13:57:30 +08:00
|
|
|
|
self.scrollView3=nil
|
2020-05-15 16:52:35 +08:00
|
|
|
|
|
|
|
|
|
if self.localTimer then
|
|
|
|
|
self.localTimer:Stop()
|
|
|
|
|
self.localTimer = nil
|
|
|
|
|
end
|
2020-06-08 13:57:30 +08:00
|
|
|
|
|
|
|
|
|
ClearRedPointObject(RedPointType.GrowthPackage)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
end
|
|
|
|
|
---------------------
|
|
|
|
|
|
|
|
|
|
-----------本模块特殊使用-----------
|
|
|
|
|
function GiftView:TimeToHMS(t)
|
|
|
|
|
if not t or t < 0 then
|
2021-03-02 16:53:12 +08:00
|
|
|
|
return Language[11365]
|
2020-05-15 16:52:35 +08:00
|
|
|
|
end
|
|
|
|
|
local _sec = t % 60
|
|
|
|
|
local allMin = math.floor(t / 60)
|
|
|
|
|
local _min = allMin % 60
|
|
|
|
|
local _hour = math.floor(allMin / 60)
|
2021-03-02 16:53:12 +08:00
|
|
|
|
return string.format(Language[10551], _hour, _min, _sec), _hour, _min, _sec
|
2020-05-15 16:52:35 +08:00
|
|
|
|
end
|
2020-06-08 13:57:30 +08:00
|
|
|
|
|
|
|
|
|
--特权商城专属
|
|
|
|
|
function GiftView:SpecialTime(t)
|
|
|
|
|
if not t or t < 0 then
|
2021-03-02 16:53:12 +08:00
|
|
|
|
return Language[11702]
|
2020-06-08 13:57:30 +08:00
|
|
|
|
end
|
|
|
|
|
local _sec = t % 60
|
|
|
|
|
local allMin = math.floor(t / 60)
|
|
|
|
|
local _min = allMin % 60
|
|
|
|
|
local allHour = math.floor(t / 3600)
|
|
|
|
|
local _hour = allHour % 24
|
|
|
|
|
local allDays = math.floor(t / 86400)
|
|
|
|
|
|
|
|
|
|
if allDays>=1 then
|
2021-03-02 16:53:12 +08:00
|
|
|
|
return string.format(Language[11703],allDays),allDays
|
2020-06-08 13:57:30 +08:00
|
|
|
|
else
|
|
|
|
|
if _hour>=1 then
|
2021-03-02 16:53:12 +08:00
|
|
|
|
return string.format(Language[11704], _hour), _hour
|
2020-06-08 13:57:30 +08:00
|
|
|
|
else
|
|
|
|
|
if _min>=1 then
|
2021-03-02 16:53:12 +08:00
|
|
|
|
return string.format(Language[11705], _min), _min
|
2020-11-03 19:10:32 +08:00
|
|
|
|
else
|
2021-03-02 16:53:12 +08:00
|
|
|
|
return Language[12152]
|
2020-06-08 13:57:30 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-03-02 16:53:12 +08:00
|
|
|
|
return Language[11702]
|
2020-06-08 13:57:30 +08:00
|
|
|
|
end
|
2020-06-13 11:47:13 +08:00
|
|
|
|
|
|
|
|
|
function GiftView:TimeCountDown()
|
|
|
|
|
if self.localTimerV2 then
|
|
|
|
|
self.localTimerV2:Stop()
|
|
|
|
|
self.localTimerV2 = nil
|
|
|
|
|
end
|
2020-07-31 10:33:05 +08:00
|
|
|
|
|
2020-07-31 13:35:15 +08:00
|
|
|
|
if RECHARGEABLE then--(是否开启充值)
|
|
|
|
|
self.localTimerV2 = Timer.New(function()
|
2020-08-27 18:35:32 +08:00
|
|
|
|
if timerList[1] then
|
2021-01-05 16:29:13 +08:00
|
|
|
|
local t1=timerList[1].freshTime-GetTimeStamp()
|
|
|
|
|
t1=t1-1
|
|
|
|
|
if t1 <= 0 then
|
2021-02-26 10:37:39 +08:00
|
|
|
|
self:RefreshData(curBuyType,false,false)
|
2020-08-27 18:35:32 +08:00
|
|
|
|
end
|
2021-03-02 16:53:12 +08:00
|
|
|
|
timerList[1].pre.text=Language[10469]..self:SpecialTime(t1)--self:SpecialTime
|
2020-07-31 13:35:15 +08:00
|
|
|
|
end
|
2020-08-27 18:35:32 +08:00
|
|
|
|
if timerList[2] then
|
2021-01-05 16:29:13 +08:00
|
|
|
|
local t2 = timerList[2].freshTime-GetTimeStamp()
|
2020-08-27 18:35:32 +08:00
|
|
|
|
t2=t2-1
|
2021-01-05 16:29:13 +08:00
|
|
|
|
if t2 <= 0 then
|
2021-02-26 10:37:39 +08:00
|
|
|
|
self:RefreshData(curBuyType,false,false)
|
2020-08-27 18:35:32 +08:00
|
|
|
|
end
|
2021-03-02 16:53:12 +08:00
|
|
|
|
timerList[2].pre.text=Language[10469]..self:SpecialTime(t2)
|
2020-07-31 13:35:15 +08:00
|
|
|
|
end
|
|
|
|
|
end,1,-1,true)
|
|
|
|
|
self.localTimerV2:Start()
|
|
|
|
|
end
|
2020-06-13 11:47:13 +08:00
|
|
|
|
end
|
2020-05-15 16:52:35 +08:00
|
|
|
|
------------------------------
|
2020-06-08 13:57:30 +08:00
|
|
|
|
return GiftView
|