Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
middleLayer_for_kyxq
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_kyxq
Commits
2ec8b7f4
Commit
2ec8b7f4
authored
Sep 26, 2023
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 解锁逻辑
parent
94028df4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
23 deletions
+62
-23
middleLayer_for_kyxq.fire
assets/middleLayer_for_kyxq/scene/middleLayer_for_kyxq.fire
+4
-1
HomePage.ts
assets/middleLayer_for_kyxq/script/HomePage.ts
+4
-3
UnitPage.ts
assets/middleLayer_for_kyxq/script/UnitPage.ts
+54
-19
No files found.
assets/middleLayer_for_kyxq/scene/middleLayer_for_kyxq.fire
View file @
2ec8b7f4
...
...
@@ -2693,7 +2693,7 @@
"__id__": 113
}
],
"_active":
tru
e,
"_active":
fals
e,
"_components": [
{
"__id__": 179
...
...
@@ -11569,6 +11569,9 @@
"unitScrollView": {
"__id__": 209
},
"loading": {
"__id__": 181
},
"_id": "07a4e3ps9Eh6nMMwqOJzdc"
},
{
...
...
assets/middleLayer_for_kyxq/script/HomePage.ts
View file @
2ec8b7f4
...
...
@@ -38,9 +38,10 @@ export default class NewClass extends cc.Component {
// 点击课程
handleClickCourseItem
()
{
handleClickCourseItem
(
pid
)
{
const
vc
=
this
.
Viewer
.
getComponent
(
"
PageViewer
"
);
vc
.
toView
(
"
UnitPage
"
,
"
rightIn
"
)
vc
.
unitPage
.
attr
({
syllabus_pid
:
pid
});
vc
.
toView
(
"
UnitPage
"
,
"
rightIn
"
);
}
// 获取课程清单
...
...
@@ -73,7 +74,7 @@ export default class NewClass extends cc.Component {
ci
.
active
=
true
;
ci
.
attr
({
syllabus_id
:
row
.
id
});
ci
.
on
(
"
click
"
,
()
=>
{
this
.
handleClickCourseItem
();
this
.
handleClickCourseItem
(
ci
[
`syllabus_id`
]
);
})
});
this
.
SvContent
.
addChild
(
ci
);
...
...
assets/middleLayer_for_kyxq/script/UnitPage.ts
View file @
2ec8b7f4
...
...
@@ -6,7 +6,7 @@
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import
{
getSprNodeByUrl
,
setSprNodeMaxLen
}
from
"
./util
"
;
import
{
getSprNodeByUrl
,
setSprNodeMaxLen
,
asyncCallNetworkApiGet
}
from
"
./util
"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
...
...
@@ -19,6 +19,9 @@ export default class NewClass extends cc.Component {
@
property
(
cc
.
Node
)
unitScrollView
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
loading
:
cc
.
Node
=
null
;
handleClickBackBtn
()
{
const
vc
=
this
.
Viewer
.
getComponent
(
"
PageViewer
"
);
vc
.
toView
(
"
HomePage
"
,
"
leftIn
"
)
...
...
@@ -28,15 +31,45 @@ export default class NewClass extends cc.Component {
// onLoad () {}
start
()
{
this
.
initView
();
async
start
()
{
this
.
loading
.
active
=
true
;
await
this
.
initView
();
this
.
loading
.
active
=
false
;
}
async
initView
()
{
await
this
.
initUnitListView
();
}
syllabusLockStatusStore
=
{};
// 课件是否解锁的存储对象 { 99343: 'locked', 19834: 'unlock' }
syllabusFinishedStore
=
{};
// 课件是否完成的存储对象 { 99343: 'finished', 19834: 'unfinish' }
async
getAndStoreSyllabusStatus
(
tree
)
{
const
oneFlow
=
[];
// 第一层需要获取解锁状态
const
twoFlow
=
[];
// 第二层需要获取完成状态
tree
.
forEach
(
item
=>
{
item
.
children
.
forEach
(
one
=>
{
oneFlow
.
push
(
one
.
id
);
one
.
children
.
forEach
(
two
=>
{
twoFlow
.
push
(
two
.
id
);
});
});
});
const
{
rows
}
=
await
asyncCallNetworkApiGet
(
`/api/kyxq/v1/user/syllabus/status`
,
{
syllabuses
:
[...
oneFlow
,
...
twoFlow
].
join
(
`,`
)});
for
(
let
i
=
0
;
i
<
rows
.
length
;
i
++
)
{
const
row
=
rows
[
i
];
if
(
oneFlow
.
includes
(
row
.
id
))
{
this
.
syllabusLockStatusStore
[
row
.
id
]
=
row
.
unlock
==
0
?
'
locked
'
:
'
unlock
'
;
}
if
(
twoFlow
.
includes
(
row
.
id
))
{
this
.
syllabusFinishedStore
[
row
.
id
]
=
row
.
end
==
0
?
'
unfinish
'
:
'
finished
'
;
}
}
initView
()
{
this
.
initUnitListView
();
}
initUnitListView
()
{
async
initUnitListView
()
{
const
dataBaseArr
=
[
[
...
...
@@ -94,7 +127,8 @@ export default class NewClass extends cc.Component {
const
dataArr
=
JSON
.
parse
(
JSON
.
stringify
(
dataBaseArr
))
// dataArr.length = Math.ceil( Math.random() * dataArr.length ); //随机显示几个假数据
const
{
rows
}
=
await
asyncCallNetworkApiGet
(
`/api/syllabus/v2/tree`
,
{
pid
:
this
.
node
[
'
syllabus_pid
'
],
deep
:
2
});
await
this
.
getAndStoreSyllabusStatus
(
rows
);
const
svNode
=
this
.
unitScrollView
;
...
...
@@ -102,7 +136,7 @@ export default class NewClass extends cc.Component {
view
.
width
=
svNode
.
width
;
view
.
height
=
svNode
.
height
;
const
itemArr
=
this
.
getUnitItemDataArr
(
dataArr
);
const
itemArr
=
this
.
getUnitItemDataArr
(
rows
);
const
sv
=
svNode
.
getComponent
(
cc
.
ScrollView
);
this
.
initScrollViewItem
(
sv
,
itemArr
,
1
);
...
...
@@ -126,7 +160,7 @@ export default class NewClass extends cc.Component {
itemNode
[
'
data
'
]
=
data
;
itemNode
.
removeAllChildren
();
const
subArr
=
data
;
const
subArr
=
data
.
children
;
const
baseX
=
subItem
.
x
;
const
baseY
=
subItem
.
y
;
...
...
@@ -143,7 +177,7 @@ export default class NewClass extends cc.Component {
const
subData
=
subArr
[
j
];
// console.log("subData: ", subData);
getSprNodeByUrl
(
subData
.
pic_url
,
(
spr
)
=>
{
getSprNodeByUrl
(
subData
.
cover
,
(
spr
)
=>
{
const
sprNode
=
spr
.
node
;
const
picLayer
=
cc
.
find
(
"
mask/pic_frame
"
,
subNode
);
...
...
@@ -174,22 +208,23 @@ export default class NewClass extends cc.Component {
}
// 为方便测试,先全部解锁
const
lockCover
=
cc
.
find
(
"
bg_cover_mask
"
,
subNode
);
const
isLock
=
Math
.
floor
(
Math
.
random
()
*
2
);
if
(
isLock
)
{
lockCover
.
active
=
true
;
}
else
{
lockCover
.
active
=
false
;
}
// 下面是正常解锁逻辑
// const unLock = this.syllabusLockStatusStore[subData.id]==='unlock';
// lockCover.active = !unLock;
// if (i==0&&j==0) {
// // 说明是第一个
// lockCover.active = false;
// }
subNode
.
addComponent
(
cc
.
Button
);
subNode
.
on
(
"
click
"
,
()
=>
{
const
vc
=
this
.
Viewer
.
getComponent
(
"
PageViewer
"
);
vc
.
toView
(
"
MissionPage
"
,
"
rightIn
"
)
})
}
const
labelNode
=
cc
.
instantiate
(
listLabel
);
...
...
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