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
f279db0d
Commit
f279db0d
authored
Mar 29, 2019
by
van.chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
最小化稳定版本
parent
8ba0c4fd
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
63 additions
and
65 deletions
+63
-65
app-routing.module.ts
src/app/app-routing.module.ts
+1
-1
app.component.ts
src/app/app.component.ts
+4
-1
login.component.html
src/app/extra/login/login.component.html
+1
-1
login.component.scss
src/app/extra/login/login.component.scss
+1
-0
login.component.ts
src/app/extra/login/login.component.ts
+2
-2
home.module.ts
src/app/home/home.module.ts
+1
-1
page-detail.component.ts
src/app/main/page-detail/page-detail.component.ts
+1
-1
page-four.component.html
src/app/main/page-four/page-four.component.html
+3
-1
page-four.component.ts
src/app/main/page-four/page-four.component.ts
+4
-2
api.service.ts
src/app/service/api.service.ts
+30
-7
auth.service.ts
src/app/service/auth.service.ts
+6
-44
http.service.ts
src/app/service/http.service.ts
+3
-3
global.scss
src/global.scss
+6
-1
No files found.
src/app/app-routing.module.ts
View file @
f279db0d
...
...
@@ -3,7 +3,7 @@ import {Routes, RouterModule, PreloadAllModules} from '@angular/router';
import
{
AuthService
}
from
'./service/auth.service'
;
const
routes
:
Routes
=
[
{
path
:
''
,
redirectTo
:
'
extra
'
,
pathMatch
:
'full'
},
{
path
:
''
,
redirectTo
:
'
main
'
,
pathMatch
:
'full'
},
{
path
:
'main'
,
canActivateChild
:
[
AuthService
],
loadChildren
:
'./home/home.module#HomePageModule'
},
{
path
:
'extra'
,
loadChildren
:
'./extra/extra.module#ExtraPageModule'
},
];
...
...
src/app/app.component.ts
View file @
f279db0d
...
...
@@ -32,6 +32,7 @@ export class AppComponent {
initializeApp
()
{
this
.
platform
.
ready
().
then
(()
=>
{
this
.
statusBar
.
styleDefault
();
this
.
statusBar
.
backgroundColorByHexString
(
'#ffffffff'
);
this
.
splashScreen
.
hide
();
this
.
registerBackButtonAction
();
// 注册返回按键事件
this
.
platform
.
resume
.
subscribe
();
// 弹出框
...
...
@@ -61,10 +62,12 @@ export class AppComponent {
registerBackButtonAction
()
{
this
.
platform
.
backButton
.
subscribe
((
event
)
=>
{
if
(
this
.
url
===
'/main
/index
'
||
this
.
url
===
'/extra'
)
{
if
(
this
.
url
===
'/main'
||
this
.
url
===
'/extra'
)
{
if
(
this
.
backBtnPressed
)
{
this
.
appMinimize
.
minimize
();
this
.
backBtnPressed
=
false
;
window
.
history
.
pushState
(
'forward'
,
null
,
this
.
url
);
// window.history.forward();
return
;
}
else
{
this
.
backBtnPressed
=
true
;
...
...
src/app/extra/login/login.component.html
View file @
f279db0d
...
...
@@ -12,6 +12,6 @@
<div
class=
"labelForInput"
>
密码
</div>
<ion-input
type=
"password"
[(
ngModel
)]="
req
.
ps
"
mode=
"ios"
class=
"input"
></ion-input>
</div>
<ion-button
mode=
"ios"
color=
"primary"
expand=
"
full
"
class=
"loginBtn"
(
click
)="
login
()"
>
Login
</ion-button>
<ion-button
mode=
"ios"
color=
"primary"
expand=
"
block
"
class=
"loginBtn"
(
click
)="
login
()"
>
Login
</ion-button>
</div>
</div>
src/app/extra/login/login.component.scss
View file @
f279db0d
...
...
@@ -34,6 +34,7 @@
.inputLine
{
padding-top
:
8%
;
border-bottom
:
2px
solid
#1890ff
;
margin
:
0
1%
;
}
.labelForInput
{
...
...
src/app/extra/login/login.component.ts
View file @
f279db0d
...
...
@@ -29,12 +29,12 @@ export class LoginComponent implements OnInit {
this
.
tf
.
transfer
({
from
:
'app-extra'
,
to
:
'app-home'
,
url
:
'/main
/index
'
,
url
:
'/main'
,
query
:
''
,
hash
:
''
});
}
else
{
// message
this
.
api
.
presentMsgToast
(
data
&&
data
.
message
?
data
.
message
:
'登录失败'
);
}
}]);
}
...
...
src/app/home/home.module.ts
View file @
f279db0d
...
...
@@ -17,7 +17,7 @@ import {PageDetailComponent} from '../main/page-detail/page-detail.component';
IonicModule
,
RouterModule
.
forChild
([
{
path
:
'
index
'
,
path
:
''
,
component
:
HomePage
},
{
...
...
src/app/main/page-detail/page-detail.component.ts
View file @
f279db0d
...
...
@@ -20,7 +20,7 @@ export class PageDetailComponent implements OnInit {
this
.
tf
.
transfer
({
from
:
'app-page-detail'
,
to
:
'app-home'
,
url
:
'/main
/index
'
,
url
:
'/main'
,
query
:
''
,
hash
:
'page_two'
});
...
...
src/app/main/page-four/page-four.component.html
View file @
f279db0d
<div
class=
"personSet"
>
<div
class=
"topBar"
>
<img
class=
"imgPart"
src=
"../../../assets/icon/favicon.png"
>
<div
class=
"imgPart"
>
<img
src=
"../../../assets/icon/favicon.png"
>
</div>
<div
class=
"topRight"
>
1111111
</div>
</div>
<ion-button
mode=
"ios"
color=
"primary"
expand=
"full"
class=
"loginBtn"
(
click
)="
getSelfInfo
()"
>
getSelfInfo
</ion-button>
...
...
src/app/main/page-four/page-four.component.ts
View file @
f279db0d
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
ApiService
}
from
'../../service/api.service'
;
import
{
TransferService
}
from
'../../service/transfer.service'
;
@
Component
({
selector
:
'app-page-four'
,
...
...
@@ -10,7 +11,7 @@ export class PageFourComponent implements OnInit {
req
:
any
=
{};
resp
:
any
=
''
;
constructor
(
private
api
:
ApiService
)
{
}
constructor
(
private
api
:
ApiService
,
private
tf
:
TransferService
)
{
}
ngOnInit
()
{}
...
...
@@ -23,8 +24,9 @@ export class PageFourComponent implements OnInit {
if
(
data
)
{
console
.
log
(
data
);
this
.
resp
=
JSON
.
stringify
(
data
);
}
else
{
this
.
api
.
presentMsgToast
(
data
&&
data
.
message
?
data
.
message
:
'登录失败'
);
}
}]);
}
}
src/app/service/api.service.ts
View file @
f279db0d
...
...
@@ -2,10 +2,11 @@ import { HttpService } from './http.service';
import
{
Injectable
}
from
'@angular/core'
;
import
{
Router
}
from
'@angular/router'
;
import
{
environment
}
from
'../../environments/environment'
;
import
{
ToastController
}
from
'@ionic/angular'
;
@
Injectable
()
export
class
ApiService
{
constructor
(
private
http
:
HttpService
,
private
router
:
Router
)
{
constructor
(
private
http
:
HttpService
,
private
router
:
Router
,
private
toast
:
ToastController
)
{
}
tokenLoseflag
=
0
;
...
...
@@ -43,7 +44,7 @@ export class ApiService {
next
(
data
);
}
else
{
if
(
!
this
.
tokenLoseflag
)
{
// this.message.error(this.translate.instant('loginOutValidityTips')
);
this
.
presentMsgToast
(
'登录失效,请重新登陆'
);
this
.
http
.
toLoginPage
(
2000
);
this
.
tokenLoseflag
=
1
;
setTimeout
(()
=>
{
...
...
@@ -55,18 +56,18 @@ export class ApiService {
}
if
(
!
error
)
{
error
=
(
err
)
=>
{
// cons
t data;
le
t
data
;
if
(
err
&&
err
.
error
&&
err
.
error
.
status
)
{
if
(
err
.
error
.
status
===
401
)
{
// data = {code: 0, message: this.translate.instant('noLoginTips')
};
data
=
{
code
:
0
,
message
:
'用户尚未登录'
};
this
.
router
.
navigate
([
'/extra'
]);
}
else
{
// data = {code: 0, message: this.translate.instant('wrongServerWithCode') + err.error.status
};
data
=
{
code
:
0
,
message
:
'服务器异常'
};
}
}
else
{
// data = {code: 0, message: this.translate.instant('wrongServer')
};
data
=
{
code
:
0
,
message
:
'服务器异常'
};
}
//
next(data);
next
(
data
);
};
}
if
(
type
===
'get'
)
{
...
...
@@ -75,4 +76,26 @@ export class ApiService {
this
.
http
.
post
(
this
.
url
+
addr
,
reqB
,
nextFunc
,
error
,
complete
);
}
}
async
presentMsgToast
(
msg
)
{
const
toast
=
await
this
.
toast
.
create
({
message
:
msg
,
duration
:
2000
,
mode
:
'ios'
,
cssClass
:
'msgToast'
});
toast
.
present
();
}
async
presentBtnToast
(
msg
,
btn
,
position
)
{
const
toast
=
await
this
.
toast
.
create
({
message
:
msg
,
showCloseButton
:
true
,
position
:
position
,
closeButtonText
:
btn
,
mode
:
'ios'
,
cssClass
:
'btnToast'
});
toast
.
present
();
}
}
src/app/service/auth.service.ts
View file @
f279db0d
import
{
Injectable
,
OnInit
}
from
'@angular/core'
;
import
{
CanActivateChild
,
Router
,
ActivatedRouteSnapshot
,
RouterStateSnapshot
}
from
'@angular/router'
;
// import { PermissionService } from './permission.service';
// import { MenuService } from './menu.service';
@
Injectable
()
export
class
AuthService
implements
CanActivateChild
,
OnInit
{
// public login = false;
// private permissionR = '';
constructor
(
private
router
:
Router
)
{
}
...
...
@@ -15,45 +11,11 @@ export class AuthService implements CanActivateChild, OnInit {
}
canActivateChild
(
route
:
ActivatedRouteSnapshot
,
state
:
RouterStateSnapshot
)
{
// const layoutCon = document.getElementById('layoutCon');
// if (layoutCon) {
// layoutCon.scrollTop = 0;
// }
// return this.checkLogin() && this.permissionCheck(state.url);
// // return this.checkLogin();
return
true
;
if
(
window
.
localStorage
.
getItem
(
'token'
))
{
return
true
;
}
else
{
this
.
router
.
navigate
([
'/extra'
]);
return
false
;
}
}
// // 登录验证,如果有值就返回true.没有就跳转登录
// checkLogin() {
// if (window.sessionStorage.getItem('_AMap_AMap.MapInner')) {
// return true;
// }
// this.router.navigate(['/extra/login']);
// return false;
// }
//
// // 路由跳转权限检测
// permissionCheck(routerUrl) {
// clearInterval(parseInt(window.sessionStorage.getItem('_inv'), 10));
// let routerReq;
// if (routerUrl.indexOf('?') > -1) {
// routerReq = routerUrl.slice(0, routerUrl.indexOf('?'));
// } else {
// routerReq = routerUrl;
// }
// routerReq = routerReq.split('/');
// if (routerReq[routerReq.length - 1] === 'xdkDetail' || routerReq[routerReq.length - 1] === 'cissDetail'
// || routerReq[routerReq.length - 1] === 'warnEdit' || routerReq[routerReq.length - 1] === 'warnNew') {
// this.permissionR = routerReq[routerReq.length - 2];
// } else {
// this.permissionR = routerReq[routerReq.length - 1];
// }
// const permissions = JSON.stringify(this.permission.getTiny());
// if (permissions.indexOf(this.permissionR) > -1) {
// return true;
// } else {
// return false;
// }
// }
}
src/app/service/http.service.ts
View file @
f279db0d
...
...
@@ -2,12 +2,12 @@ import { Injectable } from '@angular/core';
import
{
HttpClient
,
HttpHeaders
}
from
'@angular/common/http'
;
import
{
Http
,
RequestOptions
,
Response
}
from
'@angular/http'
;
import
{
Subscription
}
from
'rxjs/index'
;
import
{
Router
}
from
'@angular/router
'
;
import
{
TransferService
}
from
'./transfer.service
'
;
@
Injectable
()
export
class
HttpService
{
constructor
(
private
http
:
HttpClient
,
private
router
:
Router
)
{
constructor
(
private
http
:
HttpClient
,
private
tf
:
TransferService
)
{
this
.
subs
=
new
Array
<
Subscription
>
();
}
private
subs
:
Subscription
[];
...
...
@@ -63,7 +63,7 @@ export class HttpService {
// 跳转登录页面
toLoginPage
(
time
)
{
window
.
setTimeout
(()
=>
{
this
.
router
.
navigate
([
'/extra/login'
]
);
this
.
tf
.
transfer
({
to
:
'app-extra'
,
from
:
'app-home'
,
url
:
'/extra'
}
);
},
time
);
}
...
...
src/global.scss
View file @
f279db0d
...
...
@@ -3,9 +3,14 @@
@import
'~@ionic/angular/css/normalize.css'
;
@import
'~@ionic/angular/css/structure.css'
;
@import
'~@ionic/angular/css/typography.css'
;
@import
'~@ionic/angular/css/padding.css'
;
@import
'~@ionic/angular/css/float-elements.css'
;
@import
'~@ionic/angular/css/text-alignment.css'
;
@import
'~@ionic/angular/css/text-transformation.css'
;
@import
'~@ionic/angular/css/flex-utils.css'
;
.msgToast
,
.btnToast
{
--background
:
rgba
(
0
,
0
,
0
,
0
.7
);
--color
:
#ffffff
;
text-align
:
center
;
}
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