【登录】流程修改,添加错误码处理
parent
145eb02c06
commit
3a8a8ddeeb
|
@ -81,10 +81,7 @@ function this:BindEvent()
|
|||
end)
|
||||
end)
|
||||
Util.AddClick(this.btnNotice, function()
|
||||
RequestPanel.Show(Language[11137])
|
||||
networkMgr:SendGetHttp(LoginRoot_Url .. "jl_loginserver/getNotice?timestamp="..timeStamp.."&sign=".. timeSign,function (str)
|
||||
UIManager.OpenPanel(UIName.NoticePopup,str)
|
||||
end, nil, nil, nil)
|
||||
this.ShowNotice()
|
||||
end)
|
||||
Util.AddClick(this.UserBtn, function()
|
||||
local user = PlayerPrefs.GetString(openIdkey, defaultOpenIdkey)
|
||||
|
@ -239,18 +236,22 @@ function this:OnClose()
|
|||
SoundManager.PauseAmbient()
|
||||
end
|
||||
|
||||
-- 打开公告界面
|
||||
function this.ShowNotice()
|
||||
RequestPanel.Show(Language[11137])
|
||||
networkMgr:SendGetHttp(LoginRoot_Url .. "jl_loginserver/getNotice?timestamp="..timeStamp.."&sign=".. timeSign,function (str)
|
||||
UIManager.OpenPanel(UIName.NoticePopup,str)
|
||||
end, nil, nil, nil)
|
||||
end
|
||||
|
||||
-- 请求获取服务器列表
|
||||
function this.RequestServerList(userId, callback)
|
||||
RequestPanel.Show(Language[11139])
|
||||
Log(string.format(
|
||||
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, ServerVersion))
|
||||
|
||||
networkMgr:SendGetHttp(string.format(
|
||||
"%sjl_loginserver/getServerList?openId=%s&channel=%s&plat=android&sub_channel=%s&server_version=%s",
|
||||
LoginRoot_Url, userId, LoginRoot_Channel, LoginRoot_SubChannel, ServerVersion),
|
||||
callback, nil, nil, nil)
|
||||
LoginRoot_Url, userId, LoginRoot_Channel, LoginRoot_SubChannel, ServerVersion)
|
||||
Log(url)
|
||||
networkMgr:SendGetHttp(url, callback, nil, nil, nil)
|
||||
end
|
||||
|
||||
|
||||
|
@ -341,10 +342,7 @@ function this.OnReceiveServerList(str)
|
|||
if IsShowNotice then
|
||||
this.loginMask:SetActive(true)
|
||||
Timer.New(function()
|
||||
RequestPanel.Show(Language[11137])
|
||||
networkMgr:SendGetHttp(LoginRoot_Url .. "jl_loginserver/getNotice?timestamp="..timeStamp.."&sign=".. timeSign,function (str)
|
||||
UIManager.OpenPanel(UIName.NoticePopup,str)
|
||||
end, nil, nil, nil)
|
||||
this.ShowNotice()
|
||||
this.loginMask:SetActive(false)
|
||||
end, 2.5, 1):Start()
|
||||
end
|
||||
|
@ -355,10 +353,7 @@ function this.OnReceiveServerList(str)
|
|||
if IsShowNotice then
|
||||
this.loginMask:SetActive(true)
|
||||
Timer.New(function()
|
||||
RequestPanel.Show(Language[11137])
|
||||
networkMgr:SendGetHttp(LoginRoot_Url .. "jl_loginserver/getNotice?timestamp="..timeStamp.."&sign=".. timeSign,function (str)
|
||||
UIManager.OpenPanel(UIName.NoticePopup,str)
|
||||
end, nil, nil, nil)
|
||||
this.ShowNotice()
|
||||
this.loginMask:SetActive(false)
|
||||
end, 2.5, 1):Start()
|
||||
end
|
||||
|
@ -423,34 +418,6 @@ function this.CacheLoginData(data)
|
|||
this.recommend = data.recommend
|
||||
end
|
||||
|
||||
--用户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)
|
||||
Log("uid:" .. data.uid)
|
||||
Log("token:" .. data.token)
|
||||
if data.uid and data.token and not LoginManager.IsLogin then
|
||||
AppConst.UserId = data.uid
|
||||
AppConst.Token = data.token
|
||||
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
|
||||
end)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
--登录进主界面之前需要依次请求玩家数据,物品数据,装备数据,英雄数据,编队数据,任务数据, 异妖数据,工坊数据, 冒险数据
|
||||
function this.ExecuteLoading()
|
||||
local requestList = {
|
||||
|
@ -556,8 +523,8 @@ function this.OnLoginClick()
|
|||
PopupTipPanel.ShowTip(Language[11142])
|
||||
RequestPanel.Hide()
|
||||
else
|
||||
-- 连接socket
|
||||
this.RequestSocketLogin()
|
||||
-- 开始登录
|
||||
this.RequestHttpLogin()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
@ -572,10 +539,81 @@ function this.OnLoginClick()
|
|||
return
|
||||
end
|
||||
|
||||
-- 连接socket
|
||||
this.RequestSocketLogin()
|
||||
-- 开始登录
|
||||
this.RequestHttpLogin()
|
||||
end
|
||||
|
||||
-----------++++++++++++++++++++++++++++++++++++++++ http +++++++++++++++++++++++++++++
|
||||
-- 登录服请求登录
|
||||
function this.RequestHttpLogin()
|
||||
RequestPanel.Show(Language[11144])
|
||||
local url = ""
|
||||
if IsSDKLogin then
|
||||
url = LoginRoot_Url
|
||||
.. "jl_loginserver/getUserInfo?openId=" .. AppConst.OpenId
|
||||
.. "&serverId=" .. LoginManager.ServerId
|
||||
.. "&token=" .. AppConst.TokenStr
|
||||
.. "&platform=" .. 1
|
||||
.. "&sub_channel=" .. LoginRoot_SubChannel
|
||||
.. "&pid=" .. AppConst.SdkChannel --LoginManager.pt_pId
|
||||
.. "&gid=" .. AppConst.SdkPackageName --LoginManager.pt_gId
|
||||
.. "&version=" .. LoginRoot_PackageVersion
|
||||
else
|
||||
if IsDevelopLogin then
|
||||
-- 开发用
|
||||
local str = this.inputField.text
|
||||
PlayerPrefs.SetString(openIdkey, str)
|
||||
url = LoginRoot_Url
|
||||
.. "jl_loginserver/getUserInfo?openId=" .. str
|
||||
.. "&serverId=" .. LoginManager.ServerId
|
||||
.. "&token=111"
|
||||
.. "&platform=1"
|
||||
.. "&sub_channel=" .. LoginRoot_SubChannel
|
||||
.. "&admin=d53b3e8ef74bf72d8aafce3a1c8671a0"
|
||||
.. "&version=" .. LoginRoot_PackageVersion
|
||||
else
|
||||
url = LoginRoot_Url
|
||||
.. "jl_loginserver/getUserInfo?openId=" ..LoginManager.openId
|
||||
.. "&serverId=" .. LoginManager.ServerId
|
||||
.. "&token=" .. LoginManager.token
|
||||
.. "&platform=4"
|
||||
.. "&sub_channel=" .. LoginRoot_SubChannel
|
||||
.. "&admin=d53b3e8ef74bf72d8aafce3a1c8671a0"
|
||||
.. "&version=" .. LoginRoot_PackageVersion,
|
||||
this.OnReceiveLogin, nil, nil, nil
|
||||
end
|
||||
|
||||
end
|
||||
Log(url)
|
||||
networkMgr:SendGetHttp(url, this.OnReceiveLogin, nil, nil, nil)
|
||||
end
|
||||
|
||||
--用户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
|
||||
PopupTipPanel.ShowTip(data.reason or Language[11145])
|
||||
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
|
||||
end
|
||||
-----------++++++++++++++++++++++++++++++++++++++++ http +++++++++++++++++++++++++++++
|
||||
|
||||
-----------++++++++++++++++++++++++++++++++++++++++ socket +++++++++++++++++++++++++++++
|
||||
-- 请求连接socket
|
||||
function this.RequestSocketLogin()
|
||||
LogRed("请求连接Socket")
|
||||
|
@ -584,102 +622,23 @@ function this.RequestSocketLogin()
|
|||
SocketManager.AddNetwork(SocketType.LOGIN, LoginManager.SocketAddress, LoginManager.SocketPort)
|
||||
SocketManager.TryConnect(SocketType.LOGIN)
|
||||
end
|
||||
|
||||
|
||||
function this.OnConnect(network)
|
||||
RequestPanel.Hide()
|
||||
if network.type ~= SocketType.LOGIN then
|
||||
return
|
||||
end
|
||||
RequestPanel.Show(Language[11144])
|
||||
if IsSDKLogin then
|
||||
Log(LoginRoot_Url
|
||||
.. "jl_loginserver/getUserInfo?openId=" .. AppConst.OpenId
|
||||
.. "&serverId=" .. LoginManager.ServerId
|
||||
.. "&token=" .. AppConst.TokenStr
|
||||
.. "&platform=" .. 1
|
||||
.. "&sub_channel=" .. LoginRoot_SubChannel
|
||||
.. "&pid=" .. AppConst.SdkChannel --LoginManager.pt_pId
|
||||
.. "&gid=" .. AppConst.SdkPackageName --LoginManager.pt_gId
|
||||
.. "&version=" .. LoginRoot_PackageVersion)
|
||||
networkMgr:SendGetHttp(LoginRoot_Url
|
||||
.. "jl_loginserver/getUserInfo?openId=" .. AppConst.OpenId
|
||||
.. "&serverId=" .. LoginManager.ServerId
|
||||
.. "&token=" .. AppConst.TokenStr
|
||||
.. "&platform=" .. 1
|
||||
.. "&sub_channel=" .. LoginRoot_SubChannel
|
||||
.. "&pid=" .. AppConst.SdkChannel --LoginManager.pt_pId
|
||||
.. "&gid=" .. AppConst.SdkPackageName --LoginManager.pt_gId
|
||||
.. "&version=" .. LoginRoot_PackageVersion,
|
||||
this.OnReceiveLogin, nil, nil, nil)
|
||||
else
|
||||
if IsDevelopLogin then
|
||||
-- 开发用
|
||||
local str = this.inputField.text
|
||||
PlayerPrefs.SetString(openIdkey, str)
|
||||
networkMgr:SendGetHttp(LoginRoot_Url
|
||||
.. "jl_loginserver/getUserInfo?openId=" .. str
|
||||
.. "&serverId=" .. LoginManager.ServerId
|
||||
.. "&token=111"
|
||||
.. "&platform=1"
|
||||
.. "&sub_channel=" .. LoginRoot_SubChannel
|
||||
.. "&admin=d53b3e8ef74bf72d8aafce3a1c8671a0"
|
||||
.. "&version=" .. LoginRoot_PackageVersion,
|
||||
this.OnReceiveLogin, nil, nil, nil)
|
||||
else
|
||||
networkMgr:SendGetHttp(LoginRoot_Url
|
||||
.. "jl_loginserver/getUserInfo?openId=" ..LoginManager.openId
|
||||
.. "&serverId=" .. LoginManager.ServerId
|
||||
.. "&token=" .. LoginManager.token
|
||||
.. "&platform=4"
|
||||
.. "&sub_channel=" .. LoginRoot_SubChannel
|
||||
.. "&admin="--d53b3e8ef74bf72d8aafce3a1c8671a0"
|
||||
.. "&version=" .. LoginRoot_PackageVersion,
|
||||
this.OnReceiveLogin, nil, nil, nil)
|
||||
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
|
||||
|
||||
|
||||
|
||||
-- if IsTestLogin then
|
||||
-- networkMgr:SendGetHttp(LoginRoot_Url
|
||||
-- .. "jl_loginserver/getUserInfo?openId=" .. LoginManager.openId
|
||||
-- .. "&serverId=" .. LoginManager.ServerId
|
||||
-- .. "&token=" .. LoginManager.token
|
||||
-- .. "&platform="..4
|
||||
-- .. "&version=" .. LoginRoot_PackageVersion,
|
||||
-- this.OnReceiveLogin, nil, nil, nil)
|
||||
-- else
|
||||
|
||||
|
||||
-- --
|
||||
-- networkMgr:SendGetHttp(LoginRoot_Url
|
||||
-- .. "jl_loginserver/getUserInfo?openId=" .. str
|
||||
-- .. "&platform=3&sub_channel=" .. LoginRoot_SubChannel
|
||||
-- .. "&serverId=" .. LoginManager.ServerId
|
||||
-- .. "&token=" .. AppConst.Token
|
||||
-- .. "&version=" .. LoginRoot_PackageVersion,
|
||||
-- this.OnReceiveLogin, nil, nil, nil)
|
||||
|
||||
-- --TODO:线上调试用
|
||||
-- -- networkMgr:SendGetHttp(LoginRoot_Url
|
||||
-- -- .. "jl_loginserver/getUserInfo?openId=" .. str
|
||||
-- -- .. "&platform=1&sub_channel=" .. LoginRoot_SubChannel
|
||||
-- -- .. "&serverId=" .. LoginManager.ServerId
|
||||
-- -- .. "&token=111&admin=d53b3e8ef74bf72d8aafce3a1c8671a0"
|
||||
-- -- .. "&version=" .. LoginRoot_PackageVersion,
|
||||
-- -- this.OnReceiveLogin, nil, nil, nil)
|
||||
|
||||
-- end
|
||||
|
||||
end
|
||||
|
||||
RequestPanel.Hide()
|
||||
end)
|
||||
end
|
||||
|
||||
function this.OnDisconnect(network)
|
||||
RequestPanel.Hide()
|
||||
PopupTipPanel.ShowTip(Language[11145])
|
||||
end
|
||||
|
||||
-----------++++++++++++++++++++++++++++++++++++++++ socket +++++++++++++++++++++++++++++
|
||||
|
||||
function this.SetLoginPart(flag)
|
||||
this.loginAnim.enabled = flag
|
||||
this.btnLoginPart:SetActive(flag)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
require("Base/BasePanel")
|
||||
NoticePopup = Inherit(BasePanel)
|
||||
local this = NoticePopup
|
||||
local LoginRoot_Url = ServerConfigManager.GetVersionInfo("serverUrl")
|
||||
--初始化组件(用于子类重写)
|
||||
function NoticePopup:InitComponent()
|
||||
|
||||
|
@ -51,11 +50,6 @@ function NoticePopup:OnDestroy()
|
|||
end
|
||||
|
||||
function this.GetNotice(str)
|
||||
-- local timeStamp = Time.realtimeSinceStartup
|
||||
-- local timeSign = Util.MD5Encrypt(string.format("%s%s", timeStamp, LoginManager.sign))
|
||||
-- RequestPanel.Show("正在获取公告信息")
|
||||
-- networkMgr:SendGetHttp(LoginRoot_Url .. "jl_loginserver/getNotice?timestamp="..timeStamp.."&sign=".. timeSign,function (str)
|
||||
-- end, nil, nil, nil)
|
||||
RequestPanel.Hide()
|
||||
if str == nil then
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue