|
|
@ -30,15 +30,10 @@ |
|
|
|
<el-col :span="24" style="padding-right: 10px; padding-left: 10px"> |
|
|
|
<el-form-item prop="password"> |
|
|
|
<el-input v-model="loginData.loginForm.password" :placeholder="t('login.passwordPlaceholder')" |
|
|
|
:prefix-icon="iconLock" show-password type="password" @keyup.enter="passwordEnter" style="height: 42px;" /> |
|
|
|
:prefix-icon="iconLock" show-password type="password" @keyup.enter="getCode()" style="height: 42px;" /> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="24" style="padding-right: 10px; padding-left: 10px" v-if="needCode"> |
|
|
|
<el-form-item prop="code"> |
|
|
|
<Verify ref="VerifySlide" captchaType="blockPuzzle" mode="" :imgSize="{ width: '450px', height: '225px' }" @success="capctchaCheckSuccess" @error="capctchaCheckError"></Verify> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<!-- <el-col :span="24" style="padding-right: 10px; padding-left: 10px" v-if="needCode"> |
|
|
|
<el-col :span="24" style="padding-right: 10px; padding-left: 10px"> |
|
|
|
<el-form-item prop="code"> |
|
|
|
<div class="flex w-[100%]"> |
|
|
|
<el-input v-model="loginData.loginForm.code" :placeholder="t('login.codePlaceholder')" |
|
|
@ -52,14 +47,14 @@ |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</el-form-item> |
|
|
|
</el-col> --> |
|
|
|
</el-col> |
|
|
|
<el-col :span="24" style="padding-right: 10px; padding-left: 10px; margin-top: -20px; margin-bottom: -20px"> |
|
|
|
<el-form-item> |
|
|
|
<el-row justify="space-between" style="width: 100%"> |
|
|
|
<el-col :span="6"> |
|
|
|
<!-- <el-checkbox v-model="loginData.loginForm.rememberMe"> |
|
|
|
<el-checkbox v-model="loginData.loginForm.rememberMe"> |
|
|
|
{{ t('login.remember') }} |
|
|
|
</el-checkbox> --> |
|
|
|
</el-checkbox> |
|
|
|
</el-col> |
|
|
|
<el-col :offset="6" :span="12"> |
|
|
|
<el-link style="float: right" type="primary" |
|
|
@ -74,8 +69,14 @@ |
|
|
|
<XButton :loading="loginLoading" :title="t('login.login')" class="w-[100%]" type="primary" |
|
|
|
@click="handleLogin()" /> |
|
|
|
</el-form-item> |
|
|
|
|
|
|
|
</el-col> |
|
|
|
<!-- <Verify |
|
|
|
ref="verify" |
|
|
|
:captchaType="captchaType" |
|
|
|
:imgSize="{ width: '400px', height: '200px' }" |
|
|
|
mode="pop" |
|
|
|
@success="handleLogin" |
|
|
|
/> --> |
|
|
|
</el-row> |
|
|
|
</el-form> |
|
|
|
</template> |
|
|
@ -89,18 +90,13 @@ |
|
|
|
import * as authUtil from '@/utils/auth' |
|
|
|
import { usePermissionStore } from '@/store/modules/permission' |
|
|
|
import * as LoginApi from '@/api/login' |
|
|
|
import * as PassWordApi from '@/api/system/password' |
|
|
|
import { LoginStateEnum, useFormValid, useLoginState } from './useLogin' |
|
|
|
import { getCodeImg } from "@/api/login"; |
|
|
|
import router from "@/router"; |
|
|
|
import { CACHE_KEY, useCache } from '@/hooks/web/useCache' |
|
|
|
import * as DeptApi from '@/api/system/dept' |
|
|
|
import { getTenant } from '@/utils/systemParam' |
|
|
|
import { getSystermUpdateAlert,getSystermUpdateUrl,getNeedCode } from '@/utils/systemParam' |
|
|
|
import {validateResetTime} from "@/api/system/password"; |
|
|
|
import { Verify } from '@/components/Verifition' |
|
|
|
|
|
|
|
const needCode = ref(getNeedCode()==true||getNeedCode()=='true') |
|
|
|
import { getSystermUpdateAlert,getSystermUpdateUrl } from '@/utils/systemParam' |
|
|
|
|
|
|
|
defineOptions({ name: 'LoginForm' }) |
|
|
|
|
|
|
@ -116,7 +112,8 @@ |
|
|
|
const permissionStore = usePermissionStore() |
|
|
|
const redirect = ref<string>('') |
|
|
|
const loginLoading = ref(false) |
|
|
|
const VerifySlide = ref() |
|
|
|
const verify = ref() |
|
|
|
const captchaType = ref('blockPuzzle') // blockPuzzle 滑块 clickWord 点击文字 |
|
|
|
|
|
|
|
|
|
|
|
const getShow = computed(() => unref(getLoginState) === LoginStateEnum.LOGIN) |
|
|
@ -148,8 +145,8 @@ |
|
|
|
tenantEnable: import.meta.env.VITE_APP_TENANT_ENABLE, |
|
|
|
loginForm: { |
|
|
|
tenantName: tenantArray.value[0].name, |
|
|
|
username: '', |
|
|
|
password: '', |
|
|
|
username: 'admin', |
|
|
|
password: '123456', |
|
|
|
captchaVerification: '', |
|
|
|
rememberMe: false, |
|
|
|
code: '', |
|
|
@ -175,27 +172,14 @@ |
|
|
|
// verify.value.show() |
|
|
|
// } |
|
|
|
// } |
|
|
|
const passwordEnter = ()=>{ |
|
|
|
if(!needCode.value){ |
|
|
|
handleLogin() |
|
|
|
return |
|
|
|
}else{ |
|
|
|
getCode() |
|
|
|
} |
|
|
|
} |
|
|
|
function getCode() { |
|
|
|
console.log('getCode') |
|
|
|
if(!needCode.value){ |
|
|
|
return |
|
|
|
getCodeImg().then(res => { |
|
|
|
captchaEnabled.value = res.captchaEnabled === undefined ? true : res.captchaEnabled; |
|
|
|
if (captchaEnabled.value) { |
|
|
|
codeUrl.value = "data:image/gif;base64," + res.img; |
|
|
|
loginData.loginForm.uuid = res.uuid; |
|
|
|
} |
|
|
|
VerifySlide.value.refresh() |
|
|
|
// getCodeImg().then(res => { |
|
|
|
// captchaEnabled.value = res.captchaEnabled === undefined ? true : res.captchaEnabled; |
|
|
|
// if (captchaEnabled.value) { |
|
|
|
// codeUrl.value = "data:image/gif;base64," + res.img; |
|
|
|
// loginData.loginForm.uuid = res.uuid; |
|
|
|
// } |
|
|
|
// }); |
|
|
|
}); |
|
|
|
} |
|
|
|
//获取租户ID |
|
|
|
const getTenantId = async () => { |
|
|
@ -223,75 +207,29 @@ |
|
|
|
name: 'ForgetPassword', |
|
|
|
}) |
|
|
|
}; |
|
|
|
// 滑块校验成功 |
|
|
|
const capctchaCheckSuccess = async ({captchaVerification})=>{ |
|
|
|
console.log('capctchaCheckSuccess',captchaVerification) |
|
|
|
if(captchaVerification){ |
|
|
|
loginData.loginForm.code = captchaVerification |
|
|
|
await handleLogin() |
|
|
|
} |
|
|
|
} |
|
|
|
// 滑块校验失败 |
|
|
|
const capctchaCheckError = ()=>{ |
|
|
|
console.log('capctchaCheckError') |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const loading = ref() // ElLoading.service 返回的实例 |
|
|
|
// 登录 |
|
|
|
const handleLogin = async () => { |
|
|
|
const handleLogin = async (params) => { |
|
|
|
console.log('登录-185') |
|
|
|
loginLoading.value = true |
|
|
|
|
|
|
|
try { |
|
|
|
await getTenantId() |
|
|
|
|
|
|
|
const data = await validForm() |
|
|
|
if (!data) { |
|
|
|
return |
|
|
|
} |
|
|
|
let res = null |
|
|
|
if(!needCode.value){ |
|
|
|
res = await LoginApi.loginNoCode(loginData.loginForm) |
|
|
|
}else{ |
|
|
|
res = await LoginApi.login(loginData.loginForm) |
|
|
|
} |
|
|
|
|
|
|
|
console.log('登陆res',res) |
|
|
|
const differenceDays = await PassWordApi.validateResetTime(res.userId) |
|
|
|
switch (differenceDays){ |
|
|
|
case null: |
|
|
|
break |
|
|
|
case 0: |
|
|
|
if(getSystermUpdateAlert()=='true'||getSystermUpdateAlert()===true){ |
|
|
|
await ElMessageBox.alert( |
|
|
|
'<strong>密码到期,请立即修改</strong>', |
|
|
|
'<strong>系统迁移,请移步至</strong>' + |
|
|
|
`<a href=${getSystermUpdateUrl()} target="_blank">${getSystermUpdateUrl()}</a>`, |
|
|
|
'重要提示', |
|
|
|
{ |
|
|
|
dangerouslyUseHTMLString: true, |
|
|
|
} |
|
|
|
) |
|
|
|
router.push({path:"/updatePasswordNewTips",query:{username:loginData.loginForm.username}}) |
|
|
|
return |
|
|
|
case 1: |
|
|
|
await ElMessageBox.alert( |
|
|
|
'<strong>密码到期,请立即修改</strong>', |
|
|
|
'重要提示', |
|
|
|
{ |
|
|
|
dangerouslyUseHTMLString: true, |
|
|
|
} |
|
|
|
) |
|
|
|
router.push({path:"/updatePasswordNewTips",query:{username:loginData.loginForm.username}}) |
|
|
|
loginLoading.value = true |
|
|
|
try { |
|
|
|
await getTenantId() |
|
|
|
const data = await validForm() |
|
|
|
if (!data) { |
|
|
|
return |
|
|
|
default: |
|
|
|
await ElMessageBox.alert( |
|
|
|
'密码'+differenceDays+'到期,请尽快修改。', |
|
|
|
'重要提示', |
|
|
|
{ |
|
|
|
dangerouslyUseHTMLString: true, |
|
|
|
} |
|
|
|
) |
|
|
|
break |
|
|
|
} |
|
|
|
const res = await LoginApi.login(loginData.loginForm) |
|
|
|
if (!res) { |
|
|
|
console.log('登录-195') |
|
|
|
getCode() |
|
|
@ -308,16 +246,6 @@ |
|
|
|
authUtil.removeLoginForm() |
|
|
|
} |
|
|
|
authUtil.setToken(res) |
|
|
|
if(getSystermUpdateAlert()=='true'||getSystermUpdateAlert()===true){ |
|
|
|
await ElMessageBox.alert( |
|
|
|
'<strong>系统迁移,请移步至</strong>' + |
|
|
|
`<a href=${getSystermUpdateUrl()} target="_blank">${getSystermUpdateUrl()}</a>`, |
|
|
|
'重要提示', |
|
|
|
{ |
|
|
|
dangerouslyUseHTMLString: true, |
|
|
|
} |
|
|
|
) |
|
|
|
} |
|
|
|
if (!redirect.value) { |
|
|
|
redirect.value = '/' |
|
|
|
} |
|
|
@ -331,19 +259,14 @@ |
|
|
|
// 存储 部门信息 |
|
|
|
const { wsCache } = useCache() |
|
|
|
wsCache.set(CACHE_KEY.DEPT, await DeptApi.getSimpleDeptList()) |
|
|
|
}catch (e){ |
|
|
|
if(e.code === 1002000008){ |
|
|
|
setTimeout(function (){ |
|
|
|
router.push({path:"/updatePasswordNewTips",query:{username:loginData.loginForm.username}}) |
|
|
|
},1500) |
|
|
|
} |
|
|
|
} finally { |
|
|
|
console.log('登录-224') |
|
|
|
getCode() |
|
|
|
loginLoading.value = false |
|
|
|
loading?.value?.close() |
|
|
|
getCode() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 社交登录 |
|
|
|
const doSocialLogin = async (type : number) => { |
|
|
|
if (type === 0) { |
|
|
|