tsb_login_page.lua 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. --[[
  2. @module tsb_login_page
  3. @summary 调试宝登录页面
  4. @version 1.0
  5. @date 2026.03.04
  6. @author 李一玮
  7. @usage 本文件是调试宝登录页面,展示调试宝登录的各种用法。
  8. ]]
  9. local tsb_login_page = {}
  10. ----------------------------------------------------------------
  11. -- 页面UI元素
  12. ----------------------------------------------------------------
  13. local main_container = nil
  14. local scroll_container = nil
  15. local common_ui = require("tsb_common_page")
  16. ----------------------------------------------------------------
  17. -- 创建UI
  18. ----------------------------------------------------------------
  19. function tsb_login_page.create_ui()
  20. main_container = airui.container({
  21. parent = airui.screen,
  22. x = 0,
  23. y = 0,
  24. w = 480,
  25. h = 320,
  26. color = 0xFFFFFF,
  27. })
  28. -- 标题栏
  29. local title_bar = airui.container({
  30. parent = main_container,
  31. x = 0,
  32. y = 0,
  33. w = 480,
  34. h = 30,
  35. color = 0x007AFF,
  36. })
  37. common_ui.add_battery_display(title_bar)
  38. -- 滚动容器
  39. scroll_container = airui.container({
  40. parent = main_container,
  41. x = 0,
  42. y = 30,
  43. w = 480,
  44. h = 270,
  45. color = 0xFFFFFF,
  46. })
  47. common_ui.add_background_png(scroll_container)
  48. local welcome_msg = airui.label({
  49. parent = scroll_container,
  50. text = "欢迎登录调试宝55号",
  51. x = 170,
  52. y = 70,
  53. w = 180,
  54. h = 30,
  55. font_size = 16,
  56. color = 0x000000
  57. })
  58. -- 注册虚拟键盘,先创建再在 textarea 配置里复用
  59. local keyboard1 = airui.keyboard({
  60. x = 0,
  61. y = 0,
  62. w = 480,
  63. h = 160, -- x, y, 键盘默认打开ALIGN_BOTTOM_MID,位置从中下方开始计算
  64. mode = "numeric", -- 键盘模式,可选 "text"/"upper"/"lower"/"numeric"
  65. auto_hide = true, -- 自动隐藏键盘
  66. preview = true,
  67. preview_height = 35,
  68. bg_color = 0xf1f1f1, -- 键盘背景颜色为灰色,可选,不设置则透明
  69. on_commit = function() -- 确认事件回调,只有在按下确认键时才会触发
  70. log.info("keyboard", "commit")
  71. end
  72. })
  73. local form_container = airui.container({
  74. parent = scroll_container,
  75. x = 135,
  76. y = 100,
  77. w = 220,
  78. h = 140,
  79. color = 0xFFFFFF,
  80. color_opacity = 0,
  81. })
  82. -- 账号输入
  83. airui.label({
  84. parent = form_container,
  85. text = "账号",
  86. x = 0,
  87. y = 7,
  88. w = 60,
  89. h = 30,
  90. font_size = 14,
  91. color = 0x6D7278
  92. })
  93. local name_input = airui.textarea({
  94. parent = form_container,
  95. x = 33,
  96. y = 0,
  97. w = 180,
  98. h = 30,
  99. text = "",
  100. placeholder = "请输入账号",
  101. max_len = 20,
  102. keyboard = keyboard1
  103. })
  104. -- 密码输入
  105. airui.label({
  106. parent = form_container,
  107. text = "密码",
  108. x = 0,
  109. y = 49,
  110. w = 60,
  111. h = 30,
  112. font_size = 14,
  113. color = 0x6D7278
  114. })
  115. local email_input = airui.textarea({
  116. parent = form_container,
  117. x = 33,
  118. y = 42,
  119. w = 180,
  120. h = 30,
  121. text = "",
  122. placeholder = "请输入密码",
  123. max_len = 50,
  124. keyboard = keyboard1
  125. })
  126. -- 登录按钮
  127. local submit_btn = airui.button({
  128. parent = form_container,
  129. x = 3,
  130. y = 90,
  131. w = 100,
  132. h = 35,
  133. text = "登录",
  134. style = { bg_color = 0x2B6FF1,border_color = 0x2B6FF1, text_color = 0xFFFFFF, radius = 8 },
  135. on_click = function(self)
  136. local name = name_input:get_text()
  137. local email = email_input:get_text()
  138. _G.show_page("tsb_home_page")
  139. -- if name == "" or email == "" then
  140. -- local msg = airui.msgbox({
  141. -- text = "请填写完整信息",
  142. -- buttons = { "确定" },
  143. -- on_action = function(self, label)
  144. -- if label == "确定" then
  145. -- self:hide()
  146. -- end
  147. -- end
  148. -- })
  149. -- msg:show()
  150. -- else
  151. -- local msg = airui.msgbox({
  152. -- text = "登录成功!\n姓名: " .. name .. "\n邮箱: " .. email,
  153. -- buttons = { "确定" },
  154. -- on_action = function(self, label)
  155. -- if label == "确定" then
  156. -- self:hide()
  157. -- end
  158. -- end
  159. -- })
  160. -- msg:show()
  161. -- end
  162. end
  163. })
  164. local visitor_btn = airui.button({
  165. parent = form_container,
  166. x = 112,
  167. y = 90,
  168. w = 100,
  169. h = 35,
  170. text = "游客模式",
  171. on_click = function(self)
  172. log.info("button", "游客模式按钮被点击")
  173. _G.show_page("tsb_home_page", { visitor_mode = true })
  174. end
  175. })
  176. local basic_image = airui.image({
  177. parent = scroll_container,
  178. x = 11,
  179. y = 6,
  180. w = 120,
  181. h = 40,
  182. src = "/luadb/wbjw.png",
  183. zoom = 100,
  184. -- on_click = function(self)
  185. -- log.info("image", "基本图片被点击")
  186. -- local msg = airui.msgbox({
  187. -- text = "基本图片被点击",
  188. -- buttons = { "确定" },
  189. -- timeout = 1500,
  190. -- on_action = function(self, label)
  191. -- self:hide()
  192. -- end
  193. -- })
  194. -- msg:show()
  195. -- end
  196. })
  197. _G.current_tab = 0
  198. -- 底部信息栏
  199. common_ui.create_status_bar(main_container)
  200. end
  201. ----------------------------------------------------------------
  202. -- 初始化页面
  203. ----------------------------------------------------------------
  204. function tsb_login_page.init(params)
  205. tsb_login_page.create_ui()
  206. end
  207. ----------------------------------------------------------------
  208. -- 清理页面
  209. ----------------------------------------------------------------
  210. function tsb_login_page.cleanup()
  211. if main_container then
  212. main_container:destroy()
  213. main_container = nil
  214. scroll_container = nil
  215. --sys.timerStop(time1_id)
  216. end
  217. end
  218. return tsb_login_page