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
47e23185
Commit
47e23185
authored
Oct 27, 2023
by
limingzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: debug
parent
a1db9c7b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
97 additions
and
20 deletions
+97
-20
middleLayer_for_kyxq.fire
assets/middleLayer_for_kyxq/scene/middleLayer_for_kyxq.fire
+7
-4
HomePage.ts
assets/middleLayer_for_kyxq/script/HomePage.ts
+90
-16
No files found.
assets/middleLayer_for_kyxq/scene/middleLayer_for_kyxq.fire
View file @
47e23185
...
...
@@ -4639,7 +4639,7 @@
},
{
"__type__": "cc.Node",
"_name": "icon
_present
",
"_name": "icon",
"_objFlags": 0,
"_parent": {
"__id__": 95
...
...
@@ -4733,7 +4733,7 @@
},
{
"__type__": "cc.Node",
"_name": "
num
",
"_name": "
gold
",
"_objFlags": 0,
"_parent": {
"__id__": 95
...
...
@@ -7444,7 +7444,7 @@
},
{
"__type__": "cc.Node",
"_name": "
phone_
label",
"_name": "label",
"_objFlags": 0,
"_parent": {
"__id__": 152
...
...
@@ -7736,7 +7736,7 @@
},
{
"__type__": "cc.Node",
"_name": "
phone_
label",
"_name": "label",
"_objFlags": 0,
"_parent": {
"__id__": 158
...
...
@@ -9724,6 +9724,9 @@
"userPage": {
"__id__": 134
},
"topUserPanel": {
"__id__": 88
},
"CourseItem": {
"__id__": 119
},
...
...
assets/middleLayer_for_kyxq/script/HomePage.ts
View file @
47e23185
...
...
@@ -12,6 +12,9 @@ export default class NewClass extends cc.Component {
@
property
(
cc
.
Node
)
userPage
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
topUserPanel
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
CourseItem
:
cc
.
Node
=
null
;
...
...
@@ -30,8 +33,42 @@ export default class NewClass extends cc.Component {
handleClickUserCenter
()
{
this
.
userPage
.
active
=
true
;
// const vc = this.Viewer.getComponent("PageViewer");
// vc.toView("UserPage", "topIn")
this
.
refreshUserPage
();
}
userPagePanel
;
userPageName
;
userPagePhone
;
userPageGold
;
userPageClass
;
userPageTeacher
;
userPageTime
;
userPageVersion
;
async
refreshUserPage
()
{
if
(
!
this
.
userPagePanel
)
{
this
.
userPagePanel
=
cc
.
find
(
"
user_info/panel
"
,
this
.
userPage
);
this
.
userPageName
=
cc
.
find
(
"
left_part/name_label
"
,
this
.
userPagePanel
).
getComponent
(
cc
.
Label
);
this
.
userPagePhone
=
cc
.
find
(
"
left_part/phone_bg/label
"
,
this
.
userPagePanel
).
getComponent
(
cc
.
Label
);
this
.
userPageGold
=
cc
.
find
(
"
left_part/gold_bg/label
"
,
this
.
userPagePanel
).
getComponent
(
cc
.
Label
);
this
.
userPageVersion
=
cc
.
find
(
"
left_part/version_label
"
,
this
.
userPagePanel
).
getComponent
(
cc
.
Label
);
this
.
userPageClass
=
cc
.
find
(
"
right_part/class/label
"
,
this
.
userPagePanel
).
getComponent
(
cc
.
Label
);
this
.
userPageTeacher
=
cc
.
find
(
"
right_part/teacher/label
"
,
this
.
userPagePanel
).
getComponent
(
cc
.
Label
);
this
.
userPageTime
=
cc
.
find
(
"
right_part/time/label
"
,
this
.
userPagePanel
).
getComponent
(
cc
.
Label
);
}
this
.
userPageName
.
string
=
this
.
userInfo
.
nick_name
;
this
.
userPagePhone
.
string
=
this
.
userInfo
.
phone
;
this
.
userPageGold
.
string
=
this
.
userInfo
.
golds
;
this
.
userPageClass
.
string
=
this
.
userInfo
.
class_name
||
'
--
'
;
this
.
userPageTeacher
.
string
=
this
.
userInfo
.
tea_name
||
'
--
'
;
this
.
userPageTime
.
string
=
this
.
formatDate
(
new
Date
(
this
.
userInfo
.
create_at
));
const
engineInfo
=
await
global
.
middleLayer
.
getEngineInfo
();
this
.
userPageVersion
.
string
=
'
v
'
+
engineInfo
.
version
;
}
// 点击资源库
...
...
@@ -97,27 +134,69 @@ export default class NewClass extends cc.Component {
// onLoad () {}
userInfo
;
async
getUserInfo
()
{
this
.
userInfo
=
await
global
.
middleLayer
.
getUserInfo
();
console
.
log
(
"
userInfo:
"
,
this
.
userInfo
);
this
.
initTopUserPanel
();
// const token = cc.sys.localStorage.getItem('token');
// if (!token) {
// console.log('token not exist!');
// return;
// } else {
// console.log('token: ', token);
// }
// const resData = await asyncCallNetworkApiGet('/api/kyxq/v1/user/info', {token});
// console.log("userInfo: ", resData);
// this.userInfo = resData;
}
// const userInfo = await global.middleLayer.getUserInfo();
nameLabel
;
goldLabel
;
initTopUserPanel
()
{
const
token
=
cc
.
sys
.
localStorage
.
getItem
(
'
token
'
);
if
(
!
token
)
{
console
.
log
(
'
token not exist!
'
);
if
(
!
this
.
userInfo
)
{
return
;
}
if
(
!
this
.
nameLabel
)
{
const
nameLabelNode
=
cc
.
find
(
"
userName
"
,
this
.
topUserPanel
);
const
goldLabelNode
=
cc
.
find
(
"
userPoints/gold
"
,
this
.
topUserPanel
);
this
.
nameLabel
=
nameLabelNode
.
getComponent
(
cc
.
Label
);
this
.
goldLabel
=
goldLabelNode
.
getComponent
(
cc
.
Label
);
}
this
.
nameLabel
.
string
=
this
.
userInfo
.
nick_name
;
this
.
goldLabel
.
string
=
this
.
userInfo
.
golds
;
}
const
resData
=
await
asyncCallNetworkApiGet
(
'
/api/kyxq/v1/user/info
'
,
{
token
});
console
.
log
(
"
userInfo:
"
,
resData
);
formatDate
(
date
)
{
const
year
=
date
.
getFullYear
();
const
month
=
String
(
date
.
getMonth
()
+
1
).
padStart
(
2
,
'
0
'
);
// 月份从0开始,需要加1并且补零
const
day
=
String
(
date
.
getDate
()).
padStart
(
2
,
'
0
'
);
// 补零
return
`
${
year
}
/
${
month
}
/
${
day
}
/加入`
;
}
initBg
()
{
const
canvas
=
cc
.
find
(
"
Canvas
"
);
const
bg
=
cc
.
find
(
"
bg/bg
"
,
this
.
node
);
const
sx
=
canvas
.
width
/
bg
.
width
;
const
sy
=
canvas
.
height
/
bg
.
height
;
bg
.
scale
=
Math
.
max
(
sx
,
sy
);
}
_canTouch
=
false
;
async
start
()
{
await
this
.
getCourseList
();
await
this
.
getUserInfo
();
this
.
initTopUserPanel
();
this
.
_canTouch
=
true
;
this
.
_inited
=
true
;
...
...
@@ -125,18 +204,13 @@ export default class NewClass extends cc.Component {
this
.
initBg
();
}
initBg
()
{
const
canvas
=
cc
.
find
(
"
Canvas
"
);
const
bg
=
cc
.
find
(
"
bg/bg
"
,
this
.
node
);
const
sx
=
canvas
.
width
/
bg
.
width
;
const
sy
=
canvas
.
height
/
bg
.
height
;
bg
.
scale
=
Math
.
max
(
sx
,
sy
);
}
async
onEnable
()
{
this
.
_canTouch
=
false
;
this
.
initTopUserPanel
();
if
(
this
.
_inited
)
{
await
this
.
getCourseList
();
// await this.getUserInfo();
...
...
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