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
cae7f496
Commit
cae7f496
authored
Nov 09, 2023
by
李维
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复切换时偶现的背景消失的问题
parent
c5d5ac15
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
302 additions
and
300 deletions
+302
-300
MissionPage.ts
assets/middleLayer_for_kyxq/script/MissionPage.ts
+3
-2
UnitPage.ts
assets/middleLayer_for_kyxq/script/UnitPage.ts
+299
-298
No files found.
assets/middleLayer_for_kyxq/script/MissionPage.ts
View file @
cae7f496
...
...
@@ -198,7 +198,7 @@ export default class NewClass extends cc.Component {
initCustomBg
(
bg_image_url
)
{
console
.
log
(
"
Iniit
"
,
bg_image_url
)
if
(
!
bg_image_url
)
{
if
(
!
bg_image_url
)
{
// 没有背景图 还原默认图
cc
.
find
(
"
bg/bg_default
"
,
this
.
node
).
active
=
true
;
cc
.
find
(
"
bg/bg
"
,
this
.
node
).
active
=
false
;
...
...
@@ -206,12 +206,13 @@ export default class NewClass extends cc.Component {
}
const
canvas
=
cc
.
find
(
"
Canvas
"
);
const
bg
=
cc
.
find
(
"
bg/bg
"
,
this
.
node
);
getSprNodeByUrl
(
bg_image_url
,
(
sf
)
=>
{
getSprNodeByUrl
(
bg_image_url
,
(
sf
)
=>
{
const
sx
=
canvas
.
width
/
sf
.
node
.
width
;
const
sy
=
canvas
.
height
/
sf
.
node
.
height
;
bg
.
getComponent
(
cc
.
Sprite
).
spriteFrame
=
sf
.
spriteFrame
;
bg
.
scale
=
Math
.
max
(
sx
,
sy
);
cc
.
find
(
"
bg/bg_default
"
,
this
.
node
).
active
=
false
;
cc
.
find
(
"
bg/bg
"
,
this
.
node
).
active
=
true
;
})
}
...
...
assets/middleLayer_for_kyxq/script/UnitPage.ts
View file @
cae7f496
...
...
@@ -8,333 +8,334 @@
import
{
getSprNodeByUrl
,
setSprNodeMaxLen
,
asyncCallNetworkApiGet
,
asyncDelay
}
from
"
./util
"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
NewClass
extends
cc
.
Component
{
@
property
(
cc
.
Node
)
Viewer
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
Viewer
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
unitScrollView
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
unitScrollView
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
loading
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
loading
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
btn_preview
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
btn_works
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
btn_preview
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
btn_works
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
LessonBrief
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
LessonBrief
:
cc
.
Node
=
null
;
handleClickBackBtn
()
{
const
vc
=
this
.
Viewer
.
getComponent
(
"
PageViewer
"
);
vc
.
toView
(
"
HomePage
"
,
"
leftIn
"
)
}
handleClickBackBtn
()
{
const
vc
=
this
.
Viewer
.
getComponent
(
"
PageViewer
"
);
vc
.
toView
(
"
HomePage
"
,
"
leftIn
"
)
}
// LIFE-CYCLE CALLBACKS:
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
// onLoad () {}
async
start
()
{
this
.
initBg
();
this
.
listItem
=
cc
.
find
(
"
view/content/item
"
,
this
.
unitScrollView
);
}
async
start
()
{
this
.
initBg
();
this
.
listItem
=
cc
.
find
(
"
view/content/item
"
,
this
.
unitScrollView
);
}
async
onEnable
()
{
await
this
.
initView
();
}
async
initView
()
{
this
.
loading
.
active
=
true
;
this
.
initTitle
();
await
this
.
initUnitListView
();
this
.
loading
.
active
=
false
;
}
async
onEnable
()
{
await
this
.
initView
();
}
initBg
()
{
const
canvas
=
cc
.
find
(
"
Canvas
"
);
const
bg
=
cc
.
find
(
"
bg/bg_default
"
,
this
.
node
);
const
sx
=
canvas
.
width
/
bg
.
width
;
const
sy
=
canvas
.
height
/
bg
.
height
;
bg
.
scale
=
Math
.
max
(
sx
,
sy
);
}
initCustomBg
(
bg_image_url
)
{
if
(
!
bg_image_url
)
{
// 没有背景图 还原默认图
cc
.
find
(
"
bg/bg_default
"
,
this
.
node
).
active
=
true
;
cc
.
find
(
"
bg/bg
"
,
this
.
node
).
active
=
false
;
return
}
const
canvas
=
cc
.
find
(
"
Canvas
"
);
const
bg
=
cc
.
find
(
"
bg/bg
"
,
this
.
node
);
getSprNodeByUrl
(
bg_image_url
,
(
sf
)
=>
{
const
sx
=
canvas
.
width
/
sf
.
node
.
width
;
const
sy
=
canvas
.
height
/
sf
.
node
.
height
;
bg
.
getComponent
(
cc
.
Sprite
).
spriteFrame
=
sf
.
spriteFrame
;
bg
.
scale
=
Math
.
max
(
sx
,
sy
);
cc
.
find
(
"
bg/bg_default
"
,
this
.
node
).
active
=
false
;
})
}
async
initView
()
{
this
.
loading
.
active
=
true
;
this
.
initTitle
();
await
this
.
initUnitListView
();
this
.
loading
.
active
=
false
;
}
initBg
()
{
const
canvas
=
cc
.
find
(
"
Canvas
"
);
const
bg
=
cc
.
find
(
"
bg/bg_default
"
,
this
.
node
);
async
initTitle
()
{
const
titleLabelNode
=
cc
.
find
(
"
bg/bg_title/label
"
,
this
.
node
)
;
const
titleLabel
=
titleLabelNode
.
getComponent
(
cc
.
Label
);
titleLabel
.
string
=
this
.
node
[
'
pData
'
].
name
;
const
sx
=
canvas
.
width
/
bg
.
width
;
const
sy
=
canvas
.
height
/
bg
.
height
;
bg
.
scale
=
Math
.
max
(
sx
,
sy
);
}
const
bgTitle
=
titleLabelNode
.
parent
;
if
(
!
bgTitle
[
'
baseW
'
])
{
bgTitle
[
'
baseW
'
]
=
bgTitle
.
width
;
}
const
baseW
=
bgTitle
[
'
baseW
'
];
await
asyncDelay
(
0.01
);
if
(
titleLabelNode
.
width
*
1.2
>
baseW
)
{
bgTitle
.
width
=
titleLabelNode
.
width
*
1.2
;
// titleLabelNode.scale = baswW * 0.9 / titleLabelNode.width;
}
else
{
bgTitle
.
width
=
baseW
;
}
initCustomBg
(
bg_image_url
)
{
if
(
!
bg_image_url
)
{
// 没有背景图 还原默认图
cc
.
find
(
"
bg/bg_default
"
,
this
.
node
).
active
=
true
;
cc
.
find
(
"
bg/bg
"
,
this
.
node
).
active
=
false
;
return
}
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
canvas
=
cc
.
find
(
"
Canvas
"
);
const
bg
=
cc
.
find
(
"
bg/bg
"
,
this
.
node
);
getSprNodeByUrl
(
bg_image_url
,
(
sf
)
=>
{
const
sx
=
canvas
.
width
/
sf
.
node
.
width
;
const
sy
=
canvas
.
height
/
sf
.
node
.
height
;
bg
.
getComponent
(
cc
.
Sprite
).
spriteFrame
=
sf
.
spriteFrame
;
bg
.
scale
=
Math
.
max
(
sx
,
sy
);
cc
.
find
(
"
bg/bg_default
"
,
this
.
node
).
active
=
false
;
cc
.
find
(
"
bg/bg
"
,
this
.
node
).
active
=
true
;
})
}
async
initTitle
()
{
const
titleLabelNode
=
cc
.
find
(
"
bg/bg_title/label
"
,
this
.
node
);
const
titleLabel
=
titleLabelNode
.
getComponent
(
cc
.
Label
);
titleLabel
.
string
=
this
.
node
[
'
pData
'
].
name
;
const
bgTitle
=
titleLabelNode
.
parent
;
if
(
!
bgTitle
[
'
baseW
'
])
{
bgTitle
[
'
baseW
'
]
=
bgTitle
.
width
;
}
const
baseW
=
bgTitle
[
'
baseW
'
];
await
asyncDelay
(
0.01
);
if
(
titleLabelNode
.
width
*
1.2
>
baseW
)
{
bgTitle
.
width
=
titleLabelNode
.
width
*
1.2
;
// titleLabelNode.scale = baswW * 0.9 / titleLabelNode.width;
}
else
{
bgTitle
.
width
=
baseW
;
}
}
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
'
;
}
}
});
});
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
'
;
}
}
configData
=
[]
async
initUnitListView
()
{
const
svNode
=
this
.
unitScrollView
;
svNode
.
opacity
=
0
;
const
resData
=
await
this
.
Viewer
.
getComponent
(
"
PageViewer
"
).
getSyllabusTreeByPid
(
this
.
node
[
'
syllabus_pid
'
])
let
rows
=
[]
this
.
configData
=
null
let
bgImageUrl
=
null
;
for
(
let
v
of
resData
.
rows
)
{
if
(
v
.
name
==
"
config
"
)
{
// 课程配置文件
const
_strData
=
(
v
.
children
&&
v
.
children
[
0
]
&&
v
.
children
[
0
].
template_name
==
"
sn_config
"
&&
v
.
children
[
0
].
data
)
?
v
.
children
&&
v
.
children
[
0
]
&&
v
.
children
[
0
].
data
:
"
{}
"
this
.
configData
=
JSON
.
parse
(
_strData
)
bgImageUrl
=
this
.
configData
.
bg_image_url
}
else
{
// 课程数据
rows
.
push
(
v
)
}
}
if
(
rows
.
length
==
0
)
{
const
svNode
=
this
.
unitScrollView
;
const
sv
=
svNode
.
getComponent
(
cc
.
ScrollView
);
const
content
=
sv
.
content
;
content
.
removeAllChildren
();
return
;
}
this
.
initCustomBg
(
bgImageUrl
);
await
this
.
getAndStoreSyllabusStatus
(
rows
);
// const svNode = this.unitScrollView;
const
view
=
cc
.
find
(
"
view
"
,
svNode
);
view
.
width
=
svNode
.
width
;
view
.
height
=
svNode
.
height
;
const
itemArr
=
this
.
getUnitItemDataArr
(
rows
);
const
sv
=
svNode
.
getComponent
(
cc
.
ScrollView
);
this
.
initScrollViewItem
(
sv
,
itemArr
,
1
);
const
content
=
sv
.
content
;
const
canvas
=
cc
.
find
(
"
Canvas
"
);
if
(
content
.
width
>
canvas
.
width
)
{
content
.
x
=
-
canvas
.
width
/
2
;
}
else
{
content
.
x
=
-
content
.
width
/
2
;
}
svNode
.
opacity
=
255
;
this
.
refreshConfig
()
}
configData
=
[]
async
initUnitListView
()
{
const
svNode
=
this
.
unitScrollView
;
svNode
.
opacity
=
0
;
const
resData
=
await
this
.
Viewer
.
getComponent
(
"
PageViewer
"
).
getSyllabusTreeByPid
(
this
.
node
[
'
syllabus_pid
'
])
let
rows
=
[]
this
.
configData
=
null
let
bgImageUrl
=
null
;
for
(
let
v
of
resData
.
rows
)
{
if
(
v
.
name
==
"
config
"
)
{
// 课程配置文件
const
_strData
=
(
v
.
children
&&
v
.
children
[
0
]
&&
v
.
children
[
0
].
template_name
==
"
sn_config
"
&&
v
.
children
[
0
].
data
)
?
v
.
children
&&
v
.
children
[
0
]
&&
v
.
children
[
0
].
data
:
"
{}
"
this
.
configData
=
JSON
.
parse
(
_strData
)
bgImageUrl
=
this
.
configData
.
bg_image_url
}
else
{
// 课程数据
rows
.
push
(
v
)
}
}
// 刷新右上角“课程简介”按钮显示隐藏
refreshConfig
()
{
if
(
this
.
configData
&&
this
.
configData
.
introduces
.
length
>
0
)
{
this
.
btn_preview
.
active
=
true
}
else
{
this
.
btn_preview
.
active
=
false
}
if
(
rows
.
length
==
0
)
{
const
svNode
=
this
.
unitScrollView
;
const
sv
=
svNode
.
getComponent
(
cc
.
ScrollView
);
const
content
=
sv
.
content
;
content
.
removeAllChildren
();
return
;
}
listItem
;
getUnitItemDataArr
(
dataArr
)
{
let
listItem
=
this
.
listItem
;
let
subItem
=
cc
.
find
(
"
sub_item
"
,
listItem
);
let
listLabel
=
cc
.
find
(
"
label
"
,
listItem
);
const
itemArr
=
[];
for
(
let
i
=
0
;
i
<
dataArr
.
length
;
i
++
)
{
const
data
=
dataArr
[
i
];
const
itemNode
=
cc
.
instantiate
(
listItem
);
itemNode
[
'
data
'
]
=
data
;
itemNode
.
removeAllChildren
();
const
subArr
=
data
.
children
;
const
baseX
=
subItem
.
x
;
const
baseY
=
subItem
.
y
;
const
disX
=
530
;
let
lastX
=
0
;
for
(
let
j
=
0
;
j
<
subArr
.
length
;
j
++
)
{
const
subNode
=
cc
.
instantiate
(
subItem
)
subNode
.
x
=
baseX
+
j
*
disX
;
subNode
.
y
=
baseY
;
itemNode
.
addChild
(
subNode
);
lastX
=
subNode
.
x
;
const
subData
=
subArr
[
j
];
getSprNodeByUrl
(
subData
.
cover
,
(
spr
)
=>
{
const
sprNode
=
spr
.
node
;
const
picLayer
=
cc
.
find
(
"
mask/pic_frame
"
,
subNode
);
picLayer
.
addChild
(
sprNode
);
setSprNodeMaxLen
(
sprNode
,
picLayer
.
width
,
picLayer
.
height
,
true
);
})
const
pointBase
=
cc
.
find
(
"
point
"
,
subNode
);
const
pointLayer
=
cc
.
find
(
"
pint_layer
"
,
subNode
);
const
pointDisX
=
57
;
pointBase
.
opacity
=
0
;
for
(
let
k
=
0
;
k
<
8
;
k
++
)
{
const
clsData
=
subData
.
children
[
k
];
const
pointNode
=
cc
.
instantiate
(
pointBase
);
pointNode
.
opacity
=
255
;
if
(
clsData
)
{
const
finished
=
this
.
syllabusLockStatusStore
[
clsData
.
id
]
===
'
finished
'
;
if
(
!
finished
)
{
const
finishIcon
=
cc
.
find
(
"
blue
"
,
pointNode
);
finishIcon
.
active
=
false
;
}
}
else
{
const
finishIcon
=
cc
.
find
(
"
blue
"
,
pointNode
);
finishIcon
.
active
=
false
;
}
pointLayer
.
addChild
(
pointNode
);
pointNode
.
x
=
pointBase
.
x
+
k
*
pointDisX
;
}
// 为方便测试,先全部解锁
const
lockCover
=
cc
.
find
(
"
bg_cover_mask
"
,
subNode
);
lockCover
.
active
=
false
;
// 下面是正常解锁逻辑
// const unLock = this.syllabusLockStatusStore[subData.id]==='unlock';
// lockCover.active = !unLock;
// if (i==0&&j==0) {
// // 说明是第一个
// lockCover.active = false;
// }
const
labelNode
=
cc
.
find
(
"
label
"
,
subNode
);
const
label
=
labelNode
.
getComponent
(
cc
.
Label
);
label
.
string
=
subData
.
name
;
subNode
.
addComponent
(
cc
.
Button
);
subNode
.
on
(
"
click
"
,
()
=>
{
const
vc
=
this
.
Viewer
.
getComponent
(
"
PageViewer
"
);
vc
.
missionPage
.
attr
({
syllabus_pid
:
subData
.
id
});
vc
.
missionPage
.
attr
({
pData
:
subData
});
vc
.
toView
(
"
MissionPage
"
,
"
rightIn
"
)
})
}
const
labelNode
=
cc
.
instantiate
(
listLabel
);
const
label
=
labelNode
.
getComponent
(
cc
.
Label
);
label
.
string
=
data
.
name
//"Unit " + (i + 1);
itemNode
.
addChild
(
labelNode
);
// if (subArr.length > 2) {
itemNode
.
width
=
lastX
+
360
;
setTimeout
(()
=>
{
itemNode
.
width
=
lastX
+
360
;
},
1
);
// }
itemArr
.
push
(
itemNode
);
}
return
itemArr
;
this
.
initCustomBg
(
bgImageUrl
);
await
this
.
getAndStoreSyllabusStatus
(
rows
);
// const svNode = this.unitScrollView;
const
view
=
cc
.
find
(
"
view
"
,
svNode
);
view
.
width
=
svNode
.
width
;
view
.
height
=
svNode
.
height
;
const
itemArr
=
this
.
getUnitItemDataArr
(
rows
);
const
sv
=
svNode
.
getComponent
(
cc
.
ScrollView
);
this
.
initScrollViewItem
(
sv
,
itemArr
,
1
);
const
content
=
sv
.
content
;
const
canvas
=
cc
.
find
(
"
Canvas
"
);
if
(
content
.
width
>
canvas
.
width
)
{
content
.
x
=
-
canvas
.
width
/
2
;
}
else
{
content
.
x
=
-
content
.
width
/
2
;
}
initScrollViewItem
(
sv
,
itemArr
,
row
=
1
)
{
sv
.
scrollToTop
();
const
content
=
sv
.
content
;
content
.
width
=
sv
.
node
.
width
;
content
.
height
=
sv
.
node
.
height
;
content
.
removeAllChildren
();
const
tempH
=
content
.
height
/
row
;
const
disY
=
tempH
*
0.95
;
const
baseY
=
(
row
-
1
)
*
0.5
*
disY
;
let
rowCount
=
0
;
const
disX
=
40
;
let
colCount
=
0
;
let
lastX
=
0
;
for
(
let
i
=
0
;
i
<
itemArr
.
length
;
i
++
)
{
const
item
=
itemArr
[
i
];
item
.
x
=
lastX
+
disX
;
item
.
y
=
baseY
-
rowCount
*
disY
;
lastX
=
item
.
x
+
item
.
width
*
item
.
scale
;
content
.
addChild
(
itemArr
[
i
]);
const
tempW
=
Math
.
abs
(
item
.
x
+
disX
+
item
.
width
/
2
*
item
.
scale
);
content
.
width
=
lastX
+
disX
;
rowCount
++
;
if
(
rowCount
>=
row
)
{
rowCount
=
0
;
colCount
++
;
}
}
}
onClickPreview
()
{
this
.
LessonBrief
.
active
=
true
this
.
LessonBrief
.
getComponent
(
"
LessonBrief
"
).
setData
(
this
.
configData
.
introduces
)
this
.
LessonBrief
.
getComponent
(
"
LessonBrief
"
).
refreshUI
()
svNode
.
opacity
=
255
;
this
.
refreshConfig
()
}
// 刷新右上角“课程简介”按钮显示隐藏
refreshConfig
()
{
if
(
this
.
configData
&&
this
.
configData
.
introduces
.
length
>
0
)
{
this
.
btn_preview
.
active
=
true
}
else
{
this
.
btn_preview
.
active
=
false
}
}
listItem
;
getUnitItemDataArr
(
dataArr
)
{
let
listItem
=
this
.
listItem
;
let
subItem
=
cc
.
find
(
"
sub_item
"
,
listItem
);
let
listLabel
=
cc
.
find
(
"
label
"
,
listItem
);
const
itemArr
=
[];
for
(
let
i
=
0
;
i
<
dataArr
.
length
;
i
++
)
{
const
data
=
dataArr
[
i
];
const
itemNode
=
cc
.
instantiate
(
listItem
);
itemNode
[
'
data
'
]
=
data
;
itemNode
.
removeAllChildren
();
const
subArr
=
data
.
children
;
const
baseX
=
subItem
.
x
;
const
baseY
=
subItem
.
y
;
const
disX
=
530
;
let
lastX
=
0
;
for
(
let
j
=
0
;
j
<
subArr
.
length
;
j
++
)
{
const
subNode
=
cc
.
instantiate
(
subItem
)
subNode
.
x
=
baseX
+
j
*
disX
;
subNode
.
y
=
baseY
;
itemNode
.
addChild
(
subNode
);
lastX
=
subNode
.
x
;
const
subData
=
subArr
[
j
];
getSprNodeByUrl
(
subData
.
cover
,
(
spr
)
=>
{
const
sprNode
=
spr
.
node
;
const
picLayer
=
cc
.
find
(
"
mask/pic_frame
"
,
subNode
);
picLayer
.
addChild
(
sprNode
);
setSprNodeMaxLen
(
sprNode
,
picLayer
.
width
,
picLayer
.
height
,
true
);
})
onClickMyWork
(
evt
:
cc
.
Event
)
{
const
syllabusId
=
this
.
node
[
'
syllabus_pid
'
]
if
(
!
syllabusId
)
{
global
.
middleLayer
.
showTips
(
`未制作`
);
return
;
const
pointBase
=
cc
.
find
(
"
point
"
,
subNode
);
const
pointLayer
=
cc
.
find
(
"
pint_layer
"
,
subNode
);
const
pointDisX
=
57
;
pointBase
.
opacity
=
0
;
for
(
let
k
=
0
;
k
<
8
;
k
++
)
{
const
clsData
=
subData
.
children
[
k
];
const
pointNode
=
cc
.
instantiate
(
pointBase
);
pointNode
.
opacity
=
255
;
if
(
clsData
)
{
const
finished
=
this
.
syllabusLockStatusStore
[
clsData
.
id
]
===
'
finished
'
;
if
(
!
finished
)
{
const
finishIcon
=
cc
.
find
(
"
blue
"
,
pointNode
);
finishIcon
.
active
=
false
;
}
}
else
{
const
finishIcon
=
cc
.
find
(
"
blue
"
,
pointNode
);
finishIcon
.
active
=
false
;
}
pointLayer
.
addChild
(
pointNode
);
pointNode
.
x
=
pointBase
.
x
+
k
*
pointDisX
;
}
const
vc
=
this
.
Viewer
.
getComponent
(
"
PageViewer
"
);
vc
[
`libraryVideoPage`
].
attr
({
syllabus_pid
:
this
.
node
[
'
syllabus_pid
'
],
showMyWork
:
true
});
vc
[
`libraryVideoPage`
].
attr
({
fromPage
:
"
UnitPage
"
});
vc
.
toView
(
`LibraryVideoPage`
,
"
rightIn
"
);
// 为方便测试,先全部解锁
const
lockCover
=
cc
.
find
(
"
bg_cover_mask
"
,
subNode
);
lockCover
.
active
=
false
;
// 下面是正常解锁逻辑
// const unLock = this.syllabusLockStatusStore[subData.id]==='unlock';
// lockCover.active = !unLock;
// if (i==0&&j==0) {
// // 说明是第一个
// lockCover.active = false;
// }
const
labelNode
=
cc
.
find
(
"
label
"
,
subNode
);
const
label
=
labelNode
.
getComponent
(
cc
.
Label
);
label
.
string
=
subData
.
name
;
subNode
.
addComponent
(
cc
.
Button
);
subNode
.
on
(
"
click
"
,
()
=>
{
const
vc
=
this
.
Viewer
.
getComponent
(
"
PageViewer
"
);
vc
.
missionPage
.
attr
({
syllabus_pid
:
subData
.
id
});
vc
.
missionPage
.
attr
({
pData
:
subData
});
vc
.
toView
(
"
MissionPage
"
,
"
rightIn
"
)
})
}
const
labelNode
=
cc
.
instantiate
(
listLabel
);
const
label
=
labelNode
.
getComponent
(
cc
.
Label
);
label
.
string
=
data
.
name
//"Unit " + (i + 1);
itemNode
.
addChild
(
labelNode
);
// if (subArr.length > 2) {
itemNode
.
width
=
lastX
+
360
;
setTimeout
(()
=>
{
itemNode
.
width
=
lastX
+
360
;
},
1
);
// }
itemArr
.
push
(
itemNode
);
}
return
itemArr
;
}
initScrollViewItem
(
sv
,
itemArr
,
row
=
1
)
{
sv
.
scrollToTop
();
const
content
=
sv
.
content
;
content
.
width
=
sv
.
node
.
width
;
content
.
height
=
sv
.
node
.
height
;
content
.
removeAllChildren
();
const
tempH
=
content
.
height
/
row
;
const
disY
=
tempH
*
0.95
;
const
baseY
=
(
row
-
1
)
*
0.5
*
disY
;
let
rowCount
=
0
;
const
disX
=
40
;
let
colCount
=
0
;
let
lastX
=
0
;
for
(
let
i
=
0
;
i
<
itemArr
.
length
;
i
++
)
{
const
item
=
itemArr
[
i
];
item
.
x
=
lastX
+
disX
;
item
.
y
=
baseY
-
rowCount
*
disY
;
lastX
=
item
.
x
+
item
.
width
*
item
.
scale
;
content
.
addChild
(
itemArr
[
i
]);
const
tempW
=
Math
.
abs
(
item
.
x
+
disX
+
item
.
width
/
2
*
item
.
scale
);
content
.
width
=
lastX
+
disX
;
rowCount
++
;
if
(
rowCount
>=
row
)
{
rowCount
=
0
;
colCount
++
;
}
}
}
onClickPreview
()
{
this
.
LessonBrief
.
active
=
true
this
.
LessonBrief
.
getComponent
(
"
LessonBrief
"
).
setData
(
this
.
configData
.
introduces
)
this
.
LessonBrief
.
getComponent
(
"
LessonBrief
"
).
refreshUI
()
}
onClickMyWork
(
evt
:
cc
.
Event
)
{
const
syllabusId
=
this
.
node
[
'
syllabus_pid
'
]
if
(
!
syllabusId
)
{
global
.
middleLayer
.
showTips
(
`未制作`
);
return
;
}
// update (dt) {}
const
vc
=
this
.
Viewer
.
getComponent
(
"
PageViewer
"
);
vc
[
`libraryVideoPage`
].
attr
({
syllabus_pid
:
this
.
node
[
'
syllabus_pid
'
],
showMyWork
:
true
});
vc
[
`libraryVideoPage`
].
attr
({
fromPage
:
"
UnitPage
"
});
vc
.
toView
(
`LibraryVideoPage`
,
"
rightIn
"
);
}
// update (dt) {}
}
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