123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434 |
- <template>
- <div class="login-container">
- <div class="login-left">
- <div class="login-texts">
- <p>
- <span
- >{{ configInfor ? `${configInfor.title}-` : "" }}教材管理系统</span
- >
- </p>
- </div>
- <el-form
- :model="loginForm"
- :rules="loginRules"
- auto-complete="on"
- class="login-form"
- label-position="left"
- ref="loginForm"
- size="mini"
- >
- <div class="title-container">
- <h3 class="title">登录</h3>
- </div>
- <div class="login-input" v-show="loginCheck == 'login'">
- <p class="input-title">用户名</p>
- <el-form-item prop="username">
- <el-input
- autocomplete="off"
- name="username"
- ref="username"
- tabindex="1"
- type="text"
- v-model="loginForm.username"
- />
- </el-form-item>
- <p class="input-title">密码</p>
- <el-form-item prop="password">
- <el-input
- :key="passwordType"
- :type="passwordType"
- @keyup.enter.native="handleLogin"
- autocomplete="off"
- name="password"
- ref="password"
- tabindex="2"
- v-model="loginForm.password"
- />
- <!-- <span @click="showPwd" class="show-pwd">
- <svg-icon
- :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'"
- />
- </span>-->
- </el-form-item>
- <p class="input-title">用户类型</p>
- <el-form-item class="el-form-item-type" prop="type">
- <el-radio label="TEACHER" v-model="loginForm.type">教师</el-radio>
- <el-radio label="STUDENT" v-model="loginForm.type">学员</el-radio>
- <el-radio label="ADMIN" v-model="loginForm.type"
- >系统管理员</el-radio
- >
- <!-- <span @click="showPwd" class="show-pwd">
- <svg-icon
- :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'"
- />
- </span>-->
- </el-form-item>
- <el-button
- :loading="loading"
- @click.native.prevent="handleLogin"
- size="small"
- style="width: 100%; margin-bottom: 30px"
- type="primary"
- >登录</el-button
- >
- </div>
- </el-form>
- </div>
- <div class="login-right">
- <!-- <img alt src="@/assets/login/index.png"> -->
- </div>
- </div>
- </template>
- <script>
- import { validUsername, validPass } from "@/utils/validate";
- import { getContent, getLogin } from "@/api/ajax";
- import { getObjArr, saveObjArr } from "@/utils/role";
- import Cookies from "js-cookie";
- import { setToken } from "@/utils/auth";
- import { removeSession } from "@/utils/role";
- import { getConfigInfor } from "@/utils/index";
- export default {
- name: "Login",
- data() {
- const validateUsername = (rule, value, callback) => {
- if (!validUsername(value)) {
- callback(new Error("请输入用户名"));
- } else {
- callback();
- }
- };
- const validatePassword = (rule, value, callback) => {
- if (!value) {
- callback(new Error("请输入密码"));
- } else {
- callback();
- }
- };
- return {
- options: [],
- select: "1",
- codeText: "获取验证码",
- codeSend: false,
- //登录
- loginForm: {
- username: getObjArr("userName") || "",
- password: "",
- type: "TEACHER",
- },
- //input 规则
- loginRules: {
- username: [
- { required: true, trigger: "blur", validator: validateUsername },
- ],
- password: [
- { required: true, trigger: "blur", validator: validatePassword },
- ],
- },
- loading: false,
- passwordType: "password",
- redirect: undefined,
- loginCheck: "login",
- configInfor: null,
- };
- },
- watch: {
- $route: {
- handler: function (route) {
- this.redirect = route.query && route.query.redirect;
- },
- immediate: true,
- },
- },
- methods: {
- showPwd() {
- if (this.passwordType === "password") {
- this.passwordType = "";
- } else {
- this.passwordType = "password";
- }
- this.$nextTick(() => {
- this.$refs.password.focus();
- });
- },
- //登录
- handleLogin() {
- removeSession("SysList");
- this.$refs.loginForm.validate((valid) => {
- if (valid) {
- this.loading = true;
- let MethodName = "login_control-Login";
- let data = {
- user_type: this.loginForm.type,
- user_name: this.loginForm.username,
- password: this.loginForm.password,
- };
- getLogin(MethodName, data)
- .then((res) => {
- setToken(res);
- this.$router.push({ path: "/EnterSys" });
- })
- .catch(() => {
- this.loading = false;
- });
- } else {
- this.loading = false;
- return false;
- }
- });
- },
- async _getConfig() {
- this.configInfor = await getConfigInfor();
- },
- },
- mounted() {
- removeSession("SysList");
- this._getConfig();
- },
- };
- </script>
- <style lang="scss">
- /* 修复input 背景不协调 和光标变色 */
- /* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */
- $bg: #283443;
- $light_gray: #fff;
- $cursor: #000;
- $fc: rgb(24, 144, 255);
- @supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
- .login-container .el-input input {
- color: $cursor !important;
- }
- .el-form-item.is-success .el-input__inner {
- border-color: $fc !important;
- }
- }
- /* reset element-ui css */
- .login-input {
- font-size: 0;
- .el-input {
- display: inline-block;
- height: 32px;
- width: 85%;
- input {
- background: transparent;
- border: 0px;
- -webkit-appearance: none;
- border-radius: 0px;
- padding: 5px 5px 5px 15px;
- color: rgb(117, 117, 117);
- height: 32px;
- caret-color: #000;
- &:-webkit-autofill {
- box-shadow: 0 0 0px 1000px $light_gray inset !important;
- -webkit-text-fill-color: $cursor !important;
- }
- }
- }
- .el-form-item {
- border: 1px solid #ccc;
- // background: rgba(0, 0, 0, 0.1);
- border-radius: 5px;
- color: #454545;
- }
- .el-form-item-type {
- border-color: #fff;
- }
- }
- .sign-input {
- .school.el-select {
- width: 100%;
- margin-bottom: 14px;
- }
- .el-input {
- height: 32px;
- .el-input__inner {
- height: 32px;
- line-height: 32px;
- }
- }
- .area-code {
- margin-bottom: 14px;
- .el-input-group__prepend {
- background: #fff;
- width: 80px;
- }
- }
- }
- .code {
- display: flex;
- justify-content: space-around;
- align-items: center;
- .code-number {
- flex-basis: 80%;
- margin-right: 10px;
- .el-input--mini .el-input__inner {
- height: 32px;
- line-height: 32px;
- }
- }
- .code-btn {
- margin-top: -2px;
- .el-button--mini {
- padding: 8px 15px;
- width: 120px;
- }
- }
- .sends {
- .el-button--mini {
- background: #ccc;
- border-color: #ccc;
- }
- }
- }
- </style>
- <style lang="scss" scoped>
- $bg: #fff;
- $dark_gray: #889aa4;
- $light_gray: #eee;
- $fc: rgb(24, 144, 255);
- .login-container {
- min-height: 100%;
- height: 100%;
- width: 100%;
- background: url("../assets/login/bg-login.jpg") center no-repeat;
- background-size: cover;
- overflow: hidden;
- position: relative;
- display: flex;
- justify-content: space-between;
- align-items: center;
- .login-form {
- position: relative;
- width: 350px;
- background: #fff;
- border-radius: 5px;
- padding: 42px;
- box-sizing: border-box;
- max-width: 100%;
- overflow: hidden;
- }
- .tips {
- font-size: 14px;
- color: #fff;
- margin-bottom: 10px;
- span {
- &:first-of-type {
- margin-right: 16px;
- }
- }
- }
- .svg-container {
- padding: 0px 5px 0px 15px;
- color: $dark_gray;
- vertical-align: middle;
- width: 30px;
- display: inline-block;
- }
- .colors {
- color: blue;
- }
- .title-container {
- position: relative;
- .title {
- font-size: 24px;
- color: rgb(73, 73, 73);
- margin: 0px auto 30px auto;
- text-align: left;
- font-weight: normal;
- }
- }
- .show-pwd {
- position: absolute;
- right: 10px;
- top: 3px;
- font-size: 16px;
- color: $dark_gray;
- cursor: pointer;
- user-select: none;
- }
- }
- .input-title {
- font-size: 12px;
- font-weight: 500;
- color: rgba(19, 20, 21, 1);
- line-height: 20px;
- margin-bottom: 10px;
- }
- /*login tab切换*/
- .login-table {
- display: flex;
- justify-content: center;
- align-items: center;
- height: 40px;
- margin-bottom: 20px;
- font-size: 16px;
- p {
- flex: 1;
- text-align: center;
- color: #000;
- }
- span {
- display: inline-block;
- padding: 0 20px;
- height: 46px;
- line-height: 46px;
- cursor: pointer;
- }
- span.hover {
- color: $fc;
- border-bottom: 3px solid $fc;
- }
- }
- /*text*/
- .login-texts {
- font-size: 16px;
- font-weight: 500;
- color: #1c1c1c;
- line-height: 30px;
- margin-bottom: 20px;
- text-align: center;
- > p:nth-child(1) {
- line-height: 50px;
- > span:nth-child(1) {
- font-size: 32px;
- margin-right: 10px;
- }
- }
- }
- .login-left {
- // flex: 1;
- margin: 0 auto;
- }
- .login-right {
- // flex: 1;
- text-align: right;
- height: 100%;
- display: flex;
- align-items: flex-end;
- justify-content: flex-end;
- img {
- width: 100%;
- vertical-align: bottom;
- }
- }
- </style>
|