2025-05-24 14:29:14 +08:00
|
|
|
LoginController = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local M = {}
|
|
|
|
|
|
|
|
|
|
--- Create a new LoginController
|
|
|
|
|
function LoginController.new()
|
2025-06-23 01:19:44 +08:00
|
|
|
setmetatable(M, { __index = IController })
|
|
|
|
|
local self = setmetatable({}, { __index = M })
|
|
|
|
|
self.baseType = LoginController
|
|
|
|
|
self.class = "Login"
|
|
|
|
|
return self
|
2025-05-24 14:29:14 +08:00
|
|
|
end
|
|
|
|
|
|
2025-06-23 01:19:44 +08:00
|
|
|
local _LocalConfigAllGame = {
|
|
|
|
|
10, 13, 14, 15, 16, 17, 22, 33, 65, 66, 67, 77, 88,
|
2025-05-24 14:29:14 +08:00
|
|
|
|
2025-06-23 01:19:44 +08:00
|
|
|
101, 102, 103, 104, 105, 106, 107,
|
|
|
|
|
108,
|
|
|
|
|
301, 201, 202, 203
|
2025-05-24 14:29:14 +08:00
|
|
|
}
|
|
|
|
|
|
2025-06-23 01:19:44 +08:00
|
|
|
local FilterGame = function(games)
|
|
|
|
|
local tempGames = {}
|
|
|
|
|
for k, v in pairs(games) do
|
|
|
|
|
if IsHasDictionary(v.game_id, _LocalConfigAllGame) then
|
|
|
|
|
table.insert(tempGames, v)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return tempGames
|
2025-05-24 14:29:14 +08:00
|
|
|
end
|
|
|
|
|
|
2025-06-23 01:19:44 +08:00
|
|
|
local function __Login(cmd, _data, callBack)
|
2025-05-24 14:29:14 +08:00
|
|
|
local _client = ControllerManager.WebClient
|
2025-06-23 01:19:44 +08:00
|
|
|
_client:send(cmd, _data, function(res)
|
2025-05-24 14:29:14 +08:00
|
|
|
printlog("1111111111111111222222222222222222222222")
|
|
|
|
|
--pt(cmd)
|
2025-06-23 01:19:44 +08:00
|
|
|
--pt(res)
|
2025-05-24 14:29:14 +08:00
|
|
|
if (res.ReturnCode == 0) then
|
2025-06-23 01:19:44 +08:00
|
|
|
local data = res.Data
|
|
|
|
|
local account = data["account"]
|
|
|
|
|
local user = DataManager.SelfUser
|
|
|
|
|
user.acc = account.acc
|
2025-05-24 14:29:14 +08:00
|
|
|
user.account_id = account["id"]
|
2025-06-23 01:19:44 +08:00
|
|
|
user.diamo = account["diamo"]
|
|
|
|
|
user.nick_name = account["nick"]
|
|
|
|
|
user.sex = account["sex"]
|
|
|
|
|
user.head_url = account["portrait"]
|
|
|
|
|
user.room_id = account["roomid"]
|
|
|
|
|
user.group_id = account["groupId"]
|
|
|
|
|
user.type = account["type"]
|
|
|
|
|
user.agent = account["mng"]
|
|
|
|
|
|
|
|
|
|
user.real_info = account.real_info
|
|
|
|
|
user.phone = account.phone
|
|
|
|
|
user.address = account.address
|
|
|
|
|
user.games = FilterGame(data.games)
|
|
|
|
|
if Application.platform == RuntimePlatform.WindowsPlayer or Application.platform == RuntimePlatform.WindowsEditor then
|
2025-05-24 14:29:14 +08:00
|
|
|
--GameApplication.Instance.printLog = true
|
|
|
|
|
else
|
|
|
|
|
--GameApplication.Instance.printLog = user.type == 2
|
|
|
|
|
end
|
2025-06-23 01:19:44 +08:00
|
|
|
|
|
|
|
|
_client:setSession(data["session_id"] .. "," .. data["token"])
|
2025-05-24 14:29:14 +08:00
|
|
|
print("11111111111111111111111111111111")
|
|
|
|
|
pt(data)
|
|
|
|
|
ControllerManager.GroupClient = NetClient.new(data.groupWeb, "web_group", ConnectionProtocol.Web)
|
2025-06-23 01:19:44 +08:00
|
|
|
ControllerManager.GroupClient:setSession((data["session_id"] .. "," .. data["token"]))
|
2025-05-24 14:29:14 +08:00
|
|
|
end
|
|
|
|
|
|
2025-06-23 01:19:44 +08:00
|
|
|
if (callBack ~= nil) then
|
2025-05-24 14:29:14 +08:00
|
|
|
callBack(res)
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--手机登录
|
2025-06-23 01:19:44 +08:00
|
|
|
function M:PhoneLogin(phone, code, callback)
|
2025-05-24 14:29:14 +08:00
|
|
|
local _data = {}
|
|
|
|
|
_data["phone"] = phone
|
|
|
|
|
_data["code"] = code
|
2025-06-23 01:19:44 +08:00
|
|
|
__Login(Protocol.WEB_PHONE_LOGIN, _data, callback)
|
2025-05-24 14:29:14 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--手机密码登录
|
2025-06-23 01:19:44 +08:00
|
|
|
function M:PhonePasswordLogin(phone, password, callback)
|
2025-05-24 14:29:14 +08:00
|
|
|
local _data = {}
|
|
|
|
|
_data["phone"] = phone
|
|
|
|
|
_data["password"] = password
|
2025-06-23 01:19:44 +08:00
|
|
|
__Login(Protocol.WEB_PHONE_PASSWORD_LOGIN, _data, callback)
|
2025-05-24 14:29:14 +08:00
|
|
|
end
|
|
|
|
|
|
2025-06-23 01:19:44 +08:00
|
|
|
function M:IdPasswordLogin(uid, password, callback)
|
2025-05-24 14:29:14 +08:00
|
|
|
local _data = {}
|
|
|
|
|
_data["id"] = tonumber(uid)
|
|
|
|
|
_data["password"] = password
|
2025-06-23 01:19:44 +08:00
|
|
|
__Login(Protocol.WEB_ID_PASSWORD_LOGIN, _data, callback)
|
2025-05-24 14:29:14 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:Login(callback)
|
|
|
|
|
local user = DataManager.SelfUser
|
|
|
|
|
local _data = {}
|
|
|
|
|
_data["acc"] = user.acc
|
|
|
|
|
_data["nick"] = user.nick_name
|
|
|
|
|
_data["sex"] = user.sex
|
|
|
|
|
_data["portrait"] = user.head_url
|
2025-06-23 01:19:44 +08:00
|
|
|
__Login(Protocol.WEB_USER_LOGIN, _data, callback)
|
2025-05-24 14:29:14 +08:00
|
|
|
end
|
|
|
|
|
|
2025-06-23 01:19:44 +08:00
|
|
|
function M:QuickLogin(session_id, callback)
|
2025-05-24 14:29:14 +08:00
|
|
|
local _data = {}
|
|
|
|
|
local _client = ControllerManager.WebClient
|
|
|
|
|
_client:setSession(session_id)
|
2025-06-23 01:19:44 +08:00
|
|
|
-- ControllerManager.GroupClient:setSession(session_id)
|
|
|
|
|
__Login(Protocol.WEB_QUICK_LOGIN, _data, callback)
|
2025-05-24 14:29:14 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M.OnEnter(self)
|
2025-06-23 01:19:44 +08:00
|
|
|
--print("login controller enter")
|
2025-05-24 14:29:14 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M.OnExit(self)
|
2025-06-23 01:19:44 +08:00
|
|
|
--print("login controller exit")
|
2025-05-24 14:29:14 +08:00
|
|
|
end
|