mirror of
https://gitee.com/myxzgzs/boyue-ui-admin-vue3
synced 2025-08-08 16:32:43 +08:00
fix: 三方登录的绑定,使用 /system/social-user/get-bind-list 接口
This commit is contained in:
parent
0efa1e986b
commit
e75ddc40ab
@ -14,7 +14,7 @@ export interface SocialUserVO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 查询社交用户列表
|
// 查询社交用户列表
|
||||||
export const getSocialUserPage = async (params) => {
|
export const getSocialUserPage = async (params: any) => {
|
||||||
return await request.get({ url: `/system/social-user/page`, params })
|
return await request.get({ url: `/system/social-user/page`, params })
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,3 +22,8 @@ export const getSocialUserPage = async (params) => {
|
|||||||
export const getSocialUser = async (id: number) => {
|
export const getSocialUser = async (id: number) => {
|
||||||
return await request.get({ url: `/system/social-user/get?id=` + id })
|
return await request.get({ url: `/system/social-user/get?id=` + id })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获得绑定社交用户列表
|
||||||
|
export const getBindSocialUserList = async () => {
|
||||||
|
return await request.get({ url: '/system/social-user/get-bind-list' })
|
||||||
|
}
|
||||||
|
@ -16,10 +16,6 @@ export interface ProfileVO {
|
|||||||
id: number
|
id: number
|
||||||
name: string
|
name: string
|
||||||
}[]
|
}[]
|
||||||
socialUsers: {
|
|
||||||
type: number
|
|
||||||
openid: string
|
|
||||||
}[]
|
|
||||||
email: string
|
email: string
|
||||||
mobile: string
|
mobile: string
|
||||||
sex: number
|
sex: number
|
||||||
|
@ -181,7 +181,6 @@ function openModal() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function closeModal() {
|
function closeModal() {
|
||||||
debugger
|
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ import { useUserStore } from '@/store/modules/user'
|
|||||||
import { useUpload } from '@/components/UploadFile/src/useUpload'
|
import { useUpload } from '@/components/UploadFile/src/useUpload'
|
||||||
import { UploadRequestOptions } from 'element-plus/es/components/upload/src/upload'
|
import { UploadRequestOptions } from 'element-plus/es/components/upload/src/upload'
|
||||||
|
|
||||||
// TODO @芋艿:合并到 ProfileUser 组件中,更简洁一点
|
|
||||||
defineOptions({ name: 'UserAvatar' })
|
defineOptions({ name: 'UserAvatar' })
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
@ -30,10 +29,12 @@ const userStore = useUserStore()
|
|||||||
const cropperRef = ref()
|
const cropperRef = ref()
|
||||||
const handelUpload = async ({ data }) => {
|
const handelUpload = async ({ data }) => {
|
||||||
const { httpRequest } = useUpload()
|
const { httpRequest } = useUpload()
|
||||||
const avatar = ((await httpRequest({
|
const avatar = (
|
||||||
file: data,
|
(await httpRequest({
|
||||||
filename: 'avatar.png',
|
file: data,
|
||||||
} as UploadRequestOptions)) as unknown as { data: string }).data
|
filename: 'avatar.png'
|
||||||
|
} as UploadRequestOptions)) as unknown as { data: string }
|
||||||
|
).data
|
||||||
await updateUserProfile({ avatar })
|
await updateUserProfile({ avatar })
|
||||||
|
|
||||||
// 关闭弹窗,并更新 userStore
|
// 关闭弹窗,并更新 userStore
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { SystemUserSocialTypeEnum } from '@/utils/constants'
|
import { SystemUserSocialTypeEnum } from '@/utils/constants'
|
||||||
import { getUserProfile, ProfileVO } from '@/api/system/user/profile'
|
import { getBindSocialUserList } from '@/api/system/social/user'
|
||||||
import { socialAuthRedirect, socialBind, socialUnbind } from '@/api/system/user/socialUser'
|
import { socialAuthRedirect, socialBind, socialUnbind } from '@/api/system/user/socialUser'
|
||||||
|
|
||||||
defineOptions({ name: 'UserSocial' })
|
defineOptions({ name: 'UserSocial' })
|
||||||
@ -32,19 +32,19 @@ defineProps<{
|
|||||||
}>()
|
}>()
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
const socialUsers = ref<any[]>([])
|
const socialUsers = ref<any[]>([])
|
||||||
const userInfo = ref<ProfileVO>()
|
|
||||||
|
|
||||||
const initSocial = async () => {
|
const initSocial = async () => {
|
||||||
socialUsers.value = [] // 重置避免无限增长
|
socialUsers.value = [] // 重置避免无限增长
|
||||||
const res = await getUserProfile()
|
// 获取已绑定的社交用户列表
|
||||||
userInfo.value = res
|
const bindSocialUserList = await getBindSocialUserList()
|
||||||
|
// 检查该社交平台是否已绑定
|
||||||
for (const i in SystemUserSocialTypeEnum) {
|
for (const i in SystemUserSocialTypeEnum) {
|
||||||
const socialUser = { ...SystemUserSocialTypeEnum[i] }
|
const socialUser = { ...SystemUserSocialTypeEnum[i] }
|
||||||
socialUsers.value.push(socialUser)
|
socialUsers.value.push(socialUser)
|
||||||
if (userInfo.value?.socialUsers) {
|
if (bindSocialUserList && bindSocialUserList.length > 0) {
|
||||||
for (const j in userInfo.value.socialUsers) {
|
for (const bindUser of bindSocialUserList) {
|
||||||
if (socialUser.type === userInfo.value.socialUsers[j].type) {
|
if (socialUser.type === bindUser.type) {
|
||||||
socialUser.openid = userInfo.value.socialUsers[j].openid
|
socialUser.openid = bindUser.openid
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user