From dc13238b5f156a6196d9c554e31cf56aa2f12aa6 Mon Sep 17 00:00:00 2001
From: zhanghua <314079846@qq.com>
Date: 星期四, 21 十一月 2024 21:48:55 +0800
Subject: [PATCH] 登录页面修改

---
 src/views/login.vue |  389 +++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 278 insertions(+), 111 deletions(-)

diff --git a/src/views/login.vue b/src/views/login.vue
index 06c09d2..c17f4c4 100644
--- a/src/views/login.vue
+++ b/src/views/login.vue
@@ -1,62 +1,134 @@
 <template>
   <div class="login">
-    <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form">
-      <h3 class="title">鑻ヤ緷鍚庡彴绠$悊绯荤粺</h3>
-      <el-form-item prop="username">
-        <el-input
-          v-model="loginForm.username"
-          type="text"
-          auto-complete="off"
-          placeholder="璐﹀彿"
-        >
-          <svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" />
-        </el-input>
-      </el-form-item>
-      <el-form-item prop="password">
-        <el-input
-          v-model="loginForm.password"
-          type="password"
-          auto-complete="off"
-          placeholder="瀵嗙爜"
-          @keyup.enter.native="handleLogin"
-        >
-          <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
-        </el-input>
-      </el-form-item>
-      <el-form-item prop="code" v-if="captchaEnabled">
-        <el-input
-          v-model="loginForm.code"
-          auto-complete="off"
-          placeholder="楠岃瘉鐮�"
-          style="width: 63%"
-          @keyup.enter.native="handleLogin"
-        >
-          <svg-icon slot="prefix" icon-class="validCode" class="el-input__icon input-icon" />
-        </el-input>
-        <div class="login-code">
-          <img :src="codeUrl" @click="getCode" class="login-code-img"/>
+    <div class="nav">
+      <img alt="" src="../assets/images/bj.png" />
+      <div class="ml-[10px]">灏勬椽甯傞」鐩鐞嗙郴缁�</div>
+    </div>
+    <div class="conter">
+      <div class="left">
+        <div class="title">灏勬椽甯傞」鐩鐞嗙郴缁�</div>
+        <div>
+          杩愮敤绯荤粺鐨勮鐐广�佹柟娉曞拰鐞嗚锛屽椤圭洰娑夊強鐨勫叏閮ㄥ伐浣滆繘琛屾湁鏁堝湴绠$悊
         </div>
-      </el-form-item>
-      <el-checkbox v-model="loginForm.rememberMe" style="margin:0px 0px 25px 0px;">璁颁綇瀵嗙爜</el-checkbox>
-      <el-form-item style="width:100%;">
-        <el-button
-          :loading="loading"
-          size="medium"
-          type="primary"
-          style="width:100%;"
-          @click.native.prevent="handleLogin"
-        >
-          <span v-if="!loading">鐧� 褰�</span>
-          <span v-else>鐧� 褰� 涓�...</span>
-        </el-button>
-        <div style="float: right;" v-if="register">
-          <router-link class="link-type" :to="'/register'">绔嬪嵆娉ㄥ唽</router-link>
+        <div class="img"></div>
+      </div>
+      <div class="right">
+        <div class="tab">
+          <div
+            :class="{ active: currentTab === 'corporation' }"
+            class="login-corporation"
+            @click="currentClick('corporation')"
+          >
+            娉曚汉鐧诲綍
+          </div>
+          <div
+            :class="{ active: currentTab === 'supervise' }"
+            class="login-supervise"
+            @click="superviseClick('supervise')"
+          >
+            鐩戠閮ㄩ棬鐧诲綍
+          </div>
         </div>
