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
56c29fa1
Commit
56c29fa1
authored
Jul 14, 2022
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: token失效跳转
parent
be1b0a4f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
11 deletions
+64
-11
NJ_usercenter.ts
assets/NJ_usercenter/scene/NJ_usercenter.ts
+37
-9
clickEvent.ts
assets/NJ_usercenter/script/clickEvent.ts
+7
-2
util.ts
assets/NJ_usercenter/script/util.ts
+20
-0
No files found.
assets/NJ_usercenter/scene/NJ_usercenter.ts
View file @
56c29fa1
import
{
import
{
asyncDelay
,
onHomeworkFinish
,
asyncCallNetworkApiGet
,
asyncCallNetworkApiGet
,
asyncCallNetworkApiPost
,
jumpToLogin
,
}
from
"
../script/util
"
;
}
from
"
../script/util
"
;
import
{
MyCocosSceneComponent
}
from
"
../script/MyCocosSceneComponent
"
;
import
{
MyCocosSceneComponent
}
from
"
../script/MyCocosSceneComponent
"
;
...
@@ -59,7 +57,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -59,7 +57,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
userInfo
=
null
;
userInfo
=
null
;
async
initUserInfo
()
{
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
;
const
resObj
=
JSON
.
parse
(
res
);
if
(
resObj
.
code
!==
200
)
{
jumpToLogin
();
return
;
}
const
userInfo
=
resObj
.
data
;
cc
.
sys
.
localStorage
.
setItem
(
'
userInfo
'
,
JSON
.
stringify
(
userInfo
));
cc
.
sys
.
localStorage
.
setItem
(
'
userInfo
'
,
JSON
.
stringify
(
userInfo
));
this
.
userInfo
=
userInfo
;
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
;
...
@@ -89,7 +92,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -89,7 +92,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
return
;
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
;
const
resObj
=
JSON
.
parse
(
res
);
if
(
resObj
.
code
!==
200
)
{
jumpToLogin
();
return
;
}
const
partInfo
=
resObj
.
data
;
if
(
partInfo
)
{
if
(
partInfo
)
{
this
.
partWeekCount
=
partInfo
.
weekcount
;
this
.
partWeekCount
=
partInfo
.
weekcount
;
this
.
partCount
=
partInfo
.
count
;
this
.
partCount
=
partInfo
.
count
;
...
@@ -111,7 +119,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -111,7 +119,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
return
;
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
;
const
resObj
=
JSON
.
parse
(
res
);
if
(
resObj
.
code
!==
200
)
{
jumpToLogin
();
return
;
}
const
speakInfo
=
resObj
.
data
;
if
(
speakInfo
)
{
if
(
speakInfo
)
{
this
.
speakWeekCount
=
speakInfo
.
weekcount
;
this
.
speakWeekCount
=
speakInfo
.
weekcount
;
this
.
speakCount
=
speakInfo
.
count
;
this
.
speakCount
=
speakInfo
.
count
;
...
@@ -130,7 +143,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -130,7 +143,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
return
;
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
;
const
resObj
=
JSON
.
parse
(
res
);
if
(
resObj
.
code
!==
200
)
{
jumpToLogin
();
return
;
}
const
knowledgeInfo
=
resObj
.
data
;
if
(
knowledgeInfo
)
{
if
(
knowledgeInfo
)
{
this
.
lettercount
=
knowledgeInfo
.
lettercount
||
0
;
this
.
lettercount
=
knowledgeInfo
.
lettercount
||
0
;
this
.
wordcount
=
knowledgeInfo
.
wordcount
||
0
;
this
.
wordcount
=
knowledgeInfo
.
wordcount
||
0
;
...
@@ -154,7 +172,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -154,7 +172,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
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
;
const
resObj
=
JSON
.
parse
(
res
);
if
(
resObj
.
code
!==
200
)
{
jumpToLogin
();
return
;
}
const
chartInfo
=
resObj
.
data
;
if
(
chartInfo
)
{
if
(
chartInfo
)
{
this
.
learntimes
=
chartInfo
.
learntimes
;
this
.
learntimes
=
chartInfo
.
learntimes
;
this
.
learntotal
=
chartInfo
.
learntotal
;
this
.
learntotal
=
chartInfo
.
learntotal
;
...
@@ -229,7 +252,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -229,7 +252,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
const
draw
=
async
(
type
)
=>
{
const
draw
=
async
(
type
)
=>
{
const
pdtd
:
any
=
await
asyncCallNetworkApiGet
(
`/api/oxford/v1/kid/learn/
${
type
}
/process`
,
{
kidid
:
this
.
userInfo
.
id
,
token
:
this
.
token
});
const
pdtd
:
any
=
await
asyncCallNetworkApiGet
(
`/api/oxford/v1/kid/learn/
${
type
}
/process`
,
{
kidid
:
this
.
userInfo
.
id
,
token
:
this
.
token
});
const
resProcess
=
JSON
.
parse
(
pdtd
).
data
;
const
resObj
=
JSON
.
parse
(
pdtd
);
if
(
resObj
.
code
!==
200
)
{
jumpToLogin
();
return
;
}
const
resProcess
=
resObj
.
data
;
const
typeNode
=
cc
.
find
(
`Canvas/usercenter/view/content/scollpage/
${
type
}
_node/typebg`
);
const
typeNode
=
cc
.
find
(
`Canvas/usercenter/view/content/scollpage/
${
type
}
_node/typebg`
);
// 现在规定死5个级别
// 现在规定死5个级别
for
(
let
i
=
1
;
i
<=
5
;
i
++
)
{
for
(
let
i
=
1
;
i
<=
5
;
i
++
)
{
...
...
assets/NJ_usercenter/script/clickEvent.ts
View file @
56c29fa1
import
{
asyncDelay
,
asyncCallNetworkApiGet
,
getSpriteFrimeByUrl
,
playAudioByUrl
}
from
"
./util
"
;
import
{
jumpToLogin
,
asyncCallNetworkApiGet
,
getSpriteFrimeByUrl
,
playAudioByUrl
}
from
"
./util
"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
const
levels
=
{
const
levels
=
{
...
@@ -231,6 +231,11 @@ export default class NewClass extends cc.Component {
...
@@ -231,6 +231,11 @@ export default class NewClass extends cc.Component {
const
token
=
cc
.
sys
.
localStorage
.
getItem
(
"
token
"
);
const
token
=
cc
.
sys
.
localStorage
.
getItem
(
"
token
"
);
const
res
:
any
=
await
asyncCallNetworkApiGet
(
"
/api/oxford/v1/kid/learn/forder/report
"
,
{
kidid
:
node
.
kidid
,
folderid
:
node
.
folder_id
,
token
});
const
res
:
any
=
await
asyncCallNetworkApiGet
(
"
/api/oxford/v1/kid/learn/forder/report
"
,
{
kidid
:
node
.
kidid
,
folderid
:
node
.
folder_id
,
token
});
const
resObj
=
JSON
.
parse
(
res
);
if
(
resObj
.
code
!==
200
)
{
jumpToLogin
();
return
;
}
const
{
const
{
learntimes
,
learntimes
,
recordcount
,
recordcount
,
...
@@ -239,7 +244,7 @@ export default class NewClass extends cc.Component {
...
@@ -239,7 +244,7 @@ export default class NewClass extends cc.Component {
kn_sentences
,
kn_sentences
,
OP05
,
OP05
,
OP_06_3
OP_06_3
}
=
JSON
.
parse
(
res
)
.
data
;
}
=
resObj
.
data
;
cc
.
find
(
"
Canvas/reportdetail/view/content/userdetail_scollpage/learnshow/itembg/recordbg/recordcount
"
).
getComponent
(
cc
.
Label
).
string
=
recordcount
;
cc
.
find
(
"
Canvas/reportdetail/view/content/userdetail_scollpage/learnshow/itembg/recordbg/recordcount
"
).
getComponent
(
cc
.
Label
).
string
=
recordcount
;
cc
.
find
(
"
Canvas/reportdetail/view/content/userdetail_scollpage/learnshow/itembg/learnbg/learntime
"
).
getComponent
(
cc
.
Label
).
string
=
learntimes
;
cc
.
find
(
"
Canvas/reportdetail/view/content/userdetail_scollpage/learnshow/itembg/learnbg/learntime
"
).
getComponent
(
cc
.
Label
).
string
=
learntimes
;
...
...
assets/NJ_usercenter/script/util.ts
View file @
56c29fa1
...
@@ -423,6 +423,26 @@ export function onHomeworkFinish() {
...
@@ -423,6 +423,26 @@ export function onHomeworkFinish() {
}
}
}
}
export
function
jumpToBundle
(
bundleName
:
string
)
{
const
middleLayer
=
cc
.
find
(
'
middleLayer
'
);
if
(
middleLayer
)
{
const
middleLayerComponent
=
middleLayer
.
getComponent
(
'
middleLayer
'
);
middleLayerComponent
.
loadOnlineBundle
(
bundleName
);
}
else
{
console
.
log
(
'
jump to bundle:
'
+
bundleName
);
}
}
export
function
jumpToLogin
()
{
const
middleLayer
=
cc
.
find
(
'
middleLayer
'
);
if
(
middleLayer
)
{
const
middleLayerComponent
=
middleLayer
.
getComponent
(
'
middleLayer
'
);
middleLayerComponent
.
loadOnlineBundle
(
"
NJ_login
"
);
}
else
{
console
.
log
(
'
jump to bundle: NJ_login
'
);
}
}
export
function
asyncCallNetworkApiGet
(
apiName
,
data
)
{
export
function
asyncCallNetworkApiGet
(
apiName
,
data
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
callNetworkApiGet
(
apiName
,
data
,
(
res
=>
{
callNetworkApiGet
(
apiName
,
data
,
(
res
=>
{
...
...
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