Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
appPasture
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
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
WitCloud
appPasture
Commits
f4a4d0ef
Commit
f4a4d0ef
authored
Mar 26, 2019
by
van.chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init----对于更新新的之后的凉凉之后的项目重构
parent
a596cc75
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
2 deletions
+53
-2
app.module.ts
src/app/app.module.ts
+3
-1
page-four.component.html
src/app/main/page-four/page-four.component.html
+1
-0
page-four.component.ts
src/app/main/page-four/page-four.component.ts
+15
-1
api.service.ts
src/app/service/api.service.ts
+11
-0
token.service.ts
src/app/service/token.service.ts
+23
-0
No files found.
src/app/app.module.ts
View file @
f4a4d0ef
...
...
@@ -15,6 +15,7 @@ import { ApiService } from './service/api.service';
import
{
AuthService
}
from
'./service/auth.service'
;
import
{
HttpService
}
from
'./service/http.service'
;
import
{
TransferService
}
from
'./service/transfer.service'
;
import
{
BackgroundMode
}
from
'@ionic-native/background-mode/ngx'
;
@
NgModule
({
declarations
:
[
AppComponent
],
...
...
@@ -28,7 +29,8 @@ import { TransferService } from './service/transfer.service';
HttpService
,
AuthService
,
TransferService
,
LocalNotifications
LocalNotifications
,
BackgroundMode
],
bootstrap
:
[
AppComponent
]
})
...
...
src/app/main/page-four/page-four.component.html
View file @
f4a4d0ef
...
...
@@ -3,4 +3,5 @@
<img
class=
"imgPart"
src=
"../../../assets/icon/favicon.png"
>
<div
class=
"topRight"
>
1111111
</div>
</div>
<ion-button
mode=
"ios"
color=
"primary"
expand=
"full"
class=
"loginBtn"
(
click
)="
getSelfInfo
()"
>
getSelfInfo
</ion-button>
</div>
src/app/main/page-four/page-four.component.ts
View file @
f4a4d0ef
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
ApiService
}
from
'../../service/api.service'
;
@
Component
({
selector
:
'app-page-four'
,
...
...
@@ -7,8 +8,21 @@ import { Component, OnInit } from '@angular/core';
})
export
class
PageFourComponent
implements
OnInit
{
constructor
()
{
}
req
:
any
=
{};
constructor
(
private
api
:
ApiService
)
{
}
ngOnInit
()
{}
getSelfInfo
()
{
const
req
=
{
userName
:
this
.
req
.
name
,
password
:
this
.
req
.
ps
};
this
.
api
.
user
.
getSelfInfo
([
req
,
(
data
)
=>
{
if
(
data
)
{
console
.
log
(
data
);
}
}]);
}
}
src/app/service/api.service.ts
View file @
f4a4d0ef
...
...
@@ -16,6 +16,17 @@ export class ApiService {
logout
:
(
data
)
=>
this
.
trans
(
'get'
,
'/login/logout'
,
data
),
};
public
user
=
{
addUser
:
(
data
)
=>
this
.
trans
(
'post'
,
'/user/addUser'
,
data
),
deleteUser
:
(
data
)
=>
this
.
trans
(
'post'
,
'/user/deleteUser'
,
data
),
getAll
:
(
data
)
=>
this
.
trans
(
'get'
,
'/user/getAll'
,
data
),
getByUserNameForLike
:
(
data
)
=>
this
.
trans
(
'post'
,
'/user/getByUserNameForLike'
,
data
),
getSelfInfo
:
(
data
)
=>
this
.
trans
(
'get'
,
'/user/getSelfInfo'
,
data
),
updateSelfPassword
:
(
data
)
=>
this
.
trans
(
'post'
,
'/user/updateSelfPassword'
,
data
),
updateSelfUser
:
(
data
)
=>
this
.
trans
(
'post'
,
'/user/updateSelfUser'
,
data
),
updateUser
:
(
data
)
=>
this
.
trans
(
'post'
,
'/user/updateUser'
,
data
),
};
private
trans
(
type
,
addr
,
data
)
{
this
.
sendHttpReq
(
type
,
addr
,
data
[
0
],
data
[
1
],
data
[
2
],
data
[
3
]);
}
...
...
src/app/service/token.service.ts
0 → 100644
View file @
f4a4d0ef
import
{
Injectable
,
OnInit
}
from
'@angular/core'
;
import
{
HttpInterceptor
,
HttpHandler
,
HttpRequest
}
from
'@angular/common/http'
;
@
Injectable
()
export
class
AuthInterceptor
implements
HttpInterceptor
,
OnInit
{
constructor
()
{
}
token
:
string
;
ngOnInit
()
{
}
intercept
(
req
:
HttpRequest
<
any
>
,
next
:
HttpHandler
)
{
// 这里的拦截了所有的请求,并且加上了token
// 每次都获取最新的token
this
.
token
=
window
.
sessionStorage
.
getItem
(
'token'
)
||
''
;
const
authReq
=
req
.
clone
({
headers
:
req
.
headers
.
set
(
'AccountToken'
,
this
.
token
)});
return
next
.
handle
(
authReq
);
}
}
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