LoginController = {} local M = {} --- Create a new LoginController function LoginController.new() setmetatable(M, { __index = IController }) local self = setmetatable({}, { __index = M }) self.baseType = LoginController self.class = "Login" return self end local _LocalConfigAllGame = { 10, 13, 14, 15, 16, 17, 22, 33, 65, 66, 67, 77, 88, 101, 102, 103, 104, 105, 106, 107, 108, 301, 201, 202, 203 } 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 end local function __Login(cmd, _data, callBack) if not UnityEngine.SystemInfo.deviceUniqueIdentifier or #UnityEngine.SystemInfo.deviceUniqueIdentifier < 6 then ViewUtil.CloseModalWait() ViewUtil.ErrorMsg(nil, "", "找不到您的设备信息,若无法登录请联系客服人员解决") return end local _client = ControllerManager.WebClient _client:send(cmd, _data, function(res) if (res.ReturnCode == 0) then local data = res.Data local account = data["account"] local user = DataManager.SelfUser user.acc = account.acc user.account_id = account["id"] 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.bind_pwd = data["havePassword"] --默认设置为false,false为进入强制输入密码 -- user.bind_pwd = false 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 --GameApplication.Instance.printLog = true else --GameApplication.Instance.printLog = user.type == 2 end _client:setSession(data["session_id"] .. "," .. data["token"]) ControllerManager.GroupClient = NetClient.new(data.groupWeb, "web_group", ConnectionProtocol.Web) ControllerManager.GroupClient:setSession((data["session_id"] .. "," .. data["token"])) end if (callBack ~= nil) then callBack(res) end end) end local function __getCode(cmd, _data, callBack) local _client = ControllerManager.WebClient _client:send(Protocol.WEB_GET_CODE, { id = _data.id }, function(res) if (res.ReturnCode == 0) then _data["uuidCode"] = res.Data.code __Login(cmd, _data, callBack) end end) end --手机登录 function M:PhoneLogin(phone, code, callback) local _data = {} _data["phone"] = phone _data["code"] = code __Login(Protocol.WEB_PHONE_LOGIN, _data, callback) end --手机密码登录 function M:PhonePasswordLogin(phone, password, callback) local _data = {} _data["phone"] = phone _data["password"] = password __Login(Protocol.WEB_PHONE_PASSWORD_LOGIN, _data, callback) end function M:IdPasswordLogin(uid, password, callback) local _data = {} local result, resultInfo = pcall(function(...) _data.data = RSAHelper.Encrypt(json.encode({ id = tonumber(uid), password = password, deviceCode = UnityEngine.SystemInfo.deviceUniqueIdentifier })) end) if result then __getCode(Protocol.WEB_ID_PASSWORD_LOGIN_2, _data, callback) else ViewUtil.CloseModalWait() ViewUtil.ErrorMsg(nil, "", "您的个人信息太长,若无法登录请联系客服人员解决") end end function M:IdPasswordLogin2(uid, password, callback) local _data = {} _data["id"] = tonumber(uid) _data["password"] = password _data["deviceCode"] = UnityEngine.SystemInfo.deviceUniqueIdentifier __getCode(Protocol.WEB_ID_PASSWORD_LOGIN, _data, callback) end function M:Login2(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 _data["deviceCode"] = UnityEngine.SystemInfo.deviceUniqueIdentifier __Login(Protocol.WEB_USER_LOGIN, _data, callback) end function M:Login(callback) local user = DataManager.SelfUser local _data = {} local result = pcall(function(...) _data.data = RSAHelper.Encrypt(json.encode({ acc = user.acc, nick = user.nick_name, sex = user.sex, portrait = user .head_url, deviceCode = UnityEngine.SystemInfo.deviceUniqueIdentifier })) end) if result then __Login(Protocol.WEB_USER_LOGIN_2, _data, callback) else ViewUtil.CloseModalWait() ViewUtil.ErrorMsg(nil, "", "您的个人信息太长,若无法登录请联系客服人员解决") end end function M:QuickLogin(session_id, callback) local _data = {} _data.data = RSAHelper.Encrypt(json.encode({ quick = 1, deviceCode = UnityEngine.SystemInfo.deviceUniqueIdentifier })) local _client = ControllerManager.WebClient _client:setSession(session_id) __Login(Protocol.WEB_QUICK_LOGIN_2, _data, callback) end --快速登入加密 function M:QuickLogin2(session_id, callback) local _data = {} _data["deviceCode"] = UnityEngine.SystemInfo.deviceUniqueIdentifier local _client = ControllerManager.WebClient _client:setSession(session_id) -- ControllerManager.GroupClient:setSession(session_id) __Login(Protocol.WEB_QUICK_LOGIN, _data, callback) end function M.OnEnter(self) --print("login controller enter") end function M.OnExit(self) --print("login controller exit") end