Login.js
3.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// import {
// user as UserApi
// } from '../../config/request.js';
module.exports = {
name: 'login',
data() {
return {
winSize: {
width: '',
height: ''
},
formOffset: {
position: 'absolute',
left: '',
top: ''
},
remumber: this.$store.state.user.remumber,
login_actions: {
disabled: false
},
data: {
username: '',
password: '',
// token: ''
},
rule_data: {
username: [{
required: true,
message: '用户名不能为空!',
trigger: 'blur'
}],
password: [{
required: true,
message: '密码不能为空!',
trigger: 'blur'
}],
}
}
},
methods: {
setSize() {
this.winSize.width = $(window).width() + "px";
this.winSize.height = $(window).height() + "px";
this.formOffset.left = (parseInt(this.winSize.width) / 2 - 175) + 'px';
this.formOffset.top = (parseInt(this.winSize.height) / 2 - 178) + 'px';
},
// login(ref) {
// this.$refs[ref].validate((valid) => {
// if (valid) {
// this.login_actions.disabled = true;
// //如果记住密码,提交的信息包括真实token,密码则是假的
// //服务端登录验证优先级:用户名必须,其次先取token,不存在时再取密码
// UserApi.login.call(this, this[ref], data => {
// //登录成功之后,验证是否记住密码,如果记住密码,本地保存记住信息
// //如果没有记住,就初始化本地记住信息
// if (this.remumber.remumber_flag === true) {
// this.$store.dispatch('update_remumber', {
// remumber_flag: this.remumber.remumber_flag,
// remumber_login_info: {
// username: this[ref].username,
// token: data.userinfo.token
// }
// });
// } else {
// this.$store.dispatch('remove_remumber');
// }
// // this.$set(data.userinfo, 'access', ['/adv', '/demo/user', '/demo/user/list']);
// this.$store.dispatch('update_userinfo', {
// userinfo: data.userinfo
// }).then(() => {
// this.login_actions.disabled = false;
// this.$router.push('/demo/user/list');
// });
// }, () => {
// this.login_actions.disabled = false;
// }, () => {
// this.login_actions.disabled = false;
// });
// }
// });
// },
resetForm(ref) {
this.$refs[ref].resetFields();
}
},
created() {
this.setSize();
$(window).resize(() => {
this.setSize();
});
},
mounted() {
// console.log(this.remumber);
//如果上次登录选择的是记住密码并登录成功,则会保存状态,用户名以及token
// if (this.remumber.remumber_flag === true) {
// this.data.username = this.remumber.remumber_login_info.username;
// this.data.password = this.remumber.remumber_login_info.token.substring(0, 16);
// this.$set(this.data, 'token', this.remumber.remumber_login_info.token);
// }
}
}