feige
2024-11-10 5954aa0f9f982bba46843bf0dcc835f5efa2b667
ruoyi-ui/src/views/login.vue
@@ -37,9 +37,9 @@
        </div></div>
      <div class="yonghuming" style="">用户名</div>
      <el-form-item prop="username" style="width: 380px; height: 48px; ">
      <el-form-item prop="nickName" style="width: 380px; height: 48px; ">
        <el-input
          v-model="loginForm.username"
          v-model="loginForm.nickName"
          type="text"
          auto-complete="off"
          placeholder="请输入用户名"
@@ -150,8 +150,8 @@
      <div class="register">
        <el-form ref="registerForm" :model="registerForm" :rules="registerRules" class="register-form">
          <h3 class="title">新用户注册</h3>
          <el-form-item prop="username">
            <el-input v-model="registerForm.username" type="text" auto-complete="off" placeholder="账号">
          <el-form-item prop="nickname">
            <el-input v-model="registerForm.nickname" type="text" auto-complete="off" placeholder="账号">
              <svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" />
            </el-input>
          </el-form-item>
@@ -216,12 +216,14 @@
    </div>
  </div>
  
  <div class="gpr"></div>
  <div class="gpr">
<!--       <img :key="url" :src="url" style="width:100%;height:30%"></img> -->
  </div>
</div>
</template>
<script>
import { getCodeImg,Download } from "@/api/login";
import { getCodeImg,Download,register } from "@/api/login";
import Cookies from "js-cookie";
import { encrypt, decrypt } from '@/utils/jsencrypt'
@@ -236,20 +238,21 @@
       }
     };
    return {
     url: require('../assets/images/index.png'),
      openRegister: false,
     open: false,
      codeUrl: "",
      loginForm: {
        // username: "admin",
        // password: "admin123",
        username: "",
        nickName: "",
        password: "",
        rememberMe: false,
        code: "",
        uuid: ""
      },
      loginRules: {
        username: [
        nickName: [
          { required: true, trigger: "blur", message: "请输入您的账号" }
        ],
        password: [
@@ -261,23 +264,23 @@
      // 验证码开关
      captchaEnabled: true,
      // 注册开关
      register: true,
    //  register: true,
      redirect: undefined,
     
     
     
     registerForm: {
       username: "",
       nickname: "",
       password: "",
       confirmPassword: "",
       code: "",
       uuid: ""
     },
     registerRules: {
       username: [
       nickname: [
         { required: true, trigger: "blur", message: "请输入您的账号" },
         { min: 2, max: 20, message: '用户账号长度必须介于 2 和 20 之间', trigger: 'blur' }
       //  { min: 2, max: 20, message: '用户账号长度必须介于 2 和 20 之间', trigger: 'blur' }
       ],
       password: [
         { required: true, trigger: "blur", message: "请输入您的密码" },
@@ -306,16 +309,19 @@
  },
  methods: {
     handleRegister() {
        //alert(this.registerForm.nickname)
       this.$refs.registerForm.validate(valid => {
         if (valid) {
           this.loading = true;
         //alert(this.registerForm.nickname)
           register(this.registerForm).then(res => {
             const username = this.registerForm.username;
             this.$alert("<font color='red'>恭喜你,您的账号 " + username + " 注册成功!</font>", '系统提示', {
             const nickName = this.registerForm.nickname;
             this.$alert("<font color='red'>恭喜你,您的账号 " + nickName + " 注册成功!</font>", '系统提示', {
               dangerouslyUseHTMLString: true,
               type: 'success'
             }).then(() => {
               this.$router.push("/login");
              this.openRegister = false;
            //   this.$router.push("/login");
             }).catch(() => {});
           }).catch(() => {
             this.loading = false;
@@ -335,20 +341,21 @@
    getCode() {
      getCodeImg().then(res => {
        this.captchaEnabled = res.data.captchaEnabled === undefined ? true : res.captchaEnabled;
        if (this.captchaEnabled) {
          this.codeUrl = "data:image/gif;base64," + res.data.img;
          this.loginForm.uuid = res.data.uuid;
            this.registerForm.uuid = res.data.uuid;
        }
      });
    },
    getCookie() {
      const username = Cookies.get("username");
      const nickName = Cookies.get("nickName");
      const password = Cookies.get("password");
      const rememberMe = Cookies.get('rememberMe')
      this.loginForm = {
        username: username === undefined ? this.loginForm.username : username,
        nickName: nickName === undefined ? this.loginForm.nickName : nickName,
        password: password === undefined ? this.loginForm.password : decrypt(password),
        rememberMe: rememberMe === undefined ? false : Boolean(rememberMe)
      };
@@ -358,14 +365,15 @@
        if (valid) {
          this.loading = true;
          if (this.loginForm.rememberMe) {
            Cookies.set("username", this.loginForm.username, { expires: 30 });
            Cookies.set("nickName", this.loginForm.nickName, { 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("nickName");
            Cookies.remove("password");
            Cookies.remove('rememberMe');
          }
      //  alert(this.loginForm.nickName)
          this.$store.dispatch("Login", this.loginForm).then(() => {
            this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
          }).catch(() => {
@@ -384,20 +392,31 @@
<style rel="stylesheet/scss" lang="scss">
.gpr{
   width:100%;
   height:600px;
   background: no-repeat center/40% url("../assets/images/Group 132.png");
   // height:1000px;
   //background: no-repeat center/100% url("../assets/images/index.png");
}
    .customWidth{
         width:40%;  // 设置弹出框宽度的数值
     }
.topHeight{
   height: 40px;
   margin-right: 20px;
   top:5px;
   position: absolute;
}
.Group_132{
   // background-image: url("../assets/images/index.png");
  // background: no-repeat center/40% url("../assets/images/Group 132.png");
  height: 100%;
  width:  100%;
  // height: 1200px;
   min-width: 1300px;
    width: 100vw;
    height: 100vh;
  background-color: #FEF7FC;
  //background-position: 49.5% 16.2% ;
  // background-position: 81.7px 71.3px;
@@ -409,9 +428,9 @@
  display: flex;
  justify-content: flex-end;
  align-items: center;
  height: 100%;
  // height: 60px;
  width:  100%;
  background: no-repeat center/40% url("../assets/images/login_logo.png");
  background: no-repeat center/100% url("../assets/images/index.png");
  background-color: #FEF7FC;