|
@@ -13,14 +13,20 @@
|
|
|
<div class="dormancy">
|
|
|
<div class="title">系统休眠,请输入密码解锁</div>
|
|
|
<div class="content">
|
|
|
- <el-form ref="form" :rules="rules" :model="form">
|
|
|
+ <el-form @submit.native.prevent ref="form" :rules="rules" :model="form">
|
|
|
<el-form-item prop="pwd">
|
|
|
- <el-input show-password placeholder="请输入密码" v-model="form.pwd"></el-input>
|
|
|
+ <el-input show-password placeholder="请输入密码" tabindex="1" v-model="form.pwd"></el-input>
|
|
|
</el-form-item>
|
|
|
+ <div v-if="Number(errorNum) >= 2" class="flex-wrap">
|
|
|
+ <el-form-item class="flex1" prop="identify">
|
|
|
+ <el-input ref="identify" v-model.trim="form.identify" placeholder="请输入验证码" name="identify" tabindex="1" />
|
|
|
+ </el-form-item>
|
|
|
+ <Identify @changeCode="changeCode" :identifyCode="form.CheckCode" :contentHeight="48" style="margin-left: 24px;" />
|
|
|
+ </div>
|
|
|
<el-form-item>
|
|
|
- <button class="button-public-shadow onSubmit" @click="onSubmit('form')">
|
|
|
+ <el-button :loading="loading" style="line-height: normal;" type="primary" class="button-public-shadow onSubmit" @click="onSubmit('form')">
|
|
|
确定
|
|
|
- </button>
|
|
|
+ </el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
</div>
|
|
@@ -33,12 +39,15 @@
|
|
|
|
|
|
<script>
|
|
|
import Dialog from "@/layout/components/Dialog/index.vue";
|
|
|
+import Identify from './views/login/identify.vue';
|
|
|
import { mapGetters } from "vuex";
|
|
|
import { SsoLogin } from "@/api/apiHome";
|
|
|
+import { GetSSOCheckCode } from '@/api/login';
|
|
|
export default {
|
|
|
name: "App",
|
|
|
components: {
|
|
|
Dialog,
|
|
|
+ Identify
|
|
|
},
|
|
|
data () {
|
|
|
return {
|
|
@@ -50,15 +59,19 @@ export default {
|
|
|
form: {
|
|
|
//表单数据
|
|
|
pwd: "",
|
|
|
+ identify: "",
|
|
|
+ CheckCode: ""
|
|
|
},
|
|
|
rules: {
|
|
|
//表单验证
|
|
|
pwd: [{ required: true, message: "请输入密码", trigger: "blur" }],
|
|
|
},
|
|
|
+ flag: false,
|
|
|
+ loading: false
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
- ...mapGetters(["dialog", "token", "name", "systemSet", "roles"]),
|
|
|
+ ...mapGetters(["dialog", "token", "name", "systemSet", "roles", "errorNum"]),
|
|
|
},
|
|
|
watch: {
|
|
|
"$store.state.user.token": {
|
|
@@ -82,6 +95,11 @@ export default {
|
|
|
},
|
|
|
},
|
|
|
mounted () {
|
|
|
+ const num = Number(this.errorNum);
|
|
|
+ if (this.dialog && num >= 2) {
|
|
|
+ // this.flag = true;
|
|
|
+ this.getCheckCode();
|
|
|
+ }
|
|
|
this.beforeUnload();
|
|
|
},
|
|
|
beforeDestroy () {
|
|
@@ -146,6 +164,7 @@ export default {
|
|
|
if (result[result.length - 2] === result[result.length - 1]) {
|
|
|
// 相同时 结束倒计时
|
|
|
this.$store.dispatch("app/toggleDialog", true);
|
|
|
+ this.getCheckCode();
|
|
|
this.clearAll();
|
|
|
} else {
|
|
|
this.time = this.desc;
|
|
@@ -202,17 +221,52 @@ export default {
|
|
|
},
|
|
|
//锁屏验证
|
|
|
async ssoLogin () {
|
|
|
- const res = await SsoLogin({
|
|
|
- LoginName: this.name,
|
|
|
- LoginPwd: this.form.pwd,
|
|
|
- });
|
|
|
+ try {
|
|
|
+ this.loading = true;
|
|
|
+ const obj = {
|
|
|
+ LoginName: this.name,
|
|
|
+ LoginPwd: this.form.pwd,
|
|
|
+ }
|
|
|
+ if (Number(this.errorNum) >= 2) {
|
|
|
+ obj.CheckCode = this.form.identify;
|
|
|
+ }
|
|
|
+ const res = await SsoLogin(obj);
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.$store.dispatch("app/toggleDialog", false);
|
|
|
+ this.$store.dispatch("app/getErrorNum", 0);
|
|
|
+ this.arr = [];
|
|
|
+ this.arrLen = [];
|
|
|
+ this.time = this.desc;
|
|
|
+ this.form.pwd = "";
|
|
|
+ this.handleTimer();
|
|
|
+ this.loading = false;
|
|
|
+ } else {
|
|
|
+ const num = Number(res.returnData);
|
|
|
+ this.$store.dispatch("app/getErrorNum", num);
|
|
|
+ if (num >= 2) {
|
|
|
+ this.getCheckCode();
|
|
|
+ }
|
|
|
+ if (num >= 5) {
|
|
|
+ await this.$store.dispatch('user/logout')
|
|
|
+ this.$router.push(`/login?redirect=${this.$route.fullPath}`)
|
|
|
+ }
|
|
|
+ this.$message.error(res.message);
|
|
|
+ this.loading = false;
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error);
|
|
|
+ this.loading = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //验证码重新获取
|
|
|
+ changeCode () {
|
|
|
+ this.getCheckCode()
|
|
|
+ },
|
|
|
+ //获取动态验证码
|
|
|
+ async getCheckCode () {
|
|
|
+ const res = await GetSSOCheckCode();
|
|
|
if (res.code === 0) {
|
|
|
- this.$store.dispatch("app/toggleDialog", false);
|
|
|
- this.arr = [];
|
|
|
- this.arrLen = [];
|
|
|
- this.time = this.desc;
|
|
|
- this.form.pwd = "";
|
|
|
- this.handleTimer();
|
|
|
+ this.form.CheckCode = res.returnData;
|
|
|
} else {
|
|
|
this.$message.error(res.message);
|
|
|
}
|