From b924656abdd116b61298fa5c69104b11f4e3df35 Mon Sep 17 00:00:00 2001 From: Particle_G Date: Tue, 24 Nov 2020 02:34:46 +0800 Subject: [PATCH] change "username" textbox in login scene to "email" textbox --- parts/language/lang_zh.lua | 2 +- parts/scenes/login.lua | 10 +++++----- parts/tick.lua | 3 +-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/parts/language/lang_zh.lua b/parts/language/lang_zh.lua index 10997e9a..1f96a9d8 100644 --- a/parts/language/lang_zh.lua +++ b/parts/language/lang_zh.lua @@ -492,7 +492,7 @@ return{ login={ title="登录", register="注册", - username="用户名", + email="邮箱", password="密码", }, register={ diff --git a/parts/scenes/login.lua b/parts/scenes/login.lua index 903cd8a1..a789c88e 100644 --- a/parts/scenes/login.lua +++ b/parts/scenes/login.lua @@ -1,14 +1,14 @@ function keyDown.login(key) if key=="return"then - local username= WIDGET.active.username.value + local email= WIDGET.active.email.value local password= WIDGET.active.password.value - if #username==0 then - LOG.print(text.noUsername)return + if #email==0 or not email:match("^[a-zA-Z0-9_]+@[a-zA-Z0-9_-]+%.[a-zA-Z0-9_]+$") then + LOG.print(text.wrongEmail)return elseif #password==0 then LOG.print(text.noPassword)return end local success,data=json.encode({ - username=username, + email=email, password=password, }) if not success then @@ -32,7 +32,7 @@ end WIDGET.init("login",{ WIDGET.newText{name="title", x=80, y=50,font=70,align="L"}, WIDGET.newButton{name="register", x=1140, y=100,w=170,h=80,color="green",code=function()SCN.swapTo("register","swipeR")end}, - WIDGET.newTextBox{name="username", x=380, y=200,w=500,h=60,regex="[0-9A-Za-z_]"}, + WIDGET.newTextBox{name="email", x=380, y=200,w=500,h=60,regex="[0-9A-Za-z@._-]"}, WIDGET.newTextBox{name="password", x=380, y=300,w=626,h=60,secret=true,regex="[ -~]"}, WIDGET.newButton{name="back", x=1140, y=640,w=170,h=80,font=40,code=WIDGET.lnk_BACK}, }) \ No newline at end of file diff --git a/parts/tick.lua b/parts/tick.lua index 3c495724..dee8c3f1 100644 --- a/parts/tick.lua +++ b/parts/tick.lua @@ -155,8 +155,7 @@ function Tick.httpREQ_login(data) if response.code==200 then local success,content=json.decode(response.body) if success then - -- LOG.print(text.registerSuccessed..": "..content.message) - -- TODO: display a login success message + LOG.print(text.loginSuccessed..": "..content.message) -- TODO: save {content.token} to storage and a global variable -- TODO: save {content.user_id} to a global variable else