Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
folacin-front
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
ynby
folacin-front
Commits
051ba788
Commit
051ba788
authored
Feb 19, 2025
by
罗成兵
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
获取用户信息
parent
ce327b83
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
19 deletions
+17
-19
index.vue
folacin-app/src/views/index/index.vue
+17
-19
No files found.
folacin-app/src/views/index/index.vue
View file @
051ba788
...
...
@@ -50,8 +50,14 @@ export default {
if
(
path
!=
'/'
)
{
return
;
}
this
.
userInfo
.
token
=
result
.
token
;
vm
.
getUserByToken
(
this
.
userInfo
,
false
);
let
ios
=
isIOSWebKit
();
if
(
ios
)
{
let
data
=
JSON
.
parse
(
result
);
this
.
userInfo
.
token
=
data
.
token
;
}
else
{
this
.
userInfo
.
token
=
result
.
token
;
}
vm
.
getUserByToken
(
this
.
userInfo
);
};
},
mounted
()
{
...
...
@@ -63,21 +69,22 @@ export default {
methods
:
{
init
()
{
if
(
process
.
env
.
NODE_ENV
==
"dev"
)
{
this
.
initUserInfo
(
this
.
userInfo
,
true
);
this
.
getUserByToken
(
this
.
userInfo
,
true
);
this
.
initUserInfo
(
this
.
userInfo
);
this
.
getUserByToken
(
this
.
userInfo
);
}
else
{
let
query
=
this
.
$route
.
query
;
this
.
userInfo
.
token
=
query
.
token
this
.
initUserInfo
(
this
.
userInfo
,
true
);
this
.
initUserInfo
(
this
.
userInfo
);
if
(
!
this
.
userInfo
.
token
)
{
this
.
msg
=
"获取用户信息异常!"
callMobile
(
'init'
,
{});
}
else
{
this
.
getUserByToken
(
this
.
userInfo
,
true
)
this
.
getUserByToken
(
this
.
userInfo
)
}
}
},
getUserByToken
(
userInfo
,
isPc
)
{
getUserByToken
(
userInfo
)
{
this
.
initUserInfo
(
userInfo
);
getUserByToken
(
userInfo
.
token
).
then
(
res
=>
{
if
(
res
.
code
==
'SUCCESS'
)
{
userInfo
.
userId
=
res
.
data
.
userId
;
...
...
@@ -86,7 +93,7 @@ export default {
userInfo
.
nickName
=
res
.
data
.
nickName
;
userInfo
.
gender
=
res
.
data
.
gender
;
userInfo
.
headPortrait
=
res
.
data
.
headPortrait
;
this
.
initUserInfo
(
userInfo
,
isPc
);
this
.
initUserInfo
(
userInfo
);
this
.
showMsg
();
}
else
{
this
.
msg
=
"获取用户信息异常!"
...
...
@@ -98,17 +105,8 @@ export default {
handleBack
()
{
callMobile
(
'goIndex'
,
{});
},
initUserInfo
(
val
,
isPc
)
{
if
(
isPc
)
{
window
.
sessionStorage
.
setItem
(
'userInfo'
,
JSON
.
stringify
(
val
));
return
;
}
let
ios
=
isIOSWebKit
();
if
(
ios
)
{
window
.
sessionStorage
.
setItem
(
'userInfo'
,
val
);
}
else
{
window
.
sessionStorage
.
setItem
(
'userInfo'
,
JSON
.
stringify
(
val
));
}
initUserInfo
(
val
)
{
window
.
sessionStorage
.
setItem
(
'userInfo'
,
JSON
.
stringify
(
val
));
},
showMsg
()
{
Dialog
.
alert
({
...
...
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