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
| <template>
| <el-form class="login-form" status-icon :rules="loginRules" ref="loginForm" :model="loginForm" label-width="0">
| <el-form-item prop="username">
| <el-input size="small" @keyup.enter.native="handleLogin" v-model="loginForm.username" auto-complete="off"
| placeholder="请输入用户名">
| <i slot="prefix" class="fa fa-user"/>
| </el-input>
| </el-form-item>
| <el-form-item prop="password">
| <el-input size="small" @keyup.enter.native="handleLogin" :type="passwordType" v-model="loginForm.password"
| auto-complete="off" placeholder="请输入密码">
| <i class="el-icon-view el-input__icon" slot="suffix" @click="showPassword"/>
| <i slot="prefix" class="fa fa-lock"/>
| </el-input>
| </el-form-item>
| <el-form-item>
| <el-button type="primary" size="small" @click.native.prevent="handleLogin" class="login-submit">登录
| </el-button>
| </el-form-item>
| </el-form>
| </template>
|
| <script>
| import {Message} from "element-ui";
|
| export default {
| name: "userlogin",
| data() {
| return {
| loginForm: {
| tenantId: "000000",
| username: "",
| password: "",
| type: "account",
| },
| loginRules: {
| username: [
| {required: true, message: "请输入用户名", trigger: "blur"},
| ],
| password: [
| {required: true, message: "请输入密码", trigger: "blur"},
| {min: 6, message: "密码长度最少为6位", trigger: "blur"},
| ],
| },
| passwordType: "password",
| }
| },
| mounted() {
| },
| methods: {
| showPassword() {
| this.passwordType = this.passwordType === "password" ? "" : "password"
| },
| handleLogin() {
| this.$refs.loginForm.validate((valid) => {
| if (valid) {
| const loading = this.$loading({
| lock: true,
| text: "登录中,请稍后...",
| spinner: "el-icon-loading",
| })
| this.$store
| .dispatch("LoginByUsername", this.loginForm)
| .then((data) => {
| if (data.error_description) {
| loading.close()
| }else{
| this.$router.push({path: '/layout/home'})
| loading.close()
| }
| })
| .catch(() => {
| loading.close()
| })
| }
| })
| },
| },
| }
| </script>
|
| <style></style>
|
|