Browse Source

HL-5269

hella_online_20240911
yufei_wang 2 months ago
parent
commit
c8639ed2e1
  1. 57
      src/views/login/components/LoginForm.vue

57
src/views/login/components/LoginForm.vue

@ -34,6 +34,11 @@
</el-form-item> </el-form-item>
</el-col> </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" 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-form-item prop="code"> <el-form-item prop="code">
<div class="flex w-[100%]"> <div class="flex w-[100%]">
<el-input v-model="loginData.loginForm.code" :placeholder="t('login.codePlaceholder')" <el-input v-model="loginData.loginForm.code" :placeholder="t('login.codePlaceholder')"
@ -47,7 +52,7 @@
</div> </div>
</div> </div>
</el-form-item> </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-col :span="24" style="padding-right: 10px; padding-left: 10px; margin-top: -20px; margin-bottom: -20px">
<el-form-item> <el-form-item>
<el-row justify="space-between" style="width: 100%"> <el-row justify="space-between" style="width: 100%">
@ -69,14 +74,8 @@
<XButton :loading="loginLoading" :title="t('login.login')" class="w-[100%]" type="primary" <XButton :loading="loginLoading" :title="t('login.login')" class="w-[100%]" type="primary"
@click="handleLogin()" /> @click="handleLogin()" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<!-- <Verify
ref="verify"
:captchaType="captchaType"
:imgSize="{ width: '400px', height: '200px' }"
mode="pop"
@success="handleLogin"
/> -->
</el-row> </el-row>
</el-form> </el-form>
</template> </template>
@ -99,6 +98,8 @@
import { getTenant } from '@/utils/systemParam' import { getTenant } from '@/utils/systemParam'
import { getSystermUpdateAlert,getSystermUpdateUrl,getNeedCode } from '@/utils/systemParam' import { getSystermUpdateAlert,getSystermUpdateUrl,getNeedCode } from '@/utils/systemParam'
import {validateResetTime} from "@/api/system/password"; import {validateResetTime} from "@/api/system/password";
import { Verify } from '@/components/Verifition'
const needCode = ref(getNeedCode()==true||getNeedCode()=='true') const needCode = ref(getNeedCode()==true||getNeedCode()=='true')
defineOptions({ name: 'LoginForm' }) defineOptions({ name: 'LoginForm' })
@ -115,8 +116,7 @@
const permissionStore = usePermissionStore() const permissionStore = usePermissionStore()
const redirect = ref<string>('') const redirect = ref<string>('')
const loginLoading = ref(false) const loginLoading = ref(false)
const verify = ref() const VerifySlide = ref()
const captchaType = ref('blockPuzzle') // blockPuzzle clickWord
const getShow = computed(() => unref(getLoginState) === LoginStateEnum.LOGIN) const getShow = computed(() => unref(getLoginState) === LoginStateEnum.LOGIN)
@ -184,16 +184,18 @@
} }
} }
function getCode() { function getCode() {
console.log('getCode')
if(!needCode.value){ if(!needCode.value){
return return
} }
getCodeImg().then(res => { VerifySlide.value.refresh()
captchaEnabled.value = res.captchaEnabled === undefined ? true : res.captchaEnabled; // getCodeImg().then(res => {
if (captchaEnabled.value) { // captchaEnabled.value = res.captchaEnabled === undefined ? true : res.captchaEnabled;
codeUrl.value = "data:image/gif;base64," + res.img; // if (captchaEnabled.value) {
loginData.loginForm.uuid = res.uuid; // codeUrl.value = "data:image/gif;base64," + res.img;
} // loginData.loginForm.uuid = res.uuid;
}); // }
// });
} }
//ID //ID
const getTenantId = async () => { const getTenantId = async () => {
@ -221,10 +223,23 @@
name: 'ForgetPassword', name: 'ForgetPassword',
}) })
}; };
//
const capctchaCheckSuccess = async ({captchaVerification})=>{
console.log('capctchaCheckSuccess',captchaVerification)
if(captchaVerification){
loginData.loginForm.code = captchaVerification
await handleLogin()
}
}
//
const capctchaCheckError = ()=>{
VerifySlide.value.refresh()
}
const loading = ref() // ElLoading.service const loading = ref() // ElLoading.service
// //
const handleLogin = async (params) => { const handleLogin = async () => {
console.log('登录-185') console.log('登录-185')
if(getSystermUpdateAlert()=='true'||getSystermUpdateAlert()===true){ if(getSystermUpdateAlert()=='true'||getSystermUpdateAlert()===true){
await ElMessageBox.alert( await ElMessageBox.alert(
@ -237,8 +252,10 @@
) )
} }
loginLoading.value = true loginLoading.value = true
try { try {
await getTenantId() await getTenantId()
const data = await validForm() const data = await validForm()
if (!data) { if (!data) {
return return
@ -249,6 +266,8 @@
}else{ }else{
res = await LoginApi.login(loginData.loginForm) res = await LoginApi.login(loginData.loginForm)
} }
console.log('登陆res',res)
try{ try{
await PassWordApi.validateResetTime(res.userId) await PassWordApi.validateResetTime(res.userId)
}catch (e) { }catch (e) {
@ -293,9 +312,9 @@
wsCache.set(CACHE_KEY.DEPT, await DeptApi.getSimpleDeptList()) wsCache.set(CACHE_KEY.DEPT, await DeptApi.getSimpleDeptList())
}finally { }finally {
console.log('登录-224') console.log('登录-224')
getCode()
loginLoading.value = false loginLoading.value = false
loading?.value?.close() loading?.value?.close()
getCode()
} }
} }
// //

Loading…
Cancel
Save