Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
JM-15
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
JM-15
Commits
e74399ed
Commit
e74399ed
authored
Sep 24, 2021
by
limingzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 断线 重连 改用storeData
parent
5f8cd4e2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
4 deletions
+58
-4
play.component.ts
src/app/play/play.component.ts
+58
-4
No files found.
src/app/play/play.component.ts
View file @
e74399ed
...
@@ -157,6 +157,7 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -157,6 +157,7 @@ export class PlayComponent implements OnInit, OnDestroy {
if
(
aspect
)
{
if
(
aspect
)
{
console
.
log
(
'
aspect :
'
,
aspect
);
console
.
log
(
'
aspect :
'
,
aspect
);
this
.
initPageData
(
aspect
);
this
.
initPageData
(
aspect
);
this
.
initStoreData
(
aspect
);
}
}
if
(
data
&&
typeof
data
==
'
object
'
)
{
if
(
data
&&
typeof
data
==
'
object
'
)
{
...
@@ -185,6 +186,50 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -185,6 +186,50 @@ export class PlayComponent implements OnInit, OnDestroy {
}
}
// 用于存储私有数据 当翻页时清空
storeData
;
initStoreData
(
aspect
)
{
const
storeDataStr
=
aspect
?.
user_aspect
;
if
(
!
storeDataStr
)
{
this
.
storeData
=
{};
}
else
{
this
.
storeData
=
JSON
.
parse
(
storeDataStr
);
}
console
.
log
(
'
this.storeData:
'
,
this
.
storeData
);
}
setStoreData
(
key
,
value
,
isSend
=
true
)
{
if
(
this
.
storeData
)
{
console
.
log
(
'
this.storeData:
'
,
this
.
storeData
);
this
.
storeData
[
key
]
=
value
;
if
(
isSend
)
{
this
.
sendStoreData
();
}
}
}
getStoreData
(
key
)
{
return
this
.
storeData
&&
this
.
storeData
[
key
];
}
sendStoreData
()
{
const
data
=
this
.
storeData
;
if
(
window
&&
window
[
'
courseware
'
])
{
let
storeAspect
=
window
[
'
courseware
'
].
storeAspect
;
if
(
storeAspect
)
{
storeAspect
(
data
);
}
}
}
// 用于存储公共数据 当翻页时清空
// 用于存储公共数据 当翻页时清空
pageData
;
pageData
;
initPageData
(
aspect
)
{
initPageData
(
aspect
)
{
...
@@ -502,6 +547,9 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -502,6 +547,9 @@ export class PlayComponent implements OnInit, OnDestroy {
c
.
onEvent
(
'
game_start
'
,
(
data
,
next
)
=>
{
c
.
onEvent
(
'
game_start
'
,
(
data
,
next
)
=>
{
this
.
setStoreData
(
'
progress
'
,
'
1
'
);
this
.
gameStart
();
this
.
gameStart
();
if
(
next
)
{
if
(
next
)
{
next
();
next
();
...
@@ -558,6 +606,12 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -558,6 +606,12 @@ export class PlayComponent implements OnInit, OnDestroy {
}
}
_initView
()
{
_initView
()
{
// const spr = new MySprite()
// const spr = new MySprite()
// spr.init(this.images.get("result_panel_item"));
// spr.init(this.images.get("result_panel_item"));
...
@@ -684,7 +738,7 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -684,7 +738,7 @@ export class PlayComponent implements OnInit, OnDestroy {
relink
()
{
relink
()
{
const
progress
=
this
.
get
Pag
eData
(
'
progress
'
);
const
progress
=
this
.
get
Stor
eData
(
'
progress
'
);
if
(
this
.
isTeacher
)
{
if
(
this
.
isTeacher
)
{
if
(
progress
!=
null
)
{
if
(
progress
!=
null
)
{
...
@@ -699,7 +753,7 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -699,7 +753,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this
.
gameStart
();
this
.
gameStart
();
const
resultData
=
this
.
get
Pag
eData
(
'
resultData
'
)
const
resultData
=
this
.
get
Stor
eData
(
'
resultData
'
)
if
(
resultData
)
{
if
(
resultData
)
{
this
.
initResultView
(
resultData
);
this
.
initResultView
(
resultData
);
return
;
return
;
...
@@ -770,7 +824,7 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -770,7 +824,7 @@ export class PlayComponent implements OnInit, OnDestroy {
}
else
{
}
else
{
const
resultData
=
this
.
getResultData
();
const
resultData
=
this
.
getResultData
();
this
.
sendResult
(
resultData
);
this
.
sendResult
(
resultData
);
this
.
set
Pag
eData
(
'
resultData
'
,
resultData
);
this
.
set
Stor
eData
(
'
resultData
'
,
resultData
);
}
}
...
@@ -1560,7 +1614,7 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -1560,7 +1614,7 @@ export class PlayComponent implements OnInit, OnDestroy {
if
(
this
.
sendBtn
&&
this
.
sendBtn
.
visible
)
{
if
(
this
.
sendBtn
&&
this
.
sendBtn
.
visible
)
{
if
(
this
.
checkClickTargetSv
(
this
.
sendBtn
))
{
if
(
this
.
checkClickTargetSv
(
this
.
sendBtn
))
{
this
.
sendServerEvent
(
'
game_start
'
,
{});
this
.
sendServerEvent
(
'
game_start
'
,
{});
this
.
setPageData
(
'
progress
'
,
'
1
'
);
//
this.setPageData('progress', '1');
this
.
playAudio
(
'
submit
'
,
true
);
this
.
playAudio
(
'
submit
'
,
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