Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
88a22d90
authored
Oct 26, 2023
by
puhui999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解决钉钉绑定失败的问题
parent
6ee2492f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
10 deletions
+25
-10
src/views/Profile/Index.vue
+6
-5
src/views/Profile/components/UserSocial.vue
+19
-5
No files found.
src/views/Profile/Index.vue
View file @
88a22d90
...
...
@@ -15,7 +15,7 @@
</div>
</
template
>
<div>
<el-tabs
v-model=
"activeName"
tab-position=
"top"
style=
"height: 400px"
class=
"profile-tabs
"
>
<el-tabs
v-model=
"activeName"
class=
"profile-tabs"
style=
"height: 400px"
tab-position=
"top
"
>
<el-tab-pane
:label=
"t('profile.info.basicInfo')"
name=
"basicInfo"
>
<BasicInfo
/>
</el-tab-pane>
...
...
@@ -23,17 +23,18 @@
<ResetPwd
/>
</el-tab-pane>
<el-tab-pane
:label=
"t('profile.info.userSocial')"
name=
"userSocial"
>
<UserSocial
/>
<UserSocial
v-model:activeName=
"activeName"
/>
</el-tab-pane>
</el-tabs>
</div>
</el-card>
</div>
</template>
<
script
setup
lang=
"ts"
name=
"Profile"
>
import
{
BasicInfo
,
ProfileUser
,
ResetPwd
,
UserSocial
}
from
'./components/'
const
{
t
}
=
useI18n
()
<
script
lang=
"ts"
setup
>
import
{
BasicInfo
,
ProfileUser
,
ResetPwd
,
UserSocial
}
from
'./components'
const
{
t
}
=
useI18n
()
defineOptions
({
name
:
'Profile'
})
const
activeName
=
ref
(
'basicInfo'
)
</
script
>
<
style
scoped
>
...
...
src/views/Profile/components/UserSocial.vue
View file @
88a22d90
...
...
@@ -27,12 +27,15 @@ import { getUserProfile, ProfileVO } from '@/api/system/user/profile'
import
{
socialAuthRedirect
,
socialBind
,
socialUnbind
}
from
'@/api/system/user/socialUser'
defineOptions
({
name
:
'UserSocial'
})
defineProps
<
{
activeName
:
string
}
>
()
const
message
=
useMessage
()
const
socialUsers
=
ref
<
any
[]
>
([])
const
userInfo
=
ref
<
ProfileVO
>
()
const
initSocial
=
async
()
=>
{
socialUsers
.
value
=
[]
// 重置避免无限增长
const
res
=
await
getUserProfile
()
userInfo
.
value
=
res
for
(
const
i
in
SystemUserSocialTypeEnum
)
{
...
...
@@ -49,9 +52,12 @@ const initSocial = async () => {
}
}
const
route
=
useRoute
()
const
emit
=
defineEmits
<
{
(
e
:
'update:activeName'
,
v
:
string
):
void
}
>
()
const
bindSocial
=
()
=>
{
// 社交绑定
const
type
=
route
.
query
.
type
const
type
=
getUrlValue
(
'type'
)
const
code
=
route
.
query
.
code
const
state
=
route
.
query
.
state
if
(
!
code
)
{
...
...
@@ -59,11 +65,20 @@ const bindSocial = () => {
}
socialBind
(
type
,
code
,
state
).
then
(()
=>
{
message
.
success
(
'绑定成功'
)
emit
(
'update:activeName'
,
'userSocial'
)
initSocial
()
})
}
// 双层 encode 需要在回调后进行 decode
function
getUrlValue
(
key
:
string
):
string
{
const
url
=
new
URL
(
decodeURIComponent
(
location
.
href
))
return
url
.
searchParams
.
get
(
key
)
??
''
}
const
bind
=
(
row
)
=>
{
const
redirectUri
=
location
.
origin
+
'/user/profile?type='
+
row
.
type
// 双层 encode 解决钉钉回调 type 参数丢失的问题
const
redirectUri
=
location
.
origin
+
'/user/profile?'
+
encodeURIComponent
(
`type=
${
row
.
type
}
`
)
// 进行跳转
socialAuthRedirect
(
row
.
type
,
encodeURIComponent
(
redirectUri
)).
then
((
res
)
=>
{
window
.
location
.
href
=
res
...
...
@@ -83,9 +98,8 @@ onMounted(async () => {
watch
(
()
=>
route
,
(
newRoute
)
=>
{
()
=>
{
bindSocial
()
console
.
log
(
newRoute
)
},
{
immediate
:
true
...
...
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