账号绑定
This commit is contained in:
parent
4a1fc3e0ab
commit
35a6bc5fa7
@ -788,4 +788,20 @@ function BIReport:postAccountDelete(loginType)
|
||||
self:report(EVENT_NAME_ACCOUNT_OPT, args)
|
||||
end
|
||||
|
||||
function BIReport:postAccountBindClick(loginType)
|
||||
local args = {
|
||||
login_type = loginType,
|
||||
event_type = BIReport.ACCOUNT_OPT_TYPE.BIND_CLICK,
|
||||
}
|
||||
self:report(EVENT_NAME_ACCOUNT_OPT, args)
|
||||
end
|
||||
|
||||
function BIReport:postAccountBindFinish(loginType)
|
||||
local args = {
|
||||
login_type = loginType,
|
||||
event_type = BIReport.ACCOUNT_OPT_TYPE.BIND_FINISH,
|
||||
}
|
||||
self:report(EVENT_NAME_ACCOUNT_OPT, args)
|
||||
end
|
||||
|
||||
return BIReport
|
||||
@ -33,6 +33,7 @@ EventManager.CUSTOM_EVENT = {
|
||||
GO_CHAPTER = "GO_CHAPTER", -- 跳转主线章节
|
||||
CLOSE_BOX_HERO_UI = "CLOSE_BOX_HERO_UI",
|
||||
CLOSE_BOX_OPEN_UI = "CLOSE_BOX_OPEN_UI",
|
||||
BIND_ACCOUNT_SUCCESS = "BIND_ACCOUNT_SUCCESS",
|
||||
-- BORAD_TOUCH_BEGIN = "BORAD_TOUCH_BEGIN",
|
||||
-- BORAD_TOUCH_OVER = "BORAD_TOUCH_OVER"
|
||||
}
|
||||
|
||||
@ -370,7 +370,6 @@ function SDKManager:login(callback, loginType)
|
||||
Logger.log("三方当前正在登陆中")
|
||||
return
|
||||
end
|
||||
|
||||
self.isLogining = true
|
||||
self:_login(function(code, msg)
|
||||
if code == SDKManager.BF_LOGIN_RESULT.Success then
|
||||
@ -388,7 +387,6 @@ function SDKManager:login(callback, loginType)
|
||||
self.isLogining = false
|
||||
return
|
||||
end
|
||||
|
||||
local userId = loginResult.UserId
|
||||
local token = loginResult.Token
|
||||
local params = {}
|
||||
@ -430,12 +428,9 @@ function SDKManager:logout(callback, loginType)
|
||||
Logger.log("当前正在登出中")
|
||||
return
|
||||
end
|
||||
|
||||
self.isLogouting = true
|
||||
|
||||
|
||||
self:_logout(function(code, msg)
|
||||
if (code == SDKManager.BF_LOGIN_RESULT.Success) then
|
||||
if code == SDKManager.BF_LOGIN_RESULT.Success then
|
||||
if callback then
|
||||
callback()
|
||||
end
|
||||
@ -443,9 +438,7 @@ function SDKManager:logout(callback, loginType)
|
||||
if msg and msg ~= "" then
|
||||
local jData = json.decode(msg)
|
||||
if jData then
|
||||
local type = jData.loginType
|
||||
local msg = jData.msg
|
||||
Logger.logError("登出失败 result:%s type:%s msg:%s", code, type, msg)
|
||||
Logger.logError("登出失败 result:%s type:%s msg:%s", code, jData.loginType, jData.msg)
|
||||
else
|
||||
Logger.logError("登出失败 result:%s", code)
|
||||
end
|
||||
|
||||
@ -11,6 +11,17 @@ function AccountManager:showDeleteUI()
|
||||
return UIManager:showUI("app/ui/game_setting/account_delete_ui")
|
||||
end
|
||||
|
||||
function AccountManager:getIsBinded()
|
||||
local accountInfo = LocalData:getAccountInfo()
|
||||
if accountInfo.google_id and accountInfo.google_id ~= "" then
|
||||
return true
|
||||
end
|
||||
if accountInfo.apple_id and accountInfo.apple_id ~= "" then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function AccountManager:deleteAccount()
|
||||
self:sendMessage(ProtoMsgType.FromMsgEnum.DeleteReq, {}, {}, self.onDeleteAccount, BIReport.ITEM_GET_TYPE.NONE)
|
||||
end
|
||||
@ -25,4 +36,50 @@ function AccountManager:onDeleteAccount(result)
|
||||
end
|
||||
end
|
||||
|
||||
function AccountManager:bindAccount()
|
||||
local loginType = SDKManager.BF_LOGIN_TYPE.GOOGLE
|
||||
if Platform:isIosPlatform() then
|
||||
loginType = SDKManager.BF_LOGIN_TYPE.APPLE
|
||||
end
|
||||
|
||||
BIReport:postAccountBindClick(loginType)
|
||||
SDKManager:login(function(params)
|
||||
if not params.token then
|
||||
return
|
||||
end
|
||||
local args = {
|
||||
type = SDKManager.LOGIN_TYPE[loginType],
|
||||
id = params.id,
|
||||
token = params.token
|
||||
}
|
||||
self:sendMessage(ProtoMsgType.FromMsgEnum.BindReq, args, {}, self.onBindAccount, BIReport.ITEM_GET_TYPE.NONE)
|
||||
end, loginType)
|
||||
end
|
||||
|
||||
function AccountManager:onBindAccount(result)
|
||||
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
||||
local accountInfo = LocalData:getAccountInfo()
|
||||
local loginType = SDKManager.BF_LOGIN_TYPE.GOOGLE
|
||||
if Platform:isIosPlatform() then
|
||||
loginType = SDKManager.BF_LOGIN_TYPE.APPLE
|
||||
accountInfo.apple_id = result.reqData.id
|
||||
else
|
||||
accountInfo.googld_id = result.reqData.id
|
||||
end
|
||||
LocalData:setLastLoginInfo(loginType, result.reqData.id, result.reqData.token)
|
||||
LocalData:setAccountInfo(accountInfo)
|
||||
LocalData:save()
|
||||
|
||||
BIReport:postAccountBindFinish(loginType)
|
||||
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.BIND_ACCOUNT_SUCCESS))
|
||||
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.BIND_ACCOUNT_SUCCESS)
|
||||
else -- 一些失败的提示
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
function AccountManager:changeAccount()
|
||||
|
||||
end
|
||||
|
||||
return AccountManager
|
||||
@ -18,7 +18,9 @@ function GameSettingUI:onLoadRootComplete()
|
||||
self.uiMap = self.root:genAllChildren()
|
||||
self:_display()
|
||||
self:_addListeners()
|
||||
self:_bind()
|
||||
self:addEventListener(EventManager.CUSTOM_EVENT.BIND_ACCOUNT_SUCCESS, function()
|
||||
self:refreshAccountInfo()
|
||||
end)
|
||||
end
|
||||
|
||||
function GameSettingUI:onPressBackspace()
|
||||
@ -46,16 +48,27 @@ end
|
||||
|
||||
function GameSettingUI:initLoginBtn()
|
||||
self.uiMap["game_setting_ui.bg.google_sign_btn"]:addClickListener(function()
|
||||
|
||||
end)
|
||||
if DataManager.PlayerData:getIsBinded() then
|
||||
self.uiMap["game_setting_ui.bg.google_sign_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACCOUNT_ALREADY_BINDED_DESC))
|
||||
else
|
||||
self.uiMap["game_setting_ui.bg.google_sign_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.BIND_ACCOUNT_DESC))
|
||||
if ModuleManager.AccountManager:getIsBinded() then
|
||||
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.ACCOUNT_ALREADY_BINDED_DESC))
|
||||
return
|
||||
end
|
||||
ModuleManager.AccountManager:bindAccount()
|
||||
end)
|
||||
|
||||
self.uiMap["game_setting_ui.bg.google_switch_btn"]:addClickListener(function()
|
||||
|
||||
if ModuleManager.AccountManager:getIsBinded() then
|
||||
ModuleManager.AccountManager:changeAccount()
|
||||
else
|
||||
local params = {
|
||||
content = I18N:getGlobalText(I18N.GlobalConst.CHANGE_ACCOUNT_TIPS_DESC),
|
||||
boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL,
|
||||
okText = I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_OK),
|
||||
okFunc = function()
|
||||
ModuleManager.AccountManager:changeAccount()
|
||||
end
|
||||
}
|
||||
GFunc.showMessageBox(params)
|
||||
end
|
||||
end)
|
||||
self.uiMap["game_setting_ui.bg.google_switch_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.CHANGE_ACCOUNT_DESC))
|
||||
|
||||
@ -64,6 +77,7 @@ function GameSettingUI:initLoginBtn()
|
||||
deleteTx:addClickListener(function()
|
||||
ModuleManager.AccountManager:showDeleteUI()
|
||||
end)
|
||||
self:refreshAccountInfo()
|
||||
end
|
||||
|
||||
function GameSettingUI:_addListeners()
|
||||
@ -117,9 +131,6 @@ function GameSettingUI:_addListeners()
|
||||
end)
|
||||
end
|
||||
|
||||
function GameSettingUI:_bind()
|
||||
end
|
||||
|
||||
function GameSettingUI:refreshMusic()
|
||||
local offIcon = self.uiMap["game_setting_ui.bg.music_bg.off"]
|
||||
local onIcon = self.uiMap["game_setting_ui.bg.music_bg.on"]
|
||||
@ -138,4 +149,12 @@ function GameSettingUI:refreshVoice()
|
||||
onIcon:setVisible(status == true)
|
||||
end
|
||||
|
||||
function GameSettingUI:refreshAccountInfo()
|
||||
if ModuleManager.AccountManager:getIsBinded() then
|
||||
self.uiMap["game_setting_ui.bg.google_sign_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACCOUNT_ALREADY_BINDED_DESC))
|
||||
else
|
||||
self.uiMap["game_setting_ui.bg.google_sign_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.BIND_ACCOUNT_DESC))
|
||||
end
|
||||
end
|
||||
|
||||
return GameSettingUI
|
||||
@ -121,10 +121,6 @@ function PlayerData:getAcountId()
|
||||
return self:getAccountInfo().id or GConst.EMPTY_STRING
|
||||
end
|
||||
|
||||
function PlayerData:getIsBinded()
|
||||
return false
|
||||
end
|
||||
|
||||
function PlayerData:addVitGemBuyCount()
|
||||
self.data.vitGemCount = self.data.vitGemCount + 1
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user