-      </el-form-item>
-    </el-form>
-    <!--  搴曢儴  -->
-    <div class="el-login-footer">
-      <span>Copyright 漏 2018-2024 ruoyi.vip All Rights Reserved.</span>
+        <el-form
+          ref="loginRef"
+          :model="loginForm"
+          :rules="loginRules"
+          class="login-form"
+        >
+          <!-- <el-form-item v-if="tenantEnabled" prop="tenantId">
+            <el-select v-model="loginForm.tenantId" filterable placeholder="璇烽�夋嫨/杈撳叆鍏徃鍚嶇О" style="width: 100%">
+              <el-option v-for="item in tenantList" :key="item.tenantId" :label="item.companyName"
+                :value="item.tenantId"></el-option>
+              <template #prefix><svg-icon icon-class="company" class="el-input__icon input-icon" /></template>
+</el-select>
+</el-form-item> -->
+          <el-form-item prop="username">
+            <el-input
+              v-model="loginForm.username"
+              auto-complete="off"
+              maxlength="20"
+              placeholder="璇疯緭鍏ヨ处鍙�"
+              size="large"
+              type="text"
+            >
+              <template #prefix>
+                <svg-icon class="el-input__icon input-icon" icon-class="user" />
+              </template>
+            </el-input>
+          </el-form-item>
+          <el-form-item prop="password">
+            <el-input
+              v-model="loginForm.password"
+              auto-complete="off"
+              maxlength="20"
+              placeholder="璇疯緭鍏ュ瘑鐮�"
+              size="large"
+              type="password"
+              @keyup.enter="handleLogin"
+            >
+              <template #prefix>
+                <svg-icon
+                  class="el-input__icon input-icon"
+                  icon-class="password"
+                />
+              </template>
+            </el-input>
+          </el-form-item>
+          <el-form-item v-if="captchaEnabled" prop="code">
+            <el-input
+              v-model="loginForm.code"
+              auto-complete="off"
+              maxlength="20"
+              placeholder="楠岃瘉鐮�"
+              size="large"
+              style="width: 167px"
+              @keyup.enter="handleLogin"
+            >
+              <template #prefix>
+                <svg-icon
+                  class="el-input__icon input-icon"
+                  icon-class="validCode"
+                />
+              </template>
+            </el-input>
+            <div class="login-code">
+              <img :src="codeUrl" class="login-code-img" @click="getCode" />
+            </div>
+          </el-form-item>
+          <el-checkbox
+            v-model="loginForm.rememberMe"
+            style="margin: 0 0 25px 0; color: #2d5eff"
+            >璁颁綇瀵嗙爜</el-checkbox
+          >
+          <div></div>
+          <el-form-item style="width: 100%">
+            <el-button
+              :loading="loading"
+              size="large"
+              style="width: 100%"
+              type="primary"
+              @click.prevent="handleLogin"
+            >
+              <span v-if="!loading">鐧� 褰�</span>
+              <span v-else>鐧� 褰� 涓�...</span>
+            </el-button>
+            <div v-if="register" style="float: right">
+              <router-link :to="'/register'" class="link-type"
+                >绔嬪嵆娉ㄥ唽</router-link
+              >
+            </div>
+          </el-form-item>
+        </el-form>
+        <div class="other">
+          <div class="other-title">
+            <span style="color: #b3b8c1">鍏朵粬鐧诲綍鏂瑰紡:</span
+            ><span style="color: #2d5eff; cursor: pointer">
+              <SvgIcon icon-class="phone" />鎵嬫満楠岃瘉鐮佺櫥褰�
+            </span>
+          </div>
+          <div class="forget">蹇樿瀵嗙爜锛�</div>
+        </div>
+      </div>
     </div>
   </div>
 </template>
@@ -64,44 +136,45 @@
 <script>
 import { getCodeImg } from "@/api/login";
 import Cookies from "js-cookie";
