部分修复

develoop
ww 4 months ago
parent c85e9ee528
commit bf170a0d40
  1. 104
      src/store/modules/user.ts

@ -74,7 +74,6 @@ const useUserStore = defineStore('User', {
message: '登录成功!', message: '登录成功!',
title: `Hi ${getTime()}!`, title: `Hi ${getTime()}!`,
}) })
<<<<<<< HEAD
return 'ok' return 'ok'
} else { } else {
ElNotification({ ElNotification({
@ -120,109 +119,6 @@ const useUserStore = defineStore('User', {
this.routes = '' this.routes = ''
usePermissionStore.removeRouter() usePermissionStore.removeRouter()
location.reload() location.reload()
=======
if (res.code === 200) {
// @ts-expect-error
this.token = res.data.token as string
// @ts-expect-error
SET_TKOEN('TOKEN', this.token)
// localStorage.setItem('TOKEN', this.token)
ElNotification({
type: 'success',
message: '登录成功!',
title: `Hi ${getTime()}!`,
})
return 'ok'
} else {
// ElNotification({
// // type: 'error',
// message: res.message,
// })
ElMessage.error(res.message)
return Promise.reject(new Error(res.data.message))
}
},
//手机号登录
async userPhoneLogin(data: loginType) {
const res: any = await userPhoneLoginService(data)
console.log(res, 11111)
if (res.code === 200) {
// @ts-expect-error
this.token = res.data.token as string //接收返回的token
// @ts-expect-error
SET_TKOEN('TOKEN', this.token)
// localStorage.setItem('TOKEN', this.token)
ElNotification({
type: 'success',
message: '登录成功!',
title: `Hi ${getTime()}!`,
})
return 'ok'
} else {
ElNotification({
type: 'error',
message: res.message,
})
return Promise.reject(new Error(res.data.message))
}
},
// 获取用户信息事件
async getUserInfo() {
const result: any = await userGetInfoService(GET_TKOEN('TOKEN'))
if (result.code === 200) {
const res = await userIdenService(result.data.id)
console.log(res, 'huonghu')
// @ts-expect-error
console.log(res.data, 'res.data')
this.userInfo = res.data
console.log(this.userInfo, 'this.userInfo')
// @ts-expect-error
this.data = result.data
console.log(result, '123')
// @ts-expect-error
this.userName = result.data.username
// this.avatar = result.data.checkUser.avatar
// @ts-expect-error
this.routes = result.data.permissions
return {
result,
}
} else {
return Promise.reject('登录过期')
}
},
// 退出登录事件
logout() {
const usePermissionStore = permissionStore()
console.log(usePermissionStore)
// 清除token
REMOVE_TOKEN('TOKEN'),
// ;(this.userName = ''), (this.avatar = '')
// @ts-expect-error
(this.userName = ''),
// @ts-expect-error
(this.avatar = '')
// @ts-expect-error
this.token = ''
// @ts-expect-error
this.routes = ''
usePermissionStore.removeRouter()
location.reload()
},
>>>>>>> 0b7db324dad8347654933e91ae7e6ca8d2dabd05
}, },
}, },
getters: {}, getters: {},

Loading…
Cancel
Save