| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- --[[
- @module tsb_login_page
- @summary 调试宝登录页面
- @version 1.0
- @date 2026.03.04
- @author 李一玮
- @usage 本文件是调试宝登录页面,展示调试宝登录的各种用法。
- ]]
- local tsb_login_page = {}
- ----------------------------------------------------------------
- -- 页面UI元素
- ----------------------------------------------------------------
- local main_container = nil
- local scroll_container = nil
- local common_ui = require("tsb_common_page")
- ----------------------------------------------------------------
- -- 创建UI
- ----------------------------------------------------------------
- function tsb_login_page.create_ui()
- main_container = airui.container({
- parent = airui.screen,
- x = 0,
- y = 0,
- w = 480,
- h = 320,
- color = 0xFFFFFF,
- })
-
- -- 标题栏
- local title_bar = airui.container({
- parent = main_container,
- x = 0,
- y = 0,
- w = 480,
- h = 30,
- color = 0x007AFF,
- })
- common_ui.add_battery_display(title_bar)
- -- 滚动容器
- scroll_container = airui.container({
- parent = main_container,
- x = 0,
- y = 30,
- w = 480,
- h = 290,
- color = 0xFFFFFF,
- })
- common_ui.add_background_png(scroll_container)
- local welcome_msg = airui.label({
- parent = scroll_container,
- text = "欢迎登录调试宝55号",
- x = 170,
- y = 70,
- w = 180,
- h = 30,
- font_size = 16,
- color = 0x000000
- })
- -- 注册虚拟键盘,先创建再在 textarea 配置里复用
- local keyboard1 = airui.keyboard({
- x = 0,
- y = 0,
- w = 480,
- h = 160, -- x, y, 键盘默认打开ALIGN_BOTTOM_MID,位置从中下方开始计算
- mode = "numeric", -- 键盘模式,可选 "text"/"upper"/"lower"/"numeric"
- auto_hide = true, -- 自动隐藏键盘
- bg_color = 0xf1f1f1, -- 键盘背景颜色为灰色,可选,不设置则透明
- on_commit = function() -- 确认事件回调,只有在按下确认键时才会触发
- log.info("keyboard", "commit")
- end
- })
- local form_container = airui.container({
- parent = scroll_container,
- x = 135,
- y = 100,
- w = 220,
- h = 140,
- color = 0xFFFFFF,
- color_opacity = 0,
- })
- -- 账号输入
- airui.label({
- parent = form_container,
- text = "账号",
- x = 0,
- y = 7,
- w = 60,
- h = 30,
- font_size = 14,
- color = 0x6D7278
- })
- local name_input = airui.textarea({
- parent = form_container,
- x = 33,
- y = 0,
- w = 180,
- h = 30,
- text = "",
- placeholder = "请输入账号",
- max_len = 20,
- keyboard = keyboard1
- })
- -- 密码输入
- airui.label({
- parent = form_container,
- text = "密码",
- x = 0,
- y = 49,
- w = 60,
- h = 30,
- font_size = 14,
- color = 0x6D7278
- })
- local email_input = airui.textarea({
- parent = form_container,
- x = 33,
- y = 42,
- w = 180,
- h = 30,
- text = "",
- placeholder = "请输入密码",
- max_len = 50,
- keyboard = keyboard1
- })
- -- 登录按钮
- local submit_btn = airui.button({
- parent = form_container,
- x = 3,
- y = 90,
- w = 100,
- h = 35,
- text = "登录",
- stype = { bg_color = 0x2B6FF1,border_color = 0x2B6FF1, text_color = 0xFFFFFF, radius = 8 },
- on_click = function(self)
- local name = name_input:get_text()
- local email = email_input:get_text()
-
- _G.show_page("tsb_home_page")
- -- if name == "" or email == "" then
- -- local msg = airui.msgbox({
- -- text = "请填写完整信息",
- -- buttons = { "确定" },
- -- on_action = function(self, label)
- -- if label == "确定" then
- -- self:hide()
- -- end
- -- end
- -- })
- -- msg:show()
- -- else
- -- local msg = airui.msgbox({
- -- text = "登录成功!\n姓名: " .. name .. "\n邮箱: " .. email,
- -- buttons = { "确定" },
- -- on_action = function(self, label)
- -- if label == "确定" then
- -- self:hide()
- -- end
- -- end
- -- })
- -- msg:show()
- -- end
- end
- })
- local visitor_btn = airui.button({
- parent = form_container,
- x = 112,
- y = 90,
- w = 100,
- h = 35,
- text = "游客模式",
- on_click = function(self)
- log.info("button", "游客模式按钮被点击")
- _G.show_page("tsb_home_page", { visitor_mode = true })
- end
- })
- local basic_image = airui.image({
- parent = scroll_container,
- x = 11,
- y = 6,
- w = 120,
- h = 40,
- src = "/luadb/wbjw.png",
- zoom = 100,
- -- on_click = function(self)
- -- log.info("image", "基本图片被点击")
- -- local msg = airui.msgbox({
- -- text = "基本图片被点击",
- -- buttons = { "确定" },
- -- timeout = 1500,
- -- on_action = function(self, label)
- -- self:hide()
- -- end
- -- })
- -- msg:show()
- -- end
- })
- _G.current_tab = 0
- -- 底部信息栏
- common_ui.create_status_bar(main_container)
- end
- ----------------------------------------------------------------
- -- 初始化页面
- ----------------------------------------------------------------
- function tsb_login_page.init(params)
- tsb_login_page.create_ui()
- end
- ----------------------------------------------------------------
- -- 清理页面
- ----------------------------------------------------------------
- function tsb_login_page.cleanup()
- if main_container then
- main_container:destroy()
- main_container = nil
- scroll_container = nil
- --sys.timerStop(time1_id)
- end
- end
- return tsb_login_page
|