| | |
| | | <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form"> |
| | | <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" /> |
| | | <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" placeholder="密码" |
| | | @keyup.enter.native="handleLogin"> |
| | | <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" /> |
| | | @keyup.enter.native="handleLogin"> |
| | | <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon"/> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item prop="code" v-if="captchaEnabled"> |
| | | <el-input v-model="loginForm.code" auto-complete="off" placeholder="验证码" style="width: 63%" |
| | | @keyup.enter.native="handleLogin"> |
| | | <svg-icon slot="prefix" icon-class="validCode" class="el-input__icon input-icon" /> |
| | | @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" @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-form-item style="width:100%;"> |
| | | <el-button :loading="loading" size="medium" type="primary" style="width:100%;" |
| | | @click.native.prevent="handleLogin"> |
| | | @click.native.prevent="handleLogin"> |
| | | <span v-if="!loading">登 录</span> |
| | | <span v-else>登 录 中...</span> |
| | | </el-button> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { getCodeImg, getInfo } from "@/api/login"; |
| | | import {getCodeImg, getInfo} from "@/api/login"; |
| | | import Cookies from "js-cookie"; |
| | | import { encrypt, decrypt } from '@/utils/jsencrypt' |
| | | import { updateUserPwd } from "@/api/system/user"; |
| | | import {encrypt, decrypt} from '@/utils/jsencrypt' |
| | | import {updateUserPwd} from "@/api/system/user"; |
| | | |
| | | export default { |
| | | //新增对象、变量 |
| | |
| | | var regex = /(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[\W_])/; |
| | | if (value.length < 8 || value.length > 10) { |
| | | callback(new Error('请输入8-10位大写字母+小写字母+数字+特殊字符')); |
| | | } |
| | | else if (!regex.test(value)) { |
| | | } else if (!regex.test(value)) { |
| | | callback(new Error("请输入8-10位大写字母+小写字母+数字+特殊字符")); |
| | | } else { |
| | | callback(); |
| | |
| | | confirmPassword: undefined, |
| | | loginRules: { |
| | | username: [ |
| | | { required: true, trigger: "blur", message: "请输入您的账号" } |
| | | {required: true, trigger: "blur", message: "请输入您的账号"} |
| | | ], |
| | | password: [ |
| | | { required: true, trigger: "blur", message: "请输入您的密码" } |
| | | {required: true, trigger: "blur", message: "请输入您的密码"} |
| | | ], |
| | | code: [{ required: true, trigger: "change", message: "请输入验证码" }] |
| | | code: [{required: true, trigger: "change", message: "请输入验证码"}] |
| | | }, |
| | | rules: { |
| | | newPassword: [ |
| | | { required: true, message: "新密码不能为空", trigger: "blur" }, |
| | | { required: true, validator: validatePassword, trigger: "blur" } |
| | | {required: true, message: "新密码不能为空", trigger: "blur"}, |
| | | {required: true, validator: validatePassword, trigger: "blur"} |
| | | ], |
| | | confirmPassword: [ |
| | | { required: true, message: "确认密码不能为空", trigger: "blur" }, |
| | | { required: true, validator: equalToPassword, trigger: "blur" } |
| | | {required: true, message: "确认密码不能为空", trigger: "blur"}, |
| | | {required: true, validator: equalToPassword, trigger: "blur"} |
| | | ] |
| | | }, |
| | | loading: false, |
| | |
| | | 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("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"); |
| | |
| | | if (this.loginInfo.firstLogin == 1) { |
| | | // this.$router.push({ path: "/" }).catch(() => { }); |
| | | // return; |
| | | this.$router.push({ path: this.redirect || "/screen" }).catch(() => { }); |
| | | if (this.loginInfo.roles.includes("admin") || this.loginInfo.roles.includes("city_leader") || this.loginInfo.roles.includes("county_leader")) { |
| | | this.$router.push({path: this.redirect || "/screen"}).catch(() => { |
| | | }); |
| | | } else { |
| | | this.$router.push({path: this.redirect || "/index"}).catch(() => { |
| | | }); |
| | | } |
| | | } else { |
| | | localStorage.setItem('firstLogin', 0) |
| | | } |
| | | }).catch(() => { }) |
| | | }).catch(() => { |
| | | }) |
| | | }).catch(() => { |
| | | this.loading = false; |
| | | if (this.captchaEnabled) { |
| | |
| | | // 修改完成将firstLogin改为1 |
| | | localStorage.setItem('firstLogin', 1) |
| | | this.$modal.msgSuccess("修改成功"); |
| | | this.$router.push({ path: this.redirect || "/" }).catch(() => { }); |
| | | this.$router.push({path: this.redirect || "/"}).catch(() => { |
| | | }); |
| | | }).catch((e) => { |
| | | console.info(e) |
| | | }); |
| | |
| | | animation-delay: 0.1s; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | .login-form { |