|
@@ -30,14 +30,15 @@
|
|
|
<img src="../../assets/imgs/验证码.png" alt="">
|
|
|
</template>
|
|
|
<template #suffix>
|
|
|
- <canvas id="validCode" @click="changeValidCode" class="valid-code"></canvas>
|
|
|
+ <img style="width: 80px;height: 50px;" :src="formInfo.vCodeReal" alt="" id="validCode" @click="changeValidCode" class="valid-code" />
|
|
|
+<!-- <canvas id="validCode" @click="changeValidCode" class="valid-code"></canvas>-->
|
|
|
</template>
|
|
|
</el-input>
|
|
|
</div>
|
|
|
<div class="error" v-if="showObj.isValidCodeEmptyShow">请输入验证码</div>
|
|
|
<div class="error" v-if="!showObj.isValidCodeEmptyShow && showObj.isValidCodeErrorShow">验证码错误</div>
|
|
|
<div >
|
|
|
- <div class="btn" @click="loginMyCim">登录</div>
|
|
|
+ <div class="btn" @click="loginIn_yyfnzt">登录</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -47,59 +48,166 @@
|
|
|
import {encode} from "js-base64";
|
|
|
import {onMounted, ref} from 'vue'
|
|
|
import {drawPic} from "@/unit/valid-code";
|
|
|
-import {loginCim} from "@/service/login";
|
|
|
+import {loginCim,randomImageCode_v2,kjUserInfologin} from "@/service/login";
|
|
|
import {showMessage} from "@/unit/element-ui/tip";
|
|
|
import {useRouter} from "vue-router";
|
|
|
import {useLoginStore} from "@/pinia/login";
|
|
|
+import Cookies from "js-cookie";
|
|
|
const router = useRouter()
|
|
|
let loginPinia = useLoginStore()
|
|
|
function changeValidCode(){
|
|
|
- formInfo.value.vCodeReal = drawPic()
|
|
|
+ // formInfo.value.vCodeReal = drawPic()
|
|
|
+ randomImageCode_v2().then(res =>{
|
|
|
+ const blob = new Blob([res], { type: "image/png" });
|
|
|
+ // 创建URL对象
|
|
|
+ formInfo.value.vCodeReal = URL.createObjectURL(blob);
|
|
|
+ })
|
|
|
}
|
|
|
function loginMyCim(){
|
|
|
+ loginCim({
|
|
|
+ username:formInfo.value.username,
|
|
|
+ password:encode(formInfo.value.psd)
|
|
|
+ }).then(res => {
|
|
|
+ let isTrue = false
|
|
|
+ try {
|
|
|
+ // debugger
|
|
|
+ isTrue = res.data.msg[0].Rows.length > 0
|
|
|
+
|
|
|
+ }catch {
|
|
|
+ isTrue = false
|
|
|
+ }
|
|
|
+ if (!isTrue){
|
|
|
+ showMessage({
|
|
|
+ type:'error',
|
|
|
+ message:'无权登录'
|
|
|
+ })
|
|
|
+ }else {
|
|
|
+
|
|
|
+ router.push('/LoginedPage')
|
|
|
+ localStorage.setItem('userInfoPsdOrUserName',JSON.stringify({
|
|
|
+ ...formInfo.value,
|
|
|
+ psd:encode(formInfo.value.psd) + '21'
|
|
|
+ }))
|
|
|
+ localStorage.setItem('canSeeSystemArr',JSON.stringify(res.data.msg[0].Rows))
|
|
|
+ // localStorage.setItem('auth-token',JSON.stringify(res.data.msg[0].Rows[res.msg[0].Rows.length-1].token))
|
|
|
+ loginPinia.$state.loginInfo = formInfo.value
|
|
|
+ loginPinia.$state.canSeeSystemArr = res.data.msg[0].Rows
|
|
|
+ }
|
|
|
+ // console.log('wodem',)
|
|
|
+ })
|
|
|
+ // showObj.value.isUserNameEmptyShow = !Boolean(formInfo.value.username)
|
|
|
+ // showObj.value.isPsdErrorEmptyShow = !Boolean(formInfo.value.psd)
|
|
|
+ // showObj.value.isValidCodeEmptyShow = !Boolean(formInfo.value.codeUserInput)
|
|
|
+ // showObj.value.isValidCodeErrorShow = Boolean(formInfo.value.codeUserInput) && !(formInfo.value.codeUserInput.toLowerCase() === formInfo.value.vCodeReal.toLowerCase())
|
|
|
+ // if (showObj.value.isValidCodeErrorShow){
|
|
|
+ // randomImageCode_v2();
|
|
|
+ // }
|
|
|
+ // if (!showObj.value.isUserNameEmptyShow && !showObj.value.isPsdErrorEmptyShow && !showObj.value.isValidCodeEmptyShow && !showObj.value.isValidCodeErrorShow){
|
|
|
+ // loginCim({
|
|
|
+ // username:formInfo.value.username,
|
|
|
+ // password:encode(formInfo.value.psd)
|
|
|
+ // }).then(res => {
|
|
|
+ // let isTrue = false
|
|
|
+ // try {
|
|
|
+ // // debugger
|
|
|
+ // isTrue = res.data.msg[0].Rows.length > 0
|
|
|
+ //
|
|
|
+ // }catch {
|
|
|
+ // isTrue = false
|
|
|
+ // }
|
|
|
+ // if (!isTrue){
|
|
|
+ // showMessage({
|
|
|
+ // type:'error',
|
|
|
+ // message:'无权登录'
|
|
|
+ // })
|
|
|
+ // }else {
|
|
|
+ //
|
|
|
+ // router.push('/LoginedPage')
|
|
|
+ // localStorage.setItem('userInfoPsdOrUserName',JSON.stringify({
|
|
|
+ // ...formInfo.value,
|
|
|
+ // psd:encode(formInfo.value.psd) + '21'
|
|
|
+ // }))
|
|
|
+ // localStorage.setItem('canSeeSystemArr',JSON.stringify(res.data.msg[0].Rows))
|
|
|
+ // // localStorage.setItem('auth-token',JSON.stringify(res.data.msg[0].Rows[res.msg[0].Rows.length-1].token))
|
|
|
+ // loginPinia.$state.loginInfo = formInfo.value
|
|
|
+ // loginPinia.$state.canSeeSystemArr = res.data.msg[0].Rows
|
|
|
+ // }
|
|
|
+ // // console.log('wodem',)
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+}
|
|
|
+
|
|
|
+function loginIn_yyfnzt() {
|
|
|
showObj.value.isUserNameEmptyShow = !Boolean(formInfo.value.username)
|
|
|
showObj.value.isPsdErrorEmptyShow = !Boolean(formInfo.value.psd)
|
|
|
showObj.value.isValidCodeEmptyShow = !Boolean(formInfo.value.codeUserInput)
|
|
|
- showObj.value.isValidCodeErrorShow = Boolean(formInfo.value.codeUserInput) && !(formInfo.value.codeUserInput.toLowerCase() === formInfo.value.vCodeReal.toLowerCase())
|
|
|
- if (showObj.value.isValidCodeErrorShow){
|
|
|
- formInfo.value.vCodeReal = drawPic()
|
|
|
+ //showObj.value.isValidCodeErrorShow = Boolean(formInfo.value.codeUserInput) && !(formInfo.value.codeUserInput.toLowerCase() === formInfo.value.vCodeReal.toLowerCase())
|
|
|
+ if (showObj.value.isUserNameEmptyShow || showObj.value.isPsdErrorEmptyShow || showObj.value.isValidCodeEmptyShow){
|
|
|
+ changeValidCode();
|
|
|
+ return;
|
|
|
}
|
|
|
- if (!showObj.value.isUserNameEmptyShow && !showObj.value.isPsdErrorEmptyShow && !showObj.value.isValidCodeEmptyShow && !showObj.value.isValidCodeErrorShow){
|
|
|
- loginCim({
|
|
|
- username:formInfo.value.username,
|
|
|
- password:encode(formInfo.value.psd)
|
|
|
- }).then(res => {
|
|
|
- let isTrue = false
|
|
|
- try {
|
|
|
- // debugger
|
|
|
- isTrue = res.data.msg[0].Rows.length > 0
|
|
|
-
|
|
|
- }catch {
|
|
|
- isTrue = false
|
|
|
- }
|
|
|
- if (!isTrue){
|
|
|
+ kjUserInfologin(formInfo.value.username,encode(formInfo.value.psd),formInfo.value.codeUserInput)
|
|
|
+ .then(res => {
|
|
|
+ //刷新验证码
|
|
|
+ changeValidCode();
|
|
|
+ let data
|
|
|
+ try {
|
|
|
+ //如果没有查询到登陆信息则报错
|
|
|
+ data = res.msg[0].Rows;
|
|
|
+ }catch {
|
|
|
+ showMessage({
|
|
|
+ type: 'error',
|
|
|
+ message: '登录失败'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ //存在多条用户信息时报错
|
|
|
+ if(data.length != 1){
|
|
|
+ showMessage({
|
|
|
+ type: 'error',
|
|
|
+ message: '登录失败'
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ //验证密码输入次数
|
|
|
+ var time2 = new Date(data[0]["GETTIME"]).getTime() - new Date(data[0]["LAST_TIME"]).getTime();
|
|
|
+ if (time2<=15*60*1000){
|
|
|
+ if (+data[0].LOGIN_COUNT>0){
|
|
|
+ if (+data[0].LOGIN_COUNT<5){
|
|
|
+ showMessage({
|
|
|
+ type:'error',
|
|
|
+ message:`密码错误${+data[0].LOGIN_COUNT }次,5次将锁定账号`
|
|
|
+ })
|
|
|
+ }else {
|
|
|
+ showMessage({
|
|
|
+ type:'error',
|
|
|
+ message:'账号已锁定,请15分钟后重试'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(data[0]["USERID"] != null && data[0]["USERID"].length > 0){
|
|
|
+ loginMyCim();
|
|
|
+ }else{
|
|
|
+ showMessage({
|
|
|
+ type: 'error',
|
|
|
+ message: '登录失败'
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ })
|
|
|
+ .catch((e) => {
|
|
|
showMessage({
|
|
|
- type:'error',
|
|
|
- message:'无权登录'
|
|
|
+ type: 'error',
|
|
|
+ message: '登录失败'
|
|
|
})
|
|
|
- }else {
|
|
|
-
|
|
|
- router.push('/LoginedPage')
|
|
|
- localStorage.setItem('userInfoPsdOrUserName',JSON.stringify({
|
|
|
- ...formInfo.value,
|
|
|
- psd:encode(formInfo.value.psd) + '21'
|
|
|
- }))
|
|
|
- localStorage.setItem('canSeeSystemArr',JSON.stringify(res.data.msg[0].Rows))
|
|
|
- // localStorage.setItem('auth-token',JSON.stringify(res.data.msg[0].Rows[res.msg[0].Rows.length-1].token))
|
|
|
- loginPinia.$state.loginInfo = formInfo.value
|
|
|
- loginPinia.$state.canSeeSystemArr = res.data.msg[0].Rows
|
|
|
- }
|
|
|
- // console.log('wodem',)
|
|
|
- })
|
|
|
- }
|
|
|
+ })
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
- formInfo.value.vCodeReal = drawPic()
|
|
|
+ changeValidCode();
|
|
|
})
|
|
|
let showObj= ref({
|
|
|
isUserNameEmptyShow:false,
|