| | |
| | | <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form">
|
| | | <h3 class="title">若依后台管理系统</h3>
|
| | | <el-form-item prop="username">
|
| | | <el-input v-model="loginForm.username" type="text" auto-complete="off" placeholder="账号">
|
| | | <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>
|
| | |
| | | <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
|
| | | </el-input>
|
| | | </el-form-item>
|
| | | <el-form-item prop="code">
|
| | | <el-form-item prop="code" v-if="captchaOnOff">
|
| | | <el-input
|
| | | v-model="loginForm.code"
|
| | | auto-complete="off"
|
| | |
| | | <span v-if="!loading">登 录</span>
|
| | | <span v-else>登 录 中...</span>
|
| | | </el-button>
|
| | | <div style="float: right;" v-if="register">
|
| | | <router-link class="link-type" :to="'/register'">立即注册</router-link>
|
| | | </div>
|
| | | </el-form-item>
|
| | | </el-form>
|
| | | <!-- 底部 -->
|
| | | <div class="el-login-footer">
|
| | | <span>Copyright © 2018-2020 ruoyi.vip All Rights Reserved.</span>
|
| | | <span>Copyright © 2018-2021 ruoyi.vip All Rights Reserved.</span>
|
| | | </div>
|
| | | </div>
|
| | | </template>
|
| | |
| | | data() {
|
| | | return {
|
| | | codeUrl: "",
|
| | | cookiePassword: "",
|
| | | loginForm: {
|
| | | username: "admin",
|
| | | password: "admin123",
|
| | |
| | | },
|
| | | 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: "请输入验证码" }]
|
| | | },
|
| | | loading: false,
|
| | | // 验证码开关
|
| | | captchaOnOff: true,
|
| | | // 注册开关
|
| | | register: false,
|
| | | redirect: undefined
|
| | | };
|
| | | },
|
| | |
| | | methods: {
|
| | | getCode() {
|
| | | getCodeImg().then(res => {
|
| | | this.codeUrl = "data:image/gif;base64," + res.img;
|
| | | this.loginForm.uuid = res.uuid;
|
| | | 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() {
|
| | |
| | | Cookies.remove("password");
|
| | | Cookies.remove('rememberMe');
|
| | | }
|
| | | this.$store
|
| | | .dispatch("Login", this.loginForm)
|
| | | .then(() => {
|
| | | this.$router.push({ path: this.redirect || "/" });
|
| | | })
|
| | | .catch(() => {
|
| | | this.loading = false;
|
| | | this.$store.dispatch("Login", this.loginForm).then(() => {
|
| | | this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
|
| | | }).catch(() => {
|
| | | this.loading = false;
|
| | | if (this.captchaOnOff) {
|
| | | this.getCode();
|
| | | });
|
| | | }
|
| | | });
|
| | | }
|
| | | });
|
| | | }
|