2 Commits f69d9c73ff ... 332747d569

Author SHA1 Message Date
  psj 332747d569 Merge remote-tracking branch 'origin/master' 1 month ago
  psj 0de7d8f45d 页面登陆修改 1 month ago
3 changed files with 196 additions and 40 deletions
  1. 23 0
      src/service/index.js
  2. 26 1
      src/service/login.js
  3. 147 39
      src/views/login/Login.vue

+ 23 - 0
src/service/index.js

@@ -40,6 +40,17 @@ export const requestInstance_YYFN = axios.create({
 	},
 })
 
+export const requestInstance_YYFNIMG = axios.create({
+	baseURL: import.meta.env.VITE_BASE_API,
+	timeout: 60000,
+	method: 'post',
+	responseType: "blob",
+	withCredentials:true,
+	headers:{
+		Systemtype:"47e0971bb15b4420bf1f351510378c73"
+	},
+})
+
 // 应用赋能中台
 export const requestInstanceV2 = axios.create({
 	baseURL: import.meta.env.VITE_BASE_API_V2,
@@ -78,6 +89,18 @@ requestInstance_YYFN.interceptors.response.use(function (res) {
 	throw new Error(error)
 })
 
+requestInstance_YYFNIMG.interceptors.request.use((config) => {
+	return config
+},(error) => {
+	return new Error(error)
+})
+
+requestInstance_YYFNIMG.interceptors.response.use(function (res) {
+	return res.data
+},function (error) {
+	return new Error(error)
+})
+
 
 export const requestInstance_KJLL = axios.create({
 	baseURL: import.meta.env.VITE_BASE_API,

+ 26 - 1
src/service/login.js

@@ -3,7 +3,12 @@ import {
     requestInstance_login,
     requestInstance_KJGL,
     requestInstance_KJLL,
-    requestInstance_FXFN, requestInstance_PTJK, requestInstance_CSTJ, requestInstance_YYFN, requestInstanceV2
+    requestInstance_FXFN,
+    requestInstance_PTJK,
+    requestInstance_CSTJ,
+    requestInstance_YYFN,
+    requestInstanceV2,
+    requestInstance_YYFNIMG
 } from "@/service/index";
 
 export function loginCim(params) {
@@ -82,6 +87,26 @@ export function loginInYYFNZW(username, password, TYPE) {
     })
 }
 
+export function kjUserInfologin(username, password, verifyCode) {
+    return requestInstance_YYFN({
+        url: '/user/KJuserLogin',
+        data: {
+            "username": username,
+            "password": password,
+            "verifyCode":verifyCode,
+        },
+    })
+}
+
+//获取验证码
+export function randomImageCode_v2(username, password, TYPE) {
+    return requestInstance_YYFNIMG({
+        url: '/user/randomImageCode_v2',
+        data: {
+        },
+    })
+}
+
 export function loginInZw(username, password, TYPE) {
     return requestInstance_PTJK({
         url: '/user/userLogin',

+ 147 - 39
src/views/login/Login.vue

@@ -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,