Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
NJ_usercenter
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_usercenter
Commits
0bb49d32
Commit
0bb49d32
authored
May 20, 2022
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 修改曲线
parent
c424f54e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
206 additions
and
203 deletions
+206
-203
NJ_usercenter.ts
assets/NJ_usercenter/scene/NJ_usercenter.ts
+206
-203
No files found.
assets/NJ_usercenter/scene/NJ_usercenter.ts
View file @
0bb49d32
...
...
@@ -2,7 +2,8 @@ import {
asyncDelay
,
onHomeworkFinish
,
asyncCallNetworkApiGet
,
asyncCallNetworkApiPost
}
from
"
../script/util
"
;
asyncCallNetworkApiPost
}
from
"
../script/util
"
;
import
{
MyCocosSceneComponent
}
from
"
../script/MyCocosSceneComponent
"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
...
...
@@ -45,7 +46,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
token
=
cc
.
sys
.
localStorage
.
getItem
(
"
token
"
);
}
getFomartDate
()
{
getFomartDate
()
{
const
date
=
new
Date
();
date
.
setDate
(
date
.
getDate
()
-
date
.
getDay
()
+
1
);
const
monday
=
date
[
"
pattern
"
](
"
MM.dd
"
);
...
...
@@ -56,10 +57,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
userInfo
=
null
;
async
initUserInfo
()
{
const
res
:
any
=
await
asyncCallNetworkApiGet
(
"
/api/oxford/v1/kid/info
"
,
{
token
:
this
.
token
});
const
res
:
any
=
await
asyncCallNetworkApiGet
(
"
/api/oxford/v1/kid/info
"
,
{
token
:
this
.
token
});
const
userInfo
=
JSON
.
parse
(
res
).
data
;
this
.
userInfo
=
userInfo
;
const
avatarIndex
=
userInfo
.
avatar_url
?
parseInt
(
userInfo
.
avatar_url
)
-
1
:
0
;
const
avatarIndex
=
userInfo
.
avatar_url
?
parseInt
(
userInfo
.
avatar_url
)
-
1
:
0
;
const
usercenter
=
cc
.
find
(
"
Canvas/usercenter/view/content/scollpage/user_center
"
);
// 头像
cc
.
find
(
"
avatar
"
,
usercenter
).
getComponent
(
cc
.
Sprite
).
spriteFrame
=
this
.
picture
[
avatarIndex
];
...
...
@@ -77,7 +78,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
if
(
!
this
.
userInfo
)
{
return
;
}
const
res
:
any
=
await
asyncCallNetworkApiGet
(
"
/api/oxford/v1/kid/part/count
"
,
{
kidid
:
this
.
userInfo
.
id
,
token
:
this
.
token
});
const
res
:
any
=
await
asyncCallNetworkApiGet
(
"
/api/oxford/v1/kid/part/count
"
,
{
kidid
:
this
.
userInfo
.
id
,
token
:
this
.
token
});
const
partInfo
=
JSON
.
parse
(
res
).
data
;
if
(
partInfo
)
{
this
.
partWeekCount
=
partInfo
.
weekcount
;
...
...
@@ -87,7 +88,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
cc
.
find
(
"
learndesc
"
,
usercenter
).
getComponent
(
cc
.
RichText
).
string
=
`<color=#ae441c>本周已经学习</c> <color=#41916e><size=60>
${
this
.
partWeekCount
}
</size></color> <color=#ae441c>个小节</color>`
;
const
smallbg_1_left
=
cc
.
find
(
"
Canvas/usercenter/view/content/scollpage/smallbg_1_left
"
);
cc
.
find
(
"
smtextbg/partcount
"
,
smallbg_1_left
).
getComponent
(
cc
.
Label
).
string
=
this
.
partCount
+
""
;
cc
.
find
(
"
smtextbg/partcount
"
,
smallbg_1_left
).
getComponent
(
cc
.
Label
).
string
=
this
.
partCount
+
""
;
cc
.
find
(
"
numberbg/weekpartcount
"
,
smallbg_1_left
).
getComponent
(
cc
.
Label
).
string
=
"
+
"
+
this
.
partWeekCount
;
}
...
...
@@ -99,7 +100,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
if
(
!
this
.
userInfo
)
{
return
;
}
const
res
:
any
=
await
asyncCallNetworkApiGet
(
"
/api/oxford/v1/kid/record/count
"
,
{
kidid
:
this
.
userInfo
.
id
,
token
:
this
.
token
});
const
res
:
any
=
await
asyncCallNetworkApiGet
(
"
/api/oxford/v1/kid/record/count
"
,
{
kidid
:
this
.
userInfo
.
id
,
token
:
this
.
token
});
const
speakInfo
=
JSON
.
parse
(
res
).
data
;
if
(
speakInfo
)
{
this
.
speakWeekCount
=
speakInfo
.
weekcount
;
...
...
@@ -107,7 +108,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
const
smallbg_1_right
=
cc
.
find
(
"
Canvas/usercenter/view/content/scollpage/smallbg_1_right
"
);
cc
.
find
(
"
smtextbg/partcount
"
,
smallbg_1_right
).
getComponent
(
cc
.
Label
).
string
=
this
.
speakCount
+
""
;
cc
.
find
(
"
smtextbg/partcount
"
,
smallbg_1_right
).
getComponent
(
cc
.
Label
).
string
=
this
.
speakCount
+
""
;
cc
.
find
(
"
numberbg/weekpartcount
"
,
smallbg_1_right
).
getComponent
(
cc
.
Label
).
string
=
"
+
"
+
this
.
speakWeekCount
;
}
...
...
@@ -118,7 +119,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
if
(
!
this
.
userInfo
)
{
return
;
}
const
res
:
any
=
await
asyncCallNetworkApiGet
(
"
/api/oxford/v1/kid/knowledge/count
"
,
{
kidid
:
this
.
userInfo
.
id
,
token
:
this
.
token
});
const
res
:
any
=
await
asyncCallNetworkApiGet
(
"
/api/oxford/v1/kid/knowledge/count
"
,
{
kidid
:
this
.
userInfo
.
id
,
token
:
this
.
token
});
const
knowledgeInfo
=
JSON
.
parse
(
res
).
data
;
if
(
knowledgeInfo
)
{
this
.
lettercount
=
knowledgeInfo
.
lettercount
||
0
;
...
...
@@ -134,17 +135,17 @@ export default class SceneComponent extends MyCocosSceneComponent {
cc
.
find
(
"
sentencecount
"
,
smallbg_2_right
).
getComponent
(
cc
.
RichText
).
string
=
`<color=#41954F>
${
this
.
sentencecount
}
</c> <color=#726E6F><size=15>个</size></c>`
;
}
learntimes
=
[
0
,
0
,
25
,
50
,
99
,
73
,
8
];
learntimes
=
[
0
,
0
,
25
,
50
,
99
,
73
,
8
];
learntotal
=
0
;
average
=
0
;
async
drawChart
()
{
if
(
!
this
.
userInfo
)
{
return
;
}
const
res
:
any
=
await
asyncCallNetworkApiGet
(
"
/api/oxford/v1/kid/learn/chart
"
,
{
kidid
:
this
.
userInfo
.
id
,
token
:
this
.
token
});
const
res
:
any
=
await
asyncCallNetworkApiGet
(
"
/api/oxford/v1/kid/learn/chart
"
,
{
kidid
:
this
.
userInfo
.
id
,
token
:
this
.
token
});
const
chartInfo
=
JSON
.
parse
(
res
).
data
;
if
(
chartInfo
)
{
//
this.learntimes = chartInfo.learntimes;
this
.
learntimes
=
chartInfo
.
learntimes
;
this
.
learntotal
=
chartInfo
.
learntotal
;
this
.
average
=
chartInfo
.
average
;
}
...
...
@@ -161,20 +162,22 @@ export default class SceneComponent extends MyCocosSceneComponent {
const
chart_line
=
cc
.
find
(
`chart_line`
,
linebg
).
getComponent
(
cc
.
Graphics
);
const
max
=
Math
.
max
(...
this
.
learntimes
);
const
itemLen
=
(
maxY
-
baseY
)
/
max
;
cc
.
find
(
`dp8/hafy`
,
linebg
).
getComponent
(
cc
.
Label
).
string
=
Math
.
floor
(
max
/
2
)
+
""
;
cc
.
find
(
`dp9/max`
,
linebg
).
getComponent
(
cc
.
Label
).
string
=
max
+
""
;
const
itemLen
=
max
?
(
maxY
-
baseY
)
/
max
:
0
;
if
(
max
)
{
cc
.
find
(
`dp8/hafy`
,
linebg
).
getComponent
(
cc
.
Label
).
string
=
Math
.
floor
(
max
/
2
)
+
""
;
cc
.
find
(
`dp9/max`
,
linebg
).
getComponent
(
cc
.
Label
).
string
=
max
+
""
;
}
// 渲染刻度
const
date
=
new
Date
();
let
monthNum
;
for
(
let
i
=
1
;
i
<
8
;
i
++
)
{
const
index
=
i
;
const
value
=
this
.
learntimes
[
i
-
1
];
const
value
=
this
.
learntimes
[
i
-
1
];
date
.
setDate
(
date
.
getDate
()
-
date
.
getDay
()
+
index
);
const
xNode
=
cc
.
find
(
`dp
${
index
}
/date
${
index
}
`
,
linebg
);
const
dateStr
=
date
[
"
pattern
"
](
"
M月d日
"
);
if
(
dateStr
.
split
(
"
月
"
)[
0
]
!=
monthNum
)
{
if
(
dateStr
.
split
(
"
月
"
)[
0
]
!=
monthNum
)
{
monthNum
=
dateStr
.
split
(
"
月
"
)[
0
];
xNode
.
getComponent
(
cc
.
Label
).
string
=
dateStr
;
}
else
{
...
...
@@ -184,15 +187,15 @@ export default class SceneComponent extends MyCocosSceneComponent {
if
(
today
[
"
pattern
"
](
"
d
"
)
==
date
[
"
pattern
"
](
"
d
"
))
{
xNode
.
getComponent
(
cc
.
Label
).
string
=
"
今天
"
;
}
if
(
i
==
1
)
{
chart_line
.
moveTo
(
xNode
.
parent
.
x
,
itemLen
*
value
+
baseY
);
if
(
i
==
1
)
{
chart_line
.
moveTo
(
xNode
.
parent
.
x
,
itemLen
*
value
+
baseY
);
}
else
{
chart_line
.
lineTo
(
xNode
.
parent
.
x
,
itemLen
*
value
+
baseY
);
chart_line
.
lineTo
(
xNode
.
parent
.
x
,
itemLen
*
value
+
baseY
);
}
const
dotClone
=
cc
.
instantiate
(
dotHide
);
dotClone
.
parent
=
linebg
;
cc
.
find
(
"
pop/text
"
,
dotClone
).
getComponent
(
cc
.
Label
).
string
=
`
${
value
}
分钟`
;
dotClone
.
setPosition
(
xNode
.
parent
.
x
,
itemLen
*
value
+
baseY
);
dotClone
.
setPosition
(
xNode
.
parent
.
x
,
itemLen
*
value
+
baseY
);
dotClone
.
active
=
true
;
}
chart_line
.
stroke
();
...
...
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