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
40495102
Commit
40495102
authored
Dec 04, 2021
by
liujiangnan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://vcs.ireadabc.com/template/middleLayer_for_debug
parents
e8b463de
b1602877
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
43 deletions
+43
-43
middleLayer.js
assets/middleLayer_for_debug/script/middleLayer.js
+43
-43
No files found.
assets/middleLayer_for_debug/script/middleLayer.js
View file @
40495102
import
{
initAir
}
from
'
./air
'
;
import
{
initAir
}
from
'
./air
'
;
cc
.
Class
({
extends
:
cc
.
Component
,
properties
:
{
...
...
@@ -88,14 +88,14 @@ cc.Class({
preloadBundle
()
{
let
platform
=
"
web_desktop
"
;
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_IOS
)
{
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_IOS
)
{
platform
=
"
ios
"
;
}
else
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_ANDROID
){
}
else
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_ANDROID
)
{
platform
=
"
android
"
;
}
this
.
callNetworkApiGet
(
`http://staging-teach.ireadabc.com`
,
`/api/syllabus/v1/allbundles`
,
{
orgid
:
507
,
platform
},
(
datastr
)
=>
{
this
.
callNetworkApiGet
(
`http://staging-teach.ireadabc.com`
,
`/api/syllabus/v1/allbundles`
,
{
orgid
:
507
,
platform
},
(
datastr
)
=>
{
const
data
=
JSON
.
parse
(
datastr
);
if
(
data
.
rows
&&
data
.
rows
.
length
>
0
)
{
if
(
data
.
rows
&&
data
.
rows
.
length
>
0
)
{
this
.
preloadCount
+=
data
.
rows
.
length
;
this
.
batchPreloadScene
(
data
.
rows
);
}
...
...
@@ -104,27 +104,27 @@ cc.Class({
batchPreloadScene
(
scenes
)
{
const
_this
=
this
;
let
i
=
0
;
const
load
=
function
()
{
const
load
=
function
()
{
const
scene
=
scenes
[
i
];
if
([
"
OP11
"
,
"
op_09_plus
"
,
"
OP10_online
"
,
"
OP12
"
,
"
OPW25
"
,
"
OP_03_2
"
].
includes
(
scene
.
sceneName
))
{
_this
.
loadedCount
++
;
if
([
"
OP11
"
,
"
op_09_plus
"
,
"
OP10_online
"
,
"
OP12
"
,
"
OPW25
"
,
"
OP_03_2
"
].
includes
(
scene
.
sceneName
))
{
_this
.
loadedCount
++
;
_this
.
updateProcessBar
();
i
++
;
if
(
i
<
scenes
.
length
)
{
if
(
i
<
scenes
.
length
)
{
setTimeout
(()
=>
{
load
();
},
1
);
}
return
;
}
cc
.
assetManager
.
loadBundle
(
scene
.
bondleUrl
,
{
version
:
scene
.
version
},
(
err
,
bundle
)
=>
{
cc
.
assetManager
.
loadBundle
(
scene
.
bondleUrl
,
{
version
:
scene
.
version
},
(
err
,
bundle
)
=>
{
console
.
log
(
`
${
scene
.
bondleUrl
}
---场景开始loadBundle----`
);
bundle
.
preloadScene
(
scene
.
sceneName
,
()
=>
{},
()
=>
{
bundle
.
preloadScene
(
scene
.
sceneName
,
()
=>
{
},
()
=>
{
console
.
log
(
`
${
scene
.
sceneName
}
场景预加载结束`
);
_this
.
loadedCount
++
;
_this
.
loadedCount
++
;
_this
.
updateProcessBar
();
i
++
;
if
(
i
<
scenes
.
length
)
{
if
(
i
<
scenes
.
length
)
{
setTimeout
(()
=>
{
load
();
},
1
);
...
...
@@ -132,29 +132,29 @@ cc.Class({
});
});
}
if
(
scenes
&&
scenes
.
length
>
0
)
{
load
();
if
(
scenes
&&
scenes
.
length
>
0
)
{
load
();
}
},
preloadSource
()
{
this
.
callNetworkApiGet
(
`http://staging-teach.ireadabc.com`
,
`/api/syllabus/v1/allresources`
,
{
orgid
:
507
},
(
datastr
)
=>
{
this
.
callNetworkApiGet
(
`http://staging-teach.ireadabc.com`
,
`/api/syllabus/v1/allresources`
,
{
orgid
:
507
},
(
datastr
)
=>
{
const
data
=
JSON
.
parse
(
datastr
);
const
rows
=
data
.
rows
;
if
(
rows
&&
rows
.
length
>
0
)
{
if
(
rows
&&
rows
.
length
>
0
)
{
this
.
preloadCount
+=
rows
.
length
;
const
batchLoad
=
()
=>
{
let
tempArr
=
rows
.
splice
(
0
,
10
);
let
len
=
tempArr
.
length
;
for
(
let
i
=
0
;
i
<
tempArr
.
length
;
i
++
)
{
cc
.
assetManager
.
loadRemote
(
tempArr
[
i
],
(
err
,
texture
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
err
)
}
this
.
loadedCount
++
;
this
.
loadedCount
++
;
this
.
updateProcessBar
();
if
(
i
===
len
-
1
)
{
if
(
i
===
len
-
1
)
{
batchLoad
();
}
});
...
...
@@ -168,7 +168,7 @@ cc.Class({
updateProcessBar
()
{
const
label
=
cc
.
find
(
"
middleLayer/ui/ProgressLabel
"
).
getComponent
(
cc
.
Label
);
label
.
string
=
`正在加载:
${
this
.
loadedCount
}
/
${
this
.
preloadCount
}
`
;
if
(
this
.
loadedCount
>
this
.
preloadCount
*
0.99
)
{
if
(
this
.
loadedCount
>
this
.
preloadCount
*
0.99
)
{
cc
.
find
(
"
middleLayer/ui/ProgressLabel
"
).
active
=
false
;
}
},
...
...
@@ -201,19 +201,19 @@ cc.Class({
.
start
();
});
cc
.
find
(
'
middleLayer/BtnRight
'
).
on
(
'
click
'
,
()
=>
{
cc
.
find
(
'
middleLayer/BtnRight
'
).
on
(
'
click
'
,
()
=>
{
this
.
goNextPage
();
});
cc
.
find
(
'
middleLayer/BtnLeft
'
).
on
(
'
click
'
,
()
=>
{
cc
.
find
(
'
middleLayer/BtnLeft
'
).
on
(
'
click
'
,
()
=>
{
this
.
goPrePage
();
});
cc
.
find
(
'
middleLayer/ui/BtnOpenOsmo
'
).
on
(
'
click
'
,
()
=>
{
cc
.
find
(
'
middleLayer/ui/BtnOpenOsmo
'
).
on
(
'
click
'
,
()
=>
{
window
.
courseware
.
openOsmo
();
});
cc
.
find
(
'
middleLayer/ui/BtnCloseOsmo
'
).
on
(
'
click
'
,
()
=>
{
cc
.
find
(
'
middleLayer/ui/BtnCloseOsmo
'
).
on
(
'
click
'
,
()
=>
{
window
.
courseware
.
closeOsmo
();
});
...
...
@@ -279,19 +279,19 @@ cc.Class({
this
.
goTarIndexPage
(
this
.
courseIndex
+
1
);
},
goTarIndexPage
(
index
)
{
if
(
!
this
.
courses
||
index
==
this
.
courseIndex
||
index
<
0
||
index
>
this
.
courses
.
length
-
1
)
{
if
(
!
this
.
courses
||
index
==
this
.
courseIndex
||
index
<
0
||
index
>
this
.
courses
.
length
-
1
)
{
return
;
}
this
.
courseIndex
=
index
;
this
.
courseItem
=
this
.
courses
[
this
.
courseIndex
];
if
(
this
.
courseIndex
==
0
)
{
if
(
this
.
courseIndex
==
0
)
{
cc
.
find
(
'
middleLayer/BtnLeft
'
).
active
=
false
;
}
else
{
}
else
{
cc
.
find
(
'
middleLayer/BtnLeft
'
).
active
=
true
;
}
if
(
this
.
courseIndex
==
this
.
courses
.
length
-
1
)
{
if
(
this
.
courseIndex
==
this
.
courses
.
length
-
1
)
{
cc
.
find
(
'
middleLayer/BtnRight
'
).
active
=
false
;
}
else
{
}
else
{
cc
.
find
(
'
middleLayer/BtnRight
'
).
active
=
true
;
}
this
.
loadPageBundle
();
...
...
@@ -314,9 +314,9 @@ cc.Class({
this
.
callNetworkApiGet
(
`http://staging-teach.ireadabc.com`
,
`/api/template/v1/
${
bundleName
}
`
,
{},
(
datastr
)
=>
{
const
data
=
JSON
.
parse
(
datastr
);
let
configData
=
null
;
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_IOS
)
{
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_IOS
)
{
configData
=
data
.
data
.
conf
.
ios
;
}
else
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_ANDROID
){
}
else
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_ANDROID
)
{
configData
=
data
.
data
.
conf
.
android
;
}
else
{
configData
=
data
.
data
.
conf
.
web_desktop
;
...
...
@@ -332,20 +332,20 @@ cc.Class({
courseItem
:
null
,
loadOnlineCourseWare
(
courseId
,
linkFlag
)
{
let
api
=
`/api/courseware/v1/
${
courseId
}
/list`
;
if
(
linkFlag
===
true
)
{
if
(
linkFlag
===
true
)
{
api
=
`/api/courseware/v1/
${
courseId
}
/eq/level/list`
;
}
this
.
callNetworkApiGet
(
`http://staging-teach.ireadabc.com`
,
api
,
{},
(
datastr
)
=>
{
const
data
=
JSON
.
parse
(
datastr
);
if
(
data
.
rows
&&
data
.
rows
.
length
>
0
)
{
if
(
data
.
rows
&&
data
.
rows
.
length
>
0
)
{
this
.
courses
=
data
.
rows
;
this
.
courseIndex
=
data
.
index
||
0
;
this
.
courseItem
=
data
.
rows
[
this
.
courseIndex
];
}
if
(
this
.
courses
&&
this
.
courses
.
length
>
1
&&
this
.
courseIndex
<=
this
.
courses
.
length
-
1
)
{
if
(
this
.
courses
&&
this
.
courses
.
length
>
1
&&
this
.
courseIndex
<=
this
.
courses
.
length
-
1
)
{
cc
.
find
(
'
middleLayer/BtnRight
'
).
active
=
true
;
}
if
(
this
.
courseIndex
>
0
)
{
if
(
this
.
courseIndex
>
0
)
{
cc
.
find
(
'
middleLayer/BtnLeft
'
).
active
=
true
;
}
this
.
reWriteAir
();
...
...
@@ -358,11 +358,11 @@ cc.Class({
let
sceneName
=
''
;
let
version
=
''
;
let
bondleUrl
=
''
;
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_IOS
)
{
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_IOS
)
{
sceneName
=
data
.
ios
.
sceneName
;
version
=
data
.
ios
.
version
;
bondleUrl
=
`http://
${
address
}
:
${
port
}
/dist/ios/
${
sceneName
}
/`
;
}
else
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_ANDROID
){
}
else
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_ANDROID
)
{
sceneName
=
data
.
android
.
sceneName
;
version
=
data
.
android
.
version
;
bondleUrl
=
`http://
${
address
}
:
${
port
}
/dist/android/
${
sceneName
}
/`
;
...
...
@@ -376,11 +376,11 @@ cc.Class({
},
loadPageBundle
()
{
let
sceneName
,
version
,
bondleUrl
=
""
;
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_IOS
)
{
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_IOS
)
{
sceneName
=
this
.
courseItem
.
conf
.
ios
.
sceneName
;
version
=
this
.
courseItem
.
conf
.
ios
.
version
;
bondleUrl
=
this
.
courseItem
.
conf
.
ios
.
bondleUrl
;
}
else
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_ANDROID
){
}
else
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_ANDROID
)
{
sceneName
=
this
.
courseItem
.
conf
.
android
.
sceneName
;
version
=
this
.
courseItem
.
conf
.
android
.
version
;
bondleUrl
=
this
.
courseItem
.
conf
.
android
.
bondleUrl
;
...
...
@@ -389,7 +389,7 @@ cc.Class({
version
=
this
.
courseItem
.
conf
.
web_desktop
.
version
;
bondleUrl
=
this
.
courseItem
.
conf
.
web_desktop
.
bondleUrl
;
}
this
.
loadBundle
(
sceneName
,
version
,
bondleUrl
);
},
loadBundle
(
sceneName
,
version
,
bondleUrl
)
{
...
...
@@ -412,7 +412,7 @@ cc.Class({
reWriteAir
()
{
window
.
courseware
.
getData
=
(
callback
)
=>
{
let
data
=
null
;
if
(
this
.
courseItem
.
data
)
{
if
(
this
.
courseItem
.
data
)
{
data
=
JSON
.
parse
(
this
.
courseItem
.
data
);
}
callback
&&
callback
(
data
);
...
...
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