-import { encrypt, decrypt } from '@/utils/jsencrypt'
+import { encrypt, decrypt } from "@/utils/jsencrypt";
 
 export default {
   name: "Login",
   data() {
     return {
+      currentTab: "corporation",
       codeUrl: "",
       loginForm: {
         username: "admin",
         password: "admin123",
         rememberMe: false,
         code: "",
-        uuid: ""
+        uuid: "",
       },
       loginRules: {
         username: [
-          { required: true, trigger: "blur", message: "璇疯緭鍏ユ偍鐨勮处鍙�" }
+          { required: true, trigger: "blur", message: "璇疯緭鍏ユ偍鐨勮处鍙�" },
         ],
         password: [
-          { required: true, trigger: "blur", message: "璇疯緭鍏ユ偍鐨勫瘑鐮�" }
+          { required: true, trigger: "blur", message: "璇疯緭鍏ユ偍鐨勫瘑鐮�" },
         ],
-        code: [{ required: true, trigger: "change", message: "璇疯緭鍏ラ獙璇佺爜" }]
+        code: [{ required: true, trigger: "change", message: "璇疯緭鍏ラ獙璇佺爜" }],
       },
       loading: false,
       // 楠岃瘉鐮佸紑鍏�
       captchaEnabled: true,
       // 娉ㄥ唽寮�鍏�
       register: false,
-      redirect: undefined
+      redirect: undefined,
     };
   },
   watch: {
     $route: {
-      handler: function(route) {
+      handler: function (route) {
         this.redirect = route.query && route.query.redirect;
       },
-      immediate: true
-    }
+      immediate: true,
+    },
   },
   created() {
     this.getCode();
@@ -109,8 +182,9 @@
   },
   methods: {
     getCode() {
-      getCodeImg().then(res => {
-        this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled;
+      getCodeImg().then((res) => {
+        this.captchaEnabled =
+          res.captchaEnabled === undefined ? true : res.captchaEnabled;
         if (this.captchaEnabled) {
           this.codeUrl = "data:image/gif;base64," + res.img;
           this.loginForm.uuid = res.uuid;
@@ -120,50 +194,152 @@
     getCookie() {
       const username = Cookies.get("username");
       const password = Cookies.get("password");
-      const rememberMe = Cookies.get('rememberMe')
+      const rememberMe = Cookies.get("rememberMe");
       this.loginForm = {
         username: username === undefined ? this.loginForm.username : username,
-        password: password === undefined ? this.loginForm.password : decrypt(password),
-        rememberMe: rememberMe === undefined ? false : Boolean(rememberMe)
+        password:
+          password === undefined ? this.loginForm.password : decrypt(password),
+        rememberMe: rememberMe === undefined ? false : Boolean(rememberMe),
       };
     },
+    // 娉曚汉鐧诲綍
+    currentClick(tab) {
+      this.currentTab = tab;
+      this.loginForm.role = "2";
+      console.log(this.loginForm);
+    },
+    // 鐩戠閮ㄩ棬鐧诲綍
+    superviseClick(tab) {
+      this.currentTab = tab;
+      this.loginForm.role = "1";
+      console.log(this.loginForm);
+    },
     handleLogin() {
-      this.$refs.loginForm.validate(valid => {
+      debugger
+      this.$refs.loginForm.validate((valid) => {
         if (valid) {
           this.loading = true;
           if (this.loginForm.rememberMe) {
             Cookies.set("username", this.loginForm.username, { expires: 30 });
-            Cookies.set("password", encrypt(this.loginForm.password), { expires: 30 });
-            Cookies.set('rememberMe', this.loginForm.rememberMe, { expires: 30 });
+            Cookies.set("password", encrypt(this.loginForm.password), {
+              expires: 30,
+            });
+            Cookies.set("rememberMe", this.loginForm.rememberMe, {
+              expires: 30,
+            });
           } else {
             Cookies.remove("username");
             Cookies.remove("password");
-            Cookies.remove('rememberMe');
+            Cookies.remove("rememberMe");
           }
-          this.$store.dispatch("Login", this.loginForm).then(() => {
-            this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
-          }).catch(() => {
-            this.loading = false;
-            if (this.captchaEnabled) {
-              this.getCode();
-            }
-          });
+          this.$store
+            .dispatch("Login", this.loginForm)
+            .then(() => {
+              this.$router.push({ path: this.redirect || "/" }).catch(() => {});
+            })
+            .catch(() => {
+              this.loading = false;
+              if (this.captchaEnabled) {
+                this.getCode();
+              }
+            });
         }
       });
-    }
-  }
+    },
+  },
 };
 </script>
 
-<style rel="stylesheet/scss" lang="scss">
+<style lang="scss" scoped>
 .login {
-  display: flex;
-  justify-content: center;
-  align-items: center;
-  height: 100%;
-  background-image: url("../assets/images/login-background.jpg");
-  background-size: cover;
+  .nav {
+    display: flex;
+    align-items: center;
+    height: 40px;
+    margin-left: 24px;
+    background-color: #fff;
+    font-family: PangMenZhengDao;
+    font-size: 20px;
+    font-style: italic;
+    color: #1e2538;
+    line-height: 40px;
+  }
+
+  .conter {
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    gap: 100px;
+    height: calc(100vh - 50px);
+    background-image: url("../assets/images/login-background.png");
+    background-size: cover;
+
+    .left {
+      width: 500px;
+      height: auto;
+
+      .title {
+        font-size: 34px;
+        color: #1f2639;
+        line-height: 16px;
+      }
+
+      .img {
+        background-image: url("../assets/images/login.png");
+        background-size: cover;
+        height: 295px;
+        width: 366px;
+        margin: auto;
+        margin-top: 20px;
+      }
+    }
+
+    .right {
+      border-radius: 6px;
+      background: #ffffff;
+      width: 500px;
+      padding: 0px 25px 5px 25px;
+
+      .tab {
+        margin: 20px 0;
+        display: flex;
+        font-size: 24px;
+        line-height: 24px;
+        gap: 100px;
+
+        .login-corporation {
+          cursor: pointer;
+        }
+
+        .login-supervise {
+          cursor: pointer;
+        }
+
+        .active {
+          color: #2d5eff;
+        }
+      }
+
+      .other {
+        display: flex;
+        justify-content: space-between;
+        font-size: 14px;
+        margin-bottom: 10px;
+
+        .other-title {
+          display: flex;
+          gap: 10px;
+        }
+
+        .forget {
+          color: #2d5eff;
+          cursor: pointer;
+        }
+      }
+    }
+  }
 }
+
 .title {
   margin: 0px auto 30px auto;
   text-align: center;
@@ -171,49 +347,40 @@
 }
 
 .login-form {
-  border-radius: 6px;
-  background: #ffffff;
-  width: 400px;
-  padding: 25px 25px 5px 25px;
   .el-input {
-    height: 38px;
+    height: 40px;
+
     input {
-      height: 38px;
+      height: 40px;
     }
   }
+
   .input-icon {
     height: 39px;
     width: 14px;
-    margin-left: 2px;
+    margin-left: 0px;
   }
 }
+
 .login-tip {
   font-size: 13px;
   text-align: center;
   color: #bfbfbf;
 }
+
 .login-code {
   width: 33%;
-  height: 38px;
+  height: 40px;
   float: right;
+
   img {
     cursor: pointer;
     vertical-align: middle;
   }
 }
-.el-login-footer {
-  height: 40px;
-  line-height: 40px;
-  position: fixed;
-  bottom: 0;
-  width: 100%;
-  text-align: center;
-  color: #fff;
-  font-family: Arial;
-  font-size: 12px;
-  letter-spacing: 1px;
-}
+
 .login-code-img {
-  height: 38px;
+  height: 40px;
+  padding-left: 12px;
 }
 </style>

--
Gitblit v1.8.0