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
fb2d8590
Commit
fb2d8590
authored
Nov 11, 2023
by
李维
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化首屏展示
parent
1da8f366
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
111 additions
and
64 deletions
+111
-64
HomePage.ts
assets/middleLayer_for_kyxq/script/HomePage.ts
+26
-28
LibraryAudioPage.ts
assets/middleLayer_for_kyxq/script/LibraryAudioPage.ts
+4
-1
LibraryPage.ts
assets/middleLayer_for_kyxq/script/LibraryPage.ts
+4
-1
LibraryReadDetailPage.ts
assets/middleLayer_for_kyxq/script/LibraryReadDetailPage.ts
+7
-11
LibraryReadPage.ts
assets/middleLayer_for_kyxq/script/LibraryReadPage.ts
+3
-1
LibraryVideoPage.ts
assets/middleLayer_for_kyxq/script/LibraryVideoPage.ts
+4
-1
LoginPage.ts
assets/middleLayer_for_kyxq/script/LoginPage.ts
+3
-2
MissionPage.ts
assets/middleLayer_for_kyxq/script/MissionPage.ts
+5
-6
PageComponentBase.ts
assets/middleLayer_for_kyxq/script/PageComponentBase.ts
+35
-0
PageComponentBase.ts.meta
assets/middleLayer_for_kyxq/script/PageComponentBase.ts.meta
+9
-0
PageViewer.ts
assets/middleLayer_for_kyxq/script/PageViewer.ts
+2
-2
UnitPage.ts
assets/middleLayer_for_kyxq/script/UnitPage.ts
+9
-11
No files found.
assets/middleLayer_for_kyxq/script/HomePage.ts
View file @
fb2d8590
import
{
asyncCallNetworkApiGet
,
asyncCallNetworkApiPost
,
getSpriteFrimeByUrl
,
playLocalAudio
,
playAudioByUrl
,
getSprNodeByUrl
,
asyncDelay
}
from
"
./util
"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
import
PageComponentBaseClass
from
"
./PageComponentBase
"
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
HomePageClass
extends
cc
.
Component
{
export
default
class
HomePageClass
extends
PageComponentBaseClass
{
@
property
(
cc
.
Node
)
Viewer
:
cc
.
Node
=
null
;
...
...
@@ -97,8 +99,8 @@ export default class HomePageClass extends cc.Component {
// 点击课程
handleClickCourseItem
(
pid
,
pData
)
{
const
vc
=
this
.
Viewer
.
getComponent
(
"
PageViewer
"
);
vc
.
unitPage
.
attr
({
syllabus_pid
:
pid
});
vc
.
unitPage
.
attr
({
pData
:
pData
});
vc
.
unitPage
.
attr
({
syllabus_pid
:
pid
});
vc
.
unitPage
.
attr
({
pData
:
pData
});
vc
.
toView
({
name
:
"
UnitPage
"
,
animation
:
"
rightIn
"
...
...
@@ -110,12 +112,12 @@ export default class HomePageClass extends cc.Component {
this
.
SvContent
.
removeAllChildren
();
this
.
loading
.
active
=
true
;
const
userInfo
=
this
.
userInfo
;
const
{
rows
}
=
await
asyncCallNetworkApiGet
(
'
/api/kyxq/v1/user/jclist
'
,
{
const
{
rows
}
=
await
asyncCallNetworkApiGet
(
'
/api/kyxq/v1/user/jclist
'
,
{
jc_arr
:
userInfo
.
jc_arr
,
});
// 无数据
if
(
rows
&&
rows
.
length
==
0
)
{
if
(
rows
&&
rows
.
length
==
0
)
{
this
.
loading
.
active
=
false
;
return
}
...
...
@@ -125,11 +127,11 @@ export default class HomePageClass extends cc.Component {
if
(
!
this
.
SvContent
[
'
baseH
'
])
{
this
.
SvContent
[
'
baseH
'
]
=
this
.
SvContent
.
height
;
this
.
SvContent
.
height
*=
canvas
.
height
/
1080
*
1.1
;
this
.
SvContent
.
parent
.
height
=
this
.
SvContent
.
height
*
1.2
;
this
.
SvContent
.
parent
.
height
=
this
.
SvContent
.
height
*
1.2
;
}
let
loadEndCount
=
0
;
for
(
let
i
=
0
;
i
<
rows
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
rows
.
length
;
i
++
)
{
const
row
=
rows
[
i
];
const
ci
=
cc
.
instantiate
(
this
.
CourseItem
);
cc
.
find
(
`progressText`
,
ci
).
getComponent
(
cc
.
Label
).
string
=
`学习进度:
${
row
.
process
}
`
;
...
...
@@ -139,10 +141,10 @@ export default class HomePageClass extends cc.Component {
if
(
b
==
0
)
{
cc
.
find
(
`progress`
,
ci
).
getComponent
(
cc
.
ProgressBar
).
progress
=
0
;
}
else
{
cc
.
find
(
`progress`
,
ci
).
getComponent
(
cc
.
ProgressBar
).
progress
=
Math
.
floor
(
a
/
b
*
10
)
/
10
;
cc
.
find
(
`progress`
,
ci
).
getComponent
(
cc
.
ProgressBar
).
progress
=
Math
.
floor
(
a
/
b
*
10
)
/
10
;
}
getSprNodeByUrl
(
row
.
cover
,
async
(
resSpr
)
=>
{
getSprNodeByUrl
(
row
.
cover
,
async
(
resSpr
)
=>
{
const
coverNode
=
cc
.
find
(
`bg`
,
ci
);
const
spr
=
coverNode
.
getComponent
(
cc
.
Sprite
);
...
...
@@ -152,19 +154,18 @@ export default class HomePageClass extends cc.Component {
spr
.
spriteFrame
=
resSpr
.
spriteFrame
;
ci
.
active
=
true
;
ci
.
attr
({
syllabus_id
:
row
.
id
});
ci
.
on
(
"
click
"
,
()
=>
{
ci
.
attr
({
syllabus_id
:
row
.
id
});
ci
.
on
(
"
click
"
,
()
=>
{
this
.
handleClickCourseItem
(
ci
[
`syllabus_id`
],
row
);
})
loadEndCount
++
;
loadEndCount
++
;
if
(
loadEndCount
==
rows
.
length
)
{
await
asyncDelay
(
0.01
);
this
.
SvContent
.
opacity
=
255
;
const
contentW
=
this
.
SvContent
.
getContentSize
().
width
;
if
(
contentW
<
canvas
.
width
)
{
// this.SvContent.x = 0;
this
.
SvContent
.
x
=
-
contentW
/
2
;
}
else
{
this
.
SvContent
.
x
=
-
canvas
.
width
/
2
;
...
...
@@ -182,7 +183,6 @@ export default class HomePageClass extends cc.Component {
}
// onLoad () {}
userInfo
;
async
getUserInfo
()
{
this
.
userInfo
=
null
;
...
...
@@ -232,16 +232,14 @@ export default class HomePageClass extends cc.Component {
bg
.
scale
=
Math
.
max
(
sx
,
sy
);
}
async
start
()
{
async
start
()
{
// 调用父类中的初始化页面生命周期钩子方法
super
.
initPageHook
(
this
.
node
);
this
.
initBg
();
// 注册PageViwer发来的beforeMounted事件 [页面即将被显示]
this
.
node
.
on
(
"
beforeMounted
"
,
this
.
beforeMounted
.
bind
(
this
));
// 注册PageViwer发来的mounted事件 [页面已经切换完毕]
this
.
node
.
on
(
"
mounted
"
,
this
.
mounted
.
bind
(
this
));
}
async
beforeMount
ed
()
{
async
beforeMount
()
{
this
.
SvContent
.
removeAllChildren
();
}
async
mounted
()
{
...
...
assets/middleLayer_for_kyxq/script/LibraryAudioPage.ts
View file @
fb2d8590
import
{
getSprNodeByUrl
,
setSprNodeMaxLen
,
asyncCallNetworkApiGet
}
from
"
./util
"
;
import
PageComponentBaseClass
from
"
./PageComponentBase
"
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
LibraryAudioPageClass
extends
cc
.
Component
{
export
default
class
LibraryAudioPageClass
extends
PageComponentBaseClass
{
@
property
(
cc
.
Node
)
Viewer
:
cc
.
Node
=
null
;
...
...
@@ -30,6 +31,8 @@ export default class LibraryAudioPageClass extends cc.Component {
// onLoad () {}
async
start
()
{
// 调用父类中的初始化页面生命周期钩子方法
super
.
initPageHook
(
this
.
node
);
this
.
initUI
()
this
.
loading
.
active
=
true
;
await
this
.
initData
();
...
...
assets/middleLayer_for_kyxq/script/LibraryPage.ts
View file @
fb2d8590
import
{
getSprNodeByUrl
,
setSprNodeMaxLen
,
asyncCallNetworkApiGet
}
from
"
./util
"
;
import
PageComponentBaseClass
from
"
./PageComponentBase
"
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
LibraryPageClass
extends
cc
.
Component
{
export
default
class
LibraryPageClass
extends
PageComponentBaseClass
{
@
property
(
cc
.
Node
)
Viewer
:
cc
.
Node
=
null
;
...
...
@@ -49,6 +50,8 @@ export default class LibraryPageClass extends cc.Component {
// onLoad () {}
async
start
()
{
// 调用父类中的初始化页面生命周期钩子方法
super
.
initPageHook
(
this
.
node
);
this
.
loading
.
active
=
true
;
await
this
.
initView
();
this
.
loading
.
active
=
false
;
...
...
assets/middleLayer_for_kyxq/script/LibraryReadDetailPage.ts
View file @
fb2d8590
import
{
getSprNodeByUrl
,
setSprNodeMaxLen
,
asyncCallNetworkApiGet
}
from
"
./util
"
;
import
PageComponentBaseClass
from
"
./PageComponentBase
"
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
LibraryReadDetailPageClass
extends
cc
.
Component
{
export
default
class
LibraryReadDetailPageClass
extends
PageComponentBaseClass
{
@
property
(
cc
.
Node
)
Viewer
:
cc
.
Node
=
null
;
...
...
@@ -48,15 +49,12 @@ export default class LibraryReadDetailPageClass extends cc.Component {
// onLoad () {}
// async start() {
// this.loading.active = true;
// await this.initData();
// this.initView();
// this.loading.active = false;
// }
async
start
()
{
// 调用父类中的初始化页面生命周期钩子方法
super
.
initPageHook
(
this
.
node
);
}
async
onEnable
()
{
// if (!this.m_isLoadData){
async
mounted
()
{
this
.
loading
.
active
=
true
;
this
.
scrollView
.
opacity
=
0
;
...
...
@@ -64,8 +62,6 @@ export default class LibraryReadDetailPageClass extends cc.Component {
this
.
initView
();
this
.
scrollView
.
opacity
=
255
;
this
.
loading
.
active
=
false
;
// }
}
async
initData
()
{
...
...
assets/middleLayer_for_kyxq/script/LibraryReadPage.ts
View file @
fb2d8590
import
{
getSprNodeByUrl
,
setSprNodeMaxLen
,
asyncCallNetworkApiGet
}
from
"
./util
"
;
import
PageComponentBaseClass
from
"
./PageComponentBase
"
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
LibraryReadPageClass
extends
cc
.
Component
{
export
default
class
LibraryReadPageClass
extends
PageComponentBaseClass
{
@
property
(
cc
.
Node
)
Viewer
:
cc
.
Node
=
null
;
...
...
@@ -28,6 +29,7 @@ export default class LibraryReadPageClass extends cc.Component {
// onLoad () {}
async
start
()
{
super
.
initPageHook
(
this
.
node
)
this
.
loading
.
active
=
true
;
this
.
scrollView
.
opacity
=
0
;
...
...
assets/middleLayer_for_kyxq/script/LibraryVideoPage.ts
View file @
fb2d8590
import
{
getSprNodeByUrl
,
setSprNodeMaxLen
,
asyncCallNetworkApiGet
}
from
"
./util
"
;
import
PageComponentBaseClass
from
"
./PageComponentBase
"
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
LibraryVideoPageClass
extends
cc
.
Component
{
export
default
class
LibraryVideoPageClass
extends
PageComponentBaseClass
{
@
property
(
cc
.
Node
)
Viewer
:
cc
.
Node
=
null
;
...
...
@@ -38,6 +39,8 @@ export default class LibraryVideoPageClass extends cc.Component {
// onLoad () {}
async
start
()
{
// 调用父类中的初始化页面生命周期钩子方法
super
.
initPageHook
(
this
.
node
);
this
.
initUI
()
this
.
loading
.
active
=
true
;
await
this
.
initData
();
...
...
assets/middleLayer_for_kyxq/script/LoginPage.ts
View file @
fb2d8590
...
...
@@ -6,11 +6,12 @@
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import
{
asyncCallNetworkApiPost
}
from
"
./util
"
;
import
PageComponentBaseClass
from
"
./PageComponentBase
"
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
LoginPageClass
extends
cc
.
Component
{
export
default
class
LoginPageClass
extends
PageComponentBaseClass
{
@
property
(
cc
.
Node
)
Viewer
:
cc
.
Node
=
null
;
...
...
@@ -42,7 +43,7 @@ export default class LoginPageClass extends cc.Component {
isAgreement
:
boolean
=
false
;
start
()
{
super
.
initPageHook
(
this
.
node
)
this
.
initData
();
this
.
initListener
();
this
.
initAnonymous
();
...
...
assets/middleLayer_for_kyxq/script/MissionPage.ts
View file @
fb2d8590
...
...
@@ -6,11 +6,12 @@
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import
{
getSprNodeByUrl
,
setSprNodeMaxLen
,
asyncCallNetworkApiGet
,
asyncCallNetworkApiPost
,
getSpriteFrimeByUrl
,
asyncDelay
}
from
"
./util
"
;
import
PageComponentBaseClass
from
"
./PageComponentBase
"
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
MissionPageClass
extends
cc
.
Component
{
export
default
class
MissionPageClass
extends
PageComponentBaseClass
{
@
property
(
cc
.
Node
)
Viewer
:
cc
.
Node
=
null
;
...
...
@@ -59,15 +60,13 @@ export default class MissionPageClass extends cc.Component {
// onLoad () {}
async
start
()
{
// 调用父类中的初始化页面生命周期钩子方法
super
.
initPageHook
(
this
.
node
);
this
.
initBg
()
this
.
userInfo
=
await
this
.
Viewer
.
getComponent
(
"
PageViewer
"
).
getUserInfo
();
// 注册PageViwer发来的beforeMounted事件[页面即将被显示]
this
.
node
.
on
(
"
beforeMounted
"
,
this
.
beforeMounted
.
bind
(
this
));
// 注册PageViwer发来的mounted事件[页面已经切换完毕]
this
.
node
.
on
(
"
mounted
"
,
this
.
mounted
.
bind
(
this
));
}
async
beforeMount
ed
()
{
async
beforeMount
()
{
const
sv
=
this
.
scrollView
.
getComponent
(
cc
.
ScrollView
);
const
content
=
sv
.
content
;
content
.
removeAllChildren
();
...
...
assets/middleLayer_for_kyxq/script/PageComponentBase.ts
0 → 100644
View file @
fb2d8590
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
PageComponentBaseClass
extends
cc
.
Component
{
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
start
()
{
}
initPageHook
(
node
:
cc
.
Node
)
{
// 注册PageViwer发来的beforeMount事件 [页面即将被显示]
node
.
on
(
"
beforeMount
"
,
()
=>
this
.
beforeMount
());
// 注册PageViwer发来的mounted事件 [页面已经切换完毕]
node
.
on
(
"
mounted
"
,
()
=>
this
.
mounted
());
// 注册PageViwer发来的unmounted事件 [页面已经切换完毕]
node
.
on
(
"
unmounted
"
,
()
=>
this
.
unmounted
());
}
// 页面即将被显示
beforeMount
()
{}
mounted
()
{}
unmounted
()
{}
// update (dt) {}
}
assets/middleLayer_for_kyxq/script/PageComponentBase.ts.meta
0 → 100644
View file @
fb2d8590
{
"ver": "1.0.8",
"uuid": "36d4682e-43c1-43aa-b84a-15435434d62a",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
assets/middleLayer_for_kyxq/script/PageViewer.ts
View file @
fb2d8590
...
...
@@ -151,8 +151,8 @@ export default class PageViewerClass extends cc.Component {
return
}
// 触发页面beforeMount
ed
生命周期
this
[
PageMap
[
viewName
]].
emit
(
"
beforeMount
ed
"
);
// 触发页面beforeMount生命周期
this
[
PageMap
[
viewName
]].
emit
(
"
beforeMount
"
);
// 切换页面
await
this
.
switchView
(
this
[
PageMap
[
viewName
]],
this
.
_currentViewNode
,
animation
);
this
.
_currentViewName
=
viewName
;
...
...
assets/middleLayer_for_kyxq/script/UnitPage.ts
View file @
fb2d8590
...
...
@@ -7,11 +7,12 @@
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import
{
getSprNodeByUrl
,
setSprNodeMaxLen
,
asyncCallNetworkApiGet
,
asyncDelay
}
from
"
./util
"
;
import
PageComponentBaseClass
from
"
./PageComponentBase
"
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
UnitPageClass
extends
cc
.
Component
{
export
default
class
UnitPageClass
extends
PageComponentBaseClass
{
@
property
(
cc
.
Node
)
Viewer
:
cc
.
Node
=
null
;
...
...
@@ -42,19 +43,16 @@ export default class UnitPageClass extends cc.Component {
// onLoad () {}
async
start
()
{
// 调用父类中的初始化页面生命周期钩子方法
super
.
initPageHook
(
this
.
node
);
this
.
initBg
();
this
.
listItem
=
cc
.
find
(
"
view/content/item
"
,
this
.
unitScrollView
);
this
.
node
.
on
(
"
beforeMounted
"
,
this
.
beforeMounted
.
bind
(
this
))
// 注册PageViwer发来的beforeMounted事件 [页面即将被显示]
this
.
node
.
on
(
"
beforeMounted
"
,
this
.
beforeMounted
.
bind
(
this
));
// 注册PageViwer发来的mounted事件 [页面已经切换完毕]
this
.
node
.
on
(
"
mounted
"
,
this
.
mounted
.
bind
(
this
));
// 注册PageViwer发来的unmounted事件 [页面已经切换完毕]
this
.
node
.
on
(
"
unmounted
"
,
this
.
unmounted
.
bind
(
this
));
}
async
beforeMounted
()
{
// 页面即将显示
async
beforeMount
()
{
this
.
isDestory
=
false
;
const
svNode
=
this
.
unitScrollView
;
const
sv
=
svNode
.
getComponent
(
cc
.
ScrollView
);
...
...
@@ -62,12 +60,12 @@ export default class UnitPageClass extends cc.Component {
content
.
removeAllChildren
();
}
//
监听页面挂载时间
//
页面显示
async
mounted
()
{
await
this
.
initView
();
}
// 页面
切换走
// 页面
隐藏
isDestory
=
false
;
async
unmounted
()
{
const
sv
=
cc
.
find
(
"
middleLayer/Views/UnitPage/unit_list_node/scrollView
"
)
...
...
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