Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
middleLayer_for_debug
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
middleLayer_for_debug
Commits
4fdd2d04
Commit
4fdd2d04
authored
Dec 06, 2021
by
范雪寒
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://vcs.ireadabc.com/template/middleLayer_for_debug
parents
9817ea0f
8de5506e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
12 deletions
+42
-12
air.js
assets/middleLayer_for_debug/script/air.js
+21
-0
middleLayer.js
assets/middleLayer_for_debug/script/middleLayer.js
+21
-12
No files found.
assets/middleLayer_for_debug/script/air.js
View file @
4fdd2d04
...
@@ -189,3 +189,24 @@ export function initAir(_this) {
...
@@ -189,3 +189,24 @@ export function initAir(_this) {
};
};
}
}
export
function
timerManager
()
{
window
.
timerManager
=
{};
for
(
let
i
=
0
;
i
<
20
;
i
++
){
window
.
timerManager
[
`timer
${
i
}
`
]
=
{
handler
:
null
,
type
:
null
,
};
}
return
{
freeAll
()
{
for
(
const
key
in
window
.
timerManager
)
{
const
obj
=
window
.
timerManager
[
key
];
if
(
obj
.
handler
){
window
[
obj
.
type
](
obj
.
handler
);
}
}
}
}
}
assets/middleLayer_for_debug/script/middleLayer.js
View file @
4fdd2d04
import
{
initAir
}
from
'
./air
'
;
import
{
initAir
,
timerManager
}
from
'
./air
'
;
cc
.
Class
({
cc
.
Class
({
extends
:
cc
.
Component
,
extends
:
cc
.
Component
,
properties
:
{
properties
:
{
...
@@ -44,17 +44,14 @@ cc.Class({
...
@@ -44,17 +44,14 @@ cc.Class({
// 统计已加载的数量
// 统计已加载的数量
loadedCount
:
null
,
loadedCount
:
null
,
// 统一释放异步资源的方法
freeAll
:
null
,
onLoad
()
{
onLoad
()
{
this
.
preloadCount
=
0
;
this
.
preloadCount
=
0
;
this
.
loadedCount
=
0
;
this
.
loadedCount
=
0
;
initAir
(
this
);
initAir
(
this
);
if
(
!
window
.
preloadBundleAndSourcesFlag
)
{
this
.
freeAll
=
timerManager
().
freeAll
;
// 只加载一次就行了
// this.preloadAll();
window
.
preloadBundleAndSourcesFlag
=
true
;
cc
.
find
(
"
middleLayer/ui/ProgressLabel
"
).
active
=
true
;
cc
.
find
(
'
middleLayer/ui/loadingProgress
'
).
active
=
true
;
this
.
preloadAll
();
}
},
},
start
()
{
start
()
{
...
@@ -87,6 +84,13 @@ cc.Class({
...
@@ -87,6 +84,13 @@ cc.Class({
},
},
preloadAll
()
{
preloadAll
()
{
if
(
window
.
preloadBundleAndSourcesFlag
){
// 只加载一次就行了
return
;
}
window
.
preloadBundleAndSourcesFlag
=
true
;
cc
.
find
(
"
middleLayer/ui/ProgressLabel
"
).
active
=
true
;
cc
.
find
(
'
middleLayer/ui/loadingProgress
'
).
active
=
true
;
let
platform
=
"
web_desktop
"
;
let
platform
=
"
web_desktop
"
;
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_IOS
)
{
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_IOS
)
{
platform
=
"
ios
"
;
platform
=
"
ios
"
;
...
@@ -191,6 +195,7 @@ cc.Class({
...
@@ -191,6 +195,7 @@ cc.Class({
if
(
this
.
loadedCount
>
this
.
preloadCount
*
0.99
)
{
if
(
this
.
loadedCount
>
this
.
preloadCount
*
0.99
)
{
cc
.
find
(
"
middleLayer/ui/ProgressLabel
"
).
active
=
false
;
cc
.
find
(
"
middleLayer/ui/ProgressLabel
"
).
active
=
false
;
loadingProgress
.
active
=
false
;
loadingProgress
.
active
=
false
;
this
.
showLog
(
"
资源全部加载完成
"
);
}
}
loadingProgress
.
getComponent
(
cc
.
ProgressBar
).
progress
=
this
.
loadedCount
/
this
.
preloadCount
;
loadingProgress
.
getComponent
(
cc
.
ProgressBar
).
progress
=
this
.
loadedCount
/
this
.
preloadCount
;
},
},
...
@@ -217,6 +222,9 @@ cc.Class({
...
@@ -217,6 +222,9 @@ cc.Class({
.
call
(()
=>
{
.
call
(()
=>
{
exitBtn
.
active
=
false
;
exitBtn
.
active
=
false
;
cc
.
game
.
removePersistRootNode
(
this
.
node
);
cc
.
game
.
removePersistRootNode
(
this
.
node
);
console
.
log
(
"
======mid========
"
);
this
.
freeAll
();
console
.
log
(
"
======mid1========
"
);
cc
.
director
.
loadScene
(
"
debug_shell
"
,
()
=>
{
cc
.
director
.
loadScene
(
"
debug_shell
"
,
()
=>
{
});
});
})
})
...
@@ -357,11 +365,9 @@ cc.Class({
...
@@ -357,11 +365,9 @@ cc.Class({
courseIndex
:
0
,
courseIndex
:
0
,
courseItem
:
null
,
courseItem
:
null
,
loadOnlineCourseWare
(
courseId
,
linkFlag
)
{
loadOnlineCourseWare
(
courseId
,
linkFlag
)
{
console
.
log
(
'
loadOnlineCourseWare
'
)
this
.
showWaitingLetters
();
console
.
log
(
'
showWaitingLetters
'
);
this
.
hideUI
();
this
.
hideUI
();
console
.
log
(
'
hideUI
'
);
this
.
showWaitingLetters
();
let
api
=
`/api/courseware/v1/
${
courseId
}
/list`
;
let
api
=
`/api/courseware/v1/
${
courseId
}
/list`
;
if
(
linkFlag
===
true
)
{
if
(
linkFlag
===
true
)
{
api
=
`/api/courseware/v1/
${
courseId
}
/eq/level/list`
;
api
=
`/api/courseware/v1/
${
courseId
}
/eq/level/list`
;
...
@@ -452,6 +458,7 @@ cc.Class({
...
@@ -452,6 +458,7 @@ cc.Class({
if
(
this
.
courseItem
.
data
)
{
if
(
this
.
courseItem
.
data
)
{
data
=
JSON
.
parse
(
this
.
courseItem
.
data
);
data
=
JSON
.
parse
(
this
.
courseItem
.
data
);
}
}
this
.
log
(
"
===成功调用getData===
"
+
this
.
courseItem
.
data
);
callback
&&
callback
(
data
);
callback
&&
callback
(
data
);
}
}
window
.
courseware
.
nextPage
=
()
=>
{
window
.
courseware
.
nextPage
=
()
=>
{
...
@@ -461,11 +468,13 @@ cc.Class({
...
@@ -461,11 +468,13 @@ cc.Class({
this
.
goPrePage
();
this
.
goPrePage
();
}
}
window
.
courseware
.
sendAnswer
=
(
answerObj
)
=>
{
window
.
courseware
.
sendAnswer
=
(
answerObj
)
=>
{
this
.
log
(
"
===成功调用sendAnswer===
"
+
JSON
.
stringify
(
answerObj
));
this
.
callNetworkApiPost
(
`http://staging-teach.ireadabc.com`
,
`/api/oxford/courseware/v1/
${
this
.
courseItem
.
id
}
/saveanswer`
,
answerObj
,
(
data
)
=>
{
this
.
callNetworkApiPost
(
`http://staging-teach.ireadabc.com`
,
`/api/oxford/courseware/v1/
${
this
.
courseItem
.
id
}
/saveanswer`
,
answerObj
,
(
data
)
=>
{
answerObj
.
callback
&&
answerObj
.
callback
(
JSON
.
stringify
(
data
.
row
));
answerObj
.
callback
&&
answerObj
.
callback
(
JSON
.
stringify
(
data
.
row
));
});
});
}
}
window
.
courseware
.
getAnswer
=
(
queryObj
,
callback
)
=>
{
window
.
courseware
.
getAnswer
=
(
queryObj
,
callback
)
=>
{
this
.
log
(
"
===成功调用getAnswer===
"
+
JSON
.
stringify
(
queryObj
));
this
.
callNetworkApiGet
(
`http://staging-teach.ireadabc.com`
,
`/api/oxford/courseware/v1/
${
this
.
courseItem
.
id
}
/getanswer`
,
queryObj
,
(
datastr
)
=>
{
this
.
callNetworkApiGet
(
`http://staging-teach.ireadabc.com`
,
`/api/oxford/courseware/v1/
${
this
.
courseItem
.
id
}
/getanswer`
,
queryObj
,
(
datastr
)
=>
{
const
data
=
JSON
.
parse
(
datastr
);
const
data
=
JSON
.
parse
(
datastr
);
callback
&&
callback
(
JSON
.
stringify
(
data
.
rows
));
callback
&&
callback
(
JSON
.
stringify
(
data
.
rows
));
...
...
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