| | |
| | | <template> |
| | | <div class="login"> |
| | | <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form"> |
| | | <el-form |
| | | ref="loginForm" |
| | | :model="loginForm" |
| | | :rules="loginRules" |
| | | class="login-form" |
| | | > |
| | | <h3 class="title">浙江省OPO数字化管理平台</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 |
| | | 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" |
| | | auto-complete="off" |
| | | @focus="tip" |
| | | placeholder="密码" |
| | | @keyup.enter.native="handleLogin" |
| | | > |
| | | <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" /> |
| | | <svg-icon |
| | | slot="prefix" |
| | | icon-class="password" |
| | | class="el-input__icon input-icon" |
| | | /> |
| | | </el-input> |
| | | </el-form-item> |
| | | <br> |
| | | <br /> |
| | | <el-form-item prop="code" v-if="captchaOnOff"> |
| | | <el-input |
| | | v-model="loginForm.code" |
| | |
| | | style="width: 63%" |
| | | @keyup.enter.native="handleLogin" |
| | | > |
| | | <svg-icon slot="prefix" icon-class="validCode" class="el-input__icon input-icon" /> |
| | | <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"/> |
| | | <img :src="codeUrl" @click="getCode" class="login-code-img" /> |
| | | </div> |
| | | </el-form-item> |
| | | <el-checkbox v-model="loginForm.rememberMe" style="margin:0px 0px 25px 0px;">记住密码</el-checkbox> |
| | | <el-checkbox |
| | | v-model="loginForm.rememberMe" |
| | | style="margin:0px 0px 25px 0px;" |
| | | >记住密码</el-checkbox |
| | | > |
| | | <el-form-item style="width:100%;"> |
| | | <el-button |
| | | :loading="loading" |
| | |
| | | <span v-else>登 录 中...</span> |
| | | </el-button> |
| | | <div style="float: right;" v-if="register"> |
| | | <router-link class="link-type" :to="'/register'">立即注册</router-link> |
| | | <router-link class="link-type" :to="'/register'" |
| | | >立即注册</router-link |
| | | > |
| | | </div> |
| | | </el-form-item> |
| | | </el-form> |
| | |
| | | <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 { |
| | | codeUrl: "", |
| | | cookiePassword: "", |
| | | cookiePassword: "", |
| | | loginForm: { |
| | | username: "", |
| | | password: "", |
| | |
| | | { required: true, trigger: "blur", message: "请输入您的账号" } |
| | | ], |
| | | password: [ |
| | | { required: true, trigger: "blur", message: "密码必须包含大小写字母、数字、特殊字符中的至少三种且长度大于等于8位" } |
| | | ], |
| | | { |
| | | required: true, |
| | | trigger: "blur", |
| | | message: |
| | | "密码必须包含大小写字母、数字、特殊字符中的至少三种且长度大于等于8位" |
| | | } |
| | | ] |
| | | // code: [{ required: true, trigger: "change", message: "请输入验证码" }] |
| | | }, |
| | | loading: false, |
| | | // 验证码开关 |
| | | captchaOnOff: false, |
| | | captchaOnOff: true, |
| | | // 注册开关 |
| | | register: false, |
| | | redirect: undefined |
| | |
| | | this.getCookie(); |
| | | }, |
| | | methods: { |
| | | tip(){ |
| | | tip() { |
| | | //console.log('awdawd',聚焦); |
| | | }, |
| | | getCode() { |
| | | getCodeImg().then(res => { |
| | | this.captchaOnOff = res.captchaOnOff === undefined ? true : res.captchaOnOff; |
| | | this.captchaOnOff = |
| | | res.captchaOnOff === undefined ? true : res.captchaOnOff; |
| | | if (this.captchaOnOff) { |
| | | 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') |
| | | const rememberMe = Cookies.get("rememberMe"); |
| | | this.loginForm = { |
| | | username: username === undefined ? this.loginForm.username : username, |
| | | password: password === undefined ? this.loginForm.password : decrypt(password), |
| | | password: |
| | | password === undefined ? this.loginForm.password : decrypt(password), |
| | | rememberMe: rememberMe === undefined ? false : Boolean(rememberMe) |
| | | }; |
| | | }, |
| | |
| | | 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.captchaOnOff) { |
| | | this.getCode(); |
| | | } |
| | | }); |
| | | this.$store |
| | | .dispatch("Login", this.loginForm) |
| | | .then(() => { |
| | | this.$router.push({ path: this.redirect || "/" }).catch(() => {}); |
| | | }) |
| | | .catch(() => { |
| | | this.loading = false; |
| | | // this.$message.error("登陆失败请重试。"); |
| | | if (this.captchaOnOff) { |
| | | this.getCode(); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | |
| | | justify-content: center; |
| | | align-items: center; |
| | | height: 100%; |
| | | background-position: center center; |
| | | /* 背景图不平铺 */ |
| | | background-repeat: no-repeat; |
| | | /* 当内容高度大于图片高度时,背景图像的位置相对于viewport固定 */ |
| | | background-attachment: fixed; |
| | | /* 让背景图基于容器大小伸缩 */ |
| | | background-size: cover; |
| | | /* 设置背景颜色,背景图加载过程中会显示背景色 */ |
| | | background-color: #464646; |
| | | background-image: url("../assets/images/login-bgc.jpg"); |
| | | background-size: cover; |
| | | } |