local PayMall_Controller = {} local EventSystem = require 'Event/EventSystem' local LuaFuncEntry = require("Main/LuaFuncEntry") local math_floor = math.floor local private = {} local LIMIT_FORMATION_STR = "%s/%d" local JP_NOTICE_RECORD = "JP_NOTICE_RECORD" local STOCK_GREEN_COLOR = "115f09" local GoodType = { Lock = 1, SoldOut = 2, Purchase = 3 } --隐藏商城所需积分(大于等于) local HideMallTabsPoint = DataSheetManager.ConstData:GetDataByID("HideMallTabsPoint").IntValue local HideMallTabsSeverOpenday = DataSheetManager.ConstData:GetDataByID("HideMallTabsSeverOpenday").IntValue --对应StoreTypeData表,TypeID为2的TabID PayMall_Controller.PayMallMainTabId = { Normal = 101, Jade = 102, DyeAppearance = 104, } --字段名不跟配表里的字段名Enum一致 不能随便起 PayMall_Controller.ShopMainTabEnum = { YuanBao = "YuanBao", LongYu = "LongYu", ShiLi = "ShiLi", YanWu = "YanWu", ZuDui = "ZuDui", GongPing = "GongPing", DrawCard = "DrawCard", MonthCard = "MonthCard", JiangXing = "JiangXing", WuDao = "WuDao", JPBaiZhan = "JPBaiZhan", WeekActivity = "WeekActivity", GVGFight = "GVGFight", Storm = "Storm", TiaoZhan = "TiaoZhan", --越南专用兽魂商店 QunXiongYanWu = "QunXiongYanWu", SiegeCityStore = "SiegeCityStore", GuoZhan = "GuoZhan", } --商城Tab类型 PayMall_Controller.ShopTabType = {} PayMall_Controller.ShopTabType.PreferentialOrder = 1 -- 特惠 PayMall_Controller.ShopTabType.DirectGiftOrder = 2 -- 直购 PayMall_Controller.ShopTabType.Shop = 3 -- 商城 PayMall_Controller.ShopTabType.TotalTopUp = 4 -- 累充 PayMall_Controller.ShopTabType.Recharge = 5 -- 充值 PayMall_Controller.ShopTabTypeArray = { PayMall_Controller.ShopTabType.PreferentialOrder, PayMall_Controller.ShopTabType.DirectGiftOrder, PayMall_Controller.ShopTabType.Shop, PayMall_Controller.ShopTabType.TotalTopUp, PayMall_Controller.ShopTabType.Recharge, } PayMall_Controller.ShopTabDataArray = { --特惠 [PayMall_Controller.ShopTabType.PreferentialOrder] = { Type = PayMall_Controller.ShopTabType.PreferentialOrder, Ids = "IDS_ActivityTab_Title_2", Icon_UnSelected = "czjj_icon_th01", Icon_Selected = "czjj_icon_th02" }, --直购 [PayMall_Controller.ShopTabType.DirectGiftOrder] = { Type = PayMall_Controller.ShopTabType.DirectGiftOrder, Ids = "IDS_ActivityTab_Title_3", Icon_UnSelected = "czjj_icon_zg01", Icon_Selected = "czjj_icon_zg02" }, --商城 [PayMall_Controller.ShopTabType.Shop] = { Type = PayMall_Controller.ShopTabType.Shop, Ids = "IDS_Store_PayStore", Icon_UnSelected = "czjj_icon_sc01", Icon_Selected = "czjj_icon_sc02" }, --累充 [PayMall_Controller.ShopTabType.TotalTopUp] = { Type = PayMall_Controller.ShopTabType.TotalTopUp, Ids = "IDS_TotalTopUp_Title_1", Icon_UnSelected = "czjj_icon_lc01", Icon_Selected = "czjj_icon_lc02" }, --充值 [PayMall_Controller.ShopTabType.Recharge] = { Type = PayMall_Controller.ShopTabType.Recharge, Ids = "IDS_Store_RechargeButton", Icon_UnSelected = "czjj_icon_cz01", Icon_Selected = "czjj_icon_cz02" }, } --商城二级Tab类型,不包含成长基金(通过IsGrowthFund函数判断) PayMall_Controller.ShopChildTabType = { TreasureSoulCrystal = 103, -- 赋灵商店 DailyGift = 201, -- 每日礼包 MonthCard = 202, -- 月卡 DoubleMonthCardShop = 401, -- 月卡 OfficialPositionFund = 204, -- 官职基金 HeroFund = 205, -- 名将之路 HorseFund = 206, -- 玉络金鞍(坐骑之路) TreasureFund = 207, -- 物华天宝(宝物之路) HonorOrder = 208, -- 战令 GoldIngotFund = 209, -- 元宝战令 DirectGift1 = 301, -- 直购礼包——新手特惠 DirectGift2 = 302, -- 直购礼包——限时特惠 DirectGift3 = 303, -- 直购礼包——周常礼包 DirectGift4 = 304, -- 直购礼包——月度礼包 DirectGift5 = 305, -- 直购礼包——坐骑特惠 DirectGift6 = 306, -- 直购礼包——宝物特惠 DirectGift7 = 307, -- 定向-夏侯惇礼包 DirectGift8 = 308, -- 定向-夏侯惇外观礼包 DirectGift9 = 309, -- 定向-夏侯惇神兵外观礼包 DirectGift10 = 310, -- 直购礼包——元旦 DirectGift11 = 311, -- 直购礼包——每日礼包 } --203,213,223,233,243,253,263,273,283,293为成长基金占位,即二百几十三都是。顺序逐一领取 function PayMall_Controller.IsGrowthFund(fundID) if fundID > 200 and fundID < 299 then return fundID % 10 == 3 end return false end function PayMall_Controller.GetAllGrowthFundID() if not private.GrowthFundID then private.GrowthFundID = {} for i = 200, 299 do if PayMall_Controller.IsGrowthFund(i) then table.insert(private.GrowthFundID, i) end end end return private.GrowthFundID end function PayMall_Controller.IsXFund(tabType) return (tabType >= PayMall_Controller.ShopChildTabType.HeroFund and tabType <= PayMall_Controller.ShopChildTabType.TreasureFund) or tabType == PayMall_Controller.ShopChildTabType.GoldIngotFund end function PayMall_Controller.GetXFundRPKeyByTabType(tabType) if tabType == PayMall_Controller.ShopChildTabType.HeroFund then return CTL.RedPoint.RedPointKey.PayMall_PreferentialOrder_HeroFund elseif tabType == PayMall_Controller.ShopChildTabType.HorseFund then return CTL.RedPoint.RedPointKey.PayMall_PreferentialOrder_HorseFund elseif tabType == PayMall_Controller.ShopChildTabType.TreasureFund then return CTL.RedPoint.RedPointKey.PayMall_PreferentialOrder_TreasureFund elseif tabType == PayMall_Controller.ShopChildTabType.GoldIngotFund then return CTL.RedPoint.RedPointKey.PayMall_PreferentialOrder_GoldIngotFund end end PayMall_Controller.CurrentShowContext = nil --当前显示的基础页面Context ----------------------- 系统函数 ------------------------------ function PayMall_Controller.OnStartup() private.SetupEntryFunc(true) --注册战令红点事件 EventSystem.Regist(CTL.RedPoint.RedPointKey.HonorOrder, PayMall_Controller.AddHonorOrderRedPoint) --一些检测红点变化事件 EventSystem.Regist(EventID.AcquireSystemRedAfterUnlock, PayMall_Controller.RefreshRedTree) EventSystem.Regist(EventID.FunctionUnlockUpdate, PayMall_Controller.RefreshRedTree) EventSystem.Regist(EventID.UI_MonthCard_RewardClaimRefresh, PayMall_Controller.RefreshRedTree) EventSystem.Regist(EventID.UI_MonthCard_SetDailyRedPointRecord, PayMall_Controller.RefreshRedTree) EventSystem.Regist(EventID.UI_DailyGift_Refresh, PayMall_Controller.RefreshRedTree) EventSystem.Regist(EventID.UI_DirectGift_GiftInfoUpdate, PayMall_Controller.RefreshRedTree) EventSystem.Regist(EventID.UI_DirectGift_NewGiftInfoChange, PayMall_Controller.RefreshRedTree) EventSystem.Regist(EventID.UI_Fund_RefreshRedPoint, PayMall_Controller.RefreshRedTree) -- 基金红点 EventSystem.Regist(EventID.UI_HeroFund_RefreshPanel, PayMall_Controller.RefreshRedTree) --名X之路红点 EventSystem.Regist(EventID.UI_PushGift_NewGiftChange, PayMall_Controller.RefreshRedTree) EventSystem.Regist(EventID.UI_PushGift_TimeRefresh, PayMall_Controller.RefreshRedTree) EventSystem.Regist(EventID.UI_OperationActivity_DataChanged, private.OnDataChanged) end function private.SetupEntryFunc(isRegist) LuaFuncEntry.SetupMainEntryFunc(isRegist, LuaFuncEntry.FuncType.OnCanShowLoginCode, private.OnCanShowLoginCode, LuaFuncEntry.FuncType.OnOpenLoginCodeOver, private.OnOpenLoginCodeOver ) end function private.OnFunctionUnlockUpdate(id, state) PayMall_Controller.RefershRedTree() if id == MDL.Unlock.FunctionType.ClimbTower then PayMall_Controller.CheckIfBaizhanAddNew() end end function private.OnDataChanged() private.shopTabRps = {} for i ,v in MDL.OperationActivity.StoreTypeData:GetEnumerator() do if v.TypeID == MDL.PayMall.ShopType.Store then private.shopTabRps[v.TabID] = false end end PayMall_Controller.CheckIfBaizhanAddNew() end function PayMall_Controller.OnShutdown() private.shopTabRps = nil private.SetupEntryFunc(false) end -------------------------------------------------------------- function PayMall_Controller.GetLastDirectGiftTabType() return PayMall_Controller.ShopChildTabType.DirectGift11 end function PayMall_Controller.GetSortShopTabTypeArray() local directGiftTopNeedScore = DataSheetManager.ConstData:GetDataByID("DirectGiftTopNeedScore").IntValue --充值超过一定额度,调整排序 if MDL.Currency.GetTotalRechargeCredit() >= directGiftTopNeedScore then PayMall_Controller.ShopTabTypeArray[1] = PayMall_Controller.ShopTabType.DirectGiftOrder PayMall_Controller.ShopTabTypeArray[2] = PayMall_Controller.ShopTabType.PreferentialOrder else PayMall_Controller.ShopTabTypeArray[1] = PayMall_Controller.ShopTabType.PreferentialOrder PayMall_Controller.ShopTabTypeArray[2] = PayMall_Controller.ShopTabType.DirectGiftOrder end if MDL.Player.GetServerDayCount() < HideMallTabsSeverOpenday then if MDL.Currency.GetTotalRechargeCredit() < HideMallTabsPoint and not MDL.MonthCard.HadAllMonthCardActive() then table.removebyvalue(PayMall_Controller.ShopTabTypeArray, PayMall_Controller.ShopTabType.Shop) else if not table.containValue(PayMall_Controller.ShopTabTypeArray, PayMall_Controller.ShopTabType.Shop) then table.insert(PayMall_Controller.ShopTabTypeArray, PayMall_Controller.ShopTabType.Shop, 3) end end end return PayMall_Controller.ShopTabTypeArray end function PayMall_Controller.RefreshRedTree() --名X之路红点 if MDL.HeroFund.CanClaimAnyReward(LuaConst.ShowGoldenType.Hero) then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.PayMall_PreferentialOrder_HeroFund) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.PayMall_PreferentialOrder_HeroFund) end if MDL.HeroFund.CanClaimAnyReward(LuaConst.ShowGoldenType.Horse) then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.PayMall_PreferentialOrder_HorseFund) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.PayMall_PreferentialOrder_HorseFund) end if MDL.HeroFund.CanClaimAnyReward(LuaConst.ShowGoldenType.Treasure) then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.PayMall_PreferentialOrder_TreasureFund) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.PayMall_PreferentialOrder_TreasureFund) end if MDL.HeroFund.CanClaimAnyReward(LuaConst.ShowGoldenType.GoldIngot) then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.PayMall_PreferentialOrder_GoldIngotFund) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.PayMall_PreferentialOrder_GoldIngotFund) end --检测成长基金红点 if CTL.GrowthFund.IsHasGrowthFundToGet() or CTL.GrowthFund.HasFirstShowRP() then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.PayMall_PreferentialOrder_GrowthFund) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.PayMall_PreferentialOrder_GrowthFund) end --每日礼包红点 if CTL.DailyGift.HasDailyGiftToGet() then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.PayMall_PreferentialOrder_DailyGift) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.PayMall_PreferentialOrder_DailyGift) end --特惠月卡红点 if CTL.MonthCard.IsShowMonthCardRedPoint() then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.PayMall_PreferentialOrder_MonthCard) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.PayMall_PreferentialOrder_MonthCard) end --双月卡商城红点 if CTL.MonthCard.IsAllMonthCardActive() and MDL.RedPoint.GetOneTimeRedPointInfoByType(MDL.RedPoint.RedPointType.MonthCard) == 0 then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.PayMall_PayMallBase_DoubleMonthCard) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.PayMall_PayMallBase_DoubleMonthCard) end --官职基金红点 if CTL.GrowthFund.IsHasOfficialPositionFundToGet() then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.PayMall_PreferentialOrder_OfficialPositionFund) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.PayMall_PreferentialOrder_OfficialPositionFund) end --直购礼包红点(这里其实显示的是“新”)随便加了一个红点,刷新即可 if CTL.DirectGift.IsWelfareShowNew() then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.PayMall_DirectGiftOrder_DirectGift1) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.PayMall_DirectGiftOrder_DirectGift1) end if CTL.PushGift.IsShowNewInPayMall() then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.PayMall_DirectGiftOrder_DirectGift7) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.PayMall_DirectGiftOrder_DirectGift7) end end function PayMall_Controller.GetGoodType(goodData) if not PayMall_Controller.IsUnlockPurchase(goodData, false) then return GoodType.Lock end if PayMall_Controller.IsSoldOut(goodData) then return GoodType.SoldOut end return GoodType.Purchase end function PayMall_Controller.IsLimitedGood(goodData, isIgnoreColor) local maxLimitCanBuyNum = DataSheetManager.ConstData:GetDataByID("SigleBuyMax").IntValue local storeGoodsData = MDL.OperationActivity.StoreGoodsData:GetDataByID(goodData.ID) if storeGoodsData then maxLimitCanBuyNum = math.min(maxLimitCanBuyNum, storeGoodsData.SingleBuyMaxNum) end if goodData and goodData.LimitBuyType ~= LuaConst.LimitBuyType.NoLimit then local purchased = MDL.PayMall.GetPurchaseItemCount(goodData) local limited = MDL.PayMall.GetLimitedCount(goodData) local currCount = (limited - purchased) > 0 and limited - purchased or 0 local limitedStr = purchased >= limited and UTL.Color.FormatRedColor(tostring(currCount)) or (isIgnoreColor and currCount or UTL.Color.FormatGreenColor(tostring(currCount))) local canBuyNum = limited - purchased > 0 and limited - purchased or 1 return true, string.format(LIMIT_FORMATION_STR, limitedStr, limited), canBuyNum > maxLimitCanBuyNum and maxLimitCanBuyNum or canBuyNum end return false, "", maxLimitCanBuyNum end function PayMall_Controller.CalculateAvailablePurchase(goodData, maxBuyCount) if not goodData then return 0, false, 0 end local isInDiscount, timeStr, singlePrice = PayMall_Controller.IsInDiscount(goodData) local stockCount = UTL.Item.GetItemStockCount(goodData.MoneyID) local canBuyCount = singlePrice > 0 and math_floor(stockCount / singlePrice) or maxBuyCount canBuyCount = maxBuyCount <= canBuyCount and maxBuyCount or canBuyCount canBuyCount = canBuyCount > 0 and canBuyCount or 1 local costNum = singlePrice * canBuyCount return canBuyCount, stockCount >= costNum, costNum end function PayMall_Controller.CalculateIsStockNotEnoughToBuyMore(goodData,targetNum) if not goodData then return false end local _, _, singlePrice = PayMall_Controller.IsInDiscount(goodData) local stockCount = UTL.Item.GetItemStockCount(goodData.MoneyID) return singlePrice * targetNum > stockCount end function PayMall_Controller.IsShowPurchase(data) if data and #data.Show_Table > 0 then for _, v in ipairs (data.Show_Table) do if not MDL.Unlock.IsComplete(v.ShowCondition, v.ShowConditionParam) then return false end end end --税收商店休赛期不显示 if data and data.enum == CTL.PayMall.ShopMainTabEnum.GVGFight and not CTL.GVGFight.IsShowStore() then return false end return true end function PayMall_Controller.IsSoldOut(goodData) if PayMall_Controller.IsLimitedGood(goodData) then return MDL.PayMall.GetPurchaseItemCount(goodData) >= MDL.PayMall.GetLimitedCount(goodData) end return false end function PayMall_Controller.IsInDiscount(goodData) local costPrice = goodData.BuyPrice if goodData and goodData.ItemDiscount < 100 then local isInDiscountTime = false if goodData.DiscountOnTime > 0 and goodData.DiscountOffTime > 0 then isInDiscountTime = UTL.Time.GetServerIntervalTimeByTimeId(goodData.DiscountOnTime) <= 0 and UTL.Time.GetServerIntervalTimeByTimeId(goodData.DiscountOffTime) >= 0 end local isInDiscount = goodData.IsContinueDiscount or isInDiscountTime local timeStr if isInDiscountTime then timeStr = UIUtils.GetLocalizedTxt(Const_IDS["IDS_Store_OffEndTime"]) .. UTL.Time.ShowYMDDesc(DataSheetManager.TimeRefresh:GetDataByID(goodData.DiscountOffTime)) else timeStr = "" end costPrice = isInDiscount and costPrice * ((goodData.ItemDiscount) / 100) or costPrice return isInDiscount, timeStr, costPrice end return false, "", costPrice end --needDesc是否需要描述:有些判断其实并不需要解锁描述,只需要知道是否解锁即可 function PayMall_Controller.IsUnlockPurchase(goodData, needDesc) -- 武将 神兵碎片判断是否激活武将 local itemData = DataSheetManager.ItemData:GetDataByID(goodData.ItemID) local heroId if goodData.IsActiveHero and itemData.FirstType == LuaConst.ItemType.WeaponFragment and itemData.SecondType == LuaConst.ItemWeaponType.WeaponFragment then -- 神兵碎片 heroId = itemData.BelongerID elseif goodData.IsActiveHero and itemData.FirstType == LuaConst.ItemType.HeroFragment and (itemData.SecondType == LuaConst.ItemHeroType.HeroFragment or itemData.SecondType == LuaConst.ItemHeroType.Hero) then heroId = itemData.SecondType == LuaConst.ItemHeroType.HeroFragment and itemData.BelongerID or itemData.BelongToHero end if heroId and not MDL.HeroSelect.IsHasHero(heroId) then return false, needDesc and UIUtils.GetLocalizedTxt(Const_IDS["IDS_Store_NeedHero"]) end if goodData and #goodData.UnlockTigger_Table > 0 then for i, unlockTable in ipairs(goodData.UnlockTigger_Table) do local unlockTrggerParams = string.split(unlockTable.TriggerParam, ";") if not MDL.Unlock.IsComplete(unlockTable.TriggerType, unlockTable.TriggerParam) then local unlockStr = "" if unlockTable.TriggerType == LuaConst.UnlockConditionType.GuildBuildLevelByType then local buildID = tonumber(unlockTrggerParams[1]) local BuildingName = UIUtils.GetLocalizedTxt(Const_IDS[MDL.Guild.GetBuildName(buildID)]) unlockStr = string.FormatByIdsId(Const_IDS.IDS_GuildShop_BuildingLevelUnlockText, BuildingName, unlockTrggerParams[2]) elseif unlockTable.TriggerType == LuaConst.UnlockConditionType.TeamLevel then local TeamLevel = tonumber(unlockTable.TriggerParam) unlockStr = string.FormatByIdsId(Const_IDS.IDS_GuildShop_PlayerLevelUnlockText, TeamLevel) elseif unlockTable.TriggerType == LuaConst.UnlockConditionType.StoreCoinCost then local itemID = tonumber(unlockTrggerParams[2]) local CoinName = UTL.Item.GetItemDataSpliceByType(itemID).Name local CostLimit = tonumber(unlockTrggerParams[3]) local CoinCost = MDL.PayMall.GetCostItemCount(goodData.TabID, itemID) unlockStr = string.FormatByIdsId(Const_IDS.IDS_GuildShop_TokenCostUnlockText, CostLimit - CoinCost, CoinName) elseif unlockTable.TriggerType == LuaConst.UnlockConditionType.SyncSolo_Rank then local triggerType = DataSheetManager.TriggerType:GetDataByID(unlockTable.TriggerType) local syncSoloData = DataSheetManager.SyncSoloData:GetDataByLevelID(tonumber(unlockTable.TriggerParam)) local paramStr = UIUtils.GetLocalizedTxt(Const_IDS[syncSoloData.LevelName]) unlockStr = string.FormatByIdsId(Const_IDS[triggerType.TaskDesText], paramStr) elseif unlockTable.TriggerType == LuaConst.UnlockConditionType.ClimbTowerLevel then local climbLevelData = DataSheetManager.ClimbTowerLevel:GetDataByID(tonumber(unlockTable.TriggerParam)) local paramStr = UIUtils.GetLocalizedTxt(Const_IDS[climbLevelData.LevelName]) unlockStr = string.FormatByIdsId(Const_IDS.IDS_JP_ClimbTower_Clock, paramStr) elseif unlockTable.TriggerType == LuaConst.UnlockConditionType.CompleteMainAndSubStory then local paramList = string.split(unlockTable.TriggerParam, ";") local brief = DataSheetManager.TaskFatherData:GetDataByID(tonumber(paramList[1])).Brief unlockStr = string.FormatByIdsId(Const_IDS["IDS_ChapterGoal_Hint13_StoreTrigger"], UIUtils.GetLocalizedTxt(Const_IDS[brief])) elseif unlockTable.TriggerType == LuaConst.TriggerType.HeroAppearance_Active or unlockTable.TriggerType == LuaConst.UnlockConditionType.HeroAppearance_Active then local _, content = CTL.Appearance.AppearanceUnlockTrigger(unlockTable.TriggerParam, "IDS_CollectionTrigger_2", MDL.Appearance.AppearanceType.Hero) unlockStr = content elseif unlockTable.TriggerType == LuaConst.TriggerType.WeaponAppearance_Active or unlockTable.TriggerType == LuaConst.UnlockConditionType.WeaponAppearance_Active then local _, content = CTL.Appearance.AppearanceUnlockTrigger(unlockTable.TriggerParam, "IDS_CollectionTrigger_3", MDL.Appearance.AppearanceType.Weapon) unlockStr = content elseif unlockTable.TriggerType == LuaConst.TriggerType.LightEffect_Active or unlockTable.TriggerType == LuaConst.UnlockConditionType.LightEffect_Active then local _, content = CTL.LightEffect.LightEffectUnlockTrigger(unlockTable.TriggerParam, "IDS_CollectionTrigger_4") unlockStr = content elseif unlockTable.TriggerType == LuaConst.TriggerType.PayMall_Buy then local _, content = CTL.PayMall.UnlockTriggerHasBuy(tonumber(unlockTrggerParams[1]), tonumber(unlockTrggerParams[2]), "IDS_CollectionTrigger_5") unlockStr = content elseif unlockTable.TriggerType == LuaConst.TriggerType.NationClimbTowerAllLevel then unlockStr = string.FormatByIdsId(Const_IDS.IDS_TriggerDes_NationClimbTower, tonumber(unlockTable.TriggerParam)) end return false, unlockStr end end end return true, "" end function PayMall_Controller.IsCanPurchase(goodData, count, isHideTips) -- 购买上限 if PayMall_Controller.IsSoldOut(goodData) then if not isHideTips then CTL.Tips.AddTipsMsg(Const_IDS.IDS_ERRORCODE_1364_InfoCode_Store_BuyNumberNotInLimit) end return false end -- 花费判断 local isInDiscount, discountStr, singlePrice = PayMall_Controller.IsInDiscount(goodData) local sumCost = count * singlePrice if UTL.Item.GetItemStockCount(goodData.MoneyID) < sumCost then if not isHideTips then CTL.Tips.AddTipsMsg(UIUtils.GetLocalizedTxt(Const_IDS["IDS_Store_Deficit"]), UTL.Item.GetItemDataSpliceByType(goodData.MoneyID).Name) end return false end local isUnlockPurchase, desc = PayMall_Controller.IsUnlockPurchase(goodData) if not isUnlockPurchase then if not isHideTips and not string.isNilOrEmpty(desc) then CTL.Tips.AddTipsMsg(desc) end return false end return true end -- 获取限购文本,isActivity 是否为活动店铺 function PayMall_Controller.GetLimitedTitle(goodData,isActivityShop) if PayMall_Controller.IsLimitedGood(goodData) then return PayMall_Controller.GetLimitedTitleText(goodData.LimitBuyType,isActivityShop) end return "" end function PayMall_Controller.GetLimitedTitleText(limitBuyType,isActivityShop) local ids = nil if limitBuyType == LuaConst.LimitBuyType.Daily then ids = Const_IDS["IDS_Store_LimitDay"] elseif limitBuyType == LuaConst.LimitBuyType.Weekly then ids = Const_IDS["IDS_Store_LimitWeek"] elseif limitBuyType == LuaConst.LimitBuyType.Monthly then ids = Const_IDS["IDS_Store_LimitMonth"] elseif limitBuyType == LuaConst.LimitBuyType.Forever then ids = Const_IDS["IDS_Store_LimitLife"] --活动店铺,单独显示 if isActivityShop then ids = Const_IDS["IDS_Store_HotActivity"] end end if ids then return UIUtils.GetLocalizedTxt(ids) end end function PayMall_Controller.GetLimitedSoldout(goodData) if PayMall_Controller.IsLimitedGood(goodData) then return PayMall_Controller.GetLimitedSoldoutText(goodData.LimitBuyType) end return "" end function PayMall_Controller.GetLimitedSoldoutText(limitBuyType) local ids = nil if limitBuyType == LuaConst.LimitBuyType.Daily then ids = Const_IDS["IDS_GuildShop_SoldOutDay"] elseif limitBuyType == LuaConst.LimitBuyType.Weekly then ids = Const_IDS["IDS_GuildShop_SoldOutWeek"] elseif limitBuyType == LuaConst.LimitBuyType.Monthly then ids = Const_IDS["IDS_GuildShop_SoldOutMonth"] elseif limitBuyType == LuaConst.LimitBuyType.Forever then ids = Const_IDS["IDS_GuildShop_SoldOut"] end if ids then return UIUtils.GetLocalizedTxt(ids) end end function PayMall_Controller.IsGoodInStoreByItemId(itemId, shopType) local goodList = {} for i, v in MDL.OperationActivity.StoreGoodsData:GetEnumerator() do if v.ItemID == itemId then table.insert(goodList, v) end end for i, v in ipairs(goodList) do local storeTypeData = MDL.OperationActivity.StoreTypeData:GetDataByTabID(v.TabID) if storeTypeData.TypeID == shopType then if PayMall_Controller.IsShowPurchase(storeTypeData) then if PayMall_Controller.IsUnlockPurchase(v, false) then return true end end end end return false end function PayMall_Controller.RefreshShopRedPoints() for k, v in pairs(private.shopTabRps) do private.shopTabRps[k] = false end for i, v in MDL.OperationActivity.StoreGoodsData:GetEnumerator() do if private.shopTabRps[v.TabID] ~= nil then if not private.shopTabRps[v.TabID] and PayMall_Controller.IsShowRpByGoodData(v) then private.shopTabRps[v.TabID] = true end end end for k ,v in pairs(private.shopTabRps) do local storeTypeData = MDL.OperationActivity.StoreTypeData:GetDataByTabID(k) if MDL.Shop.GetShopTypeInfoByTabID(storeTypeData.TabID) then if storeTypeData.enum == PayMall_Controller.ShopMainTabEnum.MonthCard then --双月卡商城激活时需要有一个一次性红点 private.shopTabRps[k] = MDL.RedPoint.GetOneTimeRedPointInfoByType(MDL.RedPoint.RedPointType.MonthCard) == 0 end if private.shopTabRps[k] then private.SetTabRedPoint(storeTypeData.enum) else private.SetTabRedPoint(storeTypeData.enum, true) end end end end function PayMall_Controller.IsShowRpByTabEnum(tabEnum) return CTL.RedPoint.GetRedPointActive(private.TabToRpEnum(tabEnum)) end function PayMall_Controller.IsShowRpByGoodData(goodData) if not goodData then return false end -- 可以购买且价格为0 local isInDiscount, timeStr, singlePrice = PayMall_Controller.IsInDiscount(goodData) return PayMall_Controller.GetGoodType(goodData) == GoodType.Purchase and singlePrice == 0 end function PayMall_Controller.IsShowTabRedPoint(tabEnum) local rpEnum = private.TabToRpEnum(tabEnum) return CTL.RedPoint.GetRedPointActive(rpEnum) == true end function private.SetTabRedPoint(tabEnum, isRemove) local rpEnum = private.TabToRpEnum(tabEnum) if rpEnum then if isRemove then CTL.RedPoint.RemoveRedPoint(rpEnum) else CTL.RedPoint.AddRedPoint(rpEnum) end end end function private.TabToRpEnum(tabEnum) if tabEnum == PayMall_Controller.ShopMainTabEnum.YuanBao then return CTL.RedPoint.RedPointKey.Shop_YuanBao elseif tabEnum == PayMall_Controller.ShopMainTabEnum.LongYu then return CTL.RedPoint.RedPointKey.Shop_LongYu elseif tabEnum == PayMall_Controller.ShopMainTabEnum.ShiLi then return CTL.RedPoint.RedPointKey.Shop_ShiLi elseif tabEnum == PayMall_Controller.ShopMainTabEnum.YanWu then return CTL.RedPoint.RedPointKey.Shop_YanWu elseif tabEnum == PayMall_Controller.ShopMainTabEnum.ZuDui then return CTL.RedPoint.RedPointKey.Shop_ZuDui elseif tabEnum == PayMall_Controller.ShopMainTabEnum.GongPing then return CTL.RedPoint.RedPointKey.Shop_GongPing elseif tabEnum == PayMall_Controller.ShopMainTabEnum.MonthCard then return CTL.RedPoint.RedPointKey.Shop_MonthCard elseif tabEnum == PayMall_Controller.ShopMainTabEnum.WeekActivity then return CTL.RedPoint.RedPointKey.Shop_WeekActivity elseif tabEnum == PayMall_Controller.ShopMainTabEnum.GVGFight then return CTL.RedPoint.RedPointKey.Shop_GVGFight end return nil end function PayMall_Controller.GetItemUseState(itemID) local itemData = DataSheetManager.ItemData:GetDataByID(itemID) local belongerID = itemData.BelongerID local isShowMain = false local isShowAssist = false local breakLevel = 0 if itemData then if itemData.FirstType == LuaConst.ItemType.WeaponFragment and itemData.SecondType == LuaConst.ItemWeaponType.WeaponFragment then -- 神兵碎片 local heroId = belongerID if MDL.HeroSelect.IsHasHero(heroId) then if MDL.Player.HeroIsLineUp(heroId) then isShowMain = true elseif MDL.AssistanceFight.IsHeroOnAssistancePos(heroId) then isShowAssist = true end local heroInfo = MDL.HeroSelect.GetHeroInfo(heroId) breakLevel = heroInfo.magicWeaponLevel end elseif itemData.FirstType == LuaConst.ItemType.HeroFragment and (itemData.SecondType == LuaConst.ItemHeroType.HeroFragment or itemData.SecondType == LuaConst.ItemHeroType.Hero) then -- 武将碎片 武将 local heroId = itemData.SecondType == LuaConst.ItemHeroType.HeroFragment and belongerID or itemData.BelongToHero if MDL.HeroSelect.IsHasHero(heroId) then if MDL.Player.HeroIsLineUp(heroId) then isShowMain = true elseif MDL.AssistanceFight.IsHeroOnAssistancePos(heroId) then isShowAssist = true end breakLevel = MDL.HeroStar.GetHeroStarLevel(heroId) end elseif itemData.FirstType == LuaConst.ItemType.Horse and itemData.SecondType == LuaConst.ItemHorseType.HorseFragment then -- 坐骑碎片 local horseInfo = MDL.WarHorse.GetInfoByID(belongerID) if horseInfo and horseInfo.HeroID and horseInfo.HeroID > 0 then isShowMain = true end isShowAssist = MDL.AssistanceFight.IsHorseOnAssistancePos(belongerID) breakLevel = CTL.WarHorse.GetCurHorousBreak(belongerID) elseif itemData.FirstType == LuaConst.ItemType.Treasure and itemData.SecondType == LuaConst.ItemTreasureType.TreasureFragment then -- 宝物碎片 local heroId = MDL.Treasure.GetTreasureEquipHeroId(belongerID) if heroId and heroId > 0 then isShowMain = true end isShowAssist = MDL.AssistanceFight.IsTreasureOnAssistancePos(belongerID) local treasureInfo = MDL.Treasure.GetTreasureInfo(belongerID) if treasureInfo then breakLevel = treasureInfo.TreasureInfo.starLevel end end end return isShowMain, isShowAssist, breakLevel end function private.GetWeaponUpgradeInfo(itemData) local isShow = false local showStr if itemData then -- 神兵碎片 local itemId = itemData.ID local stockCount = UTL.Item.GetItemStockCount(itemId) isShow = true local magicWeaponId = itemData.BelongerID local heroInfo = MDL.HeroSelect.GetHeroInfo(magicWeaponId) if heroInfo then local weaponLevel = heroInfo.magicWeaponLevel or 0 local weaponStar = (heroInfo.magicWeaponStar or 0) + 1 local maxLevel = MDL.DivineWeapon.GetBreakMax(magicWeaponId) if weaponLevel == maxLevel then showStr = UIUtils.GetLocalizedTxt(Const_IDS["IDS_Store_Opt_MaxBreak"]) return isShow, showStr else if heroInfo.isMagicWeaponActive then -- 统计突破剩余道具数 local breakCount = 0 local magicWeaponData = DataSheetManager.MagicWeaponStar:GetDataByMagicWeaponID_Star(magicWeaponId, weaponLevel) for i = weaponStar, MDL.DivineWeapon.STARMAX do local costData = DataSheetManager.MagicWeaponStarItem:GetDataByItemRepeatID(magicWeaponData.Item_Table[i].ItemRepeat) for _, v in ipairs (costData.Item_Table) do if v.ItemID == itemId then breakCount = breakCount + v.ItemNum break end end end local breakNeedCountStr = stockCount >= breakCount and UTL.Color.FormatTextByColor(STOCK_GREEN_COLOR, tostring(stockCount)) or UTL.Color.FormatRedColor(tostring(stockCount)) showStr = string.format(UIUtils.GetLocalizedTxt(Const_IDS["IDS_Store_Opt_BreakNeed"]), breakNeedCountStr, tostring(breakCount)) else showStr = UIUtils.GetLocalizedTxt(Const_IDS["IDS_Store_Opt_NotActivate"]) end end else showStr = UIUtils.GetLocalizedTxt(Const_IDS["IDS_Store_Opt_NotActivate"]) end end return isShow, showStr end function private.GetHeroUpgradeInfo(itemData) local isShow = false local showStr if itemData then -- 武将碎片 武将 isShow = true local itemId = itemData.ID local stockCount = UTL.Item.GetItemStockCount(itemId) local heroId = itemData.SecondType == LuaConst.ItemHeroType.HeroFragment and itemData.BelongerID or itemData.BelongToHero if itemData.SecondType == LuaConst.ItemHeroType.Hero then if MDL.HeroSelect.IsHasHero(heroId) then showStr = UIUtils.GetLocalizedTxt(Const_IDS["IDS_Store_Opt_Activated"]) else showStr = UIUtils.GetLocalizedTxt(Const_IDS["IDS_Store_Opt_NotActivate"]) end else if MDL.HeroSelect.IsHasHero(heroId) then if CTL.HeroStar.IsHeroReachMaxStar(heroId) then showStr = UIUtils.GetLocalizedTxt(Const_IDS["IDS_Store_Opt_MaxBreak"]) return isShow, showStr else local heroStar = MDL.HeroStar.GetHeroStarLevel(heroId) local heroStage = MDL.HeroStar.GetHeroStageLevel(heroId) local maxStage = MDL.HeroStar.GetHeroMaxStageLevel(heroId) local heroStarData = DataSheetManager.HeroStar:GetDataByHeroID_Star(heroId, heroStar) local breakNeedCount = 0 for i = heroStage + 1, maxStage do local itemData = DataSheetManager.HeroStarItemRepeat:GetDataByItemRepeatID(heroStarData.Item_Table[i].ItemRepeat) for _, v in ipairs (itemData.Item_Table) do if v.ItemID == itemId then breakNeedCount = breakNeedCount + v.ItemNum break end end end local breakNeedCountStr = stockCount >= breakNeedCount and UTL.Color.FormatTextByColor(STOCK_GREEN_COLOR, tostring(stockCount)) or UTL.Color.FormatRedColor(tostring(stockCount)) showStr = string.format(UIUtils.GetLocalizedTxt(Const_IDS["IDS_Store_Opt_BreakNeed"]), breakNeedCountStr, tostring(breakNeedCount)) end else local canActiveCount = DataSheetManager.HeroNum:GetDataByID(heroId).UnlockPiece local unlockNeedCountStr = stockCount >= canActiveCount and UTL.Color.FormatTextByColor(STOCK_GREEN_COLOR, tostring(stockCount)) or UTL.Color.FormatRedColor(tostring(stockCount)) showStr = string.format(UIUtils.GetLocalizedTxt(Const_IDS["IDS_Store_Opt_ActivateNeed"]), unlockNeedCountStr, tostring(canActiveCount)) end end end return isShow, showStr end function private.GetHorseUpgradeInfo(itemData) local isShow = false local showStr if itemData then -- 坐骑碎片 isShow = true local itemId = itemData.ID local stockCount = UTL.Item.GetItemStockCount(itemId) local horseId = itemData.BelongerID local horseData = DataSheetManager.HorseData:GetDataByHorseID(horseId) local info = MDL.WarHorse.GetInfoByID(horseId) if not info then for _, v in ipairs (horseData.Item_Table) do if v.ItemID == itemId then local unlockNeedCountStr = stockCount >= v.ItemNum and UTL.Color.FormatTextByColor(STOCK_GREEN_COLOR, tostring(stockCount)) or UTL.Color.FormatRedColor(tostring(stockCount)) showStr = string.format(UIUtils.GetLocalizedTxt(Const_IDS["IDS_Store_Opt_ActivateNeed"]), unlockNeedCountStr, tostring(v.ItemNum)) break end end else local breakNeedCount = 0 local curStarConfig = DataSheetManager.HorseStar:GetDataByHorseID_Star(horseId, info.HorseInfo.starLevel) local nextStage = info.HorseInfo.starStage + 1 if nextStage > #curStarConfig.ItemRepeat then --下一个突破阶段 local nextStarConfig = DataSheetManager.HorseStar:GetDataByHorseID_Star(horseID,info.HorseInfo.starLevel + 1) if nextStarConfig then for _, v in ipairs (nextStarConfig.ItemRepeat) do local itemTable = DataSheetManager.HorseStarItem:GetDataByItemRepeatID(v).Item_Table for _, v in ipairs (itemTable) do if v.ItemID == itemId then breakNeedCount = breakNeedCount + v.ItemNum break end end end else showStr = UIUtils.GetLocalizedTxt(Const_IDS["IDS_Store_Opt_MaxBreak"]) return isShow, showStr end else for i = nextStage, #curStarConfig.ItemRepeat do local itemTable = DataSheetManager.HorseStarItem:GetDataByItemRepeatID(curStarConfig.ItemRepeat[i]).Item_Table for _, v in ipairs (itemTable) do if v.ItemID == itemId then breakNeedCount = breakNeedCount + v.ItemNum break end end end end local breakNeedCountStr = stockCount >= breakNeedCount and UTL.Color.FormatTextByColor(STOCK_GREEN_COLOR, tostring(stockCount)) or UTL.Color.FormatRedColor(tostring(stockCount)) showStr = string.format(UIUtils.GetLocalizedTxt(Const_IDS["IDS_Store_Opt_BreakNeed"]), breakNeedCountStr, tostring(breakNeedCount)) end end return isShow, showStr end function private.GetTreasureUpgradeInfo(itemData) local isShow = false local showStr if itemData then isShow = true -- 宝物碎片 local itemId = itemData.ID local stockCount = UTL.Item.GetItemStockCount(itemId) local treasureId = itemData.BelongerID if not CTL.Treasure.IsTreasureActive(treasureId) then local treasureData = DataSheetManager.TreasureData:GetDataByTreasureID(treasureId) for _, v in ipairs (treasureData.Item_Table) do if v.ItemID == itemId then local unlockNeedCountStr = stockCount >= v.ItemNum and UTL.Color.FormatTextByColor(STOCK_GREEN_COLOR, tostring(stockCount)) or UTL.Color.FormatRedColor(tostring(stockCount)) showStr = string.format(UIUtils.GetLocalizedTxt(Const_IDS["IDS_Store_Opt_ActivateNeed"]), unlockNeedCountStr, tostring(treasureData.Item_Table[1].ItemNum)) break end end else local info = MDL.Treasure.GetTreasureInfo(treasureId) local breakNeedCount = 0 local curStarConfig = DataSheetManager.TreasureStar:GetDataByTreasureID_Star(treasureId, info.TreasureInfo.starLevel) local nextStage = info.TreasureInfo.starStage + 1 if nextStage > #curStarConfig.ItemRepeat then --下一个突破阶段 --+1的写法,下一等级信息可能不存在 local __, nextStarConfig = DataSheetManager.TreasureStar:TryGetDataByTreasureID_Star(treasureId, info.TreasureInfo.starLevel + 1) if nextStarConfig then for _, v in ipairs (nextStarConfig.ItemRepeat) do local itemTable = DataSheetManager.TreasureStarItem:GetDataByItemRepeatID(v).Item_Table for _, v in ipairs (itemTable) do if v.ItemID == itemId then breakNeedCount = breakNeedCount + v.ItemNum break end end end else showStr = UIUtils.GetLocalizedTxt(Const_IDS["IDS_Store_Opt_MaxBreak"]) return isShow, showStr end else for i = nextStage, #curStarConfig.ItemRepeat do local itemTable = DataSheetManager.TreasureStarItem:GetDataByItemRepeatID(curStarConfig.ItemRepeat[i]).Item_Table for _, v in ipairs (itemTable) do if v.ItemID == itemId then breakNeedCount = breakNeedCount + v.ItemNum break end end end local breakNeedCountStr = stockCount >= breakNeedCount and UTL.Color.FormatTextByColor(STOCK_GREEN_COLOR, tostring(stockCount)) or UTL.Color.FormatRedColor(tostring(stockCount)) showStr = string.format(UIUtils.GetLocalizedTxt(Const_IDS["IDS_Store_Opt_BreakNeed"]), breakNeedCountStr, tostring(breakNeedCount)) end end end return isShow, showStr end function PayMall_Controller.GetItemUpgradeInfo(itemId) local itemData = DataSheetManager.ItemData:GetDataByID(itemId) if itemData then local stockCount = UTL.Item.GetItemStockCount(itemId) if itemData.FirstType == LuaConst.ItemType.WeaponFragment and itemData.SecondType == LuaConst.ItemWeaponType.WeaponFragment then return private.GetWeaponUpgradeInfo(itemData) elseif itemData.FirstType == LuaConst.ItemType.HeroFragment and (itemData.SecondType == LuaConst.ItemHeroType.HeroFragment or itemData.SecondType == LuaConst.ItemHeroType.Hero) then return private.GetHeroUpgradeInfo(itemData) elseif itemData.FirstType == LuaConst.ItemType.Horse and itemData.SecondType == LuaConst.ItemHorseType.HorseFragment then return private.GetHorseUpgradeInfo(itemData) elseif itemData.FirstType == LuaConst.ItemType.Treasure and itemData.SecondType == LuaConst.ItemTreasureType.TreasureFragment then return private.GetTreasureUpgradeInfo(itemData) end end return false, nil end function PayMall_Controller.CanJumpToShop(itemID) if not itemID then --没有物品ID的时候默认直接打开商铺页面即可 return true end local tabId = MDL.Shop.GetTabIDByItemId(itemID, MDL.ItemSources.SourceType.Store) if not tabId then return false end local tabEnum = MDL.OperationActivity.StoreTypeData:GetDataByTabID(tabId).enum for i ,v in MDL.OperationActivity.StoreTypeData:GetEnumerator() do if PayMall_Controller.IsShowPurchase(v) and v.enum == tabEnum then return true end end return false end PayMall_Controller.subTabID = 0 PayMall_Controller.RemoveMonthCardNewGoodRedPoint = false function PayMall_Controller.OpenViewByShopType(tabType, view, childTabType, index, data, itemId) local subView if tabType == CTL.PayMall.ShopTabType.Shop then if data.TabID ~= CTL.PayMall.ShopChildTabType.DoubleMonthCardShop and PayMall_Controller.subTabID == CTL.PayMall.ShopChildTabType.DoubleMonthCardShop then MDL.PayMall.RemoveMonthCardNewGoodRedPoint() end else if data.ID ~= CTL.PayMall.ShopChildTabType.DoubleMonthCardShop and PayMall_Controller.subTabID == CTL.PayMall.ShopChildTabType.DoubleMonthCardShop then MDL.PayMall.RemoveMonthCardNewGoodRedPoint() end end if tabType == PayMall_Controller.ShopTabType.Shop then subView = view:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIPayMallMain), {TabIndex= index, TypeData = data, itemId = itemId}) PayMall_Controller.subTabID = data.TabID if PayMall_Controller.subTabID == CTL.PayMall.ShopChildTabType.DoubleMonthCardShop then PayMall_Controller.RemoveMonthCardNewGoodRedPoint = true end else if childTabType == PayMall_Controller.ShopChildTabType.DailyGift then subView = view:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIDailyGiftMain)) elseif childTabType == PayMall_Controller.ShopChildTabType.MonthCard then subView = view:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIWelfareMonthCard)) elseif PayMall_Controller.IsGrowthFund(childTabType) then subView = view:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIGrowthFundPanel), {fundID = childTabType }, "Welfare/GrowthFund/UIGrowthFundPanel") elseif childTabType == PayMall_Controller.ShopChildTabType.OfficialPositionFund then subView = view:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIGrowthFundPanel), {fundID = childTabType }, "Welfare/GrowthFund/UIGrowthFundPanel") elseif childTabType >= PayMall_Controller.ShopChildTabType.DirectGift1 and childTabType <= PayMall_Controller.GetLastDirectGiftTabType() then local pushGiftId = data.PushGiftID if pushGiftId and pushGiftId > 0 then local giftInfo = MDL.PushGift.GetPushGiftInfoById(pushGiftId, data.PushGiftRewardID) local giftData = MDL.OperationActivity.PushGiftData:GetDataByActivityID_ID(giftInfo.activityId, giftInfo.giftId) local giftBackGroundData = DataSheetManager.PushGiftBackGround:GetDataByID(giftData.RewardId) if giftBackGroundData == nil or string.isNilOrEmpty(giftBackGroundData.BackGround) then subView = view:OpenView(GetViewClass(Const_UI_Lua.UIEnum.OperationActivity.UIDirectionalGiftCommon), {giftData = giftInfo, parentView = self}, "OperationActivity/PushGift/UIDirectionGifts/UIDirectionalGiftCurrency") else subView = view:OpenView(GetViewClass(Const_UI_Lua.UIEnum.OperationActivity.UIDirectionalGiftCommon), {giftData = giftInfo, giftBackGroundData = giftBackGroundData, parentView = self}, giftBackGroundData.BackGround) end CTL.PushGift.SetNewGift(giftInfo.activityId, giftInfo.giftId) else subView = view:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIDirectGiftPanel), {welfareId = childTabType }) end elseif childTabType == PayMall_Controller.ShopChildTabType.HonorOrder then --战令界面需要发请求 MDL.HonorOrder.HonorOrderGetTaskListRequest() subView = view:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIHonorOrderBase)) MDL.RedPoint.RemoveEnterWorldRedPoint(MDL.RedPoint.EnterWorldRedPointType.HonorOrder) elseif PayMall_Controller.IsXFund(childTabType) then subView = CTL.HeroFund.OpenView(view, childTabType) end end return subView end function private.IsCanAddPreferential(preferentialOrderData) if not MDL.Unlock.IsUnlock(preferentialOrderData.FucID) then return false end if preferentialOrderData.HideTriggerID>0 then if MDL.Unlock.IsTriggerIdComplete(preferentialOrderData.HideTriggerID) then return false end end if preferentialOrderData.ShowTriggerID>0 then if not MDL.Unlock.IsTriggerIdComplete(preferentialOrderData.ShowTriggerID) then return false end end --战令判断 if preferentialOrderData.ID == PayMall_Controller.ShopChildTabType.HonorOrder and not CTL.HonorOrder.GetHonorOrderActive() then return false end --名X之路特殊逻辑 if PayMall_Controller.IsXFund(preferentialOrderData.ID) then local type = CTL.HeroFund.GetTypeByFuncId(preferentialOrderData.FucID) if not MDL.Unlock.IsUnlock(preferentialOrderData.FucID) or not MDL.HeroFund.IsFundOpen(type) then return false end end return true end --二级页签内容 function PayMall_Controller.GetShopListByTab(tabId) local shopList = {} if tabId == PayMall_Controller.ShopTabType.PreferentialOrder then -- 特惠 for i, v in DataSheetManager.PreferentialOrder:GetEnumerator() do if private.IsCanAddPreferential(v) then table.insert(shopList, v) end end elseif tabId == PayMall_Controller.ShopTabType.DirectGiftOrder then --直购 for i, v in DataSheetManager.DirectGiftOrder:GetEnumerator() do if MDL.Unlock.IsUnlock(v.FucID) and CTL.DirectGift.IsShowNormalDirectGiftTab(v.ID) then table.insert(shopList, v) end if MDL.Unlock.IsUnlock(v.FucID) and v.PushGiftID and v.PushGiftID > 0 then if MDL.PushGift.GetPushGiftInfoById(v.PushGiftID, v.PushGiftRewardID) then table.insert(shopList, v) end end end elseif tabId == PayMall_Controller.ShopTabType.Shop then --商城 local storeTypeList = MDL.PayMall.GetShowTabs() for _, v in ipairs (storeTypeList) do -- 月卡商城改为常驻商城 if v.TabID == PayMall_Controller.ShopChildTabType.DoubleMonthCardShop then table.insert(shopList, v) else if CTL.PayMall.IsShowPurchase(v) then table.insert(shopList, v) end end end end if tabId ~= PayMall_Controller.ShopTabType.Shop and tabId ~= PayMall_Controller.ShopTabType.TotalTopUp then table.sort(shopList, private.SortShopList) end return shopList end function private.SortShopList(a, b) local pA = a.ChildTab local pB = b.ChildTab if pA ~= pB then return pA > pB else return a.ID < b.ID end end --通过战令的红点,触发界面红点 function PayMall_Controller.AddHonorOrderRedPoint(state) if state then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.PayMall_PreferentialOrder_HonorOrder) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.PayMall_PreferentialOrder_HonorOrder) end end function PayMall_Controller.OpenPayMallPopUp(goodData, activityId, activityType, titleIDS) if CTL.Currency.IsDragonJadeUsedInJapan(goodData.MoneyID) then --日本消耗龙玉特殊弹窗 UIManager.OpenView(Const_UI_Lua.UIEnum.UIPayMallPopUp, { goodData = goodData, activityId = activityId, activityType = activityType, titleIDS = titleIDS }, "PayMall/UIPayMallPopUp_JP") else UIManager.OpenView(Const_UI_Lua.UIEnum.UIPayMallPopUp, { goodData = goodData, activityId = activityId, activityType = activityType, titleIDS = titleIDS }) end end --region 日服专属 function private.CheckJPBaizhanNoticeRecord() if private.jpNoticeRecordDict == nil then local dict = PersistentData.PlayerData:Get(JP_NOTICE_RECORD) if dict == nil then private.jpNoticeRecordDict = {} else private.jpNoticeRecordDict = dict end end end --判断百战页签下是否有新增商品 function PayMall_Controller.CheckIfBaizhanAddNew() if GameAppInfo.IsJapanesePackage() == false then return end if not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.ClimbTower) then private.SetNewSymbolState_JPBaiZhan(false) return end local baizhanTabId = private.GetJPBaizhanTabID() if baizhanTabId then private.CheckJPBaizhanNoticeRecord() local isNew = false for i, v in MDL.OperationActivity.StoreGoodsData:GetEnumerator() do if v.TabID == baizhanTabId then local isUnlock, _ = PayMall_Controller.IsUnlockPurchase(v, false) if isUnlock and private.jpNoticeRecordDict[v.ID] == nil then isNew = true break end end end private.SetNewSymbolState_JPBaiZhan(isNew) end end function PayMall_Controller.RemoveBaizhanNewState() local baizhanTabId = private.GetJPBaizhanTabID() if baizhanTabId then private.CheckJPBaizhanNoticeRecord() for i, v in MDL.OperationActivity.StoreGoodsData:GetEnumerator() do if v.TabID == baizhanTabId then local isUnlock, _ = PayMall_Controller.IsUnlockPurchase(v, false) if isUnlock then private.jpNoticeRecordDict[v.ID] = 1 end end end PersistentData.PlayerData:Set(JP_NOTICE_RECORD, private.jpNoticeRecordDict, true) private.SetNewSymbolState_JPBaiZhan(false) end end function private.GetJPBaizhanTabID() if MDL.OperationActivity.StoreTypeData then for i ,v in MDL.OperationActivity.StoreTypeData:GetEnumerator() do if v.enum == CTL.PayMall.ShopMainTabEnum.JPBaiZhan then return v.TabID end end end return nil end function private.SetNewSymbolState_JPBaiZhan(value) private.isShowNewSymbol_JPBaiZhan = value EventSystem.Dispatch(EventID.UI_Shop_UpdateJPBaiZhanNewSymbolState, value) end function PayMall_Controller.GetNewSymbolState_JPBaiZhan() return private.isShowNewSymbol_JPBaiZhan end --国服三方商城 function PayMall_Controller.ReqSdkCanOpenLoginCode() if GameAppInfo.IsChinesePackage() and GameAppInfo.IsVersionGreaterThan112000() then SDKUtil.IsCanShowLoginCode() end end function PayMall_Controller.SdkOpenLoginCode() SDKUtil.OpenLoginCode(CTL.Setting.GetSdkServiceCustom()) end function PayMall_Controller.IsShowLoginCodeButton() if not GameAppInfo.IsChinesePackage() then return false end if not private.isCanOpenLoginCode then return false end return MDL.Unlock.GetDebugSwitchState(MDL.Unlock.DebugSwitchType.TypeLoginCode) end function private.OnCanShowLoginCode(code) private.isCanOpenLoginCode = (code=="200") end function private.OnOpenLoginCodeOver(code) if code == "2110" or code == "2" then end end --endregion --是否在商店买过 function PayMall_Controller.UnlockTriggerHasBuy(storeId, goodId, desc) --由于goodId是唯一的,storeId可以不用 local unlockStr local goodData = MDL.OperationActivity.StoreGoodsData:GetDataByID(goodId) local isUnlock = MDL.PayMall.GetPurchaseItemCount(goodData) > 0 if desc then unlockStr = string.FormatByIdsId(Const_IDS[desc], UIUtils.GetLocalizedTxt(Const_IDS[DataSheetManager.ItemData:GetDataByID(goodData.ItemID).Name])) end return isUnlock, unlockStr end function PayMall_Controller.IsShowShopTab() local array = PayMall_Controller.GetSortShopTabTypeArray() return table.containValue(array, PayMall_Controller.ShopTabType.Shop) end return PayMall_Controller