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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<!-- 登录页面 -->
<template>
<div class="page page-login flex flex-v">
<div class="form-wrap flex flex-1">
<el-form @submit.prevent='onSubmit' ref="form" :model="form" label-width="80px" size="small">
<h1>工作流管理平台</h1>
<el-form-item label="用户名">
<el-input v-model="form.loginName"></el-input>
</el-form-item>
<el-form-item label="密码">
<el-input v-model="form.password" type='password'></el-input>
</el-form-item>
<el-form-item label="验证码">
<el-input v-model="form.securityCode">
<img slot="append" width='60' height="30" :src='securityCodeUrl' @click='refreshCode'/>
</el-input>
</el-form-item>
<el-form-item size="large">
<el-button type="primary" native-type='submit' :loading='loading' @click='onSubmit'>登录</el-button>
</el-form-item>
</el-form>
</div>
<div class="footer">
登陆 © <a href="">信宏翔网络科技有限公司</a> 出品
</div>
</div>
</template>
<script>
import { createSocket } from '@/assets/utils/websocket'
const securityCodeUrl = '/m/securitycode/createCode?v=';
export default {
name: 'login',
created() {
this.refreshCode();
},
methods: {
login() {
this.loading = true;
this.$post('/login/login', this.form).then(this.loginSuccess).catch(this.loginFail)
},
loginSuccess({data}) {
this.$store.commit('setUserData', data);
this.$router.replace({
path: this.redirect,
});
//成功 创建websocket连接
// createSocket('ws://127.0.0.1:17011/m/ws?accessToken='+data.id)
},
loginFail(error) {
this.loading = false;
this.refreshCode();
this.$message.error(error.message);
},
refreshCode() {
this.form.securityCode = '';
this.securityCodeUrl = securityCodeUrl + Math.random();
},
onSubmit(e) {
e.preventDefault();
if(!this.form.loginName.length){
return this.$message.warning('请输入用户名')
}
if(!this.form.password.length){
return this.$message.warning('请输入密码')
}
if(!this.form.securityCode.length){
return this.$message.warning('请输入验证码')
}
this.login();
},
},
data() {
return {
loading: false,
redirect: this.$route.query.redirect || '/',
securityCodeUrl: securityCodeUrl,
form: {
loginName: '',
password: '',
securityCode: '',
}
}
}
}
</script>
<style lang="less">
.page-login {
background-image: linear-gradient(45deg, #333, #111);
background-size: 40px 40px;
margin: 0;
height: 100%;
.el-form{
margin: auto;
width: 400px;
padding: 25px 25px 0 0;
background: #fff;
h1{
text-align: center;
font-size: 20px;
font-weight: 500;
margin-bottom: 20px;
}
button{
margin-top: 10px;
width: 240px;
}
.el-input-group__append{
padding: 0;
font-size: 0;
}
}
.footer{
height: 80px;
font-size: 12px;
color: #999;
text-align: center;
line-height: 80px;
a{
color: #999;
}
}
}
</style>