|
@@ -1,6 +1,8 @@
|
|
|
<!-- eslint-disable no-undef -->
|
|
|
<template>
|
|
|
+ <!--登录块-->
|
|
|
<div class="login-container">
|
|
|
+ <!--表单区域-->
|
|
|
<el-form
|
|
|
ref="loginForm"
|
|
|
:model="loginForm"
|
|
@@ -12,8 +14,9 @@
|
|
|
<div class="title-container">
|
|
|
<h3 class="title">力山特起重机智能运维系统</h3>
|
|
|
</div>
|
|
|
-
|
|
|
+ <!-- 用户名 -->
|
|
|
<el-form-item prop="username">
|
|
|
+ <!-- 图标 -->
|
|
|
<span class="svg-container">
|
|
|
<svg-icon icon-class="user" />
|
|
|
</span>
|
|
@@ -34,6 +37,7 @@
|
|
|
placement="right"
|
|
|
manual
|
|
|
>
|
|
|
+ <!-- 密码 -->
|
|
|
<el-form-item prop="password">
|
|
|
<span class="svg-container">
|
|
|
<svg-icon icon-class="password" />
|
|
@@ -51,6 +55,7 @@
|
|
|
@blur="capsTooltip = false"
|
|
|
@keyup.enter.native="handleLogin"
|
|
|
/>
|
|
|
+ <!-- 显示密码 -->
|
|
|
<span class="show-pwd" @click="showPwd">
|
|
|
<svg-icon
|
|
|
:icon-class="passwordType === 'password' ? 'eye' : 'eye-open'"
|
|
@@ -59,40 +64,73 @@
|
|
|
</el-form-item>
|
|
|
</el-tooltip>
|
|
|
|
|
|
- <el-form-item prop="Verification ">
|
|
|
+ <!-- <el-form-item v-if="captchaEnabled" prop="code ">
|
|
|
<el-col :span="16">
|
|
|
<el-input
|
|
|
- ref="验证码"
|
|
|
- v-model="loginForm.Verification "
|
|
|
- :placeholder="('验证码')"
|
|
|
- name="Verification "
|
|
|
- type="text"
|
|
|
- tabindex="1"
|
|
|
- autocomplete="on"
|
|
|
- />
|
|
|
- </el-col>
|
|
|
- <el-col :span="8">
|
|
|
- <img class="verifyCodeImg" :src="imgUrl" @click="resetImg">
|
|
|
+ v-model="loginForm.code "
|
|
|
+ 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" class="login-code-img" @click="getCode">
|
|
|
+ </div>
|
|
|
</el-col>
|
|
|
</el-form-item>
|
|
|
+ <el-checkbox v-model="loginForm.rememberMe" style="margin-left: 20px;">记住密码</el-checkbox> -->
|
|
|
|
|
|
+ <el-form-item prop="code">
|
|
|
+ <el-input
|
|
|
+ v-model="loginForm.code"
|
|
|
+ class="code"
|
|
|
+ prefix-icon="el-icon-info"
|
|
|
+ placeholder=""
|
|
|
+ style="margin-left:5px;fill: currentColor"
|
|
|
+ />
|
|
|
+ <img
|
|
|
+ id="code"
|
|
|
+ style="float: right;margin-top: 4px; margin-left: ;cursor: pointer"
|
|
|
+ title="看不清,点击刷新"
|
|
|
+ alt="验证码"
|
|
|
+ @click="changeCode"
|
|
|
+ >
|
|
|
+ </el-form-item>
|
|
|
+ <el-checkbox v-model="loginForm.rememberMe" style="margin-left: 8px;">记住密码</el-checkbox>
|
|
|
+
|
|
|
+ <!-- 按钮 -->
|
|
|
<el-button
|
|
|
:loading="loading"
|
|
|
- type="primary"
|
|
|
- style="width: 30%; margin-bottom: 30px; margin-left: 60px"
|
|
|
- @click.native.prevent="handleLogin"
|
|
|
+ type="info"
|
|
|
+ icon="el-icon el-icon-delete"
|
|
|
+
|
|
|
+ style="width: 30%; margin-bottom: 20px; margin-left: 20px"
|
|
|
+ @click="resetLoginForm"
|
|
|
>
|
|
|
- {{ $t("login.logIn") }}
|
|
|
+ 重置
|
|
|
+ <!-- {{ $t("login.logIn") }} -->
|
|
|
</el-button>
|
|
|
<el-button
|
|
|
:loading="loading"
|
|
|
- type="info"
|
|
|
- style="width: 30%; margin-bottom: 30px; margin-left: 60px"
|
|
|
- @click="resetLoginForm"
|
|
|
+ type="warning"
|
|
|
+ icon="el-icon el-icon-circle-plus"
|
|
|
+ style="width:35%;margin-bottom: 20px; margin-left: 20px"
|
|
|
+ @click="registerForm($refs['loginForm'])"
|
|
|
>
|
|
|
- 重置
|
|
|
+ 注册
|
|
|
<!-- {{ $t("login.logIn") }} -->
|
|
|
</el-button>
|
|
|
+ <el-button
|
|
|
+ :loading="loading"
|
|
|
+ icon="el-icon el-icon-s-promotion"
|
|
|
+ type="primary"
|
|
|
+ style="width: 100%; margin-bottom: 30px; margin-left: 0px"
|
|
|
+ @click.native.prevent="handleLogin"
|
|
|
+ >
|
|
|
+ {{ $t("login.logIn") }}
|
|
|
+ </el-button>
|
|
|
+
|
|
|
</el-form>
|
|
|
|
|
|
<el-dialog :title="$t('login.thirdparty')" :visible.sync="showDialog">
|
|
@@ -110,6 +148,8 @@
|
|
|
import { validUsername } from '@/utils/validate'
|
|
|
import LangSelect from '@/components/LangSelect'
|
|
|
import SocialSign from './components/SocialSignin'
|
|
|
+import Cookies from 'js-cookie'
|
|
|
+// import LoginFunc from '@/function-namespace/auth/LoginFunc'
|
|
|
|
|
|
export default {
|
|
|
name: 'Login',
|
|
@@ -131,11 +171,13 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
return {
|
|
|
+ // 表单数据
|
|
|
loginForm: {
|
|
|
username: 'adminult',
|
|
|
password: '123456'
|
|
|
},
|
|
|
loginRules: {
|
|
|
+ // 校验规则
|
|
|
username: [
|
|
|
{ required: true, trigger: 'blur', validator: validateUsername }
|
|
|
],
|
|
@@ -165,6 +207,8 @@ export default {
|
|
|
},
|
|
|
created() {
|
|
|
// window.addEventListener('storage', this.afterQRScan)
|
|
|
+ this.getCode()
|
|
|
+ this.getCookie()
|
|
|
},
|
|
|
mounted() {
|
|
|
if (this.loginForm.username === '') {
|
|
@@ -177,6 +221,25 @@ export default {
|
|
|
// window.removeEventListener('storage', this.afterQRScan)
|
|
|
},
|
|
|
methods: {
|
|
|
+ // getCode() {
|
|
|
+ // 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
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // },
|
|
|
+ // getCookie() {
|
|
|
+ // const username = Cookies.get('username')
|
|
|
+ // const password = Cookies.get('password')
|
|
|
+ // 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)
|
|
|
+ // }
|
|
|
+ // },
|
|
|
checkCapslock(e) {
|
|
|
const { key } = e
|
|
|
this.capsTooltip = key && key.length === 1 && key >= 'A' && key <= 'Z'
|
|
@@ -195,6 +258,15 @@ export default {
|
|
|
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 })
|
|
|
+ } else {
|
|
|
+ Cookies.remove('username')
|
|
|
+ Cookies.remove('password')
|
|
|
+ Cookies.remove('rememberMe')
|
|
|
+ }
|
|
|
this.$store
|
|
|
.dispatch('user/login', this.loginForm)
|
|
|
.then(() => {
|
|
@@ -241,6 +313,7 @@ export default {
|
|
|
// }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss">
|
|
@@ -313,13 +386,12 @@ $light_gray: #eee;
|
|
|
}
|
|
|
.login-form {
|
|
|
position: relative;
|
|
|
- width: 520px;
|
|
|
+ width: 450px;
|
|
|
max-width: 100%;
|
|
|
padding: 160px 35px 0;
|
|
|
margin: 0 auto;
|
|
|
overflow: hidden;
|
|
|
}
|
|
|
-
|
|
|
.tips {
|
|
|
font-size: 14px;
|
|
|
color: #fff;
|
|
@@ -371,6 +443,31 @@ $light_gray: #eee;
|
|
|
user-select: none;
|
|
|
}
|
|
|
|
|
|
+ .login-code {
|
|
|
+ width: 33%;
|
|
|
+ height: 38px;
|
|
|
+ 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;
|
|
|
+}
|
|
|
+
|
|
|
.thirdparty-button {
|
|
|
position: absolute;
|
|
|
right: 0;
|
|
@@ -384,3 +481,4 @@ $light_gray: #eee;
|
|
|
}
|
|
|
}
|
|
|
</style>
|
|
|
+
|