2020-08-25 15:51:35 +08:00
require ( " Base/BasePanel " )
2020-05-09 13:31:21 +08:00
LoginPanel = Inherit ( BasePanel )
local this = LoginPanel
this.LoginWay = { Account = 0 , WeChat = 1 }
2021-03-02 15:18:06 +08:00
SERVER_VERSION = tonumber ( ServerConfigManager.GetSettingValue ( ServerConfigManager.SettingConfig . ServerVersion ) or 0 )
2021-06-22 15:01:02 +08:00
local IsShowNotice = false
2020-07-25 19:34:52 +08:00
2020-06-30 18:59:44 +08:00
local IsSDKLogin = AppConst.isSDK and AppConst.isSDKLogin
2020-09-04 10:25:40 +08:00
local IsDevelopLogin = true
2020-06-30 18:59:44 +08:00
2020-05-09 13:31:21 +08:00
local openIdkey = " openIdkey "
local openIdPw = " openIdPw "
2021-04-09 12:26:35 +08:00
local defaultOpenIdkey = Language [ 11135 ]
2020-05-09 13:31:21 +08:00
local defaultOpenIdPw = " "
2021-03-02 15:18:06 +08:00
local LoginRoot_Url = ServerConfigManager.GetVersionInfo ( " serverUrl " )
local LoginRoot_SubChannel = ServerConfigManager.GetVersionInfo ( " subChannel " )
local LoginRoot_Channel = ServerConfigManager.GetVersionInfo ( " channel " )
local LoginRoot_Version = ServerConfigManager.GetVersionInfo ( " version " )
local LoginRoot_PackageVersion = ServerConfigManager.GetVersionInfo ( " packageVersion " )
2021-05-18 16:19:36 +08:00
local LoginRoot_NoticeChannel = ServerConfigManager.GetSettingValue ( ServerConfigManager.SettingConfig . NOTICE_CHANNEL ) or " "
2021-06-30 09:16:28 +08:00
local LoginRoot_UserChannel = ServerConfigManager.GetSettingValue ( ServerConfigManager.SettingConfig . USER_CHANNEL ) or " "
2020-05-09 13:31:21 +08:00
local orginLayer
2021-06-30 09:52:40 +08:00
local IsUserProtoActive = ServerConfigManager.IsSettingActive ( ServerConfigManager.SettingConfig . USER_PROTO )
2020-11-17 10:44:55 +08:00
local timeStamp = Time.realtimeSinceStartup
local timeSign = Util.MD5Encrypt ( string.format ( " %s%s " , timeStamp , LoginManager.sign ) )
2021-06-24 11:38:43 +08:00
local UrlList = { }
local HaveConfirm = false
2021-06-23 19:39:46 +08:00
2020-05-09 13:31:21 +08:00
--初始化组件(用于子类重写)
function this : InitComponent ( )
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New ( )
2020-05-09 13:31:21 +08:00
orginLayer = 0
2020-08-25 17:56:55 +08:00
this.loginPart = this.gameObject
2021-05-31 17:31:31 +08:00
2020-05-09 13:31:21 +08:00
this.tip = Util.GetGameObject ( this.loginPart , " tip/Text " )
2020-08-29 17:22:46 +08:00
this.loginAnim = this.gameObject : GetComponent ( " Animator " )
this.loginAnim . enabled = false
2020-08-25 17:56:55 +08:00
this.btnLoginPart = Util.GetGameObject ( this.loginPart , " jinruyouxi " )
this.btnLogin = Util.GetGameObject ( this.loginPart , " jinruyouxi _wenzi " )
2020-05-09 13:31:21 +08:00
this.inputField = Util.GetGameObject ( this.loginPart , " InputField " ) : GetComponent ( " InputField " )
this.UserBtn = Util.GetGameObject ( this.loginPart , " userBtn " )
this.UserBtnText = Util.GetGameObject ( this.loginPart , " userBtn/Text " ) : GetComponent ( " Text " )
this.btnUser = Util.GetGameObject ( this.loginPart , " btnUser " )
this.btnNotice = Util.GetGameObject ( this.loginPart , " btnNotice " )
2021-08-27 14:20:36 +08:00
this.btnAgeTip = Util.GetGameObject ( this.loginPart , " btnAgeTip " )
this.btnAgeTipPosition = this.btnAgeTip : GetComponent ( " RectTransform " ) . localPosition
2020-09-25 21:19:01 +08:00
this.btnNotice : SetActive ( IsShowNotice )
2020-05-09 13:31:21 +08:00
---selectServerPart
this.serverSelectPart = Util.GetGameObject ( this.loginPart , " serverSelect " )
this.serverMes = Util.GetGameObject ( this.serverSelectPart , " serverMes " ) : GetComponent ( " Text " )
this.changeServerBtn = Util.GetGameObject ( this.serverSelectPart , " changeServer " )
this.sdkLoginBtn = Util.GetGameObject ( this.loginPart , " loginBtn " )
this.SetLoginPart ( false )
2020-08-25 17:56:55 +08:00
this.loginMask = Util.GetGameObject ( this.loginPart , " loginMask " )
2020-05-09 13:31:21 +08:00
this.versionText = Util.GetGameObject ( this.loginPart , " version " ) : GetComponent ( " Text " )
2021-04-09 12:26:35 +08:00
this.versionText . text = Language [ 11136 ] .. LoginRoot_Version
2021-01-28 15:37:44 +08:00
2021-06-16 10:44:12 +08:00
-- this.bg1 = Util.GetGameObject(this.gameObject, "bg11"):GetComponent("RawImage")
-- resMgr:SetStreamingTexture(this.bg1, "login_caohua.png")
2021-06-03 23:03:09 +08:00
-- 背景
2021-06-04 10:08:57 +08:00
this.bg = Util.GetGameObject ( this.gameObject , " bg " ) : GetComponent ( " Image " )
2021-06-03 23:03:09 +08:00
this.bgStr = PackageManager.GetLoginPanelBg ( )
2021-06-16 10:44:12 +08:00
this.bg . color = Color.New ( 1 , 1 , 1 , 0 )
LoadStreamingTexture ( this.spLoader , this.bgStr , function ( sp )
this.bg . sprite = sp
this.bg . color = Color.New ( 1 , 1 , 1 , 1 )
end )
2021-06-03 23:03:09 +08:00
-- logo
2021-06-03 13:52:55 +08:00
this.logo = Util.GetGameObject ( this.gameObject , " logo " ) : GetComponent ( " Image " )
2021-06-03 23:03:09 +08:00
this.logoStr = PackageManager.GetLoginPanelLogo ( )
2021-06-16 20:38:42 +08:00
if this.logoStr and this.logoStr ~= " " then
2021-06-16 10:44:12 +08:00
LoadStreamingTexture ( this.spLoader , this.logoStr , function ( sp )
this.logo . gameObject : SetActive ( true )
this.logo . sprite = sp
this.logo : SetNativeSize ( )
end )
2021-06-03 13:52:55 +08:00
else
this.logo . gameObject : SetActive ( false )
end
2021-03-07 15:33:41 +08:00
-- BindLightFlash(Util.GetGameObject(this.logo, "saoguang"), this.logo)
2021-04-09 17:38:18 +08:00
this.healthTip = Util.GetGameObject ( this.gameObject , " healthTip " )
this.healthTip : SetActive ( IS_SHOW_HEALTH_TIP )
2021-06-11 01:45:09 +08:00
this.bh = Util.GetGameObject ( this.gameObject , " healthTip/bh " ) : GetComponent ( " Text " )
local bhContent = PackageManager.GetBHContent ( )
2021-06-24 11:38:43 +08:00
-- LogError(tostring(bhContent))
2021-06-11 01:45:09 +08:00
if bhContent then
this.bh . text = bhContent
else
this.bh . text = " "
end
2021-06-02 17:52:26 +08:00
2021-06-04 10:08:57 +08:00
this.video = Util.GetGameObject ( this.gameObject , " VideoPlayer " )
2021-06-23 19:39:46 +08:00
--用户隐私协议
2021-06-24 11:38:43 +08:00
this.protos = Util.GetGameObject ( this.gameObject , " protos " )
2021-06-24 09:50:55 +08:00
this.instructionsBtn = Util.GetGameObject ( this.gameObject , " protos/instructionsBtn " )
this.privacyBtn = Util.GetGameObject ( this.gameObject , " protos/privacyBtn " )
2021-06-24 11:38:43 +08:00
this.ConfirmBtn = Util.GetGameObject ( this.gameObject , " protos/Confirm " )
this.ConfirmImg = Util.GetGameObject ( this.ConfirmBtn , " gou " )
2021-06-30 09:52:40 +08:00
this.protos : SetActive ( IsUserProtoActive )
2020-05-09 13:31:21 +08:00
end
--绑定事件(用于子类重写)
function this : BindEvent ( )
Util.AddClick ( this.btnLogin , this.OnLoginClick )
--this.dropDown:ClearOptions()
Util.AddInputField_OnEndEdit ( this.inputField . gameObject , function ( str )
PlayerPrefs.SetString ( openIdkey , str )
end )
Util.AddClick ( this.btnUser , function ( )
local user = PlayerPrefs.GetString ( openIdkey , defaultOpenIdkey )
local userPw = PlayerPrefs.GetString ( openIdPw , defaultOpenIdPw )
UIManager.OpenPanel ( UIName.LoginPopup , user , userPw , function ( str , pw )
this.UserBtnText . text = str
PlayerPrefs.SetString ( openIdkey , str )
PlayerPrefs.SetString ( openIdPw , pw )
end )
end )
Util.AddClick ( this.btnNotice , function ( )
2021-03-23 16:15:32 +08:00
this.ShowNotice ( )
2020-05-09 13:31:21 +08:00
end )
2021-08-27 14:20:36 +08:00
Util.AddClick ( this.btnAgeTip , function ( )
UIManager.OpenPanel ( UIName.HelpPopup , HELP_TYPE.AgeTip , this.btnAgeTipPosition . x , this.btnAgeTipPosition . y )
end )
2020-05-09 13:31:21 +08:00
Util.AddClick ( this.UserBtn , function ( )
local user = PlayerPrefs.GetString ( openIdkey , defaultOpenIdkey )
local userPw = PlayerPrefs.GetString ( openIdPw , defaultOpenIdPw )
UIManager.OpenPanel ( UIName.LoginPopup , user , userPw , function ( str , pw )
this.UserBtnText . text = str
PlayerPrefs.SetString ( openIdkey , str )
PlayerPrefs.SetString ( openIdPw , pw )
end )
end )
---SelectServer
Util.AddClick ( this.changeServerBtn , function ( )
2021-08-09 16:32:14 +08:00
local function reServerCallback ( str )
if str == nil then
return
2020-05-09 13:31:21 +08:00
end
2021-08-09 16:32:14 +08:00
if str ~= nil and str ~= " " then
MyPCall ( function ( )
local json = require ' cjson '
local data = json.decode ( str )
-- selectServerPart
this.SetServerList ( data )
-- 打开服务器选择界面
UIManager.OpenPanel ( UIName.ServerListSelectPanel , {
serverList = this.serverList ,
myServerList = this.myServerList ,
lastServer = this.lastServer ,
recommend = this.recommend ,
callback = function ( index )
local list = this.serverList [ index ]
PlayerManager.serverInfo = list
LoginManager.SocketAddress = list.ip
LoginManager.SocketPort = list.port
LoginManager.ServerId = list.server_id
LoginManager.state = list.state
--local severArea = tonumber(string.sub(list.server_id, 0, -5))
this.serverMes . text = PlayerManager.serverInfo . name -- .. "\t<color=#56F384FF>" .. severArea .. "</color>" .. Language[11138]
end
} )
end )
end
end
-- 判断获取服务器的id
if IsSDKLogin then
this.RequestServerList ( AppConst.OpenId , reServerCallback )
else
local userId = PlayerPrefs.GetString ( openIdkey , defaultOpenIdkey )
this.RequestServerList ( userId , reServerCallback )
end
2020-05-09 13:31:21 +08:00
end )
--SDK 登录
Util.AddClick ( this.sdkLoginBtn , function ( )
2021-12-07 11:39:38 +08:00
-- 喜扑IOS包sdk无法屏蔽点击事件, 不允许主动触发
if LoginRoot_Channel == " XP2 " then
return
end
2020-05-09 13:31:21 +08:00
this.SDKLogin ( )
end )
2021-06-23 19:39:46 +08:00
--用户隐私协议
2021-06-24 09:50:55 +08:00
Util.AddClick ( this.instructionsBtn , function ( )
2021-08-25 14:27:08 +08:00
OpenWeb ( UrlList [ 1 ] )
2021-06-24 09:50:55 +08:00
end )
Util.AddClick ( this.privacyBtn , function ( )
2021-08-25 14:27:08 +08:00
OpenWeb ( UrlList [ 2 ] )
2021-06-24 11:38:43 +08:00
end )
Util.AddClick ( this.ConfirmBtn , function ( )
local confirm = PlayerPrefs.GetInt ( " IHaveConfirmProtos " )
if confirm == 0 then
this.ConfirmImg : SetActive ( true )
PlayerPrefs.SetInt ( " IHaveConfirmProtos " , 1 )
elseif confirm == 1 then
this.ConfirmImg : SetActive ( false )
PlayerPrefs.SetInt ( " IHaveConfirmProtos " , 0 )
end
2021-06-24 09:50:55 +08:00
end )
2021-06-23 19:39:46 +08:00
2020-05-09 13:31:21 +08:00
end
2021-03-20 15:00:44 +08:00
-- sdk 初始化完成回调
function this . OnInitSuccess ( )
this.SDKLogin ( )
end
2020-05-09 13:31:21 +08:00
--添加事件监听(用于子类重写)
function this : AddListener ( )
Game.GlobalEvent : AddEvent ( Protocal.Connect , this.OnConnect )
Game.GlobalEvent : AddEvent ( Protocal.Disconnect , this.OnDisconnect )
Game.GlobalEvent : AddEvent ( GameEvent.LoginSuccess . OnLoginSuccess , this.RefreshLoginStatus )
2020-07-22 11:42:37 +08:00
Game.GlobalEvent : AddEvent ( GameEvent.LoginSuccess . OnLogout , this.OnLogout )
2021-03-20 15:00:44 +08:00
Game.GlobalEvent : AddEvent ( GameEvent.SDK . InitSuccess , this.OnInitSuccess )
2020-05-09 13:31:21 +08:00
end
--移除事件监听(用于子类重写)
function this : RemoveListener ( )
Game.GlobalEvent : RemoveEvent ( Protocal.Connect , this.OnConnect )
Game.GlobalEvent : RemoveEvent ( Protocal.Disconnect , this.OnDisconnect )
Game.GlobalEvent : RemoveEvent ( GameEvent.LoginSuccess . OnLoginSuccess , this.RefreshLoginStatus )
2020-07-22 11:42:37 +08:00
Game.GlobalEvent : RemoveEvent ( GameEvent.LoginSuccess . OnLogout , this.OnLogout )
2021-03-20 15:00:44 +08:00
Game.GlobalEvent : RemoveEvent ( GameEvent.SDK . InitSuccess , this.OnInitSuccess )
2020-07-20 19:57:49 +08:00
end
function this : OnLogout ( )
if IsSDKLogin then
2020-07-22 22:12:20 +08:00
this.SetLoginPart ( false )
2021-04-21 19:28:35 +08:00
this.sdkLoginBtn : SetActive ( true )
2020-07-20 19:57:49 +08:00
this.inputField . gameObject : SetActive ( false )
this.UserBtn : SetActive ( false )
this.btnUser : SetActive ( false )
this.btnNotice . transform.position = this.btnUser . transform.position
this.SDKLogin ( )
else
this.sdkLoginBtn : SetActive ( false )
local userId = PlayerPrefs.GetString ( openIdkey , defaultOpenIdkey )
if IsDevelopLogin then
this.UserBtn : SetActive ( false )
this.btnUser : SetActive ( false )
this.inputField . gameObject : SetActive ( true )
this.inputField . text = userId
else
this.UserBtn : SetActive ( true )
this.btnUser : SetActive ( true )
this.inputField . gameObject : SetActive ( false )
this.UserBtnText . text = userId
end
2021-04-09 12:26:35 +08:00
RequestPanel.Show ( Language [ 11139 ] )
2020-07-20 19:57:49 +08:00
this.SetLoginPart ( true )
2020-08-22 15:31:14 +08:00
-- 获取服务器列表
this.RequestServerList ( userId , this.OnReceiveServerList )
2020-07-20 19:57:49 +08:00
end
2020-05-09 13:31:21 +08:00
end
function this : OnSortingOrderChange ( )
Util.AddParticleSortLayer ( self.gameObject , self.sortingOrder - orginLayer )
orginLayer = this.sortingOrder
end
--界面打开时调用(用于子类重写)
function this : OnOpen ( ... )
2022-07-15 16:00:33 +08:00
2022-07-15 16:02:35 +08:00
-- local url="http://82.157.34.193:9991/delivery/ohayooGetExternal"
-- local data="body;高级基金;notify_url;http://82.157.34.193:9991/delivery/OhayooCallback;open_id;32AtGSX36PYLuNbx;custom_callback_info;20001190_78_4001_IOS;order_no;200011901931657796390;product_id;78;sign_type;MD5;subject;高级基金;total_amount;12800;trade_time;1657796390;valid_time;2592000"
-- HttpManager:SendPostHttp(url,data, this.OnReceiveLogin, nil, nil, nil)
2021-06-02 18:08:03 +08:00
--设置背景
2021-06-04 10:08:57 +08:00
PackageManager.SetVideo ( this.video , this.bg )
2020-05-09 13:31:21 +08:00
if AppConst.Code ~= " " then
2021-01-26 17:08:39 +08:00
MsgPanel.ShowOne ( GetLanguageStrById ( AppConst.Code ) )
2020-05-09 13:31:21 +08:00
AppConst.Code = " "
end
2020-06-30 18:59:44 +08:00
if IsSDKLogin then
2020-07-22 22:12:20 +08:00
this.SetLoginPart ( false )
2021-04-21 19:28:35 +08:00
this.sdkLoginBtn : SetActive ( true )
2020-06-30 18:59:44 +08:00
this.inputField . gameObject : SetActive ( false )
this.UserBtn : SetActive ( false )
this.btnUser : SetActive ( false )
this.btnNotice . transform.position = this.btnUser . transform.position
2020-07-18 19:24:19 +08:00
this.SDKLogin ( )
2020-05-09 13:31:21 +08:00
else
2020-06-30 18:59:44 +08:00
this.sdkLoginBtn : SetActive ( false )
2020-05-09 13:31:21 +08:00
2020-06-30 18:59:44 +08:00
local userId = PlayerPrefs.GetString ( openIdkey , defaultOpenIdkey )
if IsDevelopLogin then
this.UserBtn : SetActive ( false )
this.btnUser : SetActive ( false )
this.inputField . gameObject : SetActive ( true )
this.inputField . text = userId
else
this.UserBtn : SetActive ( true )
this.btnUser : SetActive ( true )
this.inputField . gameObject : SetActive ( false )
this.UserBtnText . text = userId
end
2020-05-09 13:31:21 +08:00
2021-04-09 12:26:35 +08:00
RequestPanel.Show ( Language [ 11139 ] )
2020-05-09 13:31:21 +08:00
this.SetLoginPart ( true )
2020-08-22 15:31:14 +08:00
-- 获取服务器列表
this.RequestServerList ( userId , this.OnReceiveServerList )
2020-05-09 13:31:21 +08:00
end
2021-06-24 11:38:43 +08:00
2020-06-30 18:59:44 +08:00
local tran = this.tip : GetComponent ( " RectTransform " )
2021-01-27 12:08:09 +08:00
--LayoutUtility.GetPreferredWidth(tran)
local offsetX = ( GetPreferredWidth ( tran ) + Screen.width ) / 2
2020-06-30 18:59:44 +08:00
tran.anchoredPosition = Vector2.New ( offsetX , 0 )
tran : DOAnchorPosX ( - offsetX , 30 , false ) : SetEase ( Ease.Linear ) : SetLoops ( - 1 )
2021-11-09 10:49:37 +08:00
-- 初始化一些数据
LoginManager.InitPackInfo ( )
2020-06-30 18:59:44 +08:00
2020-05-09 13:31:21 +08:00
SoundManager.PlayMusic ( SoundConfig.BGM_Login )
SoundManager.PlayAmbient ( SoundConfig.Ambient_Login )
2021-11-03 10:13:44 +08:00
-- local data = {}
-- local godData = this.GetGodSoulDataByLv(10023,5)
-- local godSingleDatas = {}
-- for i = 1,#godData do
-- godSingleDatas[i] = 0
-- end
-- local curHeroData = {}
-- --用条件进行匹配,使得满足条件
-- GodSoulManager.PutQueen(godData, godDatas, 1,godSingleDatas,curHeroData,5)
2020-05-09 13:31:21 +08:00
end
--界面关闭时调用(用于子类重写)
function this : OnClose ( )
this.SetLoginPart ( false )
SoundManager.PauseAmbient ( )
end
2021-06-22 15:01:02 +08:00
function this . CheckNoticeShow ( )
-- 判断公告显示
2021-08-05 14:39:39 +08:00
IsShowNotice = not ServerConfigManager.IsSettingActive ( ServerConfigManager.SettingConfig . IS_NO_NOTICE )
2021-06-22 15:01:02 +08:00
this.btnNotice : SetActive ( IsShowNotice )
end
2021-03-23 16:15:32 +08:00
-- 打开公告界面
function this . ShowNotice ( )
2021-04-09 12:26:35 +08:00
RequestPanel.Show ( Language [ 11137 ] )
2021-05-18 15:37:37 +08:00
--LogError("LoginRoot_NoticeChannel=="..LoginRoot_NoticeChannel)
2021-06-18 18:25:51 +08:00
-- 如果有渠道包配置的id则加上
2021-06-30 22:19:37 +08:00
local noticeChannel = LoginRoot_NoticeChannel
2021-06-22 17:51:14 +08:00
local subNoticeID = PackageManager.GetSubNoticeID ( )
if subNoticeID then
2021-06-30 22:19:37 +08:00
noticeChannel = noticeChannel .. subNoticeID
2021-08-05 14:41:08 +08:00
else
local packID = PackageManager.GetPackageID ( )
if packID then
2021-08-05 16:34:05 +08:00
noticeChannel = noticeChannel .. packID
2021-08-05 14:41:08 +08:00
end
2021-06-18 18:25:51 +08:00
end
2021-06-30 22:19:37 +08:00
local url = LoginRoot_Url .. " jl_loginserver/getNotice?timestamp= " .. timeStamp .. " &sign= " .. timeSign .. " &packageName= " .. noticeChannel
2021-11-09 10:49:37 +08:00
HttpManager : SendGetHttp ( url , function ( str )
2021-03-23 16:15:32 +08:00
UIManager.OpenPanel ( UIName.NoticePopup , str )
end , nil , nil , nil )
end
2020-08-22 15:31:14 +08:00
2021-06-22 15:01:02 +08:00
-- 请求获取
function this . RequestServerVersion ( func )
2021-06-30 09:35:51 +08:00
local ChannelID = LoginRoot_UserChannel == " " and LoginRoot_Channel or LoginRoot_UserChannel
2021-06-22 15:01:02 +08:00
local packId = PackageManager.GetPackageID ( )
if packId then
ChannelID = ChannelID .. packId
end
2021-06-30 09:53:32 +08:00
local url = LoginRoot_Url .. " jl_loginserver/getServerVersion?serverVersion= " .. ChannelID
2021-11-09 10:49:37 +08:00
HttpManager : SendGetHttp ( url , function ( str )
2021-07-13 18:55:21 +08:00
if str == " " or str == " null " or string.find ( str , " html " ) then
2021-06-22 15:01:02 +08:00
LogWarn ( " 获取到的ServerVersion数据是空值, 请检查! " )
else
local json = require ' cjson '
local context = json.decode ( str )
2021-07-09 17:33:21 +08:00
if IsSDKLogin then
-- 当前包的版本号小于GM配置的版本号则包连接正式服, 否则连接提审服
local vcode = ServerConfigManager.GetSDKVersionCode ( )
if vcode <= context.serverInfo then
SERVER_VERSION = 0 -- 正式服
else
SERVER_VERSION = 1 -- 提审服
end
end
2021-06-22 15:01:02 +08:00
end
--
if func then
func ( )
end
end , nil , nil , function ( errCode , errMsg )
2021-07-31 16:02:49 +08:00
LogError ( " GetServerVersion Error: " .. tostring ( errCode ) .. " , " .. tostring ( errMsg ) )
2021-06-22 15:01:02 +08:00
if func then
func ( )
end
end )
end
2020-08-22 15:31:14 +08:00
-- 请求获取服务器列表
function this . RequestServerList ( userId , callback )
2021-06-22 15:01:02 +08:00
this.RequestServerVersion ( function ( )
this.CheckNoticeShow ( )
RequestPanel.Show ( Language [ 11139 ] )
local url = string.format (
" %sjl_loginserver/getServerList?openId=%s&channel=%s&plat=android&sub_channel=%s&server_version=%s " ,
LoginRoot_Url , userId , LoginRoot_Channel , LoginRoot_SubChannel , SERVER_VERSION )
2021-11-09 10:49:37 +08:00
HttpManager : SendGetHttp ( url , callback , nil , nil , nil )
2021-06-22 15:01:02 +08:00
end )
2021-06-30 09:35:51 +08:00
2021-06-24 11:38:43 +08:00
--用户协议,隐私政策
this.RequestProtos ( userId )
2020-08-22 15:31:14 +08:00
end
2021-06-24 11:38:43 +08:00
--获取用户隐私协议
function this . RequestProtos ( userId )
this.protos : SetActive ( false )
this.ConfirmImg : SetActive ( PlayerPrefs.GetInt ( " IHaveConfirmProtos " ) == 1 )
UrlList [ 1 ] = " "
UrlList [ 2 ] = " "
2021-06-30 09:52:40 +08:00
if not IsUserProtoActive then
Log ( " 用户和隐私协议功能未开启 " )
return
end
2021-06-30 09:35:51 +08:00
local ChannelID = LoginRoot_UserChannel == " " and LoginRoot_Channel or LoginRoot_UserChannel
2021-06-24 11:56:09 +08:00
local PackageID = PackageManager.GetPackageID ( )
if PackageID then
2021-06-30 09:35:51 +08:00
ChannelID = ChannelID .. PackageID
2021-06-24 11:56:09 +08:00
end
2021-06-30 09:52:40 +08:00
local url = LoginRoot_Url .. " jl_loginserver/getAgreement?gamePack= " .. ChannelID
2021-11-09 10:49:37 +08:00
HttpManager : SendGetHttp ( url , function ( str )
2021-06-30 09:35:51 +08:00
local json = require ' cjson '
local data = json.decode ( str )
if data.parms then
UrlList [ 1 ] = data.parms . instructions
UrlList [ 2 ] = data.parms . privacy
Log ( " instructionsUrl: " .. tostring ( UrlList [ 1 ] ) .. " privacyUrl: " .. tostring ( UrlList [ 2 ] ) )
HaveConfirm = true
else
this.protos : SetActive ( false )
Log ( " 用户和隐私协议地址为空 " )
HaveConfirm = false
return
end
if UrlList [ 1 ] ~= " " and UrlList [ 2 ] ~= " " then
this.protos : SetActive ( true )
HaveConfirm = true
else
this.protos : SetActive ( false )
HaveConfirm = false
end
end , nil , nil , nil )
2021-06-24 11:38:43 +08:00
end
2020-08-22 15:31:14 +08:00
2020-05-09 13:31:21 +08:00
--界面销毁时调用(用于子类重写)
function this : OnDestroy ( )
2021-04-21 13:12:04 +08:00
this.spLoader : Destroy ( )
2021-06-02 18:08:03 +08:00
PackageManager.UnloadVideo ( )
2020-05-09 13:31:21 +08:00
end
2020-08-22 15:31:14 +08:00
this.isWaiting = false
2020-05-09 13:31:21 +08:00
function this . SDKLogin ( )
2020-08-22 15:31:14 +08:00
if not this.isWaiting then
this.isWaiting = true
Timer.New ( function ( )
SDKMgr : Login ( )
this.isWaiting = false
end , 1 , 1 ) : Start ( )
end
2020-05-09 13:31:21 +08:00
end
2020-09-09 20:17:40 +08:00
function this . RefreshLoginStatus ( result )
if result == SDK_RESULT.SUCCESS then
2021-04-09 12:26:35 +08:00
RequestPanel.Show ( Language [ 11139 ] )
2020-05-09 13:31:21 +08:00
this.SetLoginPart ( true )
2021-04-21 19:28:35 +08:00
this.sdkLoginBtn : SetActive ( false )
2020-08-22 15:31:14 +08:00
-- 获取服务器列表
this.RequestServerList ( AppConst.OpenId , this.OnReceiveServerList )
2020-05-09 13:31:21 +08:00
else
this.sdkLoginBtn : SetActive ( true )
end
end
function this . SetSDKExtensionParams ( params )
if not params or params == " " then
return
end
local json = require ' cjson '
local context = json.decode ( params )
BindPhoneNumberManager.SetPtToken ( context.token )
LoginManager.pt_pId = context.pid
LoginManager.pt_gId = context.gid
end
--收到公告
function this . OnReceiveAnnouncement ( str )
if str == nil then
return
end ;
pcall ( function ( )
local json = require ' cqueryAllies '
local data = json.decode ( str ) ;
if data.content ~= nil and data.content ~= " " then
UIManager.OpenPanel ( UIName.GongGaoPanel , data.content )
end
end ) ;
end
--获取服务器列表地址
function this . OnReceiveServerList ( str )
if str == nil then
return
2020-06-30 18:59:44 +08:00
end
2020-05-09 13:31:21 +08:00
if str ~= nil and str ~= " " then
MyPCall ( function ( )
local json = require ' cjson '
local data = json.decode ( str )
---selectServerPart
this.SetServerList ( data )
2020-06-30 18:59:44 +08:00
if not IsSDKLogin and not IsDevelopLogin then
2020-05-09 13:31:21 +08:00
local user = PlayerPrefs.GetString ( openIdkey , defaultOpenIdkey )
local userPw = PlayerPrefs.GetString ( openIdPw , defaultOpenIdPw )
if user == defaultOpenIdkey or userPw == defaultOpenIdPw then
UIManager.OpenPanel ( UIName.RegistPopup , function ( str , pw )
this.UserBtnText . text = str
PlayerPrefs.SetString ( openIdkey , str )
PlayerPrefs.SetString ( openIdPw , pw )
end )
else
LoginManager.RequestUser ( user , userPw , function ( code )
if code ~= 0 then
UIManager.OpenPanel ( UIName.LoginPopup , user , userPw , function ( str , pw )
this.UserBtnText . text = str
PlayerPrefs.SetString ( openIdkey , str )
PlayerPrefs.SetString ( openIdPw , pw )
end )
else
2020-09-25 21:19:01 +08:00
if IsShowNotice then
this.loginMask : SetActive ( true )
Timer.New ( function ( )
2021-03-23 16:15:32 +08:00
this.ShowNotice ( )
2020-09-25 21:19:01 +08:00
this.loginMask : SetActive ( false )
end , 2.5 , 1 ) : Start ( )
end
2020-05-09 13:31:21 +08:00
end
end )
end
else
2020-09-25 21:19:01 +08:00
if IsShowNotice then
this.loginMask : SetActive ( true )
Timer.New ( function ( )
2021-03-23 16:15:32 +08:00
this.ShowNotice ( )
2020-09-25 21:19:01 +08:00
this.loginMask : SetActive ( false )
end , 2.5 , 1 ) : Start ( )
end
2020-05-09 13:31:21 +08:00
end
end )
end
end
function this . SetServerList ( data )
this.CacheLoginData ( data )
2020-10-10 09:55:15 +08:00
-- 默认选择第一个服务器
local lastIndex = 1
-- 判断要显示的服务器
local showServer
2020-05-09 13:31:21 +08:00
2020-10-10 09:55:15 +08:00
if this.lastServer then --有最近登录显示最近登录,没有显示推荐,否则显示第一个服
showServer = this.lastServer . serverid
2020-05-09 13:31:21 +08:00
else
2020-10-10 09:55:15 +08:00
if this.recommend then
showServer = this.recommend
2020-09-19 16:59:56 +08:00
end
2020-05-09 13:31:21 +08:00
end
2020-10-10 09:55:15 +08:00
-- 如果有要显示的服务器判断位置
if showServer then
for i = 1 , # this.serverList do
if this.serverList [ i ] . server_id == showServer then
lastIndex = i
break
end
end
2020-09-25 21:19:01 +08:00
end
2020-05-09 13:31:21 +08:00
PlayerManager.serverInfo = this.serverList [ lastIndex ]
LoginManager.SocketAddress = this.serverList [ lastIndex ] . ip
LoginManager.SocketPort = tonumber ( this.serverList [ lastIndex ] . port )
LoginManager.ServerId = this.serverList [ lastIndex ] . server_id
2020-07-30 18:50:41 +08:00
LoginManager.state = this.serverList [ lastIndex ] . state
2020-05-09 13:31:21 +08:00
2021-03-19 11:37:22 +08:00
--local severArea = tonumber(string.sub(this.serverList[lastIndex].server_id, 0, -5))
2021-04-09 12:26:35 +08:00
this.serverMes . text = PlayerManager.serverInfo . name -- .. "\t<color=#56F384FF>" .. severArea .. "</color>" .. Language[11138]
2020-05-09 13:31:21 +08:00
RequestPanel.Hide ( )
end
function this . CacheLoginData ( data )
this.serverList = { }
for i = 1 , # data.serverList do
this.serverList [ i ] = data.serverList [ i ]
end
2021-10-11 15:01:49 +08:00
--取消serverId排序, 改用后端原数据, 手动把isnew的数据插入到第一个
local tempList = { }
for i = 1 , # this.serverList do
if this.serverList [ i ] . isnew > 0 then
local tempData = this.serverList [ i ]
for j = i , 2 , - 1 do
this.serverList [ j ] = this.serverList [ j - 1 ]
end
this.serverList [ 1 ] = tempData
break
2020-05-09 13:31:21 +08:00
end
2021-10-11 15:01:49 +08:00
end
2020-05-09 13:31:21 +08:00
this.myServerList = { }
for i = 1 , # data.myServerList do
this.myServerList [ i ] = data.myServerList [ i ]
end
this.lastServer = data.lastServer
this.recommend = data.recommend
end
--登录进主界面之前需要依次请求玩家数据,物品数据,装备数据,英雄数据,编队数据,任务数据, 异妖数据,工坊数据, 冒险数据
function this . ExecuteLoading ( )
2020-06-03 19:09:01 +08:00
local requestList = {
2020-09-25 21:19:01 +08:00
--[[[1] = ]] function ( ) NetManager.PlayerInfoRequest ( LoadingPanel.OnStep ) end , -- 基础信息
2022-07-11 15:43:04 +08:00
--[[[2] = ]] function ( ) NetManager.GetComparenumInfoRequest ( LoadingPanel.OnStep ) end , -- 数字游戏信息
2020-09-25 21:19:01 +08:00
--[[[2] = ]] function ( ) NetManager.RequestMission ( LoadingPanel.OnStep ) end , -- 任务信息
--[[[3] = ]] function ( ) NetManager.ItemInfoRequest ( 0 , LoadingPanel.OnStep ) end , -- 物品信息
2021-12-07 11:50:03 +08:00
-- [[[4] = ]]function() NetManager.AllEquipRequest(0, LoadingPanel.OnStep) end, -- 装备(走背包了)
2021-09-10 10:30:50 +08:00
--[[[5] = ]] function ( ) NetManager.AllEquipTreasureRequest ( 0 , LoadingPanel.OnStep ) end , -- 宝物
2021-12-07 11:50:03 +08:00
-- [[[6] = ]]function() NetManager.GetSoulPrintDataRequest(0, LoadingPanel.OnStep) end, -- 魂印(走背包了)
2020-11-27 10:57:50 +08:00
--[[[7] = ]] function ( ) NetManager.DiffMonsterRequest ( 0 , LoadingPanel.OnStep ) end , -- 异妖
2021-09-10 10:30:50 +08:00
--[[[8] = ]] function ( ) NetManager.HeroInfoRequest ( 0 , LoadingPanel.OnStep ) end , -- 神将信息
2020-09-25 21:19:01 +08:00
--[[[9] = ]] function ( ) NetManager.TeamInfoRequest ( LoadingPanel.OnStep ) end , -- 编队
2021-09-30 15:19:10 +08:00
--[[[10] =]] function ( ) NetManager.GetAllMailData ( LoadingPanel.OnStep ) end , -- 邮件
--[[[11] =]] function ( ) NetManager.GetAllFightDataRequest ( LoadingPanel.OnStep ) end , -- 关卡信息
--[[[12] =]] function ( ) NetManager.GetActivityAllRewardRequest ( LoadingPanel.OnStep ) end , -- 活动奖励
--[[[13] =]] function ( ) NetManager.RequestBaseArenaData ( LoadingPanel.OnStep ) end , -- 竞技场
--[[[14] =]] function ( ) ShopManager.InitData ( LoadingPanel.OnStep ) end , -- 商店
--function() NetManager.GetWorkShopInfoRequest(LoadingPanel.OnStep) end, -- 工坊?
--[[[15] =]] function ( ) ChatManager.InitData ( LoadingPanel.OnStep ) end , -- 聊天
--[[[16] =]] function ( ) NetManager.GetAllFunState ( LoadingPanel.OnStep ) end , -- 功能开启信息
--[[[17] =]] function ( ) NetManager.RequestGetFriendInfo ( 1 , LoadingPanel.OnStep ) end , -- 好友
--[[[18] =]] function ( ) NetManager.RequestGetFriendInfo ( 2 , LoadingPanel.OnStep ) end , -- 好友申请
--[[[19] =]] function ( ) NetManager.RequestGetFriendInfo ( 3 , LoadingPanel.OnStep ) end , -- 好友搜索
--[[[20] =]] function ( ) NetManager.RequestGetFriendInfo ( 4 , LoadingPanel.OnStep ) end , -- 黑名单
--[[[21] =]] function ( ) FriendChatManager.InitData ( LoadingPanel.OnStep ) end , -- 好友消息
--[[[22] =]] function ( ) MyGuildManager.InitBaseData ( LoadingPanel.OnStep ) end , -- 公会信息
2021-10-21 11:10:55 +08:00
--function() GuildFightManager.InitBaseData(LoadingPanel.OnStep) end, -- 公会战
--[[[23] =]] function ( ) NetManager.GetAllGuildSkillData ( LoadingPanel.OnStep ) end , -- 公会技能
--[[[24] =]] function ( ) NetManager.InitFightPointLevelInfo ( LoadingPanel.OnStep ) end , -- 关卡
--[[[25] =]] function ( ) NetManager.GetExpeditionRequest ( ExpeditionManager.expeditionLeve , LoadingPanel.OnStep ) end , -- 大闹天宫
--[[[26] =]] function ( ) NetManager.GuildHelpGetAllRequest ( LoadingPanel.OnStep ) end , -- 公会援助
--[[[27] =]] function ( ) DeathPosManager.InitData ( LoadingPanel.OnStep ) end , -- 十绝阵
--[[[28] =]] function ( ) NetManager.TreasureOfHeavenScoreRequest ( LoadingPanel.OnStep ) end , -- 天宫秘宝积分
--[[[29] =]] function ( ) NetManager.RankFirstRequest ( { 3 , 22 , 20 , 4 , 21 } , { 0 , 0 , 0 , 0 , 20 } , LoadingPanel.OnStep ) end , -- 排行榜数据
--[[[30] =]] function ( ) NetManager.GetSituationInfoRequest ( LoadingPanel.OnStep ) end , --轩辕宝镜
--[[[31] =]] function ( ) NetManager.RefreshTimeSLRequest ( LoadingPanel.OnStep ) end , --青龙秘宝倒计时
--[[[32] =]] function ( ) HeroManager.CheckRepeatTreasure ( LoadingPanel.OnStep ) end , --检测所有重复穿戴的宝器并卸下
--[[[33] =]] function ( ) XiaoYaoManager.GetOpenMapData ( LoadingPanel.OnStep ) end , --逍遥游
--[[[34] =]] function ( ) NetManager.GetHeroSkinData ( LoadingPanel.OnStep ) end , --皮肤
--[[[35] =]] function ( ) NetManager.GetFourElementGetInfo ( LoadingPanel.OnStep ) end , --四灵试炼
2022-04-14 16:07:45 +08:00
--[[[35] =]] function ( ) NetManager.GetChallengeCopyInfo ( LoadingPanel.OnStep ) end , --挑战副本
2021-10-21 11:10:55 +08:00
--[[[36] =]] function ( ) MonsterCampManager.SetMyHelpHeroData ( nil , nil , LoadingPanel.OnStep ) end , --助战神将
--[[[37] =]] function ( ) NetManager.HongMengInfoResponse ( LoadingPanel.OnStep ) end , --鸿蒙阵
2021-12-07 11:50:03 +08:00
--[[[38] =]] function ( ) NetManager.AllBookEnableResponse ( LoadingPanel.OnStep ) end , --天枢密卷
2021-10-21 11:10:55 +08:00
--[[[39] =]] function ( ) NetManager.AllEndLessHeroDataResponse ( 0 , LoadingPanel.OnStep ) end , --无尽英雄数据
--[[[40] =]] function ( ) NetManager.GetEndlessTreasureInfoResponse ( LoadingPanel.OnStep ) end , --无尽密保
--[[[41] =]] function ( ) MyGuildManager.ReuqsetRedPackage ( LoadingPanel.OnStep ) end , --请求红包
--[[[42] =]] function ( ) NetManager.HardStageRequest ( LoadingPanel.OnStep ) end , --山河社稷图
--[[[43] =]] function ( ) NetManager.VipLevelStateRequset ( LoadingPanel.OnStep ) end , --vip
2021-12-03 16:09:33 +08:00
function ( ) JumpServerManager.LoginGetWorldArenaInfoRequest ( LoadingPanel.OnStep ) end , --跨服天梯
2021-10-21 11:10:55 +08:00
--[[[44] =]] function ( ) NetManager.RequestRedPacketData ( LoadingPanel.OnStep ) end , --福利红包
--[[[45] =]] function ( ) NetManager.BeautyBagWishEquipRequest ( nil , LoadingPanel.OnStep ) end , --心愿魂印
--[[[46] =]] function ( ) LingLongBaoJingManager.InitData ( LoadingPanel.OnStep ) end , --玲珑宝镜
--[[[47] =]] function ( ) NetManager.IsCrossRequert ( LoadingPanel.OnStep ) end , --跨服
--[[[48] =]] function ( ) NetManager.TaiChuSecretvolumeRequest ( LoadingPanel.OnStep ) end , --太初密卷
--[[[49] =]] function ( ) NetManager.CrossYuXuLunDaoGetInfoRequest ( 2 , LoadingPanel.OnStep ) end , --玉虚论道红点
--[[[50] =]] function ( ) NetManager.GetLikeableDataRequest ( LoadingPanel.OnStep ) end , --好感度
2021-11-18 11:55:26 +08:00
--[[[51] =]] function ( ) NetManager.GetTransformationRequest ( LoadingPanel.OnStep ) end , --身外化身
2021-12-08 17:30:54 +08:00
--[[[52] =]] function ( ) NetManager.GetLingMaiInfoRequest ( 0 , LoadingPanel.OnStep ) end , --灵脉秘境
--[[[53] =]] function ( ) NetManager.SendGetTailsmanSoulData ( LoadingPanel.OnStep ) end , --法宝之灵
--[[[54] =]] function ( ) NetManager.RequestArenaRankData ( 1 , LoadingPanel.OnStep ) end , --获取竞技场数据
2022-01-04 15:10:35 +08:00
--[[[55] =]] function ( ) HomeLandManager.GetData ( LoadingPanel.OnStep ) end , --家园获取数据
2022-01-06 16:40:24 +08:00
--[[[56] =]] function ( ) NetManager.ExplorerMapInfoRequest ( LoadingPanel.OnStep ) end , --灵脉秘境
2022-03-07 16:05:38 +08:00
--[[[57] =]] function ( ) CommonActPageManager.GetPowerRicePower ( LoadingPanel.OnStep ) end , --战力冲刺
2021-09-30 15:19:10 +08:00
function ( ) -- 登录请求最终接口,所有请求放在此接口之前
2021-02-25 14:33:23 +08:00
-- 登录成功确认
2021-12-27 12:05:43 +08:00
NetManager.LoginConfimRequest ( )
-- 登录时初始化主界面竖条显示为打开状态
PlayerPrefs.SetInt ( PlayerManager.uid .. " MainRightBarSetting " , 1 )
2020-06-03 19:09:01 +08:00
if AppConst.isGuide then
2021-02-27 18:09:58 +08:00
if GuideManager.GetCurId ( GuideType.Force ) == 1 and PlayerManager.nickName == tostring ( PlayerManager.uid ) and PlayerManager.level == 1 then
2021-03-15 20:16:03 +08:00
-- 新的引导
-- StoryManager.EventTrigger(300001)
2020-06-03 19:09:01 +08:00
--创号阶段先进入剧情对话,进入假战斗,然后对话起名,最后进入主界面
2021-04-13 15:10:40 +08:00
StoryManager.EventTrigger ( 300007 )
2021-03-19 11:10:48 +08:00
-- 新的引导
2021-04-12 18:11:37 +08:00
-- StoryManager.EventTrigger(100001)
2020-09-25 14:11:05 +08:00
else
PatFaceManager.isLogin = true
UIManager.OpenPanel ( UIName.FightPointPassMainPanel )
LoadingPanel.End ( )
2020-05-09 13:31:21 +08:00
end
2020-06-03 19:09:01 +08:00
else
UIManager.OpenPanelAsync ( UIName.MainPanel , function ( )
if RoomManager.RoomAddress == nil or RoomManager.RoomAddress == " " then
RoomManager.IsMatch = 0
elseif RoomManager.RoomAddress == " 1 " then
RoomManager.IsMatch = 1
UIManager.OpenPanel ( UIName.GMPanel )
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip ( Language [ 11141 ] )
2020-06-03 19:09:01 +08:00
else
if RoomManager.CurRoomType == 1 then
2021-01-09 14:20:06 +08:00
Log ( " 在房间里,需要重新获取房间游戏数据~~~~~~~~~~ " )
2020-06-03 19:09:01 +08:00
RoomManager.RoomReGetGameRequest ( RoomManager.RoomAddress )
end
2020-05-09 13:31:21 +08:00
end
2020-06-03 19:09:01 +08:00
LoadingPanel.End ( )
end )
end
-- 登录成功刷新红点数据
RedpotManager.CheckAllRedPointStatus ( )
-- 检查新字状态
FunctionOpenMananger.InitCheck ( )
this.SubmitGameData ( )
DataCenterManager.CommitBootStatus ( )
end ,
}
--
for _ , func in ipairs ( requestList ) do
LoadingPanel.AddStep ( func )
end
2020-05-09 13:31:21 +08:00
LoadingPanel.Start ( )
this : ClosePanel ( )
end
2020-08-22 15:31:14 +08:00
this.isLoginClick = false
2020-05-09 13:31:21 +08:00
function this . OnLoginClick ( )
2021-06-30 09:52:40 +08:00
if IsUserProtoActive and HaveConfirm and PlayerPrefs.GetInt ( " IHaveConfirmProtos " ) == 0 then
2021-06-24 11:38:43 +08:00
PopupTipPanel.ShowTip ( " 为了保证您的个人隐私和隐私安全,请详细阅读并同意用户协议及隐私政策 " )
return
end
2021-07-29 11:44:35 +08:00
-- 只要不是流畅,拥挤,爆满状态就不让登录
2021-08-09 14:10:54 +08:00
if not LoginManager.IsServerStateEnterable ( LoginManager.state ) then
2020-08-22 15:31:14 +08:00
local function reServerCallback ( str )
if str == nil then
return
end
if str ~= nil and str ~= " " then
MyPCall ( function ( )
local json = require ' cjson '
local data = json.decode ( str )
---selectServerPart
this.SetServerList ( data )
2021-07-29 11:44:35 +08:00
-- 还是不可进状态则提示服务器维护中
2021-08-09 14:10:54 +08:00
if not LoginManager.IsServerStateEnterable ( LoginManager.state ) then
2021-08-09 16:52:21 +08:00
PopupTipPanel.ShowTip ( " 服务器还未开启哦,具体开服时间可见公告~ " )
2020-08-22 15:31:14 +08:00
RequestPanel.Hide ( )
else
2021-03-23 16:15:32 +08:00
-- 开始登录
this.RequestHttpLogin ( )
2020-08-22 15:31:14 +08:00
end
end )
end
end
-- 判断获取服务器的id
if IsSDKLogin then
this.RequestServerList ( AppConst.OpenId , reServerCallback )
else
local userId = PlayerPrefs.GetString ( openIdkey , defaultOpenIdkey )
this.RequestServerList ( userId , reServerCallback )
end
2020-07-30 18:50:41 +08:00
return
end
2020-08-22 15:31:14 +08:00
2021-03-23 16:15:32 +08:00
-- 开始登录
this.RequestHttpLogin ( )
2020-08-22 15:31:14 +08:00
end
2021-03-23 16:15:32 +08:00
-----------++++++++++++++++++++++++++++++++++++++++ http +++++++++++++++++++++++++++++
-- 登录服请求登录
function this . RequestHttpLogin ( )
2021-04-09 12:26:35 +08:00
RequestPanel.Show ( Language [ 11144 ] )
2021-03-23 16:15:32 +08:00
local url = " "
2021-06-30 09:16:28 +08:00
local user_channel = LoginRoot_UserChannel == " " and LoginRoot_Channel or LoginRoot_UserChannel
2020-06-30 18:59:44 +08:00
if IsSDKLogin then
2021-03-23 16:15:32 +08:00
url = LoginRoot_Url
2021-04-12 18:56:07 +08:00
.. " jl_loginserver/getUserInfo?openId= " .. AppConst.OpenId
2020-07-16 19:51:38 +08:00
.. " &serverId= " .. LoginManager.ServerId
.. " &token= " .. AppConst.TokenStr
.. " &platform= " .. 1
2021-06-30 09:16:28 +08:00
.. " &channel= " .. user_channel
2020-07-16 19:51:38 +08:00
.. " &sub_channel= " .. LoginRoot_SubChannel
.. " &pid= " .. AppConst.SdkChannel --LoginManager.pt_pId
2020-07-24 10:22:20 +08:00
.. " &gid= " .. AppConst.SdkPackageName --LoginManager.pt_gId
2021-03-23 16:15:32 +08:00
.. " &version= " .. LoginRoot_PackageVersion
2021-05-31 15:15:20 +08:00
.. " &timeStamp= " .. LoginManager.SdkLoginTimeStamp
2021-06-08 17:27:24 +08:00
.. " &ext= " .. encodeURI ( LoginManager.extData )
.. " &platform_appid= " .. LoginManager.p_appId
2020-05-09 13:31:21 +08:00
else
2020-06-30 18:59:44 +08:00
if IsDevelopLogin then
-- 开发用
local str = this.inputField . text
2021-11-11 10:07:14 +08:00
if str == Language [ 11135 ] then
RequestPanel.Hide ( )
PopupTipPanel.ShowTip ( Language [ 11135 ] )
return
end
2020-06-30 18:59:44 +08:00
PlayerPrefs.SetString ( openIdkey , str )
2021-03-23 16:15:32 +08:00
url = LoginRoot_Url
2020-06-30 18:59:44 +08:00
.. " jl_loginserver/getUserInfo?openId= " .. str
2020-05-09 13:31:21 +08:00
.. " &serverId= " .. LoginManager.ServerId
2020-06-30 18:59:44 +08:00
.. " &token=111 "
2020-08-22 15:31:14 +08:00
.. " &platform=1 "
2021-06-30 09:16:28 +08:00
.. " &channel= " .. user_channel
2020-06-30 18:59:44 +08:00
.. " &sub_channel= " .. LoginRoot_SubChannel
.. " &admin=d53b3e8ef74bf72d8aafce3a1c8671a0 "
2021-03-23 16:15:32 +08:00
.. " &version= " .. LoginRoot_PackageVersion
2021-05-31 15:15:20 +08:00
.. " &timeStamp=0 "
2020-05-09 13:31:21 +08:00
else
2021-03-23 16:15:32 +08:00
url = LoginRoot_Url
2020-06-30 18:59:44 +08:00
.. " jl_loginserver/getUserInfo?openId= " .. LoginManager.openId
2020-05-09 13:31:21 +08:00
.. " &serverId= " .. LoginManager.ServerId
2020-06-30 18:59:44 +08:00
.. " &token= " .. LoginManager.token
.. " &platform=4 "
2021-06-30 09:16:28 +08:00
.. " &channel= " .. user_channel
2020-06-30 18:59:44 +08:00
.. " &sub_channel= " .. LoginRoot_SubChannel
2020-08-25 15:51:35 +08:00
.. " &admin=d53b3e8ef74bf72d8aafce3a1c8671a0 "
2021-05-31 15:15:20 +08:00
.. " &version= " .. LoginRoot_PackageVersion
.. " &timeStamp=0 " ,
2021-03-23 16:15:32 +08:00
this.OnReceiveLogin , nil , nil , nil
2020-06-30 18:59:44 +08:00
end
2020-05-09 13:31:21 +08:00
end
2021-11-09 10:49:37 +08:00
HttpManager : SendGetHttp ( url , this.OnReceiveLogin , nil , nil , nil )
2021-03-23 16:15:32 +08:00
end
2020-05-09 13:31:21 +08:00
2021-03-23 16:15:32 +08:00
--用户id登录
function this . OnReceiveLogin ( str )
RequestPanel.Hide ( )
if str == nil then
return
end
if str ~= nil and str ~= " " then
MyPCall ( function ( )
Log ( str )
local json = require ' cjson '
local data = json.decode ( str )
if data.errorCode and data.errorCode == - 1 then
2021-09-02 22:12:58 +08:00
MsgPanel.ShowOne ( data.reason or Language [ 11145 ] )
2021-03-23 16:15:32 +08:00
return
end
if data.uid and data.token and not LoginManager.IsLogin then
AppConst.UserId = data.uid
AppConst.Token = data.token
this.RequestSocketLogin ( )
end
end )
end
2020-05-09 13:31:21 +08:00
end
2021-03-23 16:15:32 +08:00
-----------++++++++++++++++++++++++++++++++++++++++ http +++++++++++++++++++++++++++++
2020-05-09 13:31:21 +08:00
2021-03-23 16:15:32 +08:00
-----------++++++++++++++++++++++++++++++++++++++++ socket +++++++++++++++++++++++++++++
-- 请求连接socket
function this . RequestSocketLogin ( )
2021-05-29 15:39:21 +08:00
Log ( " 请求连接Socket " )
2021-04-09 12:26:35 +08:00
RequestPanel.Show ( Language [ 11143 ] )
2021-03-23 16:15:32 +08:00
SocketManager.Disconnect ( SocketType.LOGIN )
SocketManager.AddNetwork ( SocketType.LOGIN , LoginManager.SocketAddress , LoginManager.SocketPort )
SocketManager.TryConnect ( SocketType.LOGIN )
end
function this . OnConnect ( network )
local openId = AppConst.isSDKLogin and AppConst.OpenId or PlayerPrefs.GetString ( openIdkey )
NetManager.LoginRequest ( openId , function ( )
if not LoginManager.IsLogin then
LoginManager.IsLogin = true
this.ExecuteLoading ( )
end
RequestPanel.Hide ( )
end )
end
2020-05-09 13:31:21 +08:00
function this . OnDisconnect ( network )
RequestPanel.Hide ( )
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip ( Language [ 11145 ] )
2020-05-09 13:31:21 +08:00
end
2021-03-23 16:15:32 +08:00
-----------++++++++++++++++++++++++++++++++++++++++ socket +++++++++++++++++++++++++++++
2020-05-09 13:31:21 +08:00
function this . SetLoginPart ( flag )
2020-08-29 17:22:46 +08:00
this.loginAnim . enabled = flag
2021-06-03 23:03:09 +08:00
this.btnLoginPart : SetActive ( flag and tostring ( this.bgStr ) == " dl_ui_effect_bg " )
2020-08-25 17:56:55 +08:00
this.btnLogin : SetActive ( flag )
2020-05-09 13:31:21 +08:00
this.serverSelectPart : SetActive ( flag )
end
function this . SubmitGameData ( )
local isNewRole = PlayerPrefs.GetString ( tostring ( PlayerManager.uid ) , " " )
2021-06-01 21:13:03 +08:00
if isNewRole == " " and PlayerManager.level == 1 then
2020-05-09 13:31:21 +08:00
PlayerPrefs.SetString ( tostring ( PlayerManager.uid ) , tostring ( PlayerManager.uid ) )
SubmitExtraData ( { type = SDKSubMitType.TYPE_CREATE_ROLE } )
end
SubmitExtraData ( { type = SDKSubMitType.TYPE_ENTER_GAME } )
end
2020-06-23 18:36:24 +08:00
return LoginPanel