tsb_login_page.lua 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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 = 290,
  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. bg_color = 0xf1f1f1, -- 键盘背景颜色为灰色,可选,不设置则透明
  67. on_commit = function() -- 确认事件回调,只有在按下确认键时才会触发
  68. log.info("keyboard", "commit")
  69. end
  70. })
  71. local form_container = airui.container({
  72. parent = scroll_container,
  73. x = 135,
  74. y = 100,
  75. w = 220,
  76. h = 140,
  77. color = 0xFFFFFF,
  78. color_opacity = 0,
  79. })
  80. -- 账号输入
  81. airui.label({
  82. parent = form_container,
  83. text = "账号",
  84. x = 0,
  85. y = 7,
  86. w = 60,
  87. h = 30,
  88. font_size = 14,
  89. color = 0x6D7278
  90. })
  91. local name_input = airui.textarea({
  92. parent = form_container,
  93. x = 33,
  94. y = 0,
  95. w = 180,
  96. h = 30,
  97. text = "",
  98. placeholder = "请输入账号",
  99. max_len = 20,
  100. keyboard = keyboard1
  101. })
  102. -- 密码输入
  103. airui.label({
  104. parent = form_container,
  105. text = "密码",
  106. x = 0,
  107. y = 49,
  108. w = 60,
  109. h = 30,
  110. font_size = 14,
  111. color = 0x6D7278
  112. })
  113. local email_input = airui.textarea({
  114. parent = form_container,
  115. x = 33,
  116. y = 42,
  117. w = 180,
  118. h = 30,
  119. text = "",
  120. placeholder = "请输入密码",
  121. max_len = 50,
  122. keyboard = keyboard1
  123. })
  124. -- 登录按钮
  125. local submit_btn = airui.button({
  126. parent = form_container,
  127. x = 3,
  128. y = 90,
  129. w = 100,
  130. h = 35,
  131. text = "登录",
  132. stype = { bg_color = 0x2B6FF1,border_color = 0x2B6FF1, text_color = 0xFFFFFF, radius = 8 },
  133. on_click = function(self)
  134. local name = name_input:get_text()
  135. local email = email_input:get_text()
  136. _G.show_page("tsb_home_page")
  137. -- if name == "" or email == "" then
  138. -- local msg = airui.msgbox({
  139. -- text = "请填写完整信息",
  140. -- buttons = { "确定" },
  141. -- on_action = function(self, label)
  142. -- if label == "确定" then
  143. -- self:hide()
  144. -- end
  145. -- end
  146. -- })
  147. -- msg:show()
  148. -- else
  149. -- local msg = airui.msgbox({
  150. -- text = "登录成功!\n姓名: " .. name .. "\n邮箱: " .. email,
  151. -- buttons = { "确定" },
  152. -- on_action = function(self, label)
  153. -- if label == "确定" then
  154. -- self:hide()
  155. -- end
  156. -- end
  157. -- })
  158. -- msg:show()
  159. -- end
  160. end
  161. })
  162. local visitor_btn = airui.button({
  163. parent = form_container,
  164. x = 112,
  165. y = 90,
  166. w = 100,
  167. h = 35,
  168. text = "游客模式",
  169. on_click = function(self)
  170. log.info("button", "游客模式按钮被点击")
  171. _G.show_page("tsb_home_page", { visitor_mode = true })
  172. end
  173. })
  174. local basic_image = airui.image({
  175. parent = scroll_container,
  176. x = 11,
  177. y = 6,
  178. w = 120,
  179. h = 40,
  180. src = "/luadb/wbjw.png",
  181. zoom = 100,
  182. -- on_click = function(self)
  183. -- log.info("image", "基本图片被点击")
  184. -- local msg = airui.msgbox({
  185. -- text = "基本图片被点击",
  186. -- buttons = { "确定" },
  187. -- timeout = 1500,
  188. -- on_action = function(self, label)
  189. -- self:hide()
  190. -- end
  191. -- })
  192. -- msg:show()
  193. -- end
  194. })
  195. _G.current_tab = 0
  196. -- 底部信息栏
  197. common_ui.create_status_bar(main_container)
  198. end
  199. ----------------------------------------------------------------
  200. -- 初始化页面
  201. ----------------------------------------------------------------
  202. function tsb_login_page.init(params)
  203. tsb_login_page.create_ui()
  204. end
  205. ----------------------------------------------------------------
  206. -- 清理页面
  207. ----------------------------------------------------------------
  208. function tsb_login_page.cleanup()
  209. if main_container then
  210. main_container:destroy()
  211. main_container = nil
  212. scroll_container = nil
  213. --sys.timerStop(time1_id)
  214. end
  215. end
  216. return tsb_login_page