Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
NJ_BookTable
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
NJ_BookTable
Commits
4767555b
Commit
4767555b
authored
Jun 10, 2022
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 跳转课件
parent
412543e3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
12 deletions
+27
-12
NJ_BookTable.ts
assets/NJ_BookTable/scene/NJ_BookTable.ts
+27
-12
No files found.
assets/NJ_BookTable/scene/NJ_BookTable.ts
View file @
4767555b
import
{
asyncDelay
,
playAudioByUrl
,
asyncGetSpriteFrimeByUrl
,
buttonOnClick
}
from
"
../script/util
"
;
import
{
asyncDelay
,
playAudioByUrl
,
asyncGetSpriteFrimeByUrl
,
buttonOnClick
,
jumpToCourseWare
,
asyncCallNetworkApiGet
}
from
"
../script/util
"
;
import
{
MyCocosSceneComponent
}
from
"
../script/MyCocosSceneComponent
"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
...
...
@@ -24,22 +24,37 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
initListener
();
}
rows
=
[];
async
initView
()
{
const
levelNode
=
cc
.
find
(
`Canvas/bg/L
${
this
.
data
.
choseLevel
}
`
);
if
(
!
levelNode
)
{
if
(
!
levelNode
)
{
return
;
}
levelNode
.
active
=
true
;
cc
.
find
(
`box/title`
,
levelNode
).
getComponent
(
cc
.
Label
).
string
=
this
.
data
.
title
;
try
{
const
bookImgFrame
:
any
=
await
asyncGetSpriteFrimeByUrl
(
this
.
data
.
bookImg
);
const
bookImgFrame
:
any
=
await
asyncGetSpriteFrimeByUrl
(
this
.
data
.
bookImg
);
cc
.
find
(
`Canvas/bg/bookImg/img`
).
getComponent
(
cc
.
Sprite
).
spriteFrame
=
bookImgFrame
;
}
catch
(
error
)
{
console
.
error
(
error
);
}
const
middleLayer
=
cc
.
find
(
'
middleLayer
'
);
if
(
!
middleLayer
)
{
return
;
}
const
tableData
=
middleLayer
.
getComponent
(
'
middleLayer
'
).
getData
(
"
NJ_BookTable
"
);
if
(
tableData
&&
tableData
.
folderId
)
{
const
resStr
=
await
asyncCallNetworkApiGet
(
'
/api/syllabus/v1/list
'
,
{
pid
:
tableData
.
folderId
});
console
.
log
(
'
resStr =
'
+
resStr
);
const
res
=
JSON
.
parse
(
resStr
);
this
.
rows
=
res
.
rows
.
filter
(
row
=>
row
.
name
!=
'
索引页
'
);
}
}
initListener
()
{
const
bgButton
=
cc
.
find
(
`Canvas/bg/bookImg`
);
...
...
@@ -48,32 +63,32 @@ export default class SceneComponent extends MyCocosSceneComponent {
});
const
levelNode
=
cc
.
find
(
`Canvas/bg/L
${
this
.
data
.
choseLevel
}
`
);
if
(
!
levelNode
)
{
if
(
!
levelNode
)
{
return
;
}
const
levelButton
=
cc
.
find
(
`box`
,
levelNode
);
levelButton
.
on
(
'
click
'
,
()
=>
{
levelButton
.
on
(
'
click
'
,
()
=>
{
if
(
levelButton
[
'
cantClick
'
])
{
return
;
}
levelButton
[
'
cantClick
'
]
=
true
;
// TODO 播放骨骼动画
playAudioByUrl
(
this
.
data
.
questionTextAudio
,
()
=>
{
playAudioByUrl
(
this
.
data
.
questionTextAudio
,
()
=>
{
// TODO 更新骨骼动画状态
levelButton
[
'
cantClick
'
]
=
false
;
});
})
buttonOnClick
(
cc
.
find
(
`kdh`
,
levelNode
),
()
=>
{
// TODO 跳转到看动画(第一个课件)
jumpToCourseWare
(
this
.
rows
[
0
].
id
);
});
buttonOnClick
(
cc
.
find
(
`dgs`
,
levelNode
),
()
=>
{
// TODO 跳转到读故事(第二个课件)
jumpToCourseWare
(
this
.
rows
[
1
].
id
);
});
buttonOnClick
(
cc
.
find
(
`qpy`
,
levelNode
),
()
=>
{
// TODO 跳转到趣配音(第三个课件)
jumpToCourseWare
(
this
.
rows
[
2
].
id
);
});
}
}
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