Skip to content

Commit d62e607

Browse files
author
puhui999
committed
修正绑定第三方跳转扫码登录错误
1 parent 2bef7f7 commit d62e607

File tree

1 file changed

+34
-9
lines changed

1 file changed

+34
-9
lines changed

src/views/Profile/components/UserSocial.vue

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
<template>
22
<el-table :data="socialUsers" :show-header="false">
3-
<el-table-column type="seq" title="序号" width="60" fixed="left" />
4-
<el-table-column label="社交平台" align="left" width="120">
3+
<el-table-column fixed="left" title="序号" type="seq" width="60" />
4+
<el-table-column align="left" label="社交平台" width="120">
55
<template #default="{ row }">
6-
<img class="h-5 align-middle" :src="row.img" alt="" />
6+
<img :src="row.img" alt="" class="h-5 align-middle" />
77
<p class="mr-5">{{ row.title }}</p>
88
</template>
99
</el-table-column>
10-
<el-table-column label="操作" align="center">
10+
<el-table-column align="center" label="操作">
1111
<template #default="{ row }">
1212
<template v-if="row.openid">
1313
已绑定
14-
<XTextButton type="primary" class="mr-5" @click="unbind(row)" title="(解绑)" />
14+
<XTextButton class="mr-5" title="(解绑)" type="primary" @click="unbind(row)" />
1515
</template>
1616
<template v-else>
1717
未绑定
18-
<XTextButton type="primary" class="mr-5" @click="bind(row)" title="(绑定)" />
18+
<XTextButton class="mr-5" title="(绑定)" type="primary" @click="bind(row)" />
1919
</template>
2020
</template>
2121
</el-table-column>
2222
</el-table>
2323
</template>
24-
<script setup lang="ts">
24+
<script lang="ts" name="UserSocial" setup>
2525
import { SystemUserSocialTypeEnum } from '@/utils/constants'
2626
import { getUserProfile, ProfileVO } from '@/api/system/user/profile'
27-
import { socialAuthRedirect, socialUnbind } from '@/api/system/user/socialUser'
27+
import { socialAuthRedirect, socialBind, socialUnbind } from '@/api/system/user/socialUser'
2828
2929
const message = useMessage()
3030
const socialUsers = ref<any[]>([])
@@ -46,11 +46,25 @@ const initSocial = async () => {
4646
}
4747
}
4848
}
49+
const route = useRoute()
50+
const bindSocial = () => {
51+
// 社交绑定
52+
const type = route.query.type
53+
const code = route.query.code
54+
const state = route.query.state
55+
if (!code) {
56+
return
57+
}
58+
socialBind(type, code, state).then(() => {
59+
message.success('绑定成功')
60+
initSocial()
61+
})
62+
}
4963
const bind = (row) => {
5064
const redirectUri = location.origin + '/user/profile?type=' + row.type
5165
// 进行跳转
5266
socialAuthRedirect(row.type, encodeURIComponent(redirectUri)).then((res) => {
53-
window.location.href = res.data
67+
window.location.href = res
5468
})
5569
}
5670
const unbind = async (row) => {
@@ -64,4 +78,15 @@ const unbind = async (row) => {
6478
onMounted(async () => {
6579
await initSocial()
6680
})
81+
82+
watch(
83+
() => route,
84+
(newRoute) => {
85+
bindSocial()
86+
console.log(newRoute)
87+
},
88+
{
89+
immediate: true
90+
}
91+
)
6792
</script>

0 commit comments

Comments
 (0)