c1_lua/lua/app/ui/game_setting/account_binding_ui.lua
2025-08-08 17:13:56 +08:00

67 lines
2.8 KiB
Lua

local AccountBindUI = class("AccountBindUI", BaseUI)
function AccountBindUI:isFullScreen()
return false
end
function AccountBindUI:getPrefabPath()
return "assets/prefabs/ui/setting/account_bind_ui.prefab"
end
function AccountBindUI:onLoadRootComplete()
self.uiMap = self.root:genAllChildren()
self.uiMap["account_bind_ui.title_bg_img.title_text"]:setText(I18N:getGlobalText(I18N.GlobalConst.MESSAGE_BOX_TITLE))
self.uiMap["account_bind_ui.title_bg_img.bg.content_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.BIND_TIPS_DESC))
self:initBindBtn()
self.uiMap["account_bind_ui.title_bg_img.close_btn"]:addClickListener(function()
self:closeUI()
end)
self:addEventListener(EventManager.CUSTOM_EVENT.BIND_ACCOUNT_SUCCESS, function()
self:refreshAccountInfo()
end)
self:refreshAccountInfo()
end
function AccountBindUI:initBindBtn()
if Platform:isIosPlatform() then
self.uiMap["account_bind_ui.title_bg_img.apple_sign_btn"]:setVisible(true)
self.uiMap["account_bind_ui.title_bg_img.google_sign_btn"]:setVisible(false)
self.uiMap["account_bind_ui.title_bg_img.apple_sign_btn"]:addClickListener(function()
if ModuleManager.AccountManager:getIsBinded() then
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.ACCOUNT_ALREADY_BINDED_DESC))
return
end
ModuleManager.AccountManager:bindAccount()
end)
else
self.uiMap["account_bind_ui.title_bg_img.apple_sign_btn"]:setVisible(false)
self.uiMap["account_bind_ui.title_bg_img.google_sign_btn"]:setVisible(true)
self.uiMap["account_bind_ui.title_bg_img.google_sign_btn"]:addClickListener(function()
if ModuleManager.AccountManager:getIsBinded() then
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.ACCOUNT_ALREADY_BINDED_DESC))
return
end
ModuleManager.AccountManager:bindAccount()
end)
end
end
function AccountBindUI:refreshAccountInfo()
if Platform:isIosPlatform() then
if ModuleManager.AccountManager:getIsBinded() then
self.uiMap["account_bind_ui.title_bg_img.apple_sign_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACCOUNT_ALREADY_BINDED_DESC))
else
self.uiMap["account_bind_ui.title_bg_img.apple_sign_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.BIND_ACCOUNT_DESC))
end
else
if ModuleManager.AccountManager:getIsBinded() then
self.uiMap["account_bind_ui.title_bg_img.google_sign_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACCOUNT_ALREADY_BINDED_DESC))
else
self.uiMap["account_bind_ui.title_bg_img.google_sign_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.BIND_ACCOUNT_DESC))
end
end
end
return AccountBindUI