From e54afa9e32404cbca824fa41be070e573587588a Mon Sep 17 00:00:00 2001
From: pxzsky <pxzsky@163.com>
Date: 星期二, 14 三月 2023 18:42:30 +0800
Subject: [PATCH] 登录修改接口参数

---
 src/api/login.js          |   27 +++++++++++--
 src/views/user/login.vue  |   69 +++++++++++++++++++++-------------
 src/store/modules/user.js |    6 ++
 3 files changed, 70 insertions(+), 32 deletions(-)

diff --git a/src/api/login.js b/src/api/login.js
index 649f59c..b76a766 100644
--- a/src/api/login.js
+++ b/src/api/login.js
@@ -1,13 +1,16 @@
 import request from '@/utils/request'
 
 // 鐧诲綍鏂规硶
-export function login(username, password, code, uuid) {
+export function login(username, password, code, uuid, loginType, verifyType) {
+// export function login(data) {
   const data = {
     username,
     password,
     code,
-    uuid
-  }
+    uuid,
+    loginType,
+    verifyType
+  };
   return request({
     url: '/login',
     headers: {
@@ -49,11 +52,25 @@
 // 鑾峰彇楠岃瘉鐮�
 export function getCodeImg() {
   return request({
-    url: '/captchaImage',
+    // url: '/captchaImage',
+    url: '/captcha/image',
     headers: {
       isToken: false
     },
     method: 'get',
     timeout: 20000
   })
-}
\ No newline at end of file
+}
+
+// 鑾峰彇娌℃湁楠岃瘉鐮佹儏鍐碉紝鏃跺厠鑻憋紝2023-03-14
+export function getCodeNone() {
+  return request({
+    // url: '/captchaNone',
+    url: '/captcha/none',
+    headers: {
+      isToken: false
+    },
+    method: 'get',
+    timeout: 20000
+  })
+}
diff --git a/src/store/modules/user.js b/src/store/modules/user.js
index cd54143..0d437c8 100644
--- a/src/store/modules/user.js
+++ b/src/store/modules/user.js
@@ -1,5 +1,6 @@
 import { login, logout, getInfo } from '@/api/login'
 import { getToken, setToken, removeToken } from '@/utils/auth'
+import log from "@/views/monitor/job/log";
 
 const user = {
   state: {
@@ -35,8 +36,11 @@
       const password = userInfo.password
       const code = userInfo.code
       const uuid = userInfo.uuid
+      const loginType = userInfo.loginType
+      const verifyType = userInfo.verifyType
+
       return new Promise((resolve, reject) => {
-        login(username, password, code, uuid).then(res => {
+        login(username, password, code, uuid, loginType, verifyType).then(res => {
           // console.log(res.data.token)
           // setToken(res.token)
           setToken(res.data.token)
diff --git a/src/views/user/login.vue b/src/views/user/login.vue
index 497dfc6..53cec33 100644
--- a/src/views/user/login.vue
+++ b/src/views/user/login.vue
@@ -65,12 +65,12 @@
 </template>
 
 <script>
-import { getCodeImg } from "@/api/login";
-import dragVerify from './dragVerify/index.vue'// 婊戝姩楠岃瘉缁勪欢
-import Cookies from "js-cookie";
-import { encrypt, decrypt } from '@/utils/jsencrypt'
+  import {getCodeImg, getCodeNone} from "@/api/login";
+  import dragVerify from './dragVerify/index.vue' // 婊戝姩楠岃瘉缁勪欢
+  import Cookies from "js-cookie";
+  import {encrypt} from '@/utils/jsencrypt'
 
-export default {
+  export default {
   components: {
     'drag-verify': dragVerify
   },
@@ -79,12 +79,13 @@
       verify:false,  // 婊戝姩鏍¢獙
       codeUrl: "",
       loginForm: {
-        verifyType: 'code',//  'code': 楠岃瘉鐮�  'slide':婊戝潡  'jigsaw':鎷煎浘
-        username: "supervisor",
-        password: "123456",
-        rememberMe: false,
+        username: 'supervisor',
+        password: '123456',
         code:'',
-        uuid: ""
+        uuid: '',
+        loginType: 'user_pass',  // 鐢ㄦ埛鍚嶃�佸瘑鐮佹柟寮忕櫥褰�
+        verifyType: 'slide'//  'code': 楠岃瘉鐮�  'slide':婊戝潡  'jigsaw':鎷煎浘
+        // rememberMe: false,
       },
       loginRules: {
         username: [
@@ -112,9 +113,9 @@
     }
   },
   created() {
-    if(this.loginForm.verifyType==='code'){
-      this.getCode();
-    }
+    // if(this.loginForm.verifyType==='code'){
+    // }
+    this.getCode();
     this.getCookie();
   },
   methods: {
@@ -122,20 +123,34 @@
       this.verify = true
     },
     getCode() {
-      getCodeImg().then(res => {
-        // console.log(res);
-        // this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled;
-        this.captchaEnabled = res.data.captchaEnabled === undefined ? true : res.data.captchaEnabled;
-        console.log("captchaEnabled = " + this.captchaEnabled);
-        if (this.captchaEnabled) {
-          // this.codeUrl = "data:image/gif;base64," + res.img;
-          this.codeUrl = "data:image/jpeg;base64," + res.data.img;
-          // this.loginForm.uuid = res.uuid;
-        }
-        // 鏈夋病鏈夐獙璇佺爜锛岄兘闇�瑕乽uid浣滀负鍞竴鏍囪瘑锛�2022-12-01
-        this.loginForm.uuid = res.data.uuid;
+      if(this.loginForm.verifyType==='code'){
+        getCodeImg().then(res => {
+          // console.log(res);
+          // this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled;
+          this.captchaEnabled = res.data.captchaEnabled === undefined ? true : res.data.captchaEnabled;
+          console.log("captchaEnabled = " + this.captchaEnabled);
+          if (this.captchaEnabled) {
+            // this.codeUrl = "data:image/gif;base64," + res.img;
+            this.codeUrl = "data:image/jpeg;base64," + res.data.img;
+            // this.loginForm.uuid = res.uuid;
+          }
+          // 鏈夋病鏈夐獙璇佺爜锛岄兘闇�瑕乽uid浣滀负鍞竴鏍囪瘑锛�2022-12-01
+          this.loginForm.uuid = res.data.uuid;
 
-      }).catch(err=>{console.log(err);});
+        }).catch(err=>{console.log(err);});
+
+      } else if(this.loginForm.verifyType==='jigsaw'){
+        // 鎷煎浘鏂瑰紡锛岀湅闇�瑕佸暐鍙傛暟锛屾殏鏈疄鐜�
+
+      } else if(this.loginForm.verifyType==='slide' || this.loginForm.verifyType==='sms'){
+        // 涓嶉渶瑕侀獙璇佺爜锛屼絾浠嶉渶瑕佽姹傛帴鍙h幏鍙杣uid
+        getCodeNone().then(res => {
+          this.loginForm.uuid = res.data.uuid;
+        }).catch(err=>{console.error(err);});
+
+      } else {
+        this.$message.error('涓嶆敮鎸佺殑楠岃瘉鐮佺被鍨�:' + this.loginForm.verifyType);
+      }
     },
     getCookie() {
       const username = Cookies.get("username");
@@ -163,6 +178,8 @@
             Cookies.remove("password");
             Cookies.remove('rememberMe');
           }
+          // console.log(this.loginForm);
+          // console.log("-----------------------------");
           this.$store.dispatch("Login", this.loginForm).then(() => {
             this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
           }).catch(() => {

--
Gitblit v1.9.1