pc-master #232
@ -34,7 +34,7 @@
|
||||
记住密码
|
||||
</div>
|
||||
</div>
|
||||
<div class="login-btn" @keyup.enter="toLogin" @click="login">登 录</div>
|
||||
<div class="login-btn" @click="login">登 录</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -47,6 +47,8 @@ export default {
|
||||
save: false,
|
||||
password: "",
|
||||
username: "",
|
||||
loading:null,
|
||||
isLoad:false,
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
@ -61,20 +63,35 @@ export default {
|
||||
if (localStorage.getItem("token")) {
|
||||
this.$router.push({ name: "index" });
|
||||
}
|
||||
this.toLogin();
|
||||
window.addEventListener('keyup', this.handleKeyUp);
|
||||
},
|
||||
beforeDestroy() {
|
||||
window.removeEventListener('keyup', this.handleKeyUp);
|
||||
},
|
||||
methods: {
|
||||
toLogin() {
|
||||
document.onkeydown = e =>{
|
||||
if (!e.shiftKey && e.keyCode === 13) {
|
||||
e.cancelBubble = true; //ie阻止冒泡行为
|
||||
e.stopPropagation();//Firefox阻止冒泡行为
|
||||
e.preventDefault(); //取消事件的默认动作*换行
|
||||
if (e.srcElement.value) {
|
||||
this.login()
|
||||
}
|
||||
}
|
||||
handleKeyUp() {
|
||||
if (event.key === 'Enter'&&this.isLoad==false) {
|
||||
this.isLoad=true
|
||||
this.loading = this.$loading({
|
||||
lock: true,
|
||||
text: '登录中',
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.7)'
|
||||
});
|
||||
this.login();
|
||||
}
|
||||
// document.onkeydown = (e) => {
|
||||
// if (!e.shiftKey && e.keyCode === 13) {
|
||||
// e.cancelBubble = true; //ie阻止冒泡行为
|
||||
// e.stopPropagation(); //Firefox阻止冒泡行为
|
||||
// e.preventDefault(); //取消事件的默认动作*换行
|
||||
// console.log(e,111);
|
||||
// if (e.srcElement.value) {
|
||||
// console.log(11);
|
||||
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
},
|
||||
login() {
|
||||
var store = this.$store.state;
|
||||
@ -95,6 +112,8 @@ export default {
|
||||
password: this.password,
|
||||
}; // 替换为你要发送的数据
|
||||
this.api.login(data).then((res) => {
|
||||
this.loading.close()
|
||||
this.isLoad=false
|
||||
if (this.save) {
|
||||
localStorage.setItem("save", 1);
|
||||
localStorage.setItem("username", this.username);
|
||||
@ -119,6 +138,9 @@ export default {
|
||||
localStorage.removeItem("token");
|
||||
this.$message.error(res.data.msg);
|
||||
}
|
||||
}).catch(err=>{
|
||||
this.loading.close()
|
||||
this.isLoad=false
|
||||
});
|
||||
},
|
||||
},
|
||||
|
@ -724,18 +724,28 @@ this.dataInit();
|
||||
for (let index = 0; index < inputList.length; index++) {
|
||||
inputList[index].onfocus = this.selectValue;//input放入焦点,全选文本
|
||||
}
|
||||
window.addEventListener('keyup', this.handleKeyUp);
|
||||
},
|
||||
beforeDestroy() {
|
||||
window.removeEventListener('keyup', this.handleKeyUp);
|
||||
},
|
||||
methods: {
|
||||
modelClose(){
|
||||
this.$router.go(-1); // 返回前一页
|
||||
},
|
||||
modelConfirm(){
|
||||
handleKeyUp() {
|
||||
if (event.key === 'Enter') {
|
||||
|
||||
this.modelConfirm();
|
||||
}
|
||||
},
|
||||
modelConfirm(){
|
||||
if(this.modelPassword=='230509'){
|
||||
this.warnModel=false
|
||||
}else{
|
||||
this.$message('密码错误');
|
||||
}
|
||||
},
|
||||
},
|
||||
//失去焦点 计算公式 x/10
|
||||
blurChange10(code, el) {
|
||||
var store = this.$store.state
|
||||
|
Loading…
x
Reference in New Issue
Block a user