Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wisdom-ces
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
wangqinghua
wisdom-ces
Commits
aefcc831
Commit
aefcc831
authored
Apr 08, 2019
by
wangqinghua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
答题时 物理键返回 判断
parent
94c344ba
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
111 additions
and
12 deletions
+111
-12
app.module.ts
src/app/app.module.ts
+4
-0
learning-do.ts
src/pages/home/learning/learning-do/learning-do.ts
+8
-5
learning-result.ts
src/pages/home/learning/learning-result/learning-result.ts
+2
-1
tabs.ts
src/pages/tabs/tabs.ts
+9
-4
appHttpService.ts
src/service/appHttpService.ts
+2
-2
backButton.service.ts
src/service/backButton.service.ts
+71
-0
emit.service.ts
src/service/emit.service.ts
+15
-0
No files found.
src/app/app.module.ts
View file @
aefcc831
...
...
@@ -33,6 +33,8 @@ import {LoginService} from "../pages/login/login.service";
import
{
LearnManageService
}
from
"../pages/home/learn-manage/learnManage.service"
;
import
{
CommonService
}
from
"../service/common.service"
;
import
{
TabsService
}
from
"../pages/tabs/tabs.service"
;
import
{
BackButtonService
}
from
"../service/backButton.service"
;
import
{
EmitService
}
from
"../service/emit.service"
;
@
NgModule
({
declarations
:
[
...
...
@@ -92,6 +94,8 @@ import {TabsService} from "../pages/tabs/tabs.service";
LoginService
,
CommonService
,
TabsService
,
BackButtonService
,
EmitService
,
{
provide
:
ErrorHandler
,
useClass
:
IonicErrorHandler
}
]
})
...
...
src/pages/home/learning/learning-do/learning-do.ts
View file @
aefcc831
import
{
Component
,
ViewChild
}
from
'@angular/core'
;
import
{
Component
,
EventEmitter
,
Output
,
ViewChild
}
from
'@angular/core'
;
import
{
IonicPage
,
Nav
,
Navbar
,
NavController
,
NavParams
,
Slides
,
ToastController
}
from
'ionic-angular'
;
import
{
message
}
from
"../../../../app/main"
;
import
{
AppGlobal
,
AppService
}
from
"../../../../service/appHttpService"
;
...
...
@@ -7,6 +7,7 @@ import {LearnService} from "../learn.service";
import
{
DatePipe
}
from
"@angular/common"
;
import
{
CommonService
}
from
"../../../../service/common.service"
;
import
{
ReviewResultPage
}
from
"../review-result/review-result"
;
import
{
EmitService
}
from
"../../../../service/emit.service"
;
@
IonicPage
()
@
Component
({
...
...
@@ -15,8 +16,7 @@ import {ReviewResultPage} from "../review-result/review-result";
})
export
class
LearningDoPage
{
@
ViewChild
(
Slides
)
slides
:
Slides
;
@
ViewChild
(
Navbar
)
navbar
:
Navbar
;
@
ViewChild
(
Nav
)
nav
:
Nav
;
@
ViewChild
(
Navbar
)
navbar
:
Navbar
;
type
;
//是否重做
title
;
// 问卷标题
...
...
@@ -29,10 +29,12 @@ export class LearningDoPage {
index
=
0
;
//当前题目的序号
useTime
=
0
;
//用时
constructor
(
public
navCtrl
:
NavController
,
public
navParams
:
NavParams
,
private
learnSer
:
LearnService
,
public
commonSer
:
CommonService
,
public
toastCtrl
:
ToastController
,
public
appService
:
AppService
,
public
datePipe
:
DatePipe
)
{
public
toastCtrl
:
ToastController
,
public
appService
:
AppService
,
public
datePipe
:
DatePipe
,
public
eventEmitSer
:
EmitService
,
private
nav
:
Nav
)
{
}
ionViewDidLoad
()
{
this
.
eventEmitSer
.
eventEmit
.
emit
(
'true'
);
this
.
navbar
.
backButtonClick
=
()
=>
{
this
.
commonSer
.
alert
(
"是否退出当前测试,中途退出直接交卷?"
,
(
res
)
=>
{
this
.
submit
()
...
...
@@ -41,7 +43,7 @@ export class LearningDoPage {
}
ionViewDidEnter
()
{
this
.
nav
.
swipeBackEnabled
=
false
;
//
this.nav.swipeBackEnabled = false;
this
.
testId
=
this
.
navParams
.
get
(
'testId'
);
this
.
title
=
this
.
navParams
.
get
(
'title'
);
this
.
type
=
this
.
navParams
.
get
(
'type'
);
...
...
@@ -184,6 +186,7 @@ export class LearningDoPage {
title
:
this
.
title
})
}
this
.
eventEmitSer
.
eventEmit
.
emit
(
'false'
);
}
)
...
...
src/pages/home/learning/learning-result/learning-result.ts
View file @
aefcc831
import
{
Component
,
ViewChild
}
from
'@angular/core'
;
import
{
IonicPage
,
Navbar
,
NavController
,
NavParams
}
from
'ionic-angular'
;
import
{
IonicPage
,
Nav
,
Nav
bar
,
NavController
,
NavParams
}
from
'ionic-angular'
;
import
{
ReviewLearnPage
}
from
"../review-learn/review-learn"
;
import
{
LearnService
}
from
"../learn.service"
;
...
...
@@ -24,6 +24,7 @@ export class LearningResultPage {
public
learnSer
:
LearnService
)
{
}
ionViewDidLoad
()
{
this
.
testId
=
this
.
navParams
.
get
(
'testId'
);
this
.
title
=
this
.
navParams
.
get
(
'title'
);
...
...
src/pages/tabs/tabs.ts
View file @
aefcc831
import
{
Component
,
Renderer
,
ElementRef
,
ViewChild
}
from
'@angular/core'
;
import
{
NavParams
,
NavController
,
AlertController
,
Events
,
Tabs
}
from
'ionic-angular'
;
import
{
NavParams
,
NavController
,
AlertController
,
Events
,
Tabs
,
Platform
}
from
'ionic-angular'
;
import
{
ContactPage
}
from
'./contact/contact'
;
import
{
HomePage
}
from
'./home/home'
;
import
{
MinePage
}
from
'./mine/mine'
;
import
{
Storage
}
from
'@ionic/storage'
;
import
{
ModifyPasswordPage
}
from
'../mine/person/modifyPassword/modifyPassword'
;
import
{
AppService
,
AppGlobal
}
from
'../../service/appHttpService'
;
import
{
NoticePage
}
from
"./notice/notice"
;
import
{
BackButtonService
}
from
"../../service/backButton.service"
;
@
Component
({
templateUrl
:
'tabs.html'
...
...
@@ -34,7 +33,9 @@ export class TabsPage {
public
event
:
Events
,
public
render
:
Renderer
,
public
elementRef
:
ElementRef
,
public
appService
:
AppService
public
appService
:
AppService
,
private
backButtonService
:
BackButtonService
,
public
platform
:
Platform
,
)
{
this
.
tabRoots
=
[{
root
:
HomePage
,
...
...
@@ -62,6 +63,10 @@ export class TabsPage {
index
:
3
}];
this
.
platform
.
ready
().
then
(()
=>
{
this
.
backButtonService
.
registerBackButtonAction
(
this
.
myTabs
);
});
//判断是否密码为初始六个0
// this.userInfo = this.storage.get("userLoginInfo").then((value) => {
// this.userInfo = value;
...
...
src/service/appHttpService.ts
View file @
aefcc831
...
...
@@ -14,8 +14,8 @@ export class AppGlobal {
//接口基地址
// static domain = "http://101.89.112.92:80"; //正式环境
//
static domain = "http://180.168.156.212:2931"; //测试环境
static
domain
=
""
;
//本地环境
static
domain
=
"http://180.168.156.212:2931"
;
//测试环境
//
static domain = ""; //本地环境
//图片地址
...
...
src/service/backButton.service.ts
0 → 100644
View file @
aefcc831
import
{
EventEmitter
,
Injectable
}
from
'@angular/core'
;
import
{
Platform
,
ToastController
,
App
,
NavController
,
Tabs
}
from
'ionic-angular'
;
import
{
EmitService
}
from
"./emit.service"
;
@
Injectable
()
export
class
BackButtonService
{
//控制硬件返回按钮是否触发,默认false
backButtonPressed
:
boolean
=
false
;
isDo
=
false
;
//是否答题中,默认false;
//构造函数 依赖注入
constructor
(
public
platform
:
Platform
,
public
appCtrl
:
App
,
public
eventEmitSer
:
EmitService
,
public
toastCtrl
:
ToastController
)
{
// 接收发射过来的数据
this
.
eventEmitSer
.
eventEmit
.
subscribe
((
value
:
any
)
=>
{
if
(
value
==
"true"
)
{
//答题中
this
.
isDo
=
true
;
}
else
{
//答题结束
this
.
isDo
=
false
;
}
});
}
//注册方法
registerBackButtonAction
(
tabRef
:
Tabs
):
void
{
//registerBackButtonAction是系统自带的方法
this
.
platform
.
registerBackButtonAction
(()
=>
{
//获取NavController
let
activeNav
:
NavController
=
this
.
appCtrl
.
getActiveNavs
()[
0
];
//如果可以返回上一页,则执行pop
if
(
activeNav
.
canGoBack
())
{
alert
(
this
.
isDo
);
if
(
!
this
.
isDo
){
activeNav
.
pop
();
}
}
else
{
if
(
tabRef
==
null
||
tabRef
.
_selectHistory
[
tabRef
.
_selectHistory
.
length
-
1
]
===
tabRef
.
getByIndex
(
0
).
id
)
{
//执行退出
// this.showExit();
}
else
{
//选择首页第一个的标签
tabRef
.
select
(
0
);
}
}
});
}
//退出应用方法
private
showExit
():
void
{
//如果为true,退出
if
(
this
.
backButtonPressed
)
{
this
.
platform
.
exitApp
();
}
else
{
//第一次按,弹出Toast
this
.
toastCtrl
.
create
({
message
:
'再按一次退出应用'
,
duration
:
2000
,
position
:
'top'
}).
present
();
//标记为true
this
.
backButtonPressed
=
true
;
//两秒后标记为false,如果退出的话,就不会执行了
setTimeout
(()
=>
this
.
backButtonPressed
=
false
,
2000
);
}
}
}
\ No newline at end of file
src/service/emit.service.ts
0 → 100644
View file @
aefcc831
import
{
Injectable
,
EventEmitter
,
OnInit
}
from
"@angular/core"
;
@
Injectable
()
export
class
EmitService
implements
OnInit
{
public
eventEmit
:
any
;
constructor
()
{
// 定义发射事件
this
.
eventEmit
=
new
EventEmitter
();
}
ngOnInit
()
{
}
}
\ No newline at end of file
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