Commit 965eec33 authored by 罗超's avatar 罗超

修改自动登录

parent b3aa323e
......@@ -3,9 +3,9 @@ import Api,{ HttpResponse, Result } from './../utils/request';
class UserServices{
static async AutoLoginAsync(userId:number):Promise<HttpResponse>{
let msg = {EmployeeId:userId}
return Api.Post("admin_get_GetErpLoginInfoByUid",msg)
static async AutoLoginAsync(t:string):Promise<HttpResponse>{
let msg = {t}
return Api.Post("travel_auto_login",msg)
}
static async PasswordLoginAsync(account:string,pwd:string,tid:string=''):Promise<HttpResponse>{
......
......@@ -23,6 +23,10 @@ export interface UserLoginResult {
status:'ERROR'|'CHOSEN'|'SUCCESS',
data?:any[]
}
export interface AutoLoginResult{
isSuccess:boolean,
message:string
}
export const useUserStore = defineStore('user', {
state:()=>({
......@@ -46,34 +50,38 @@ export const useUserStore = defineStore('user', {
},
},
actions:{
async setUserAutoLoginAsync(userId:number){
async setUserAutoLoginAsync(tempToken:string):Promise<AutoLoginResult> {
try {
let response = await UserService.AutoLoginAsync(userId)
const response = await UserService.AutoLoginAsync(tempToken)
if (response.data.resultCode == ApiResult.SUCCESS) {
const d = response.data.data
// d.nickname=d.emName
// d.photo = d.Icon
// d.company = d.GroupName
// d.logo = d.GroupPic
// d.isTemplate = d.IsEditTripTemplate
// d.ia = 0
// d.it = true
// d.expire = d.Expire
// d.ic = d.IsGroupCreate
// d.id = d.DisplayId
// d.iv = 0
this.token = d.token
d.nickname=d.emName
d.photo = d.Icon
d.company = d.GroupName
d.logo = d.GroupPic
d.isTemplate = d.IsEditTripTemplate
d.ia = 0
d.it = true
d.expire = d.Expire
d.ic = d.IsGroupCreate
d.id = d.DisplayId
d.iv = 0
this.userInfo = d
this.userInfo = d.userinfo
if(!this.userInfo.photo || !this.userInfo.photo.includes('http://')|| !this.userInfo.photo.includes('https://')){
this.userInfo.photo = USER_DEFAULT_HEADER
}
if(!this.userInfo.logo || !this.userInfo.logo.includes('http://')|| !this.userInfo.logo.includes('https://')){
this.userInfo.logo = ENTERPRISE_DEFAULT_HEADER
}
return true
return { isSuccess:true, message:''}
}else{
return { isSuccess:false, message:response.data.message}
}
} catch (error) {}
return false
} catch (error) {
return { isSuccess:false, message:'登录异常,请刷新页面重试'}
}
},
setUserLoginOut(){
this.token=''
......
<template>
<div class="full-height column flex-center items-center" v-if="!result">
<el-empty :image-size="200" description="抱歉,你的账户信息不存在" />
<div class="full-height column flex-center items-center" v-if="result && !result.isSuccess">
<el-empty :image-size="200" :description="result.message" />
</div>
</template>
<script setup lang="ts">
import { useUserStore } from '@/store/user';
import { AutoLoginResult, useUserStore } from '@/store/user';
import { query } from '@/utils/common';
import { ElLoading } from 'element-plus';
import { ref } from 'vue';
......@@ -14,16 +14,16 @@ import { useRouter } from 'vue-router';
const router = useRouter();
const forword = decodeURIComponent(router.currentRoute.value.query.forword)
const param = query(forword)
const result = ref(true)
const result = ref<AutoLoginResult|null>(null)
const userLoginHandler = async ()=>{
const loading = ElLoading.service({
fullscreen:true,
lock:true
})
if(param.uid){
let response = await useUserStore().setUserAutoLoginAsync(parseInt(param.uid))
if(response){
if(param.uid && param.uid!=''){
const response = await useUserStore().setUserAutoLoginAsync(param.uid)
if(response.isSuccess){
if(param.model=='0') {
router.push({
path: `/team_editor/${param.ConfigId}`
......@@ -37,11 +37,11 @@ const userLoginHandler = async ()=>{
path: "/space"
})
}
return
}
}
result.value=false
result.value = response
} else
result.value = { isSuccess:false, message:'无法获取到令牌信息'}
loading.close()
}
userLoginHandler()
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment