【登录】流程修改,添加错误码处理
parent
145eb02c06
commit
3a8a8ddeeb
|
@ -81,10 +81,7 @@ function this:BindEvent()
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
Util.AddClick(this.btnNotice, function()
|
Util.AddClick(this.btnNotice, function()
|
||||||
RequestPanel.Show(Language[11137])
|
this.ShowNotice()
|
||||||
networkMgr:SendGetHttp(LoginRoot_Url .. "jl_loginserver/getNotice?timestamp="..timeStamp.."&sign=".. timeSign,function (str)
|
|
||||||
UIManager.OpenPanel(UIName.NoticePopup,str)
|
|
||||||
end, nil, nil, nil)
|
|
||||||
end)
|
end)
|
||||||
Util.AddClick(this.UserBtn, function()
|
Util.AddClick(this.UserBtn, function()
|
||||||
local user = PlayerPrefs.GetString(openIdkey, defaultOpenIdkey)
|
local user = PlayerPrefs.GetString(openIdkey, defaultOpenIdkey)
|
||||||
|
@ -239,18 +236,22 @@ function this:OnClose()
|
||||||
SoundManager.PauseAmbient()
|
SoundManager.PauseAmbient()
|
||||||
end
|
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)
|
function this.RequestServerList(userId, callback)
|
||||||
RequestPanel.Show(Language[11139])
|
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",
|
"%sjl_loginserver/getServerList?openId=%s&channel=%s&plat=android&sub_channel=%s&server_version=%s",
|
||||||
LoginRoot_Url, userId, LoginRoot_Channel, LoginRoot_SubChannel, ServerVersion))
|
LoginRoot_Url, userId, LoginRoot_Channel, LoginRoot_SubChannel, ServerVersion)
|
||||||
|
Log(url)
|
||||||
networkMgr:SendGetHttp(string.format(
|
networkMgr:SendGetHttp(url, callback, nil, nil, nil)
|
||||||
"%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)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -341,10 +342,7 @@ function this.OnReceiveServerList(str)
|
||||||
if IsShowNotice then
|
if IsShowNotice then
|
||||||
this.loginMask:SetActive(true)
|
this.loginMask:SetActive(true)
|
||||||
Timer.New(function()
|
Timer.New(function()
|
||||||
RequestPanel.Show(Language[11137])
|
this.ShowNotice()
|
||||||
networkMgr:SendGetHttp(LoginRoot_Url .. "jl_loginserver/getNotice?timestamp="..timeStamp.."&sign=".. timeSign,function (str)
|
|
||||||
UIManager.OpenPanel(UIName.NoticePopup,str)
|
|
||||||
end, nil, nil, nil)
|
|
||||||
this.loginMask:SetActive(false)
|
this.loginMask:SetActive(false)
|
||||||
end, 2.5, 1):Start()
|
end, 2.5, 1):Start()
|
||||||
end
|
end
|
||||||
|
@ -355,10 +353,7 @@ function this.OnReceiveServerList(str)
|
||||||
if IsShowNotice then
|
if IsShowNotice then
|
||||||
this.loginMask:SetActive(true)
|
this.loginMask:SetActive(true)
|
||||||
Timer.New(function()
|
Timer.New(function()
|
||||||
RequestPanel.Show(Language[11137])
|
this.ShowNotice()
|
||||||
networkMgr:SendGetHttp(LoginRoot_Url .. "jl_loginserver/getNotice?timestamp="..timeStamp.."&sign=".. timeSign,function (str)
|
|
||||||
UIManager.OpenPanel(UIName.NoticePopup,str)
|
|
||||||
end, nil, nil, nil)
|
|
||||||
this.loginMask:SetActive(false)
|
this.loginMask:SetActive(false)
|
||||||
end, 2.5, 1):Start()
|
end, 2.5, 1):Start()
|
||||||
end
|
end
|
||||||
|
@ -423,34 +418,6 @@ function this.CacheLoginData(data)
|
||||||
this.recommend = data.recommend
|
this.recommend = data.recommend
|
||||||
end
|
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()
|
function this.ExecuteLoading()
|
||||||
local requestList = {
|
local requestList = {
|
||||||
|
@ -556,8 +523,8 @@ function this.OnLoginClick()
|
||||||
PopupTipPanel.ShowTip(Language[11142])
|
PopupTipPanel.ShowTip(Language[11142])
|
||||||
RequestPanel.Hide()
|
RequestPanel.Hide()
|
||||||
else
|
else
|
||||||
-- 连接socket
|
-- 开始登录
|
||||||
this.RequestSocketLogin()
|
this.RequestHttpLogin()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
@ -572,10 +539,81 @@ function this.OnLoginClick()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 连接socket
|
-- 开始登录
|
||||||
this.RequestSocketLogin()
|
this.RequestHttpLogin()
|
||||||
end
|
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
|
-- 请求连接socket
|
||||||
function this.RequestSocketLogin()
|
function this.RequestSocketLogin()
|
||||||
LogRed("请求连接Socket")
|
LogRed("请求连接Socket")
|
||||||
|
@ -584,102 +622,23 @@ function this.RequestSocketLogin()
|
||||||
SocketManager.AddNetwork(SocketType.LOGIN, LoginManager.SocketAddress, LoginManager.SocketPort)
|
SocketManager.AddNetwork(SocketType.LOGIN, LoginManager.SocketAddress, LoginManager.SocketPort)
|
||||||
SocketManager.TryConnect(SocketType.LOGIN)
|
SocketManager.TryConnect(SocketType.LOGIN)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function this.OnConnect(network)
|
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()
|
RequestPanel.Hide()
|
||||||
if network.type ~= SocketType.LOGIN then
|
end)
|
||||||
return
|
|
||||||
end
|
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)
|
|
||||||
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
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function this.OnDisconnect(network)
|
function this.OnDisconnect(network)
|
||||||
RequestPanel.Hide()
|
RequestPanel.Hide()
|
||||||
PopupTipPanel.ShowTip(Language[11145])
|
PopupTipPanel.ShowTip(Language[11145])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-----------++++++++++++++++++++++++++++++++++++++++ socket +++++++++++++++++++++++++++++
|
||||||
|
|
||||||
function this.SetLoginPart(flag)
|
function this.SetLoginPart(flag)
|
||||||
this.loginAnim.enabled = flag
|
this.loginAnim.enabled = flag
|
||||||
this.btnLoginPart:SetActive(flag)
|
this.btnLoginPart:SetActive(flag)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
require("Base/BasePanel")
|
require("Base/BasePanel")
|
||||||
NoticePopup = Inherit(BasePanel)
|
NoticePopup = Inherit(BasePanel)
|
||||||
local this = NoticePopup
|
local this = NoticePopup
|
||||||
local LoginRoot_Url = ServerConfigManager.GetVersionInfo("serverUrl")
|
|
||||||
--初始化组件(用于子类重写)
|
--初始化组件(用于子类重写)
|
||||||
function NoticePopup:InitComponent()
|
function NoticePopup:InitComponent()
|
||||||
|
|
||||||
|
@ -51,11 +50,6 @@ function NoticePopup:OnDestroy()
|
||||||
end
|
end
|
||||||
|
|
||||||
function this.GetNotice(str)
|
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()
|
RequestPanel.Hide()
|
||||||
if str == nil then
|
if str == nil then
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue