Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
supervise-front
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
5
Issues
5
List
Board
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
牛晓林
supervise-front
Commits
09370c7e
Commit
09370c7e
authored
Aug 08, 2019
by
niuxiaolin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加登录功能
parent
7ddb1346
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
2 deletions
+19
-2
login.component.html
src/app/login/login.component.html
+4
-0
login.component.less
src/app/login/login.component.less
+3
-0
login.component.ts
src/app/login/login.component.ts
+12
-2
No files found.
src/app/login/login.component.html
View file @
09370c7e
...
...
@@ -37,5 +37,8 @@
</nz-form-control>
</nz-form-item>
<
<
nz-form-item
*
ngIf=
"error"
nzFlex
>
<label
class=
"text-error"
>
用户名或者密码出错!
</label>
</nz-form-item>
</form>
</div>
\ No newline at end of file
src/app/login/login.component.less
View file @
09370c7e
...
...
@@ -12,6 +12,9 @@ form{
background: #13151591;
padding: 2em;
}
.text-error{
color:red;
}
:host {
display: block;
margin: 0 auto;
...
...
src/app/login/login.component.ts
View file @
09370c7e
...
...
@@ -3,7 +3,7 @@ import { Component, OnDestroy, Inject, Optional, OnInit } from '@angular/core';
import
{
Router
}
from
'@angular/router'
;
import
{
FormGroup
,
FormBuilder
,
Validators
}
from
'@angular/forms'
;
import
{
NzMessageService
,
NzModalService
}
from
'ng-zorro-antd'
;
import
{
HttpClient
}
from
'@angular/common/http'
;
import
{
HttpClient
,
HttpParams
}
from
'@angular/common/http'
;
import
{
DefaultService
}
from
'../api'
;
...
...
@@ -17,6 +17,7 @@ import { DefaultService } from '../api';
})
export
class
LoginComponent
implements
OnInit
{
validateForm
:
FormGroup
;
error
:
boolean
;
submitForm
():
void
{
for
(
const
i
in
this
.
validateForm
.
controls
)
{
...
...
@@ -24,7 +25,16 @@ export class LoginComponent implements OnInit {
this
.
validateForm
.
controls
[
i
].
updateValueAndValidity
();
}
if
(
this
.
validateForm
.
valid
){
this
.
http
.
post
(
this
.
s
.
basePath
+
"/user/login"
,
this
.
validateForm
.
value
).
subscribe
();
let
urlParams
:
URLSearchParams
=
new
URLSearchParams
();
this
.
http
.
get
(
`
${
this
.
s
.
basePath
}
/user/login/
${
this
.
validateForm
.
value
.
userName
}
/
${
this
.
validateForm
.
value
.
password
}
`
).
subscribe
(
res
=>
{
if
((
res
as
any
).
code
==
1
){
location
.
href
=
"./#/home"
;
}
else
{
this
.
error
=
true
;
}
});
}
}
...
...
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