账号相关
This commit is contained in:
parent
74a9205f30
commit
304ed48943
@ -223,6 +223,11 @@ function LocalData:getLastLoginInfo()
|
||||
local str = self:getString(LOCAL_DATA_KEY.LAST_LOGIN_INFO, "{}")
|
||||
local info = json.decode(str)
|
||||
info.type = info.type or NetManager.LOGIN_TYPE.ANONYMOUS
|
||||
if type(info.type) == "number" then
|
||||
if info.type == SDKManager.BF_LOGIN_TYPE.GOOGLE then
|
||||
info.type = NetManager.LOGIN_TYPE.GOOGLE
|
||||
end
|
||||
end
|
||||
info.id = info.id or DeviceHelper:getDeviceId()
|
||||
info.token = info.token
|
||||
return info
|
||||
|
||||
@ -35,11 +35,13 @@ end
|
||||
|
||||
function AccountManager:bindAccount()
|
||||
local loginType = SDKManager.BF_LOGIN_TYPE.GOOGLE
|
||||
local loginTypeStr = NetManager.LOGIN_TYPE.GOOGLE
|
||||
if Platform:isIosPlatform() then
|
||||
loginType = SDKManager.BF_LOGIN_TYPE.APPLE
|
||||
loginTypeStr = NetManager.LOGIN_TYPE.APPLE
|
||||
end
|
||||
|
||||
BIReport:postAccountBindClick(loginType)
|
||||
BIReport:postAccountBindClick(loginTypeStr)
|
||||
SDKManager:login(function(params)
|
||||
if not params.token then
|
||||
return
|
||||
@ -57,18 +59,19 @@ function AccountManager:onBindAccount(result)
|
||||
if result.status == 0 then
|
||||
local accountInfo = LocalData:getAccountInfo()
|
||||
local loginType = SDKManager.BF_LOGIN_TYPE.GOOGLE
|
||||
local loginTypeStr = NetManager.LOGIN_TYPE.GOOGLE
|
||||
if Platform:isIosPlatform() then
|
||||
loginType = SDKManager.BF_LOGIN_TYPE.APPLE
|
||||
loginTypeStr = NetManager.LOGIN_TYPE.APPLE
|
||||
accountInfo.apple_id = result.reqData.id
|
||||
LocalData:setLastLoginInfo(NetManager.LOGIN_TYPE.APPLE, result.reqData.id)
|
||||
else
|
||||
accountInfo.google_id = result.reqData.id
|
||||
LocalData:setLastLoginInfo(NetManager.LOGIN_TYPE.GOOGLE, result.reqData.id)
|
||||
end
|
||||
LocalData:setLastLoginInfo(loginTypeStr, result.reqData.id)
|
||||
LocalData:setAccountInfo(accountInfo)
|
||||
LocalData:save()
|
||||
|
||||
BIReport:postAccountBindFinish(loginType, true)
|
||||
BIReport:postAccountBindFinish(loginTypeStr, true)
|
||||
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.BIND_ACCOUNT_SUCCESS))
|
||||
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.BIND_ACCOUNT_SUCCESS)
|
||||
else
|
||||
@ -82,21 +85,23 @@ function AccountManager:onBindAccount(result)
|
||||
params.content = I18N:getGlobalText(I18N.GlobalConst.BIND_ACCOUNT_FAILED)
|
||||
end
|
||||
GFunc.showMessageBox(params)
|
||||
local loginType = SDKManager.BF_LOGIN_TYPE.GOOGLE
|
||||
local loginTypeStr = NetManager.LOGIN_TYPE.GOOGLE
|
||||
if Platform:isIosPlatform() then
|
||||
loginType = SDKManager.BF_LOGIN_TYPE.APPLE
|
||||
loginTypeStr = NetManager.LOGIN_TYPE.APPLE
|
||||
end
|
||||
BIReport:postAccountBindFinish(loginType, false)
|
||||
BIReport:postAccountBindFinish(loginTypeStr, false)
|
||||
end
|
||||
end
|
||||
|
||||
function AccountManager:changeAccount()
|
||||
local loginType = SDKManager.BF_LOGIN_TYPE.GOOGLE
|
||||
local loginTypeStr = NetManager.LOGIN_TYPE.GOOGLE
|
||||
if Platform:isIosPlatform() then
|
||||
loginType = SDKManager.BF_LOGIN_TYPE.APPLE
|
||||
loginTypeStr = NetManager.LOGIN_TYPE.APPLE
|
||||
end
|
||||
|
||||
BIReport:postAccountChangeClick(loginType)
|
||||
BIReport:postAccountChangeClick(loginTypeStr)
|
||||
SDKManager:login(function(params)
|
||||
if not params.token then
|
||||
return
|
||||
@ -130,17 +135,18 @@ function AccountManager:onChangeAccount(result)
|
||||
if result.status == 0 then
|
||||
local accountInfo = LocalData:getAccountInfo()
|
||||
local loginType = SDKManager.BF_LOGIN_TYPE.GOOGLE
|
||||
local loginTypeStr = NetManager.LOGIN_TYPE.GOOGLE
|
||||
if Platform:isIosPlatform() then
|
||||
loginType = SDKManager.BF_LOGIN_TYPE.APPLE
|
||||
loginTypeStr = NetManager.LOGIN_TYPE.APPLE
|
||||
accountInfo.apple_id = result.reqData.id
|
||||
LocalData:setLastLoginInfo(NetManager.LOGIN_TYPE.APPLE, result.reqData.id)
|
||||
else
|
||||
accountInfo.google_id = result.reqData.id
|
||||
LocalData:setLastLoginInfo(NetManager.LOGIN_TYPE.GOOGLE, result.reqData.id)
|
||||
end
|
||||
LocalData:setLastLoginInfo(loginTypeStr, result.reqData.id)
|
||||
LocalData:setAccountInfo(accountInfo)
|
||||
LocalData:save()
|
||||
BIReport:postAccountChangeFinish(loginType, true)
|
||||
BIReport:postAccountChangeFinish(loginTypeStr, true)
|
||||
ModuleManager.LoginManager:goToLoginScene()
|
||||
else
|
||||
local params = {
|
||||
@ -153,11 +159,11 @@ function AccountManager:onChangeAccount(result)
|
||||
params.content = I18N:getGlobalText(I18N.GlobalConst.CHANGE_ACCOUNT_FAILED)
|
||||
end
|
||||
GFunc.showMessageBox(params)
|
||||
local loginType = SDKManager.BF_LOGIN_TYPE.GOOGLE
|
||||
local loginTypeStr = NetManager.LOGIN_TYPE.GOOGLE
|
||||
if Platform:isIosPlatform() then
|
||||
loginType = SDKManager.BF_LOGIN_TYPE.APPLE
|
||||
loginTypeStr = NetManager.LOGIN_TYPE.APPLE
|
||||
end
|
||||
BIReport:postAccountChangeFinish(loginType, false)
|
||||
BIReport:postAccountChangeFinish(loginTypeStr, false)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user