c1_lua/lua/app/ui/game_setting/cdkey_ui.lua
2023-06-13 20:53:53 +08:00

59 lines
2.0 KiB
Lua

local CdkeyUI = class("CdkeyUI", BaseUI)
function CdkeyUI:getPrefabPath()
return "assets/prefabs/ui/setting/cdkey_ui.prefab"
end
function CdkeyUI:isFullScreen()
return false
end
function CdkeyUI:onLoadRootComplete()
local uiMap = self.root:genAllChildren()
uiMap["cdkey_ui.title_bg_img.title_text"]:setText("临时文本:兑换码")
uiMap["cdkey_ui.title_bg_img.close_btn"]:addClickListener(function()
self:closeUI()
end)
uiMap["cdkey_ui.title_bg_img.cancel_btn.text"]:setText(I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_CANCEL))
uiMap["cdkey_ui.title_bg_img.cancel_btn"]:addClickListener(function()
self:closeUI()
end)
uiMap["cdkey_ui.title_bg_img.confirm_btn.text"]:setText(I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_OK))
uiMap["cdkey_ui.title_bg_img.confirm_btn"]:addClickListener(function()
local text = self.inputField:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TMP_INPUT_FIELD).text
if not text or text == "" then
GFunc.showToast("临时文本:请输入兑换码")
return
end
end)
uiMap["cdkey_ui.title_bg_img.desc_1"]:setText("临时文本:每个兑换码仅能使用一次")
self.desc2 = uiMap["cdkey_ui.title_bg_img.desc_2"]
self.desc2:setText(GConst.EMPTY_STRING)
local placeholder = uiMap["cdkey_ui.title_bg_img.input_field.text_area.placeholder"]
placeholder:setText("临时文本:请输入兑换码")
self.inputField = uiMap["cdkey_ui.title_bg_img.input_field"]
self.inputField:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TMP_INPUT_FIELD).text = ""
-- self:addEventListener(EventManager.CUSTOM_EVENT.CDKEY_FINISH, function(code)
-- if not code or code == 0 then
-- self.inputField:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TMP_INPUT_FIELD).text = ""
-- -- GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.SETTING_CDKEY_DESC_3))
-- end
-- self:updateErrorCode(code or 0)
-- end)
end
function CdkeyUI:updateErrorCode(errorCode)
if errorCode == 0 then
self.desc2:setText(GConst.EMPTY_STRING)
else
-- self.desc2:setText(I18N:getGlobalText(I18N.GlobalConst["ERROR_CODE_" .. errorCode]))
end
end
return CdkeyUI