登录和注册页面分离
This commit is contained in:
@@ -80,7 +80,6 @@ return{
|
||||
jsonError="Json error",
|
||||
|
||||
noUsername="Please enter your username",
|
||||
wrongCode="Please enter invitation code",
|
||||
wrongEmail="Wrong email address",
|
||||
noPassword="Please enter your password",
|
||||
diffPassword="Passwords don't match",
|
||||
@@ -465,10 +464,16 @@ return{
|
||||
down="↓",
|
||||
},
|
||||
login={
|
||||
title="Log in / Sign up",
|
||||
title="Log in",
|
||||
register="Sign up",
|
||||
username="Username",
|
||||
password="Password",
|
||||
},
|
||||
register={
|
||||
title="Sign up",
|
||||
login="Log in",
|
||||
username="Username",
|
||||
email="Email address",
|
||||
code="Invitation Code",
|
||||
password="Password",
|
||||
password2="Reenter password",
|
||||
},
|
||||
|
||||
@@ -83,7 +83,6 @@ return{
|
||||
jsonError="Erreur json",
|
||||
|
||||
noUsername="Entrez votre nom d'utilisateur",
|
||||
wrongCode="Veuillez entrer un code d'invitation",
|
||||
wrongEmail="Mauvaise adresse email",
|
||||
noPassword="Entrez votre mot de passe",
|
||||
diffPassword="Les mots de passe ne se correspondent pas",
|
||||
@@ -463,10 +462,16 @@ return{
|
||||
down="↓",
|
||||
},
|
||||
login={
|
||||
title="Connexion / Enregistrement",
|
||||
title="Connexion",
|
||||
register="Enregistrement",
|
||||
username="Nom d'utilisateur",
|
||||
password="Mot de passe",
|
||||
},
|
||||
register={
|
||||
title="Enregistrement",
|
||||
login="Connexion",
|
||||
username="Nom d'utilisateur",
|
||||
email="E-mail",
|
||||
code="Code d'invitation",
|
||||
password="Mot de passe",
|
||||
password2="Confirmer le mot de passe",
|
||||
},
|
||||
|
||||
@@ -83,7 +83,6 @@ return{
|
||||
|
||||
noUsername="Por favor ingresa un nombre de usuario",
|
||||
|
||||
-- wrongCode="Please enter invitation code",
|
||||
-- wrongEmail="Wrong email address",
|
||||
noPassword="Por favor ingresa una contraseña",
|
||||
diffPassword="Las contraseñas no coinciden",
|
||||
@@ -467,10 +466,16 @@ return{
|
||||
down="↓",
|
||||
},
|
||||
login={
|
||||
title="Entrar/Registrarse",
|
||||
title="Entrar",
|
||||
register="Registrarse",
|
||||
username="Nombre de Usuario",
|
||||
password="Contraseña",
|
||||
},
|
||||
register={
|
||||
title="Registrarse",
|
||||
login="Entrar",
|
||||
username="Nombre de Usuario",
|
||||
email="Correo Elec.",
|
||||
code="Código de Invit.",
|
||||
password="Contraseña",
|
||||
password2="Repetir Contr.",
|
||||
},
|
||||
|
||||
@@ -399,10 +399,16 @@ return{
|
||||
down="↓",
|
||||
},
|
||||
login={
|
||||
title="Log in / Sign up",
|
||||
title="Log in",
|
||||
register="Sign up",
|
||||
username="#",
|
||||
password="*",
|
||||
},
|
||||
register={
|
||||
title="Sign up",
|
||||
login="Log in",
|
||||
username="#",
|
||||
email="@",
|
||||
code="%",
|
||||
password="*",
|
||||
password2="*",
|
||||
},
|
||||
|
||||
@@ -34,7 +34,6 @@ return{
|
||||
finesse_fc="全连",
|
||||
|
||||
noUsername="别闹。",
|
||||
wrongCode="有人邀请你注册了?",
|
||||
wrongEmail="别乱输。",
|
||||
noPassword="注册会不会?",
|
||||
diffPassword="字不认识?",
|
||||
@@ -114,7 +113,7 @@ return{
|
||||
his="黑历史",
|
||||
qq="QQ对线",
|
||||
},
|
||||
login={
|
||||
register={
|
||||
password2="你觉得应该填啥",
|
||||
},
|
||||
sound={
|
||||
|
||||
@@ -81,7 +81,6 @@ return{
|
||||
jsonError="json错误",
|
||||
|
||||
noUsername="请填写用户名",
|
||||
wrongCode="请填写邀请码",
|
||||
wrongEmail="邮箱格式错误",
|
||||
noPassword="请填写密码",
|
||||
diffPassword="两次密码不一致",
|
||||
@@ -489,10 +488,16 @@ return{
|
||||
save="用户档案管理",
|
||||
},
|
||||
login={
|
||||
title="登录/注册",
|
||||
title="登录",
|
||||
register="注册",
|
||||
username="用户名",
|
||||
password="密码",
|
||||
},
|
||||
register={
|
||||
title="注册",
|
||||
login="登录",
|
||||
username="用户名",
|
||||
email="邮箱",
|
||||
code="邀请码",
|
||||
password="密码",
|
||||
password2="确认密码",
|
||||
},
|
||||
|
||||
@@ -1,26 +1,15 @@
|
||||
function keyDown.login(key)
|
||||
if key=="return"then
|
||||
local username= WIDGET.active.username.value
|
||||
local email= WIDGET.active.email.value
|
||||
local code= WIDGET.active.code.value
|
||||
local password= WIDGET.active.password.value
|
||||
local password2=WIDGET.active.password2.value
|
||||
if #username==0 then
|
||||
LOG.print(text.noUsername)return
|
||||
elseif not email:match("^[a-zA-Z0-9_]+@[a-zA-Z0-9_-]+%.[a-zA-Z0-9_]+$")then
|
||||
LOG.print(text.wrongEmail)return
|
||||
elseif #code~=12 then
|
||||
LOG.print(text.wrongCode)return
|
||||
elseif #password==0 or #password2==0 then
|
||||
elseif #password==0 then
|
||||
LOG.print(text.noPassword)return
|
||||
elseif password~=password2 then
|
||||
LOG.print(text.diffPassword)return
|
||||
end
|
||||
local data=urlencode.encode{
|
||||
username=username,
|
||||
email=email,
|
||||
password=password,
|
||||
code=code,
|
||||
}
|
||||
httpRequest(
|
||||
TICK.httpREQ_register,
|
||||
@@ -38,10 +27,8 @@ end
|
||||
|
||||
WIDGET.init("login",{
|
||||
WIDGET.newText{name="title", x=80, y=50,font=70,align="L"},
|
||||
WIDGET.newTextBox{name="username", x=380, y=160,w=500,h=60,regex="[0-9A-Za-z_]"},
|
||||
WIDGET.newTextBox{name="email", x=380, y=260,w=626,h=60,regex="[0-9A-Za-z@._-]"},
|
||||
WIDGET.newTextBox{name="code", x=380, y=360,w=626,h=60,regex="[0-9A-Za-z]"},
|
||||
WIDGET.newTextBox{name="password", x=380, y=460,w=626,h=60,secret=true,regex="[ -~]"},
|
||||
WIDGET.newTextBox{name="password2", x=380, y=560,w=626,h=60,secret=true,regex="[ -~]"},
|
||||
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="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},
|
||||
})
|
||||
@@ -35,7 +35,7 @@ end
|
||||
|
||||
WIDGET.init("main",{
|
||||
WIDGET.newButton{name="offline",x=150,y=220,w=200,h=140,color="lRed", font=40,code=WIDGET.lnk_goScene("mode")},
|
||||
WIDGET.newButton{name="online", x=370,y=220,w=200,h=140,color="lCyan", font=40,code=WIDGET.lnk_goScene(LOGIN and"netgame"or"login")},
|
||||
WIDGET.newButton{name="online", x=370,y=220,w=200,h=140,color="lCyan", font=40,code=WIDGET.lnk_goScene(LOGIN and"netgame"or"register")},
|
||||
WIDGET.newButton{name="custom", x=590,y=220,w=200,h=140,color="lBlue", font=40,code=WIDGET.lnk_goScene("customGame")},
|
||||
WIDGET.newButton{name="setting",x=150,y=380,w=200,h=140,color="lOrange",font=40,code=WIDGET.lnk_goScene("setting_game")},
|
||||
WIDGET.newButton{name="stat", x=370,y=380,w=200,h=140,color="lGreen", font=40,code=WIDGET.lnk_goScene("stat")},
|
||||
|
||||
43
parts/scenes/register.lua
Normal file
43
parts/scenes/register.lua
Normal file
@@ -0,0 +1,43 @@
|
||||
function keyDown.register(key)
|
||||
if key=="return"then
|
||||
local username= WIDGET.active.username.value
|
||||
local email= WIDGET.active.email.value
|
||||
local password= WIDGET.active.password.value
|
||||
local password2=WIDGET.active.password2.value
|
||||
if #username==0 then
|
||||
LOG.print(text.noUsername)return
|
||||
elseif not email:match("^[a-zA-Z0-9_]+@[a-zA-Z0-9_-]+%.[a-zA-Z0-9_]+$")then
|
||||
LOG.print(text.wrongEmail)return
|
||||
elseif #password==0 or #password2==0 then
|
||||
LOG.print(text.noPassword)return
|
||||
elseif password~=password2 then
|
||||
LOG.print(text.diffPassword)return
|
||||
end
|
||||
local data=urlencode.encode{
|
||||
username=username,
|
||||
email=email,
|
||||
password=password,
|
||||
}
|
||||
httpRequest(
|
||||
TICK.httpREQ_register,
|
||||
"api/account/register",
|
||||
"POST",
|
||||
{["Content-Type"]="application/x-www-form-urlencoded"},
|
||||
data
|
||||
)
|
||||
elseif key=="escape"then
|
||||
SCN.back()
|
||||
else
|
||||
WIDGET.keyPressed(key)
|
||||
end
|
||||
end
|
||||
|
||||
WIDGET.init("register",{
|
||||
WIDGET.newText{name="title", x=80, y=50,font=70,align="L"},
|
||||
WIDGET.newButton{name="login", x=1140, y=100,w=170,h=80,color="green",code=function()SCN.swapTo("login","swipeL")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=300,w=626,h=60,regex="[0-9A-Za-z@._-]"},
|
||||
WIDGET.newTextBox{name="password", x=380, y=400,w=626,h=60,secret=true,regex="[ -~]"},
|
||||
WIDGET.newTextBox{name="password2", x=380, y=500,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},
|
||||
})
|
||||
Reference in New Issue
Block a user