miduo_client/Assets/ManagedResources/~Lua/Framework/Manager/PackageManager.lua

168 lines
5.9 KiB
Lua
Raw Normal View History

2021-05-31 17:31:31 +08:00
PackageManager = {}
local this = PackageManager
function PackageManager.Initialize()
this.PackageName = "test"
if AppConst.isSDK then
this.PackageName = AndroidDeviceInfo.Instance:GetPackageName()
end
LogGreen("当前包名为:"..this.PackageName)
-- 获取当前包配置名,没有就按本地配置
this.ConfigName = ServerConfigManager.GetSettingValue(ServerConfigManager.SettingConfig.PACKAGE_CONFIG)
2021-06-04 16:09:52 +08:00
if not this.ConfigName then
this.ConfigName = "LOCAL"
end
2021-05-31 17:31:31 +08:00
local PackagerConfig = ConfigManager.GetConfig(ConfigName.PackageConfig)
for _, config in ConfigPairs(PackagerConfig) do
if config.ConfigName == this.ConfigName then
2021-05-31 17:31:31 +08:00
this.config = config
break
2021-05-31 17:31:31 +08:00
end
end
2021-06-16 17:29:17 +08:00
-- 获取stream设置
if ServerConfigManager.IsSettingActive(ServerConfigManager.SettingConfig.IS_LOAD_STREAMING) then
resMgr:LoadStreamingText("PackConfig", function(config)
local json = require 'cjson'
local data = json.decode(config)
this.StreamConfig = data
end)
end
2021-05-31 17:31:31 +08:00
end
2021-06-16 17:29:17 +08:00
-- 获取包名
function PackageManager.GetPackageID()
2021-07-27 10:04:22 +08:00
-- 优先使用sdk自带的
if LoginManager.SdkSubChannel and LoginManager.SdkSubChannel ~= "" then
2021-07-27 10:04:22 +08:00
return LoginManager.SdkSubChannel
end
-- 否则使用配置的
2021-06-16 17:29:17 +08:00
if this.StreamConfig then
return this.StreamConfig.PackID
end
end
-- 获取子渠道包公告配置
function PackageManager.GetSubNoticeID()
if this.StreamConfig then
return this.StreamConfig.SubNoticeID
end
end
2021-05-31 17:31:31 +08:00
-- 获取包名
function PackageManager.GetPackageName()
return this.PackageName
end
-- 获取充值计费点字段
function PackageManager.GetRechargeField()
if this.config then
return this.config.RechargeField
end
2021-05-31 17:31:31 +08:00
end
-- 获取登录背景图
function PackageManager.GetLoginPanelBg()
2021-06-16 17:29:17 +08:00
if this.StreamConfig then
return this.StreamConfig.LoginPanelBG
end
if this.config then
return this.config.LoginPanelBg
end
end
2021-06-03 13:52:55 +08:00
-- 获取登录Logo
function PackageManager.GetLoginPanelLogo()
2021-06-16 17:29:17 +08:00
if this.StreamConfig then
return this.StreamConfig.LoginPanelLogo
end
2021-06-03 13:52:55 +08:00
if this.config then
return this.config.LoginLogo
end
end
-- 获取充值计费点字段
function PackageManager.GetCustomEventField()
if this.config then
return this.config.CustomEventField
end
end
-- 获取loading图list
function PackageManager.GetLoadingList()
2021-06-16 17:29:17 +08:00
if this.StreamConfig then
local list = string.split(this.StreamConfig.LoadingPanelBG, "#")
return list
end
if this.config then
local list = string.split(this.config.LoadingImgList, "#")
return list
end
2021-06-02 18:08:03 +08:00
end
2021-06-11 01:45:09 +08:00
-- 获取登录背景图
function PackageManager.GetBHContent()
if this.config then
return this.config.BHContent
end
end
2021-06-02 18:08:03 +08:00
function PackageManager.SetVideo(obj, bg)
obj:SetActive(false)
if ServerConfigManager.IsSettingActive(ServerConfigManager.SettingConfig.IS_PLAY_LOGIN_VIDEO) then
if this.StreamConfig and this.StreamConfig.LoginPanelVideoBG and this.StreamConfig.LoginPanelVideoBG ~= "" then
Log("加载Stream视频"..tostring(this.StreamConfig.LoginPanelVideoBG))
if UIManager.IsOpen(UIName.LoginPanel) then
local video = obj:GetComponent("VideoPlayer")
video.url = UnityEngine.Application.streamingAssetsPath .."/Res/"..tostring(this.StreamConfig.LoginPanelVideoBG)..".mp4"
video:Play()
bg:DOFade(0, 2)
obj:SetActive(true)
2021-06-04 12:01:08 +08:00
end
elseif this.config and this.config.VideoName and this.config.VideoName ~= "" then
Log("加载视频:"..tostring(this.config.VideoName))
resMgr:PreLoadAssetAsync(this.config.VideoName, function(isOk)
if isOk then
if UIManager.IsOpen(UIName.LoginPanel) then
local video = obj:GetComponent("VideoPlayer")
-- video.url = ServerConfigManager.GetVersionInfo("resUrl") .. AppConst.PlatformPath .."/"..tostring(this.config.VideoName) ..".mp4"
-- video.clip = resMgr:LoadAsset(this.config.VideoName)
video.url = "file://" .. AppConst.PersistentDataPath .."/"..tostring(this.config.VideoName)
video:Play()
bg:DOFade(0, 2)
obj:SetActive(true)
end
else
Log("视频加载失败:"..this.config.VideoName)
end
end)
2021-06-04 12:01:08 +08:00
else
2021-06-24 11:38:43 +08:00
Log("包名:"..tostring(this.config.PackageName).."登录视频为空!")
2021-06-03 10:39:25 +08:00
end
2021-06-02 18:08:03 +08:00
end
end
function PackageManager.UnloadVideo()
2021-06-04 12:01:08 +08:00
if this.config then
if this.config.VideoName then
-- Log("卸载视频:"..tostring(this.config.VideoName))
-- resMgr:UnLoadAsset(this.config.VideoName)
end
2021-06-02 21:04:45 +08:00
end
2021-06-10 15:20:31 +08:00
end
function PackageManager.GetCCCode()
return ServerConfigManager.GetSettingValue(ServerConfigManager.SettingConfig.PACKAGE_CC_CODE) or ""
end
-- 获取APPID
local AppIDConfig = {
["com.tcxsw.project"] = "6a7c5e329e565fbecb9761f4ebdff709",
["com.tcxkf.project"] = "6a7c5e329e565fbecb9761f4ebdff709",
["com.tcxxqcs.project"] = "6a7c5e329e565fbecb9761f4ebdff709",
["com.tcxxq.project"] = "2c3239afdb0c14631e8ad97b35e289d9",
["com.tcx.project"] = "4bffbf7342f2bbb161734e7b3fe30ffe",
["com.tcxzb.project"] = "4bffbf7342f2bbb161734e7b3fe30ffe",
["com.tcxttml.project"] = "2cf98795b423de90af647d369efd3419",
["com.tcxcsb.project"] = "2806a89515659caecc964d727dbd49c8",
["com.tcxcn.test"] = "a3ad5f4090d59aecc42332088987f83b",
["com.tcxcn.project"] = "a3ad5f4090d59aecc42332088987f83b",
["com.tcxqd.project"] = "d4263a2ed36fd2b34ab8fa23e1f95dea",
}
function PackageManager.GetAppID()
if AppIDConfig[this.PackageName] then
return AppIDConfig[this.PackageName]
end
2021-05-31 17:31:31 +08:00
end