...
|
...
|
@@ -8,9 +8,16 @@ |
|
|
<el-form-item prop="checkPass">
|
|
|
<el-input type="password" v-model="ruleForm2.checkPass" placeholder="密码" @keydown.enter.native="keyDown" show-password></el-input>
|
|
|
</el-form-item>
|
|
|
<!-- <el-form-item prop="checkPass">-->
|
|
|
<!-- <el-input type="password" v-model="ruleForm2.checkPass" placeholder="密码" @keyup.enter.native="handleSubmit2"></el-input>-->
|
|
|
<!-- </el-form-item>-->
|
|
|
<el-form-item prop="verify">
|
|
|
<el-input type="text" v-model="ruleForm2.verify" placeholder="请在2分钟内输入下方图片中的答案" @keyup.enter.native="handleSubmit2"></el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
<img
|
|
|
style="width: 125px; height: 60px"
|
|
|
:src="verifyImg"
|
|
|
@click="getVerifyCode"
|
|
|
>
|
|
|
</el-form-item>
|
|
|
<el-checkbox v-model="checked" checked class="remeberme">记住密码</el-checkbox>
|
|
|
<el-form-item style="width:100%;">
|
|
|
<el-button type="primary" style="width:100%;" @click.native.prevent="handleSubmit2" :loading="logining" :plain="true">登录</el-button>
|
...
|
...
|
@@ -43,15 +50,18 @@ |
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
vedioCanPlay: true,
|
|
|
fixStyle: '',
|
|
|
logining: false,
|
|
|
ruleForm2: {
|
|
|
verifyImg: "",
|
|
|
vedioCanPlay: true,
|
|
|
fixStyle: '',
|
|
|
logining: false,
|
|
|
ruleForm2: {
|
|
|
account: '',
|
|
|
// checkPass: 'zzairport@kako2020'
|
|
|
checkPass: ''
|
|
|
},
|
|
|
rules2: {
|
|
|
checkPass: '',
|
|
|
verify: '',
|
|
|
verifyToken: ''
|
|
|
},
|
|
|
rules2: {
|
|
|
account: [
|
|
|
{ required: true, message: '请输入账号', trigger: 'blur' },
|
|
|
//{ validator: validaePass }
|
...
|
...
|
@@ -59,10 +69,13 @@ |
|
|
checkPass: [
|
|
|
{ required: true, message: '请输入密码', trigger: 'blur' },
|
|
|
//{ validator: validaePass2 }
|
|
|
],
|
|
|
checkVerify: [
|
|
|
{ required: false, message: '请输入验证码', trigger: 'blur' }
|
|
|
]
|
|
|
},
|
|
|
checked: true,
|
|
|
userMenus: []
|
|
|
},
|
|
|
checked: true,
|
|
|
userMenus: []
|
|
|
};
|
|
|
},
|
|
|
methods: {
|
...
|
...
|
@@ -105,18 +118,20 @@ |
|
|
// 本地存储用户目录 ,防刷新目录丢失用
|
|
|
sessionStorage.setItem('menu', JSON.stringify(_this.$router.options.routes));
|
|
|
},
|
|
|
randCode: function(){
|
|
|
getRandCode().then((res) =>{
|
|
|
|
|
|
}).catch({
|
|
|
|
|
|
});
|
|
|
},
|
|
|
keyDown(e) {
|
|
|
if(e.keyCode===13) { //用户点击了ctrl+enter触发
|
|
|
this.handleSubmit2()
|
|
|
}
|
|
|
},
|
|
|
getVerifyCode: function(){
|
|
|
getRandCode().then((res) =>{
|
|
|
let status = res.status;
|
|
|
this.ruleForm2.verifyToken = res.data.jwtToken;
|
|
|
this.verifyImg = res.data.data.verifyImg;
|
|
|
}).catch({
|
|
|
|
|
|
});
|
|
|
},
|
|
|
handleSubmit2: function (ev) {
|
|
|
var _this = this;
|
|
|
this.$refs.ruleForm2.validate((valid) => {
|
...
|
...
|
@@ -124,7 +139,12 @@ |
|
|
//_this.$router.replace('/table');
|
|
|
this.logining = true;
|
|
|
//NProgress.start();
|
|
|
var loginParams = {username: this.ruleForm2.account, password: this.ruleForm2.checkPass};
|
|
|
var loginParams = {
|
|
|
username: this.ruleForm2.account,
|
|
|
password: this.ruleForm2.checkPass,
|
|
|
verify: this.ruleForm2.verify,
|
|
|
verifyToken:this.ruleForm2.verifyToken
|
|
|
};
|
|
|
http.login(loginParams).then(res => {
|
|
|
this.logining = false;
|
|
|
//NProgress.done();
|
...
|
...
|
@@ -133,11 +153,12 @@ |
|
|
let token = authentication.token;
|
|
|
let loginUserMenus = res.data.loginUserMenus;
|
|
|
if (status !== 200) {
|
|
|
let msg = "登录错误";
|
|
|
this.$message({
|
|
|
message: msg,
|
|
|
type: "error"
|
|
|
});
|
|
|
this.getVerifyCode();
|
|
|
let msg = "登录错误";
|
|
|
this.$message({
|
|
|
message: msg,
|
|
|
type: "error"
|
|
|
});
|
|
|
} else if (token) {
|
|
|
sessionStorage.setItem('user', JSON.stringify(authentication));
|
|
|
sessionStorage.setItem('token','Bearer '+ token);
|
...
|
...
|
@@ -147,20 +168,17 @@ |
|
|
//处理用户menu
|
|
|
_this.userMenus = loginUserMenus.list;
|
|
|
let sysMenus = _this.$router.options.routes;
|
|
|
|
|
|
|
|
|
_this.handleMenuList(_this.$router.options.routes,_this.userMenus);
|
|
|
|
|
|
// console.log("user:");
|
|
|
// console.log(_this.$router.options.routes);
|
|
|
_this.$router.push({path: '/main'});
|
|
|
}
|
|
|
}).catch(error => {
|
|
|
this.$message({
|
|
|
message: error.toString()+"-登录验证失败",
|
|
|
type: "error"
|
|
|
});
|
|
|
this.logining = false;
|
|
|
this.$message({
|
|
|
message: error.toString()+"-登录验证失败;",
|
|
|
type: "error"
|
|
|
});
|
|
|
this.getVerifyCode();
|
|
|
}).finally(()=>{
|
|
|
this.logining = false;
|
|
|
});
|
|
|
} else {
|
|
|
return false;
|
...
|
...
|
@@ -168,7 +186,7 @@ |
|
|
});
|
|
|
}
|
|
|
},
|
|
|
mounted:function () {
|
|
|
mounted:function () {
|
|
|
this.$store.commit('set_user_menu', []);
|
|
|
this.$store.commit('set_user_info', {
|
|
|
userId: 0,
|
...
|
...
|
@@ -213,8 +231,10 @@ |
|
|
_this.handleSubmit2();
|
|
|
}
|
|
|
};
|
|
|
// this.randCode();
|
|
|
}
|
|
|
},
|
|
|
created(){
|
|
|
this.getVerifyCode()
|
|
|
},
|
|
|
}
|
|
|
|
|
|
</script>
|
...
|
...
|
|