Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
NJ_login
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
NJ_login
Commits
22657424
Commit
22657424
authored
May 17, 2022
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:
parent
40483358
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
45 deletions
+55
-45
NJ_login.ts
assets/NJ_login/scene/NJ_login.ts
+55
-45
No files found.
assets/NJ_login/scene/NJ_login.ts
View file @
22657424
...
...
@@ -10,6 +10,53 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
initListener
();
}
middleLayer
;
initData
()
{
const
middleLayer
=
cc
.
find
(
'
middleLayer
'
)?.
getComponent
(
'
middleLayer
'
);
if
(
middleLayer
)
{
this
.
middleLayer
=
middleLayer
;
}
}
async
login
(
phone
,
password
,
passCode
=
''
)
{
if
(
!
this
.
checkPhone
(
phone
))
{
console
.
log
(
'
请输入正确的手机号码
'
);
return
;
}
const
check
=
cc
.
find
(
'
Canvas/bg/ui/btnLaw/check
'
);
if
(
!
check
.
active
)
{
console
.
log
(
'
请勾选下方协议
'
);
return
;
}
const
res
=
await
this
.
middleLayer
.
asyncCallNetworkApiPost
(
'
/api/oxford/v1/login
'
,
{
phone
:
phone
,
password
:
password
,
sms_code
:
passCode
});
console
.
log
(
'
res =
'
+
JSON
.
stringify
(
res
));
}
checkPhone
(
phone
)
{
const
test
=
/^
[
1
]([
3-9
])[
0-9
]{9}
$/
;
if
(
!
test
.
test
(
phone
))
{
return
false
;
}
return
true
;
}
async
sendCode
(
phone
)
{
if
(
!
this
.
checkPhone
(
phone
))
{
console
.
log
(
'
请输入正确的手机号码
'
);
return
;
}
const
res
=
await
this
.
middleLayer
.
asyncCallNetworkApiPost
(
'
/api/oxford/v1/sendcode
'
,
{
phone
:
phone
});
console
.
log
(
'
res =
'
+
JSON
.
stringify
(
res
));
}
initListener
()
{
const
btnLaw
=
cc
.
find
(
'
Canvas/bg/ui/btnLaw
'
);
buttonOnClick
(
btnLaw
,
()
=>
{
...
...
@@ -18,21 +65,17 @@ export default class SceneComponent extends MyCocosSceneComponent {
},
1.02
);
const
btnLogin
=
cc
.
find
(
'
Canvas/bg/ui/loginNode/btnLogin
'
);
buttonOnClick
(
btnLogin
,
()
=>
{
buttonOnClick
(
btnLogin
,
async
()
=>
{
const
inputPhone
=
cc
.
find
(
'
Canvas/bg/ui/loginNode/phone/inputPhone
'
);
const
phone
=
inputPhone
.
getComponent
(
cc
.
EditBox
).
string
;
const
inputPassword
=
cc
.
find
(
'
Canvas/bg/ui/loginNode/password/password
'
);
const
password
=
inputPassword
.
getComponent
(
cc
.
EditBox
).
string
;
const
check
=
cc
.
find
(
'
Canvas/bg/ui/btnLaw/check
'
);
if
(
!
check
.
active
)
{
console
.
log
(
'
请勾选下方协议
'
);
return
;
}
this
.
login
(
phone
,
password
);
});
const
btnResetPassword
=
cc
.
find
(
'
Canvas/bg/ui/forgetNode/btnResetPassword
'
);
buttonOnClick
(
btnResetPassword
,
()
=>
{
buttonOnClick
(
btnResetPassword
,
async
()
=>
{
const
inputPhone
=
cc
.
find
(
'
Canvas/bg/ui/forgetNode/phone/inputPhone
'
);
const
phone
=
inputPhone
.
getComponent
(
cc
.
EditBox
).
string
;
const
inputPassword
=
cc
.
find
(
'
Canvas/bg/ui/forgetNode/password/password
'
);
...
...
@@ -40,15 +83,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
const
inputPassCode
=
cc
.
find
(
'
Canvas/bg/ui/forgetNode/passCode/passCode
'
);
const
passCode
=
inputPassCode
.
getComponent
(
cc
.
EditBox
).
string
;
const
check
=
cc
.
find
(
'
Canvas/bg/ui/btnLaw/check
'
);
if
(
!
check
.
active
)
{
console
.
log
(
'
请勾选下方协议
'
);
return
;
}
this
.
login
(
phone
,
password
,
passCode
);
});
const
btnRegister
=
cc
.
find
(
'
Canvas/bg/ui/registerNode/btnRegister
'
);
buttonOnClick
(
btnRegister
,
()
=>
{
buttonOnClick
(
btnRegister
,
async
()
=>
{
const
inputPhone
=
cc
.
find
(
'
Canvas/bg/ui/registerNode/phone/inputPhone
'
);
const
phone
=
inputPhone
.
getComponent
(
cc
.
EditBox
).
string
;
const
inputPassword
=
cc
.
find
(
'
Canvas/bg/ui/registerNode/password/password
'
);
...
...
@@ -56,22 +95,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
const
inputPassCode
=
cc
.
find
(
'
Canvas/bg/ui/registerNode/passCode/passCode
'
);
const
passCode
=
inputPassCode
.
getComponent
(
cc
.
EditBox
).
string
;
const
check
=
cc
.
find
(
'
Canvas/bg/ui/btnLaw/check
'
);
if
(
!
check
.
active
)
{
console
.
log
(
'
请勾选下方协议
'
);
return
;
}
this
.
login
(
phone
,
password
,
passCode
);
});
const
btnSendCode
=
cc
.
find
(
'
Canvas/bg/ui/registerNode/passCode/btnSendCode
'
);
buttonOnClick
(
btnSendCode
,
async
()
=>
{
const
inputPhone
=
cc
.
find
(
'
Canvas/bg/ui/registerNode/phone/inputPhone
'
);
const
phone
=
inputPhone
.
getComponent
(
cc
.
EditBox
).
string
;
const
test
=
/^
[
1
]([
3-9
])[
0-9
]{9}
$/
;
if
(
!
test
.
test
(
phone
))
{
console
.
log
(
'
请输入正确的手机号码
'
);
return
;
}
const
label
=
btnSendCode
.
getChildByName
(
'
label
'
).
getComponent
(
cc
.
Label
);
// 发送验证码
...
...
@@ -91,25 +121,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
.
repeatForever
()
.
start
();
}
const
middleLayer
=
cc
.
find
(
'
middleLayer
'
)?.
getComponent
(
'
middleLayer
'
);
if
(
middleLayer
)
{
const
res
=
await
middleLayer
.
asyncCallNetworkApiGet
(
'
/api/oxford/v1/sendcode
'
,
{
phone
:
phone
});
console
.
log
(
'
res =
'
+
JSON
.
stringify
(
res
));
}
this
.
sendCode
(
phone
);
});
const
btnSendCode2
=
cc
.
find
(
'
Canvas/bg/ui/forgetNode/passCode/btnSendCode
'
);
buttonOnClick
(
btnSendCode2
,
async
()
=>
{
const
inputPhone
=
cc
.
find
(
'
Canvas/bg/ui/forgetNode/phone/inputPhone
'
);
const
phone
=
inputPhone
.
getComponent
(
cc
.
EditBox
).
string
;
const
test
=
/^
[
1
]([
3-9
])[
0-9
]{9}
$/
;
if
(
!
test
.
test
(
phone
))
{
console
.
log
(
'
请输入正确的手机号码
'
);
return
;
}
const
label
=
btnSendCode2
.
getChildByName
(
'
label
'
).
getComponent
(
cc
.
Label
);
if
(
label
.
string
==
'
发送验证码
'
)
{
let
countDown
=
10
;
...
...
@@ -127,14 +144,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
.
repeatForever
()
.
start
();
}
const
middleLayer
=
cc
.
find
(
'
middleLayer
'
)?.
getComponent
(
'
middleLayer
'
);
if
(
middleLayer
)
{
const
res
=
await
middleLayer
.
asyncCallNetworkApiPost
(
'
/api/oxford/v1/sendcode
'
,
{
phone
:
phone
});
console
.
log
(
'
res =
'
+
JSON
.
stringify
(
res
));
}
this
.
sendCode
(
phone
);
});
const
btnGotoRegister
=
cc
.
find
(
'
Canvas/bg/ui/loginNode/btnRegister
'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment