index.vue 5.23 KB
<template>
  <div class="login-container">
    <el-form
      ref="loginForm"
      :model="loginForm"
      :rules="loginRules"
      class="login-form"
      auto-complete="on"
      label-position="left"
    >
      <!-- <img
        src="../../assets/images/logo.png"
        style="
          width: 120px;
          height: 120px;
          position: absolute;
          top: -250px;
          left: 190px;
        "
        alt
      /> -->
      <img
        src="../../assets/images/chiken.png"
        style="width: 428px; height: 142px; position: absolute; top: -142px"
        alt
      />
      <div class="title-container">
        <h3 class="title">欢迎使用教育云平台!</h3>
      </div>

      <el-form-item prop="username">
        <i class="fa fa-user" aria-hidden="true"></i>
        <el-input
          ref="username"
          v-model="loginForm.username"
          placeholder="请输入用户名"
          name="username"
          type="text"
          autofocus="autofocus"
          tabindex="1"
          maxlength="40"
          auto-complete="on"
        />
      </el-form-item>

      <el-form-item prop="password">
        <i class="fa fa-unlock-alt" aria-hidden="true"></i>
        <el-input
          :key="passwordType"
          ref="password"
          v-model="loginForm.password"
          :type="passwordType"
          placeholder="请输入登录密码"
          name="password"
          class="mima"
          maxlength="16"
          tabindex="2"
          auto-complete="on"
          @keyup.enter.native="submitForm"
        />
        <span class="show-pwd" @click="showPwd">
          <i
            class="fa"
            aria-hidden="true"
            :class="passwordType === 'password' ? 'fa-eye-slash' : 'fa-eye'"
          ></i>
        </span>
      </el-form-item>
      <el-button
        type="primary"
        style="
          width: 80%;
          display: block;
          margin: 0 auto;
          margin-bottom: 30px;
          margin-top: 10px;
        "
        round
        :disabled="!disableClick"
        @click.native.prevent="submitForm"
        >登录</el-button
      >
    </el-form>
  </div>
</template>
<script>
export default {
  data() {
    return {
      disableClick: true,
      passwordType: "password",
      loginForm: {
        username: "15911715665",
        password: "Csiy88888",
      },
      loginRules: {
        username: [
          { required: true, message: "请输入用户账号",trigger: "blur" }
        ],
        password: [
          { required: true,  message: "请输入账号密码",trigger: "blur" }
        ]
      },
      url: "",
    };
  },
  created() {
    this.url = this.$route.query?.url || "";
  },
  methods: {
    showPwd() {
      if (this.passwordType === "password") {
        this.passwordType = "";
      } else {
        this.passwordType = "password";
      }
      this.$nextTick(() => {
        this.$refs.password.focus();
      });
    },
    submitForm() {
      if (this.loginForm.username === "" || this.loginForm.password === "") {
        this.$message({
          showClose: true,
          message: "账号或密码不能为空",
          type: "error",
        });
        return false;
      } else {
        this.$store.dispatch("Login",{...this.loginForm,url:this.url})
      }
    },
  },
  mounted() {},
};
</script>
<style lang="scss">
$bg: #283443;
$dark_gray: #889aa4;
$light_gray: #000;
$cursor: #000;

@supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
  .login-container .el-input input {
    color: $cursor;
  }
}
.login-container {
  width: 100%;
  height: 100vh;
  background: url("../../assets/images/login-bg.png") no-repeat;
  background-size: cover;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  .el-input {
    display: inline-block;
    height: 47px;
    width: 85%;
    input::-ms-reveal {
      display: none;
    }
    input {
      background: transparent;
      border: 0px;
      -webkit-appearance: none;
      border-radius: 0px;
      font-size:16px;
      color: $light_gray;
      height: 52px;
      caret-color: $cursor;

      &:-webkit-autofill {
        box-shadow: 0 0 0px 1000px #e5e5e5 inset !important;
        -webkit-text-fill-color: $cursor !important;
      }
    }
  }

  .el-form-item {
    border: 1px solid #e5e5e5;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 5px;
    color: #454545;
  }
  .login-form {
    position: relative;
    width: 500px;
    height: 331px;
    max-width: 100%;
    padding: 30px 35px 0;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    margin-top: 200px;
    box-sizing: border-box;
  }

  .tips {
    font-size: 14px;
    color: #fff;
    margin-bottom: 10px;

    span {
      &:first-of-type {
        margin-right: 16px;
      }
    }
  }

  .fa {
    padding: 5px 0px 6px 15px;
    color: $dark_gray;
    font-size: 20px;
  }

  .title-container {
    position: relative;

    .title {
      font-size: 24px;
      color: $light_gray;
      margin: 0px auto 40px auto;
      text-align: center;
      font-weight: bold;
    }
  }

  .show-pwd {
    position: absolute;
    right: 10px;
    top: 7px;
    font-size: 16px;
    color: $dark_gray;
    cursor: pointer;
    user-select: none;
  }
}
</style>